From f8fe097c3a028299dac9306855d2539bdc3d15dd Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 13 Sep 2014 12:22:07 +0200 Subject: [PATCH] Add support for events identified tvmedia in protocoll --- picturereader.c | 25 +++++++++++++++ vdrcommand.h | 3 ++ vompclientrrproc.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++ vompclientrrproc.h | 3 ++ 4 files changed, 108 insertions(+) diff --git a/picturereader.c b/picturereader.c index a940ebe..d336b38 100644 --- a/picturereader.c +++ b/picturereader.c @@ -1,5 +1,6 @@ #include "picturereader.h" #include +#include #include @@ -166,6 +167,30 @@ std::string PictureReader::getPictName(TVMediaRequest & req) return std::string(""); } }; break; + case 4: { // I do not know + // First get the schedules + cSchedulesLock MutexLock; + const cSchedules *Schedules = cSchedules::Schedules(MutexLock); + const cSchedule *Schedule = NULL; + if (Schedules) + { + Schedule = Schedules->GetSchedule( + Channels.GetByChannelID( + tChannelID::FromString(req.primary_name.c_str()))); + } + cEvent *event = NULL; + if (Schedule) Schedule->GetEvent(req.primary_id); + ScraperGetPosterThumb getter; + getter.event = event; + getter.recording = NULL; + if (x->scraper && event) { + x->scraper->Service("GetPosterThumb",&getter); + return getter.poster.path; + } else { + return std::string(""); + } + }; break; + default: return std::string(""); break; diff --git a/vdrcommand.h b/vdrcommand.h index 9b2d0e0..de3d29f 100644 --- a/vdrcommand.h +++ b/vdrcommand.h @@ -74,6 +74,9 @@ const static ULONG VDR_GETSCRAPERMOVIEINFO = 39; const static ULONG VDR_GETSCRAPERSERIESINFO = 40; const static ULONG VDR_LOADTVMEDIA =41; const static ULONG VDR_LOADTVMEDIARECTHUMB =42; +const static ULONG VDR_GETEVENTSCRAPEREVENTTYPE = 43; +const static ULONG VDR_LOADTVMEDIAEVENTTHUMB =44; + const static ULONG VDR_SHUTDOWN = 666; class VDR_Command : public SerializableList { diff --git a/vompclientrrproc.c b/vompclientrrproc.c index d8e1bb7..f45fa29 100644 --- a/vompclientrrproc.c +++ b/vompclientrrproc.c @@ -290,6 +290,13 @@ bool VompClientRRProc::processPacket() case VDR_LOADTVMEDIARECTHUMB: result = processLoadTvMediaRecThumb(); break; + case VDR_GETEVENTSCRAPEREVENTTYPE: + result = processGetEventScraperEventType(); + break; + case VDR_LOADTVMEDIAEVENTTHUMB: + result = processLoadTvMediaEventThumb(); + break; + #endif case VDR_GETMEDIALIST: result = processGetMediaList(); @@ -2033,6 +2040,51 @@ int VompClientRRProc::processGetRecScraperEventType() return 1; } +int VompClientRRProc::processGetEventScraperEventType() +{ + ScraperGetEventType call; + call.type = tNone; + ULONG channelid = ntohl(*(ULONG*)req->data); + ULONG eventid = ntohl(*(ULONG*)(req->data+4)); + const cEvent *event = NULL; + + cChannel* channel = x.channelFromNumber(channelid); + +#if VDRVERSNUM < 10300 + cMutexLock MutexLock; + const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock); +#else + cSchedulesLock MutexLock; + const cSchedules *Schedules = cSchedules::Schedules(MutexLock); +#endif + const cSchedule * Schedule; + if (Schedules && channel) + { + const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID()); + if (Schedule) { + event = Schedule->GetEvent(eventid); + } + } + + if (event && x.scraper) + { + call.event = event; + x.scraper->Service("GetEventType",&call); + } + resp->addUCHAR(call.type); + if (call.type == tMovie) + { + resp->addLONG(call.movieId); + } else if (call.type == tSeries){ + resp->addLONG(call.seriesId); + resp->addLONG(call.episodeId); + } + resp->finalise(); + x.tcp.sendPacket(resp->getPtr(), resp->getLen()); + + return 1; +} + #define ADDSTRING_TO_PAKET(y) if ((y)!=0) resp->addString(x.charconvutf8->Convert(y)); else resp->addString(""); int VompClientRRProc::processGetScraperMovieInfo() @@ -2198,6 +2250,31 @@ int VompClientRRProc::processLoadTvMediaRecThumb() return 1; } +int VompClientRRProc::processLoadTvMediaEventThumb() +{ + TVMediaRequest tvreq; + tvreq.streamID = req->requestID; + tvreq.type = 4; // unknown but primary_id is set + UINT channelid = ntohl(*(ULONG*)req->data); + tvreq.primary_id = ntohl(*(ULONG*)(req->data+4)); + tvreq.secondary_id = 0; + cChannel* channel = x.channelFromNumber(channelid); + + if (channel) tvreq.primary_name = std::string((const char*)channel->GetChannelID().ToString()); + tvreq.type_pict = 1; + tvreq.container = 0; + tvreq.container_member = 0; + log->log("RRProc", Log::DEBUG, "TVMedia request %d %s",req->requestID,req->data); + x.pict->addTVMediaRequest(tvreq); + + + resp->finalise(); + + x.tcp.sendPacket(resp->getPtr(), resp->getLen()); + + return 1; +} + diff --git a/vompclientrrproc.h b/vompclientrrproc.h index 0d2cf1e..e59fddf 100644 --- a/vompclientrrproc.h +++ b/vompclientrrproc.h @@ -88,6 +88,9 @@ class VompClientRRProc : public Thread int processGetScraperSeriesInfo(); int processLoadTvMedia(); int processLoadTvMediaRecThumb(); + int processGetEventScraperEventType(); + int processLoadTvMediaEventThumb(); + #endif int processLogin(); int processConfigSave(); -- 2.39.2