2 Copyright 2008 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef VOMPSTANDALONE
24 #include <vdr/recording.h>
25 #include <vdr/channels.h>
26 #include <vdr/videodir.h>
27 #include <vdr/plugin.h>
28 #include <vdr/timers.h>
30 #include <vdr/remote.h>
31 #include "recplayer.h"
32 #include "mvpreceiver.h"
33 #include "services/scraper2vdr.h"
36 #include "vompclientrrproc.h"
37 #include "vompclient.h"
40 #include "mediaplayer.h"
41 #include "servermediafile.h"
43 #include "vdrcommand.h"
44 #include "picturereader.h"
48 ULONG VompClientRRProc::VOMP_PROTOCOL_VERSION_MIN = 0x00000301;
49 ULONG VompClientRRProc::VOMP_PROTOCOL_VERSION_MAX = 0x00000302;
51 // cc is release protocol version, increase with every release, that changes protocol
52 // dd is development protocol version, set to zero at every release,
53 // increase for every protocol change in git
54 // bb not equal zero should indicate a non loggytronic protocol
55 // aa is reserved for future use
56 // VOMP_PROTOCOL_VERSION_MIN is the protocol version minimal supported by the server
57 // VOMP_PROTOCOL_VERSION_MAX is the protocol version maximal supported by the server
58 // This allows to run older clients from a new server
59 // Increase the minimal protocol version everytime you break compatibility for a certain
62 ULONG VompClientRRProc::getProtocolVersionMin()
64 return VOMP_PROTOCOL_VERSION_MIN;
67 ULONG VompClientRRProc::getProtocolVersionMax()
69 return VOMP_PROTOCOL_VERSION_MAX;
72 VompClientRRProc::VompClientRRProc(VompClient& x)
75 log = Log::getInstance();
80 VompClientRRProc::~VompClientRRProc()
85 bool VompClientRRProc::init()
87 int a = threadStart();
92 bool VompClientRRProc::recvRequest(RequestPacket* newRequest)
96 Now we have a queue system is used,
97 since on rare occasion the client fire two request at once
98 e.g. heavily channel switching
99 then processing only a single request would cause a deadlock in the client
103 log->log("RRProc", Log::DEBUG, "recvReq");
105 req_queue.push(newRequest);
106 threadSignalNoLock();
107 log->log("RRProc", Log::DEBUG, "recvReq set req and signalled");
113 void VompClientRRProc::threadMethod()
116 log->log("RRProc", Log::DEBUG, "threadMethod startup");
118 if (req_queue.size() != 0)
121 - log->log("RRProc", Log::ERR, "threadMethod err 1");
125 That was how the code used to be.
127 TODO: Work out why this happens.
130 log->log("RRProc", Log::ERR, "threadMethod startup with already queued packets");
131 while (req_queue.size())
133 //log->log("RRProc", Log::DEBUG, "thread while");
134 req = req_queue.front();
137 threadUnlock(); // allow recvRequest to be queuing packets while we are working on this one
139 if (!processPacket())
141 log->log("RRProc", Log::ERR, "processPacket exited with fail");
147 log->log("RRProc", Log::ERR, "threadMethod startup with already queued packets done.");
153 log->log("RRProc", Log::DEBUG, "threadMethod waiting");
154 threadWaitForSignal(); // unlocks, waits, relocks
155 if (req_queue.size() == 0)
157 log->log("RRProc", Log::INFO, "threadMethod err 2 or quit");
162 // signalled with something in queue
164 log->log("RRProc", Log::DEBUG, "thread woken with req, queue size: %i", req_queue.size());
166 while (req_queue.size())
168 //log->log("RRProc", Log::DEBUG, "thread while");
169 req = req_queue.front();
172 threadUnlock(); // allow recvRequest to be queuing packets while we are working on this one
174 if (!processPacket())
176 log->log("RRProc", Log::ERR, "processPacket exited with fail");
183 // locked and run out of packets to process
187 bool VompClientRRProc::processPacket()
189 resp = new ResponsePacket();
190 if (!resp->init(req->requestID))
192 log->log("RRProc", Log::ERR, "response packet init fail");
195 if (req->data) free(req->data);
207 result = processLogin();
209 #ifndef VOMPSTANDALONE
211 result = processGetRecordingsList();
214 result = processDeleteRecording();
217 result = processGetChannelsList();
220 result = processStartStreamingChannel();
223 result = processGetBlock();
226 result = processStopStreaming();
229 result = processStartStreamingRecording();
232 result = processGetChannelSchedule();
236 result = processConfigSave();
239 result = processConfigLoad();
241 #ifndef VOMPSTANDALONE
243 result = processReScanRecording(); // FIXME obselete
246 result = processGetTimers();
249 result = processSetTimer();
252 result = processPositionFromFrameNumber();
255 result = processFrameNumberFromPosition();
258 result = processMoveRecording();
261 result = processGetIFrame();
264 result = processGetRecInfo();
267 result = processGetMarks();
270 result = processGetChannelPids();
273 result = processDeleteTimer();
276 result = processVDRShutdown();
278 case VDR_GETRECSCRAPEREVENTTYPE:
279 result = processGetRecScraperEventType();
281 case VDR_GETSCRAPERMOVIEINFO:
282 result = processGetScraperMovieInfo();
284 case VDR_GETSCRAPERSERIESINFO:
285 result = processGetScraperSeriesInfo();
287 case VDR_LOADTVMEDIA:
288 result = processLoadTvMedia();
290 case VDR_LOADTVMEDIARECTHUMB:
291 result = processLoadTvMediaRecThumb();
294 case VDR_GETMEDIALIST:
295 result = processGetMediaList();
298 result = processOpenMedia();
300 case VDR_GETMEDIABLOCK:
301 result = processGetMediaBlock();
304 result = processGetLanguageList();
307 result = processGetLanguageContent();
309 case VDR_GETMEDIAINFO:
310 result = processGetMediaInfo();
312 case VDR_CLOSECHANNEL:
313 result = processCloseMediaChannel();
316 result = processSetCharset();
323 if (req->data) free(req->data);
327 if (result) return true;
331 int VompClientRRProc::processLogin()
333 if (req->dataLength != 6) return 0;
337 char configFileName[PATH_MAX];
338 snprintf(configFileName, PATH_MAX, "%s/vomp-%02X-%02X-%02X-%02X-%02X-%02X.conf", x.configDir, req->data[0], req->data[1], req->data[2], req->data[3], req->data[4], req->data[5]);
339 x.config.init(configFileName);
341 // Send the login reply
343 time_t timeNow = time(NULL);
344 struct tm* timeStruct = localtime(&timeNow);
345 int timeOffset = timeStruct->tm_gmtoff;
347 resp->addULONG(timeNow);
348 resp->addLONG(timeOffset);
349 resp->addULONG(VOMP_PROTOCOL_VERSION_MIN);
350 resp->addULONG(VOMP_PROTOCOL_VERSION_MAX);
352 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
353 log->log("RRProc", Log::DEBUG, "written login reply len %lu", resp->getLen());
356 x.netLog(); // safe to run here since the client won't start net logging for a while yet
361 int VompClientRRProc::processSetCharset()
363 int charset = ntohl(*(ULONG*)req->data);
364 if (charset>0 && charset<3)
366 log->log("RRProc", Log::DEBUG, "Set charset to %d", charset);
367 x.setCharset(charset);
372 log->log("RRProc", Log::DEBUG, "Invalid charset %d", charset);
376 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
380 int VompClientRRProc::processConfigSave()
382 char* section = (char*)req->data;
386 for (UINT k = 0; k < req->dataLength; k++)
388 if (req->data[k] == '\0')
392 key = (char*)&req->data[k+1];
396 value = (char*)&req->data[k+1];
402 // if the last string (value) doesnt have null terminator, give up
403 if (req->data[req->dataLength - 1] != '\0') return 0;
405 log->log("RRProc", Log::DEBUG, "Config save: %s %s %s", section, key, value);
406 if (x.config.setValueString(section, key, value))
416 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
421 int VompClientRRProc::processConfigLoad()
423 char* section = (char*)req->data;
426 for (UINT k = 0; k < req->dataLength; k++)
428 if (req->data[k] == '\0')
430 key = (char*)&req->data[k+1];
435 char* value = x.config.getValueString(section, key);
439 resp->addString(value);//client coding, do not touch
440 log->log("RRProc", Log::DEBUG, "Written config load packet");
446 log->log("RRProc", Log::DEBUG, "Written config load failed packet");
450 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
456 //helper for sending from a serialize buffer
457 //insert the used len into the first 4 Bytes of the buffer
458 void VompClientRRProc::sendPacket(SerializeBuffer *b) {
459 resp->copyin(b->getStart(),b->getCurrent()-b->getStart());
461 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
465 * media List Request:
466 * Media List response:
469 #define MLISTBUF 500000
470 int VompClientRRProc::processGetMediaList()
472 SerializeBuffer buffer(req->data,req->dataLength);
473 MediaURI uri(0,NULL,NULL);
474 VDR_GetMediaListRequest request(&uri);
475 if (request.deserialize(&buffer) != 0) {
476 log->log("Client", Log::ERR, "getMediaList unable to deserialize");
479 const char *dirname=uri.getName();
480 log->log("Client", Log::DEBUG, "getMediaList for %s", dirname);
483 if (dirname == NULL) {
484 ml=x.media->getRootList();
486 ml=x.media->getMediaList(&uri);
489 log->log("Client", Log::ERR, "getMediaList returned NULL");
492 SerializeBuffer rbuf(MLISTBUF,false,true);
493 ULONG flags=0; //TODO: real error handling by setting flags
494 VDR_GetMediaListResponse response(&flags,ml);
495 if (response.serialize(&rbuf) != 0) {
496 log->log("Client", Log::ERR, "getMediaList returned NULL");
500 log->log("Client", Log::DEBUG, "getMediaList size %u", ml->size());
505 log->log("Client", Log::DEBUG, "Written Media list");
510 * openMedia response:
512 int VompClientRRProc::processOpenMedia()
514 SerializeBuffer buffer(req->data,req->dataLength);
515 MediaURI uri(0,NULL,NULL);
519 VDR_OpenMediumRequest request(&channel,&uri,&xs,&ys);
520 if (request.deserialize(&buffer) != 0) {
521 log->log("Client", Log::ERR, "openMediaRequest unable to deserialize");
524 const char *name=uri.getName();
525 log->log("Client", Log::DEBUG, "openMediaRequest for %s", name);
527 int rt=x.media->openMedium(channel,&uri,&size,xs,ys);
532 log->log("Client", Log::ERR, "openMediaRequest unable to open");
534 VDR_OpenMediumResponse response(&flags,&size);
535 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
536 if (response.serialize(&rbuf) != 0) {
537 log->log("Client", Log::ERR, "openMediaRequest cannot serialize");
540 log->log("Client", Log::DEBUG, "openMediaRequest size %llu", size);
547 * packet - no serialized response!
549 int VompClientRRProc::processGetMediaBlock()
551 SerializeBuffer buffer(req->data,req->dataLength);
555 VDR_GetMediaBlockRequest request(&channel,&position,&amount);
556 if (request.deserialize(&buffer) != 0) {
557 log->log("Client", Log::ERR, "getMediaBlock unable to deserialize");
560 log->log("Client", Log::DEBUG, "getMediaBlock pos = %llu length = %lu,chan=%lu", position, amount,channel);
562 UCHAR sendBuffer[amount ];
563 ULONG amountReceived = 0;
564 UCHAR *rbuf=sendBuffer;
565 int rt=x.media->getMediaBlock(channel,position,amount,&amountReceived,&rbuf);
566 if (!amountReceived || rt != 0)
568 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
572 if (rbuf != sendBuffer) {
573 //the provider did not use the optimized handling with using my buffer
574 resp->copyin(rbuf,amountReceived);
577 // the provider did not allocate a new buffer
578 resp->copyin(sendBuffer,amountReceived);
582 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
583 log->log("Client", Log::DEBUG, "written ok %lu", amountReceived);
590 int VompClientRRProc::processGetMediaInfo()
592 SerializeBuffer buffer(req->data,req->dataLength);
594 VDR_GetMediaInfoRequest request(&channel);
595 if (request.deserialize(&buffer) != 0) {
596 log->log("Client", Log::ERR, "getMediaInfo unable to deserialize");
599 log->log("Client", Log::DEBUG, "getMediaInfo chan=%lu", channel);
602 int rt=x.media->getMediaInfo(channel,&mi);
605 log->log("Client", Log::ERR, "getMediaInfo unable to get");
607 VDR_GetMediaInfoResponse response(&flags,&mi);
608 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
609 if (response.serialize(&rbuf) != 0) {
610 log->log("Client", Log::ERR, "getMediaInfo cannot serialize");
622 int VompClientRRProc::processCloseMediaChannel()
624 SerializeBuffer buffer(req->data,req->dataLength);
626 VDR_CloseMediaChannelRequest request(&channel);
627 if (request.deserialize(&buffer) != 0) {
628 log->log("Client", Log::ERR, "closeMediaChannel unable to deserialize");
632 log->log("Client", Log::DEBUG, "closeMediaChannel chan=%lu", channel);
633 int rt=x.media->closeMediaChannel(channel);
636 log->log("Client", Log::ERR, "closeMediaChannel unable to get");
638 VDR_CloseMediaChannelResponse response(&flags);
639 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
640 if (response.serialize(&rbuf) != 0) {
641 log->log("Client", Log::ERR, "closeMediaChannel cannot serialize");
650 int VompClientRRProc::processGetLanguageList()
652 x.i18n.findLanguages();
653 const I18n::lang_code_list& languages = x.i18n.getLanguageList();
655 I18n::lang_code_list::const_iterator iter;
656 for (iter = languages.begin(); iter != languages.end(); ++iter)
658 resp->addString(iter->first.c_str()); // Source code is acsii
659 resp->addString(x.charconvutf8->Convert(iter->second.c_str())); //translate string can be any utf-8 character
662 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
666 int VompClientRRProc::processGetLanguageContent()
668 if (req->dataLength <= 0) return 0;
669 std::string code, result;
670 code.assign((char*)req->data, req->dataLength - 1);
671 x.i18n.findLanguages();
672 I18n::trans_table texts = x.i18n.getLanguageContent(code);
673 I18n::trans_table::const_iterator iter;
674 for (iter = texts.begin(); iter != texts.end(); ++iter)
676 resp->addString(iter->first.c_str());// source code is acsii since it is english
677 resp->addString(x.charconvutf8->Convert(iter->second.c_str())); // translate text can be any unicode string, it is stored as UTF-8
680 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
684 #ifndef VOMPSTANDALONE
686 int VompClientRRProc::processGetRecordingsList()
689 #if APIVERSNUM > 20101
690 int Percent = cVideoDirectory::VideoDiskSpace(&FreeMB);
692 int Percent = VideoDiskSpace(&FreeMB);
694 int Total = (FreeMB / (100 - Percent)) * 100;
696 resp->addULONG(Total);
697 resp->addULONG(FreeMB);
698 resp->addULONG(Percent);
700 cRecordings Recordings;
703 for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording))
705 #if VDRVERSNUM < 10721
706 resp->addULONG(recording->start);
708 resp->addULONG(recording->Start());
710 resp->addUCHAR(recording->IsNew() ? 1 : 0);
711 resp->addString(x.charconvsys->Convert(recording->Name())); //coding of recording name is system dependent
712 resp->addString(recording->FileName());//file name are not visible by user do not touch
716 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
718 log->log("RRProc", Log::DEBUG, "Written recordings list");
723 int VompClientRRProc::processDeleteRecording()
725 // data is a pointer to the fileName string
727 cRecordings Recordings;
728 Recordings.Load(); // probably have to do this
730 cRecording* recording = Recordings.GetByName((char*)req->data);
732 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
736 log->log("RRProc", Log::DEBUG, "deleting recording: %s", recording->Name());
738 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
741 if (recording->Delete())
743 // Copy svdrp's way of doing this, see if it works
744 #if VDRVERSNUM > 10300
745 ::Recordings.DelByName(recording->FileName());
765 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
770 int VompClientRRProc::processMoveRecording()
772 log->log("RRProc", Log::DEBUG, "Process move recording");
773 char* fileName = (char*)req->data;
774 char* newPath = NULL;
776 for (UINT k = 0; k < req->dataLength; k++)
778 if (req->data[k] == '\0')
780 newPath = (char*)&req->data[k+1];
784 if (!newPath) return 0;
786 cRecordings Recordings;
787 Recordings.Load(); // probably have to do this
789 cRecording* recording = Recordings.GetByName((char*)fileName);
791 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
795 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
798 log->log("RRProc", Log::DEBUG, "moving recording: %s", recording->Name());
799 log->log("RRProc", Log::DEBUG, "moving recording: %s", recording->FileName());
800 log->log("RRProc", Log::DEBUG, "to: %s", newPath);
802 const char* t = recording->FileName();
804 char* dateDirName = NULL; int k;
805 char* titleDirName = NULL; int j;
807 // Find the datedirname
808 for(k = strlen(t) - 1; k >= 0; k--)
812 log->log("RRProc", Log::DEBUG, "l1: %i", strlen(&t[k+1]) + 1);
813 dateDirName = new char[strlen(&t[k+1]) + 1];
814 strcpy(dateDirName, &t[k+1]);
819 // Find the titledirname
821 for(j = k-1; j >= 0; j--)
825 log->log("RRProc", Log::DEBUG, "l2: %i", (k - j - 1) + 1);
826 titleDirName = new char[(k - j - 1) + 1];
827 memcpy(titleDirName, &t[j+1], k - j - 1);
828 titleDirName[k - j - 1] = '\0';
833 log->log("RRProc", Log::DEBUG, "datedirname: %s", dateDirName);
834 log->log("RRProc", Log::DEBUG, "titledirname: %s", titleDirName);
835 #if APIVERSNUM > 20101
836 log->log("RRProc", Log::DEBUG, "viddir: %s", cVideoDirectory::Name());
838 log->log("RRProc", Log::DEBUG, "viddir: %s", VideoDirectory);
841 char* newPathConv = new char[strlen(newPath)+1];
842 strcpy(newPathConv, newPath);
843 ExchangeChars(newPathConv, true);
844 log->log("RRProc", Log::DEBUG, "EC: %s", newPathConv);
846 #if APIVERSNUM > 20101
847 char* newContainer = new char[strlen(cVideoDirectory::Name()) + strlen(newPathConv) + strlen(titleDirName) + 1];
848 log->log("RRProc", Log::DEBUG, "l10: %i", strlen(cVideoDirectory::Name()) + strlen(newPathConv) + strlen(titleDirName) + 1);
849 sprintf(newContainer, "%s%s%s", cVideoDirectory::Name(), newPathConv, titleDirName);
851 char* newContainer = new char[strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1];
852 log->log("RRProc", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1);
853 sprintf(newContainer, "%s%s%s", VideoDirectory, newPathConv, titleDirName);
855 delete[] newPathConv;
857 log->log("RRProc", Log::DEBUG, "%s", newContainer);
860 int statret = stat(newContainer, &dstat);
861 if ((statret == -1) && (errno == ENOENT)) // Dir does not exist
863 log->log("RRProc", Log::DEBUG, "new dir does not exist");
864 int mkdirret = mkdir(newContainer, 0755);
867 delete[] dateDirName;
868 delete[] titleDirName;
869 delete[] newContainer;
873 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
877 else if ((statret == 0) && (! (dstat.st_mode && S_IFDIR))) // Something exists but it's not a dir
879 delete[] dateDirName;
880 delete[] titleDirName;
881 delete[] newContainer;
885 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
889 // Ok, the directory container has been made, or it pre-existed.
891 char* newDir = new char[strlen(newContainer) + 1 + strlen(dateDirName) + 1];
892 sprintf(newDir, "%s/%s", newContainer, dateDirName);
894 log->log("RRProc", Log::DEBUG, "doing rename '%s' '%s'", t, newDir);
895 int renameret = rename(t, newDir);
898 // Success. Test for remove old dir containter
899 char* oldTitleDir = new char[k+1];
900 memcpy(oldTitleDir, t, k);
901 oldTitleDir[k] = '\0';
902 log->log("RRProc", Log::DEBUG, "len: %i, cp: %i, strlen: %i, oldtitledir: %s", k+1, k, strlen(oldTitleDir), oldTitleDir);
903 rmdir(oldTitleDir); // can't do anything about a fail result at this point.
904 delete[] oldTitleDir;
909 #if VDRVERSNUM > 10311
911 ::Recordings.Update();
913 // Success. Send a different packet from just a ulong
914 resp->addULONG(1); // success
915 resp->addString(newDir); //system depent do not convert
923 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
925 delete[] dateDirName;
926 delete[] titleDirName;
927 delete[] newContainer;
934 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
941 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
947 int VompClientRRProc::processGetChannelsList()
951 char* chanConfig = x.config.getValueString("General", "Channels");
953 if (chanConfig) allChans = strcasecmp(chanConfig, "FTA only");
955 for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
957 #if VDRVERSNUM < 10300
958 if (!channel->GroupSep() && (!channel->Ca() || allChans))
960 if (!channel->GroupSep() && (!channel->Ca(0) || allChans))
963 log->log("RRProc", Log::DEBUG, "name: '%s'", channel->Name());
965 if (channel->Vpid()) type = 1;
966 #if VDRVERSNUM < 10300
969 else if (channel->Apid(0)) type = 2;
973 resp->addULONG(channel->Number());
974 resp->addULONG(type);
975 resp->addString(x.charconvsys->Convert(channel->Name()));
976 #if VDRVERSNUM < 10703
979 resp->addULONG(channel->Vtype());
985 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
987 log->log("RRProc", Log::DEBUG, "Written channels list");
992 int VompClientRRProc::processGetChannelPids()
994 ULONG channelNumber = ntohl(*(ULONG*)req->data);
996 cChannel* channel = x.channelFromNumber(channelNumber);
1001 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1010 #if VDRVERSNUM < 10300
1012 log->log("RRProc", Log::DEBUG, "Apid1: %i", channel->Apid1());
1013 log->log("RRProc", Log::DEBUG, "Apid2: %i", channel->Apid2());
1015 if (channel->Apid2())
1017 else if (channel->Apid1())
1024 for (const int *Apid = channel->Apids(); *Apid; Apid++)
1028 for (const int *Dpid = channel->Dpids(); *Dpid; Dpid++)
1032 for (const int *Spid = channel->Spids(); *Spid; Spid++)
1039 // Format of response
1058 resp->addULONG(channel->Vpid());
1059 #if VDRVERSNUM < 10703
1062 resp->addULONG(channel->Vtype());
1064 resp->addULONG(numApids);
1066 #if VDRVERSNUM < 10300
1069 resp->addULONG(channel->Apid1());
1070 resp->addString("");
1074 resp->addULONG(channel->Apid2());
1075 resp->addString("");
1080 for (ULONG i = 0; i < numApids; i++)
1082 resp->addULONG(channel->Apid(i));
1083 resp->addString(x.charconvsys->Convert(channel->Alang(i)));
1085 resp->addULONG(numDpids);
1086 for (ULONG i = 0; i < numDpids; i++)
1088 resp->addULONG(channel->Dpid(i));
1089 resp->addString(x.charconvsys->Convert(channel->Dlang(i)));
1091 resp->addULONG(numSpids);
1092 for (ULONG i = 0; i < numSpids; i++)
1094 resp->addULONG(channel->Spid(i));
1095 resp->addString(x.charconvsys->Convert(channel->Slang(i)));
1098 resp->addULONG(channel->Tpid());
1099 // Format of extended response, for compatibility with older client at the end
1111 #if VDRVERSNUM < 10300
1121 for (ULONG i = 0; i < numApids; i++)
1123 #if VDRVERSNUM < 10715
1126 resp->addULONG(channel->Atype(i));
1129 for (ULONG i = 0; i < numDpids; i++)
1131 #if VDRVERSNUM < 10715
1132 resp->addULONG(0x6A /*AC3*/);
1134 resp->addULONG(channel->Dtype(i));
1137 for (ULONG i = 0; i < numSpids; i++)
1139 #if VDRVERSNUM < 10715
1144 resp->addULONG(channel->SubtitlingType(i));
1145 resp->addULONG(channel->CompositionPageId(i));
1146 resp->addULONG(channel->AncillaryPageId(i));
1153 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1155 log->log("RRProc", Log::DEBUG, "Written channels pids");
1160 int VompClientRRProc::processStartStreamingChannel()
1164 log->log("RRProc", Log::ERR, "Client called start streaming twice");
1168 log->log("RRProc", Log::DEBUG, "req->dataLength = %i", req->dataLength);
1169 ULONG channelNumber = ntohl(*(ULONG*)req->data);
1171 cChannel* channel = x.channelFromNumber(channelNumber);
1176 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1180 // get the priority we should use
1182 int priority = x.config.getValueLong("General", "Live priority", &fail);
1185 log->log("RRProc", Log::DEBUG, "Config: Live TV priority: %i", priority);
1189 log->log("RRProc", Log::DEBUG, "Config: Live TV priority config fail");
1193 // a bit of sanity..
1194 #if VDRVERSNUM < 10725
1195 if (priority < 0) priority = 0;
1197 if (priority < -99) priority = -99;
1199 if (priority > 99) priority = 99;
1201 log->log("RRProc", Log::DEBUG, "Using live TV priority %i", priority);
1202 x.lp = MVPReceiver::create(channel, priority);
1208 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1212 if (!x.lp->init(&x.tcp, req->requestID))
1218 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1224 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1228 int VompClientRRProc::processStopStreaming()
1230 log->log("RRProc", Log::DEBUG, "STOP STREAMING RECEIVED");
1233 x.lp->detachMVPReceiver();
1237 else if (x.recplayer)
1239 x.writeResumeData();
1242 delete x.recordingManager;
1244 x.recordingManager = NULL;
1249 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1253 int VompClientRRProc::processGetBlock()
1257 log->log("RRProc", Log::ERR, "Get block called during live streaming");
1263 log->log("RRProc", Log::ERR, "Get block called when no recording open");
1267 UCHAR* data = req->data;
1269 ULLONG position = x.ntohll(*(ULLONG*)data);
1270 data += sizeof(ULLONG);
1271 ULONG amount = ntohl(*(ULONG*)data);
1273 log->log("RRProc", Log::DEBUG, "getblock pos = %llu length = %lu", position, amount);
1275 UCHAR sendBuffer[amount];
1276 ULONG amountReceived = x.recplayer->getBlock(&sendBuffer[0], position, amount);
1278 if (!amountReceived)
1281 log->log("RRProc", Log::DEBUG, "written 4(0) as getblock got 0");
1285 resp->copyin(sendBuffer, amountReceived);
1286 log->log("RRProc", Log::DEBUG, "written %lu", amountReceived);
1290 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1291 log->log("RRProc", Log::DEBUG, "Finished getblock, have sent %lu", resp->getLen());
1295 int VompClientRRProc::processStartStreamingRecording()
1297 // data is a pointer to the fileName string
1299 x.recordingManager = new cRecordings;
1300 x.recordingManager->Load();
1302 cRecording* recording = x.recordingManager->GetByName((char*)req->data);
1304 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
1308 x.recplayer = new RecPlayer(recording);
1310 resp->addULLONG(x.recplayer->getLengthBytes());
1311 resp->addULONG(x.recplayer->getLengthFrames());
1313 #if VDRVERSNUM < 10703
1314 resp->addUCHAR(true);//added for TS
1316 resp->addUCHAR(recording->IsPesRecording());//added for TS
1320 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1322 log->log("RRProc", Log::DEBUG, "written totalLength");
1326 delete x.recordingManager;
1327 x.recordingManager = NULL;
1332 int VompClientRRProc::processPositionFromFrameNumber()
1336 ULONG frameNumber = ntohl(*(ULONG*)req->data);
1340 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1344 retval = x.recplayer->positionFromFrameNumber(frameNumber);
1347 resp->addULLONG(retval);
1349 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1351 log->log("RRProc", Log::DEBUG, "Wrote posFromFrameNum reply to client");
1355 int VompClientRRProc::processFrameNumberFromPosition()
1359 ULLONG position = x.ntohll(*(ULLONG*)req->data);
1363 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1367 retval = x.recplayer->frameNumberFromPosition(position);
1370 resp->addULONG(retval);
1372 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1374 log->log("RRProc", Log::DEBUG, "Wrote frameNumFromPos reply to client");
1378 int VompClientRRProc::processGetIFrame()
1380 bool success = false;
1382 ULONG* data = (ULONG*)req->data;
1384 ULONG frameNumber = ntohl(*data);
1386 ULONG direction = ntohl(*data);
1388 ULLONG rfilePosition = 0;
1389 ULONG rframeNumber = 0;
1390 ULONG rframeLength = 0;
1394 log->log("RRProc", Log::DEBUG, "GetIFrame recording called when no recording being played!");
1398 success = x.recplayer->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
1401 // returns file position, frame number, length
1405 resp->addULLONG(rfilePosition);
1406 resp->addULONG(rframeNumber);
1407 resp->addULONG(rframeLength);
1415 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1417 log->log("RRProc", Log::DEBUG, "Wrote GNIF reply to client %llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
1421 int VompClientRRProc::processGetChannelSchedule()
1423 ULONG* data = (ULONG*)req->data;
1425 ULONG channelNumber = ntohl(*data);
1427 ULONG startTime = ntohl(*data);
1429 ULONG duration = ntohl(*data);
1431 log->log("RRProc", Log::DEBUG, "get schedule called for channel %lu", channelNumber);
1433 cChannel* channel = x.channelFromNumber(channelNumber);
1438 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1440 log->log("RRProc", Log::DEBUG, "written 0 because channel = NULL");
1444 log->log("RRProc", Log::DEBUG, "Got channel");
1446 #if VDRVERSNUM < 10300
1447 cMutexLock MutexLock;
1448 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1450 cSchedulesLock MutexLock;
1451 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1457 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1459 log->log("RRProc", Log::DEBUG, "written 0 because Schedule!s! = NULL");
1463 log->log("RRProc", Log::DEBUG, "Got schedule!s! object");
1465 const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
1470 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1472 log->log("RRProc", Log::DEBUG, "written 0 because Schedule = NULL");
1476 log->log("RRProc", Log::DEBUG, "Got schedule object");
1478 const char* empty = "";
1479 bool atLeastOneEvent = false;
1482 ULONG thisEventTime;
1483 ULONG thisEventDuration;
1484 const char* thisEventTitle;
1485 const char* thisEventSubTitle;
1486 const char* thisEventDescription;
1488 #if VDRVERSNUM < 10300
1490 const cEventInfo *event;
1491 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1493 event = Schedule->GetEventNumber(eventNumber);
1495 thisEventID = event->GetEventID();
1496 thisEventTime = event->GetTime();
1497 thisEventDuration = event->GetDuration();
1498 thisEventTitle = event->GetTitle();
1499 thisEventSubTitle = event->GetSubtitle();
1500 thisEventDescription = event->GetExtendedDescription();
1504 for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
1506 thisEventID = event->EventID();
1507 thisEventTime = event->StartTime();
1508 thisEventDuration = event->Duration();
1509 thisEventTitle = event->Title();
1510 thisEventSubTitle = NULL;
1511 thisEventDescription = event->Description();
1515 //in the past filter
1516 if ((thisEventTime + thisEventDuration) < (ULONG)time(NULL)) continue;
1519 if ((thisEventTime + thisEventDuration) <= startTime) continue;
1522 if (thisEventTime >= (startTime + duration)) continue;
1524 if (!thisEventTitle) thisEventTitle = empty;
1525 if (!thisEventSubTitle) thisEventSubTitle = empty;
1526 if (!thisEventDescription) thisEventDescription = empty;
1528 resp->addULONG(thisEventID);
1529 resp->addULONG(thisEventTime);
1530 resp->addULONG(thisEventDuration);
1532 resp->addString(x.charconvsys->Convert(thisEventTitle));
1533 resp->addString(x.charconvsys->Convert(thisEventSubTitle));
1534 resp->addString(x.charconvsys->Convert(thisEventDescription));
1536 atLeastOneEvent = true;
1539 log->log("RRProc", Log::DEBUG, "Got all event data");
1541 if (!atLeastOneEvent)
1544 log->log("RRProc", Log::DEBUG, "Written 0 because no data");
1548 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1550 log->log("RRProc", Log::DEBUG, "written schedules packet");
1555 int VompClientRRProc::processGetTimers()
1558 int numTimers = Timers.Count();
1560 resp->addULONG(numTimers);
1562 for (int i = 0; i < numTimers; i++)
1564 timer = Timers.Get(i);
1566 #if VDRVERSNUM < 10300
1567 resp->addULONG(timer->Active());
1569 resp->addULONG(timer->HasFlags(tfActive));
1571 resp->addULONG(timer->Recording());
1572 resp->addULONG(timer->Pending());
1573 resp->addULONG(timer->Priority());
1574 resp->addULONG(timer->Lifetime());
1575 resp->addULONG(timer->Channel()->Number());
1576 resp->addULONG(timer->StartTime());
1577 resp->addULONG(timer->StopTime());
1578 resp->addULONG(timer->Day());
1579 resp->addULONG(timer->WeekDays());
1580 resp->addString(timer->File()); //Filename is system specific and not visible by user
1584 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1586 log->log("RRProc", Log::DEBUG, "Written timers list");
1591 int VompClientRRProc::processSetTimer()
1593 char* timerString = new char[strlen((char*)req->data) + 1];
1594 strcpy(timerString, (char*)req->data);
1596 #if VDRVERSNUM < 10300
1598 // If this is VDR 1.2 the date part of the timer string must be reduced
1599 // to just DD rather than YYYY-MM-DD
1601 int s = 0; // source
1602 int d = 0; // destination
1604 while(c != 2) // copy up to date section, including the second ':'
1606 timerString[d] = req->data[s];
1607 if (req->data[s] == ':') c++;
1611 // now it has copied up to the date section
1613 while(c != 2) // waste YYYY-MM-
1615 if (req->data[s] == '-') c++;
1618 // now source is at the DD
1619 memcpy(&timerString[d], &req->data[s], req->dataLength - s);
1620 d += req->dataLength - s;
1621 timerString[d] = '\0';
1623 log->log("RRProc", Log::DEBUG, "Timer string after 1.2 conversion:");
1626 log->log("RRProc", Log::DEBUG, "%s", timerString);
1628 cTimer *timer = new cTimer;
1629 if (timer->Parse((char*)timerString))
1631 cTimer *t = Timers.GetTimer(timer);
1635 #if VDRVERSNUM < 10300
1638 Timers.SetModified();
1642 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1643 return 1; // FIXME - cTimer* timer is leaked here!
1649 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1656 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1662 int VompClientRRProc::processDeleteTimer()
1664 log->log("RRProc", Log::DEBUG, "Delete timer called");
1669 INT delChannel = ntohl(*(ULONG*)&req->data[position]); position += 4;
1670 INT delWeekdays = ntohl(*(ULONG*)&req->data[position]); position += 4;
1671 INT delDay = ntohl(*(ULONG*)&req->data[position]); position += 4;
1672 INT delStart = ntohl(*(ULONG*)&req->data[position]); position += 4;
1673 INT delStop = ntohl(*(ULONG*)&req->data[position]); position += 4;
1676 for (ti = Timers.First(); ti; ti = Timers.Next(ti))
1678 if ( (ti->Channel()->Number() == delChannel)
1679 && ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
1680 && (ti->StartTime() == delStart)
1681 && (ti->StopTime() == delStop) )
1689 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1693 if (!Timers.BeingEdited())
1695 if (!ti->Recording())
1698 Timers.SetModified();
1701 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1706 log->log("RRProc", Log::ERR, "Unable to delete timer - timer is running");
1709 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1715 log->log("RRProc", Log::ERR, "Unable to delete timer - timers being edited at VDR");
1718 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1723 int VompClientRRProc::processGetRecInfo()
1725 // data is a pointer to the fileName string
1727 cRecordings Recordings;
1728 Recordings.Load(); // probably have to do this
1730 cRecording *recording = Recordings.GetByName((char*)req->data);
1732 time_t timerStart = 0;
1733 time_t timerStop = 0;
1734 char* summary = NULL;
1735 char* shorttext = NULL;
1736 char* description = NULL;
1738 bool newsummary=false;
1739 ULONG resumePoint = 0;
1743 log->log("RRProc", Log::ERR, "GetRecInfo found no recording");
1746 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1751 4 bytes: start time for timer
1752 4 bytes: end time for timer
1753 4 bytes: resume point
1755 4 bytes: num components
1762 8 bytes: frames per second
1765 // Get current timer
1767 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
1770 timerStart = rc->Timer()->StartTime();
1771 timerStop = rc->Timer()->StopTime();
1772 log->log("RRProc", Log::DEBUG, "GRI: RC: %lu %lu", timerStart, timerStop);
1775 resp->addULONG(timerStart);
1776 resp->addULONG(timerStop);
1780 /* char* value = x.config.getValueString("ResumeData", (char*)req->data);
1783 resumePoint = strtoul(value, NULL, 10);
1787 char* ResumeIdC = x.config.getValueString("General", "ResumeId");
1790 ResumeId = atoi(ResumeIdC);
1794 ResumeId = 0; //default if not defined in vomp-MAC.conf
1796 while (ResumeIDLock)
1797 cCondWait::SleepMs(100);
1798 ResumeIDLock = true;
1799 int OldSetupResumeID = Setup.ResumeID;
1800 Setup.ResumeID = ResumeId; //UGLY: quickly change resumeid
1801 #if VDRVERSNUM < 10703
1802 cResumeFile ResumeFile(recording->FileName()); //get corresponding resume file
1804 cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording()); //get corresponding resume file
1806 Setup.ResumeID = OldSetupResumeID; //and restore it back
1807 ResumeIDLock = false;
1809 int resume = ResumeFile.Read();
1810 //isyslog("VOMPDEBUG: resumePoint = %i, resume = %i, ResumeId = %i",resumePoint, resume, ResumeId);
1812 resumePoint = ResumeFile.Read();
1814 log->log("RRProc", Log::DEBUG, "GRI: RP: %lu", resumePoint);
1816 resp->addULONG(resumePoint);
1820 #if VDRVERSNUM < 10300
1821 summary = (char*)recording->Summary();
1823 const cRecordingInfo *Info = recording->Info();
1824 shorttext = (char*)Info->ShortText();
1825 description = (char*) (char*)Info->Description();
1826 if (isempty(shorttext)) summary=description;
1827 else if (isempty(description)) summary=shorttext;
1829 int length=strlen(description)+strlen(shorttext)+4;
1830 summary=new char[length];
1831 snprintf(summary,length,"%s\n\n%s",shorttext,description);
1835 if (isempty(summary)) summary = (char*)Info->Description();
1837 log->log("RRProc", Log::DEBUG, "GRI: S: %s", summary);
1840 resp->addString(x.charconvsys->Convert(summary));
1841 if (newsummary) delete [] summary;
1845 resp->addString("");
1850 #if VDRVERSNUM < 10300
1852 // Send 0 for numchannels - this signals the client this info is not available
1856 const cComponents* components = Info->Components();
1858 log->log("RRProc", Log::DEBUG, "GRI: D1: %p", components);
1866 resp->addULONG(components->NumComponents());
1868 tComponent* component;
1869 for (int i = 0; i < components->NumComponents(); i++)
1871 component = components->Component(i);
1873 log->log("RRProc", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
1875 resp->addUCHAR(component->stream);
1876 resp->addUCHAR(component->type);
1878 if (component->language)
1880 resp->addString(x.charconvsys->Convert(component->language));
1884 resp->addString("");
1886 if (component->description)
1888 resp->addString(x.charconvsys->Convert(component->description));
1892 resp->addString("");
1898 double framespersec;
1899 #if VDRVERSNUM < 10703
1900 framespersec = FRAMESPERSEC;
1902 framespersec = Info->FramesPerSecond();
1904 resp->adddouble(framespersec);
1905 title = (char*)Info->Title();
1908 resp->addString(x.charconvsys->Convert(title));
1912 resp->addString(x.charconvsys->Convert(recording->Name()));
1918 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1920 log->log("RRProc", Log::DEBUG, "Written getrecinfo");
1930 int VompClientRRProc::processReScanRecording()
1934 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1938 x.recplayer->scan();
1940 resp->addULLONG(x.recplayer->getLengthBytes());
1941 resp->addULONG(x.recplayer->getLengthFrames());
1943 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1944 log->log("RRProc", Log::DEBUG, "Rescan recording, wrote new length to client");
1948 // FIXME without client calling rescan, getblock wont work even tho more data is avail
1950 int VompClientRRProc::processGetMarks()
1952 // data is a pointer to the fileName string
1955 cRecordings Recordings;
1956 Recordings.Load(); // probably have to do this
1958 cRecording *recording = Recordings.GetByName((char*)req->data);
1960 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
1964 #if VDRVERSNUM < 10703
1965 Marks.Load(recording->FileName());
1967 Marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording());
1971 for (const cMark *m = Marks.First(); m; m = Marks.Next(m))
1973 #if VDRVERSNUM < 10721
1974 ULLONG mposition = m->position;
1976 ULLONG mposition = m->Position();
1978 log->log("RRProc", Log::DEBUG, "found Mark %i", mposition);
1980 resp->addULONG(mposition);
1985 log->log("RRProc", Log::DEBUG, "no marks found, sending 0-mark");
1991 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1993 log->log("RRProc", Log::DEBUG, "Written Marks list");
1998 int VompClientRRProc::processVDRShutdown()
2000 log->log("RRProc", Log::DEBUG, "Trying to shutdown VDR");
2001 VompClient::decClients(); // Temporarily make this client disappear
2002 cRemote::Put(kPower);
2003 VompClient::incClients();
2005 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2009 int VompClientRRProc::processGetRecScraperEventType()
2011 Recordings.Load(); // probably have to do this
2013 cRecording *recording = Recordings.GetByName((char*)req->data);
2014 ScraperGetEventType call;
2017 if (recording && x.scraper)
2019 call.recording = recording;
2020 x.scraper->Service("GetEventType",&call);
2022 resp->addUCHAR(call.type);
2023 if (call.type == tMovie)
2025 resp->addLONG(call.movieId);
2026 } else if (call.type == tSeries){
2027 resp->addLONG(call.seriesId);
2028 resp->addLONG(call.episodeId);
2031 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2036 #define ADDSTRING_TO_PAKET(y) if ((y)!=0) resp->addString(x.charconvutf8->Convert(y)); else resp->addString("");
2038 int VompClientRRProc::processGetScraperMovieInfo()
2042 movie.movieId = ntohl(*(ULONG*)req->data);
2044 log->log("RRProc", Log::DEBUG, "No Scraper, get SeriesInfo");
2045 return 0; //stupid, I have no scraper why are you still asking
2047 x.scraper->Service("GetMovie",&movie);
2050 ADDSTRING_TO_PAKET(movie.title.c_str());
2051 ADDSTRING_TO_PAKET(movie.originalTitle.c_str());
2052 ADDSTRING_TO_PAKET(movie.tagline.c_str());
2053 ADDSTRING_TO_PAKET(movie.overview.c_str());
2054 resp->addUCHAR(movie.adult);
2055 ADDSTRING_TO_PAKET(movie.collectionName.c_str());
2057 resp->addLONG(movie.budget);
2058 resp->addLONG(movie.revenue);
2059 ADDSTRING_TO_PAKET(movie.genres.c_str());
2060 ADDSTRING_TO_PAKET(movie.homepage.c_str());
2061 ADDSTRING_TO_PAKET(movie.releaseDate.c_str());
2062 resp->addLONG(movie.runtime);
2063 resp->adddouble(movie.popularity);
2064 resp->adddouble(movie.voteAverage);
2065 resp->addULONG(movie.poster.width);
2066 resp->addULONG(movie.poster.height);
2067 resp->addULONG(movie.fanart.width);
2068 resp->addULONG(movie.fanart.height);
2069 resp->addULONG(movie.collectionPoster.width);
2070 resp->addULONG(movie.collectionPoster.height);
2071 resp->addULONG(movie.collectionFanart.width);
2072 resp->addULONG(movie.collectionFanart.height);
2073 resp->addULONG(movie.actors.size());
2074 for (ULONG acty=0; acty < movie.actors.size(); acty++) {
2075 ADDSTRING_TO_PAKET(movie.actors[acty].name.c_str());
2076 ADDSTRING_TO_PAKET(movie.actors[acty].role.c_str());
2077 resp->addULONG(movie.actors[acty].actorThumb.width);
2078 resp->addULONG(movie.actors[acty].actorThumb.height);
2082 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2089 int VompClientRRProc::processGetScraperSeriesInfo()
2092 series.seriesId = ntohl(*(ULONG*)req->data);
2093 series.episodeId = ntohl(*(ULONG*)(req->data+4));
2095 log->log("RRProc", Log::DEBUG, "No Scraper, get SeriesInfo");
2096 return 0; //stupid, I have no scraper why are you still asking
2098 x.scraper->Service("GetSeries",&series);
2100 ADDSTRING_TO_PAKET(series.name.c_str());
2101 ADDSTRING_TO_PAKET(series.overview.c_str());
2102 ADDSTRING_TO_PAKET(series.firstAired.c_str());
2103 ADDSTRING_TO_PAKET(series.network.c_str());
2104 ADDSTRING_TO_PAKET(series.genre.c_str());
2105 resp->adddouble(series.rating);
2106 ADDSTRING_TO_PAKET(series.status.c_str());
2108 resp->addLONG(series.episode.number);
2109 resp->addLONG(series.episode.season);
2110 ADDSTRING_TO_PAKET(series.episode.name.c_str());
2111 ADDSTRING_TO_PAKET(series.episode.firstAired.c_str());
2112 ADDSTRING_TO_PAKET(series.episode.guestStars.c_str());
2113 ADDSTRING_TO_PAKET(series.episode.overview.c_str());
2114 resp->adddouble(series.episode.rating);
2115 resp->addULONG(series.episode.episodeImage.width);
2116 resp->addULONG(series.episode.episodeImage.height);
2118 ULONG num_actors = series.actors.size();
2119 resp->addULONG(num_actors);
2120 for (ULONG acty=0; acty < num_actors; acty++) {
2121 ADDSTRING_TO_PAKET(series.actors[acty].name.c_str());
2122 ADDSTRING_TO_PAKET(series.actors[acty].role.c_str());
2123 resp->addULONG(series.actors[acty].actorThumb.width);
2124 resp->addULONG(series.actors[acty].actorThumb.height);
2126 ULONG num_posters = series.posters.size();
2127 resp->addULONG(num_posters);
2128 for (ULONG medias = 0; medias < num_posters; medias++ ) {
2129 cTvMedia media=series.posters[medias];
2130 resp->addULONG(media.width);
2131 resp->addULONG(media.height);
2134 ULONG num_banners = series.banners.size();
2135 resp->addULONG(num_banners);
2136 for (ULONG medias = 0; medias < num_banners; medias++ ) {
2137 cTvMedia media=series.banners[medias];
2138 resp->addULONG(media.width);
2139 resp->addULONG(media.height);
2141 ULONG num_fanarts = series.fanarts.size();
2142 resp->addULONG(num_fanarts);
2143 for (ULONG medias = 0; medias < num_fanarts; medias++ ) {
2144 cTvMedia media=series.fanarts[medias];
2145 resp->addULONG(media.width);
2146 resp->addULONG(media.height);
2148 resp->addULONG(series.seasonPoster.width);
2149 resp->addULONG(series.seasonPoster.height);
2153 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2158 int VompClientRRProc::processLoadTvMedia()
2160 TVMediaRequest tvreq;
2161 tvreq.streamID = req->requestID;
2162 tvreq.type = ntohl(*(ULONG*)req->data);
2163 tvreq.primary_id = ntohl(*(ULONG*)(req->data+4));
2164 tvreq.secondary_id = ntohl(*(ULONG*)(req->data+8));
2165 tvreq.type_pict = ntohl(*(ULONG*)(req->data+12));
2166 tvreq.container = ntohl(*(ULONG*)(req->data+16));
2167 tvreq.container_member = ntohl(*(ULONG*)(req->data+20));
2168 log->log("RRProc", Log::DEBUG, "TVMedia request %d",req->requestID);
2169 x.pict->addTVMediaRequest(tvreq);
2174 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2179 int VompClientRRProc::processLoadTvMediaRecThumb()
2181 TVMediaRequest tvreq;
2182 tvreq.streamID = req->requestID;
2183 tvreq.type = 3; // unknown but primary_name is set
2184 tvreq.primary_id = 0;
2185 tvreq.primary_name = std::string((const char*) req->data);
2186 tvreq.secondary_id = 0;
2187 tvreq.type_pict = 1;
2188 tvreq.container = 0;
2189 tvreq.container_member = 0;
2190 log->log("RRProc", Log::DEBUG, "TVMedia request %d %s",req->requestID,req->data);
2191 x.pict->addTVMediaRequest(tvreq);
2196 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2205 #endif // !VOMPSTANDALONE