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();
291 case VDR_GETMEDIALIST:
292 result = processGetMediaList();
295 result = processOpenMedia();
297 case VDR_GETMEDIABLOCK:
298 result = processGetMediaBlock();
301 result = processGetLanguageList();
304 result = processGetLanguageContent();
306 case VDR_GETMEDIAINFO:
307 result = processGetMediaInfo();
309 case VDR_CLOSECHANNEL:
310 result = processCloseMediaChannel();
313 result = processSetCharset();
320 if (req->data) free(req->data);
324 if (result) return true;
328 int VompClientRRProc::processLogin()
330 if (req->dataLength != 6) return 0;
334 char configFileName[PATH_MAX];
335 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]);
336 x.config.init(configFileName);
338 // Send the login reply
340 time_t timeNow = time(NULL);
341 struct tm* timeStruct = localtime(&timeNow);
342 int timeOffset = timeStruct->tm_gmtoff;
344 resp->addULONG(timeNow);
345 resp->addLONG(timeOffset);
346 resp->addULONG(VOMP_PROTOCOL_VERSION_MIN);
347 resp->addULONG(VOMP_PROTOCOL_VERSION_MAX);
349 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
350 log->log("RRProc", Log::DEBUG, "written login reply len %lu", resp->getLen());
353 x.netLog(); // safe to run here since the client won't start net logging for a while yet
358 int VompClientRRProc::processSetCharset()
360 int charset = ntohl(*(ULONG*)req->data);
361 if (charset>0 && charset<3)
363 log->log("RRProc", Log::DEBUG, "Set charset to %d", charset);
364 x.setCharset(charset);
369 log->log("RRProc", Log::DEBUG, "Invalid charset %d", charset);
373 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
377 int VompClientRRProc::processConfigSave()
379 char* section = (char*)req->data;
383 for (UINT k = 0; k < req->dataLength; k++)
385 if (req->data[k] == '\0')
389 key = (char*)&req->data[k+1];
393 value = (char*)&req->data[k+1];
399 // if the last string (value) doesnt have null terminator, give up
400 if (req->data[req->dataLength - 1] != '\0') return 0;
402 log->log("RRProc", Log::DEBUG, "Config save: %s %s %s", section, key, value);
403 if (x.config.setValueString(section, key, value))
413 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
418 int VompClientRRProc::processConfigLoad()
420 char* section = (char*)req->data;
423 for (UINT k = 0; k < req->dataLength; k++)
425 if (req->data[k] == '\0')
427 key = (char*)&req->data[k+1];
432 char* value = x.config.getValueString(section, key);
436 resp->addString(value);//client coding, do not touch
437 log->log("RRProc", Log::DEBUG, "Written config load packet");
443 log->log("RRProc", Log::DEBUG, "Written config load failed packet");
447 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
453 //helper for sending from a serialize buffer
454 //insert the used len into the first 4 Bytes of the buffer
455 void VompClientRRProc::sendPacket(SerializeBuffer *b) {
456 resp->copyin(b->getStart(),b->getCurrent()-b->getStart());
458 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
462 * media List Request:
463 * Media List response:
466 #define MLISTBUF 500000
467 int VompClientRRProc::processGetMediaList()
469 SerializeBuffer buffer(req->data,req->dataLength);
470 MediaURI uri(0,NULL,NULL);
471 VDR_GetMediaListRequest request(&uri);
472 if (request.deserialize(&buffer) != 0) {
473 log->log("Client", Log::ERR, "getMediaList unable to deserialize");
476 const char *dirname=uri.getName();
477 log->log("Client", Log::DEBUG, "getMediaList for %s", dirname);
480 if (dirname == NULL) {
481 ml=x.media->getRootList();
483 ml=x.media->getMediaList(&uri);
486 log->log("Client", Log::ERR, "getMediaList returned NULL");
489 SerializeBuffer rbuf(MLISTBUF,false,true);
490 ULONG flags=0; //TODO: real error handling by setting flags
491 VDR_GetMediaListResponse response(&flags,ml);
492 if (response.serialize(&rbuf) != 0) {
493 log->log("Client", Log::ERR, "getMediaList returned NULL");
497 log->log("Client", Log::DEBUG, "getMediaList size %u", ml->size());
502 log->log("Client", Log::DEBUG, "Written Media list");
507 * openMedia response:
509 int VompClientRRProc::processOpenMedia()
511 SerializeBuffer buffer(req->data,req->dataLength);
512 MediaURI uri(0,NULL,NULL);
516 VDR_OpenMediumRequest request(&channel,&uri,&xs,&ys);
517 if (request.deserialize(&buffer) != 0) {
518 log->log("Client", Log::ERR, "openMediaRequest unable to deserialize");
521 const char *name=uri.getName();
522 log->log("Client", Log::DEBUG, "openMediaRequest for %s", name);
524 int rt=x.media->openMedium(channel,&uri,&size,xs,ys);
529 log->log("Client", Log::ERR, "openMediaRequest unable to open");
531 VDR_OpenMediumResponse response(&flags,&size);
532 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
533 if (response.serialize(&rbuf) != 0) {
534 log->log("Client", Log::ERR, "openMediaRequest cannot serialize");
537 log->log("Client", Log::DEBUG, "openMediaRequest size %llu", size);
544 * packet - no serialized response!
546 int VompClientRRProc::processGetMediaBlock()
548 SerializeBuffer buffer(req->data,req->dataLength);
552 VDR_GetMediaBlockRequest request(&channel,&position,&amount);
553 if (request.deserialize(&buffer) != 0) {
554 log->log("Client", Log::ERR, "getMediaBlock unable to deserialize");
557 log->log("Client", Log::DEBUG, "getMediaBlock pos = %llu length = %lu,chan=%lu", position, amount,channel);
559 UCHAR sendBuffer[amount ];
560 ULONG amountReceived = 0;
561 UCHAR *rbuf=sendBuffer;
562 int rt=x.media->getMediaBlock(channel,position,amount,&amountReceived,&rbuf);
563 if (!amountReceived || rt != 0)
565 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
569 if (rbuf != sendBuffer) {
570 //the provider did not use the optimized handling with using my buffer
571 resp->copyin(rbuf,amountReceived);
574 // the provider did not allocate a new buffer
575 resp->copyin(sendBuffer,amountReceived);
579 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
580 log->log("Client", Log::DEBUG, "written ok %lu", amountReceived);
587 int VompClientRRProc::processGetMediaInfo()
589 SerializeBuffer buffer(req->data,req->dataLength);
591 VDR_GetMediaInfoRequest request(&channel);
592 if (request.deserialize(&buffer) != 0) {
593 log->log("Client", Log::ERR, "getMediaInfo unable to deserialize");
596 log->log("Client", Log::DEBUG, "getMediaInfo chan=%lu", channel);
599 int rt=x.media->getMediaInfo(channel,&mi);
602 log->log("Client", Log::ERR, "getMediaInfo unable to get");
604 VDR_GetMediaInfoResponse response(&flags,&mi);
605 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
606 if (response.serialize(&rbuf) != 0) {
607 log->log("Client", Log::ERR, "getMediaInfo cannot serialize");
619 int VompClientRRProc::processCloseMediaChannel()
621 SerializeBuffer buffer(req->data,req->dataLength);
623 VDR_CloseMediaChannelRequest request(&channel);
624 if (request.deserialize(&buffer) != 0) {
625 log->log("Client", Log::ERR, "closeMediaChannel unable to deserialize");
629 log->log("Client", Log::DEBUG, "closeMediaChannel chan=%lu", channel);
630 int rt=x.media->closeMediaChannel(channel);
633 log->log("Client", Log::ERR, "closeMediaChannel unable to get");
635 VDR_CloseMediaChannelResponse response(&flags);
636 SerializeBuffer rbuf(response.getSerializedLen()+4,false,true);
637 if (response.serialize(&rbuf) != 0) {
638 log->log("Client", Log::ERR, "closeMediaChannel cannot serialize");
647 int VompClientRRProc::processGetLanguageList()
649 x.i18n.findLanguages();
650 const I18n::lang_code_list& languages = x.i18n.getLanguageList();
652 I18n::lang_code_list::const_iterator iter;
653 for (iter = languages.begin(); iter != languages.end(); ++iter)
655 resp->addString(iter->first.c_str()); // Source code is acsii
656 resp->addString(x.charconvutf8->Convert(iter->second.c_str())); //translate string can be any utf-8 character
659 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
663 int VompClientRRProc::processGetLanguageContent()
665 if (req->dataLength <= 0) return 0;
666 std::string code, result;
667 code.assign((char*)req->data, req->dataLength - 1);
668 x.i18n.findLanguages();
669 I18n::trans_table texts = x.i18n.getLanguageContent(code);
670 I18n::trans_table::const_iterator iter;
671 for (iter = texts.begin(); iter != texts.end(); ++iter)
673 resp->addString(iter->first.c_str());// source code is acsii since it is english
674 resp->addString(x.charconvutf8->Convert(iter->second.c_str())); // translate text can be any unicode string, it is stored as UTF-8
677 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
681 #ifndef VOMPSTANDALONE
683 int VompClientRRProc::processGetRecordingsList()
686 #if APIVERSNUM > 20101
687 int Percent = cVideoDirectory::VideoDiskSpace(&FreeMB);
689 int Percent = VideoDiskSpace(&FreeMB);
691 int Total = (FreeMB / (100 - Percent)) * 100;
693 resp->addULONG(Total);
694 resp->addULONG(FreeMB);
695 resp->addULONG(Percent);
697 cRecordings Recordings;
700 for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording))
702 #if VDRVERSNUM < 10721
703 resp->addULONG(recording->start);
705 resp->addULONG(recording->Start());
707 resp->addUCHAR(recording->IsNew() ? 1 : 0);
708 resp->addString(x.charconvsys->Convert(recording->Name())); //coding of recording name is system dependent
709 resp->addString(recording->FileName());//file name are not visible by user do not touch
713 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
715 log->log("RRProc", Log::DEBUG, "Written recordings list");
720 int VompClientRRProc::processDeleteRecording()
722 // data is a pointer to the fileName string
724 cRecordings Recordings;
725 Recordings.Load(); // probably have to do this
727 cRecording* recording = Recordings.GetByName((char*)req->data);
729 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
733 log->log("RRProc", Log::DEBUG, "deleting recording: %s", recording->Name());
735 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
738 if (recording->Delete())
740 // Copy svdrp's way of doing this, see if it works
741 #if VDRVERSNUM > 10300
742 ::Recordings.DelByName(recording->FileName());
762 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
767 int VompClientRRProc::processMoveRecording()
769 log->log("RRProc", Log::DEBUG, "Process move recording");
770 char* fileName = (char*)req->data;
771 char* newPath = NULL;
773 for (UINT k = 0; k < req->dataLength; k++)
775 if (req->data[k] == '\0')
777 newPath = (char*)&req->data[k+1];
781 if (!newPath) return 0;
783 cRecordings Recordings;
784 Recordings.Load(); // probably have to do this
786 cRecording* recording = Recordings.GetByName((char*)fileName);
788 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
792 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
795 log->log("RRProc", Log::DEBUG, "moving recording: %s", recording->Name());
796 log->log("RRProc", Log::DEBUG, "moving recording: %s", recording->FileName());
797 log->log("RRProc", Log::DEBUG, "to: %s", newPath);
799 const char* t = recording->FileName();
801 char* dateDirName = NULL; int k;
802 char* titleDirName = NULL; int j;
804 // Find the datedirname
805 for(k = strlen(t) - 1; k >= 0; k--)
809 log->log("RRProc", Log::DEBUG, "l1: %i", strlen(&t[k+1]) + 1);
810 dateDirName = new char[strlen(&t[k+1]) + 1];
811 strcpy(dateDirName, &t[k+1]);
816 // Find the titledirname
818 for(j = k-1; j >= 0; j--)
822 log->log("RRProc", Log::DEBUG, "l2: %i", (k - j - 1) + 1);
823 titleDirName = new char[(k - j - 1) + 1];
824 memcpy(titleDirName, &t[j+1], k - j - 1);
825 titleDirName[k - j - 1] = '\0';
830 log->log("RRProc", Log::DEBUG, "datedirname: %s", dateDirName);
831 log->log("RRProc", Log::DEBUG, "titledirname: %s", titleDirName);
832 #if APIVERSNUM > 20101
833 log->log("RRProc", Log::DEBUG, "viddir: %s", cVideoDirectory::Name());
835 log->log("RRProc", Log::DEBUG, "viddir: %s", VideoDirectory);
838 char* newPathConv = new char[strlen(newPath)+1];
839 strcpy(newPathConv, newPath);
840 ExchangeChars(newPathConv, true);
841 log->log("RRProc", Log::DEBUG, "EC: %s", newPathConv);
843 #if APIVERSNUM > 20101
844 char* newContainer = new char[strlen(cVideoDirectory::Name()) + strlen(newPathConv) + strlen(titleDirName) + 1];
845 log->log("RRProc", Log::DEBUG, "l10: %i", strlen(cVideoDirectory::Name()) + strlen(newPathConv) + strlen(titleDirName) + 1);
846 sprintf(newContainer, "%s%s%s", cVideoDirectory::Name(), newPathConv, titleDirName);
848 char* newContainer = new char[strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1];
849 log->log("RRProc", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPathConv) + strlen(titleDirName) + 1);
850 sprintf(newContainer, "%s%s%s", VideoDirectory, newPathConv, titleDirName);
852 delete[] newPathConv;
854 log->log("RRProc", Log::DEBUG, "%s", newContainer);
857 int statret = stat(newContainer, &dstat);
858 if ((statret == -1) && (errno == ENOENT)) // Dir does not exist
860 log->log("RRProc", Log::DEBUG, "new dir does not exist");
861 int mkdirret = mkdir(newContainer, 0755);
864 delete[] dateDirName;
865 delete[] titleDirName;
866 delete[] newContainer;
870 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
874 else if ((statret == 0) && (! (dstat.st_mode && S_IFDIR))) // Something exists but it's not a dir
876 delete[] dateDirName;
877 delete[] titleDirName;
878 delete[] newContainer;
882 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
886 // Ok, the directory container has been made, or it pre-existed.
888 char* newDir = new char[strlen(newContainer) + 1 + strlen(dateDirName) + 1];
889 sprintf(newDir, "%s/%s", newContainer, dateDirName);
891 log->log("RRProc", Log::DEBUG, "doing rename '%s' '%s'", t, newDir);
892 int renameret = rename(t, newDir);
895 // Success. Test for remove old dir containter
896 char* oldTitleDir = new char[k+1];
897 memcpy(oldTitleDir, t, k);
898 oldTitleDir[k] = '\0';
899 log->log("RRProc", Log::DEBUG, "len: %i, cp: %i, strlen: %i, oldtitledir: %s", k+1, k, strlen(oldTitleDir), oldTitleDir);
900 rmdir(oldTitleDir); // can't do anything about a fail result at this point.
901 delete[] oldTitleDir;
906 #if VDRVERSNUM > 10311
908 ::Recordings.Update();
910 // Success. Send a different packet from just a ulong
911 resp->addULONG(1); // success
912 resp->addString(newDir); //system depent do not convert
920 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
922 delete[] dateDirName;
923 delete[] titleDirName;
924 delete[] newContainer;
931 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
938 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
944 int VompClientRRProc::processGetChannelsList()
948 char* chanConfig = x.config.getValueString("General", "Channels");
950 if (chanConfig) allChans = strcasecmp(chanConfig, "FTA only");
952 for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
954 #if VDRVERSNUM < 10300
955 if (!channel->GroupSep() && (!channel->Ca() || allChans))
957 if (!channel->GroupSep() && (!channel->Ca(0) || allChans))
960 log->log("RRProc", Log::DEBUG, "name: '%s'", channel->Name());
962 if (channel->Vpid()) type = 1;
963 #if VDRVERSNUM < 10300
966 else if (channel->Apid(0)) type = 2;
970 resp->addULONG(channel->Number());
971 resp->addULONG(type);
972 resp->addString(x.charconvsys->Convert(channel->Name()));
973 #if VDRVERSNUM < 10703
976 resp->addULONG(channel->Vtype());
982 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
984 log->log("RRProc", Log::DEBUG, "Written channels list");
989 int VompClientRRProc::processGetChannelPids()
991 ULONG channelNumber = ntohl(*(ULONG*)req->data);
993 cChannel* channel = x.channelFromNumber(channelNumber);
998 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1007 #if VDRVERSNUM < 10300
1009 log->log("RRProc", Log::DEBUG, "Apid1: %i", channel->Apid1());
1010 log->log("RRProc", Log::DEBUG, "Apid2: %i", channel->Apid2());
1012 if (channel->Apid2())
1014 else if (channel->Apid1())
1021 for (const int *Apid = channel->Apids(); *Apid; Apid++)
1025 for (const int *Dpid = channel->Dpids(); *Dpid; Dpid++)
1029 for (const int *Spid = channel->Spids(); *Spid; Spid++)
1036 // Format of response
1055 resp->addULONG(channel->Vpid());
1056 #if VDRVERSNUM < 10703
1059 resp->addULONG(channel->Vtype());
1061 resp->addULONG(numApids);
1063 #if VDRVERSNUM < 10300
1066 resp->addULONG(channel->Apid1());
1067 resp->addString("");
1071 resp->addULONG(channel->Apid2());
1072 resp->addString("");
1077 for (ULONG i = 0; i < numApids; i++)
1079 resp->addULONG(channel->Apid(i));
1080 resp->addString(x.charconvsys->Convert(channel->Alang(i)));
1082 resp->addULONG(numDpids);
1083 for (ULONG i = 0; i < numDpids; i++)
1085 resp->addULONG(channel->Dpid(i));
1086 resp->addString(x.charconvsys->Convert(channel->Dlang(i)));
1088 resp->addULONG(numSpids);
1089 for (ULONG i = 0; i < numSpids; i++)
1091 resp->addULONG(channel->Spid(i));
1092 resp->addString(x.charconvsys->Convert(channel->Slang(i)));
1095 resp->addULONG(channel->Tpid());
1096 // Format of extended response, for compatibility with older client at the end
1108 #if VDRVERSNUM < 10300
1118 for (ULONG i = 0; i < numApids; i++)
1120 #if VDRVERSNUM < 10715
1123 resp->addULONG(channel->Atype(i));
1126 for (ULONG i = 0; i < numDpids; i++)
1128 #if VDRVERSNUM < 10715
1129 resp->addULONG(0x6A /*AC3*/);
1131 resp->addULONG(channel->Dtype(i));
1134 for (ULONG i = 0; i < numSpids; i++)
1136 #if VDRVERSNUM < 10715
1141 resp->addULONG(channel->SubtitlingType(i));
1142 resp->addULONG(channel->CompositionPageId(i));
1143 resp->addULONG(channel->AncillaryPageId(i));
1150 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1152 log->log("RRProc", Log::DEBUG, "Written channels pids");
1157 int VompClientRRProc::processStartStreamingChannel()
1161 log->log("RRProc", Log::ERR, "Client called start streaming twice");
1165 log->log("RRProc", Log::DEBUG, "req->dataLength = %i", req->dataLength);
1166 ULONG channelNumber = ntohl(*(ULONG*)req->data);
1168 cChannel* channel = x.channelFromNumber(channelNumber);
1173 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1177 // get the priority we should use
1179 int priority = x.config.getValueLong("General", "Live priority", &fail);
1182 log->log("RRProc", Log::DEBUG, "Config: Live TV priority: %i", priority);
1186 log->log("RRProc", Log::DEBUG, "Config: Live TV priority config fail");
1190 // a bit of sanity..
1191 #if VDRVERSNUM < 10725
1192 if (priority < 0) priority = 0;
1194 if (priority < -99) priority = -99;
1196 if (priority > 99) priority = 99;
1198 log->log("RRProc", Log::DEBUG, "Using live TV priority %i", priority);
1199 x.lp = MVPReceiver::create(channel, priority);
1205 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1209 if (!x.lp->init(&x.tcp, req->requestID))
1215 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1221 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1225 int VompClientRRProc::processStopStreaming()
1227 log->log("RRProc", Log::DEBUG, "STOP STREAMING RECEIVED");
1230 x.lp->detachMVPReceiver();
1234 else if (x.recplayer)
1236 x.writeResumeData();
1239 delete x.recordingManager;
1241 x.recordingManager = NULL;
1246 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1250 int VompClientRRProc::processGetBlock()
1254 log->log("RRProc", Log::ERR, "Get block called during live streaming");
1260 log->log("RRProc", Log::ERR, "Get block called when no recording open");
1264 UCHAR* data = req->data;
1266 ULLONG position = x.ntohll(*(ULLONG*)data);
1267 data += sizeof(ULLONG);
1268 ULONG amount = ntohl(*(ULONG*)data);
1270 log->log("RRProc", Log::DEBUG, "getblock pos = %llu length = %lu", position, amount);
1272 UCHAR sendBuffer[amount];
1273 ULONG amountReceived = x.recplayer->getBlock(&sendBuffer[0], position, amount);
1275 if (!amountReceived)
1278 log->log("RRProc", Log::DEBUG, "written 4(0) as getblock got 0");
1282 resp->copyin(sendBuffer, amountReceived);
1283 log->log("RRProc", Log::DEBUG, "written %lu", amountReceived);
1287 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1288 log->log("RRProc", Log::DEBUG, "Finished getblock, have sent %lu", resp->getLen());
1292 int VompClientRRProc::processStartStreamingRecording()
1294 // data is a pointer to the fileName string
1296 x.recordingManager = new cRecordings;
1297 x.recordingManager->Load();
1299 cRecording* recording = x.recordingManager->GetByName((char*)req->data);
1301 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
1305 x.recplayer = new RecPlayer(recording);
1307 resp->addULLONG(x.recplayer->getLengthBytes());
1308 resp->addULONG(x.recplayer->getLengthFrames());
1310 #if VDRVERSNUM < 10703
1311 resp->addUCHAR(true);//added for TS
1313 resp->addUCHAR(recording->IsPesRecording());//added for TS
1317 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1319 log->log("RRProc", Log::DEBUG, "written totalLength");
1323 delete x.recordingManager;
1324 x.recordingManager = NULL;
1329 int VompClientRRProc::processPositionFromFrameNumber()
1333 ULONG frameNumber = ntohl(*(ULONG*)req->data);
1337 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1341 retval = x.recplayer->positionFromFrameNumber(frameNumber);
1344 resp->addULLONG(retval);
1346 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1348 log->log("RRProc", Log::DEBUG, "Wrote posFromFrameNum reply to client");
1352 int VompClientRRProc::processFrameNumberFromPosition()
1356 ULLONG position = x.ntohll(*(ULLONG*)req->data);
1360 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1364 retval = x.recplayer->frameNumberFromPosition(position);
1367 resp->addULONG(retval);
1369 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1371 log->log("RRProc", Log::DEBUG, "Wrote frameNumFromPos reply to client");
1375 int VompClientRRProc::processGetIFrame()
1377 bool success = false;
1379 ULONG* data = (ULONG*)req->data;
1381 ULONG frameNumber = ntohl(*data);
1383 ULONG direction = ntohl(*data);
1385 ULLONG rfilePosition = 0;
1386 ULONG rframeNumber = 0;
1387 ULONG rframeLength = 0;
1391 log->log("RRProc", Log::DEBUG, "GetIFrame recording called when no recording being played!");
1395 success = x.recplayer->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
1398 // returns file position, frame number, length
1402 resp->addULLONG(rfilePosition);
1403 resp->addULONG(rframeNumber);
1404 resp->addULONG(rframeLength);
1412 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1414 log->log("RRProc", Log::DEBUG, "Wrote GNIF reply to client %llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
1418 int VompClientRRProc::processGetChannelSchedule()
1420 ULONG* data = (ULONG*)req->data;
1422 ULONG channelNumber = ntohl(*data);
1424 ULONG startTime = ntohl(*data);
1426 ULONG duration = ntohl(*data);
1428 log->log("RRProc", Log::DEBUG, "get schedule called for channel %lu", channelNumber);
1430 cChannel* channel = x.channelFromNumber(channelNumber);
1435 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1437 log->log("RRProc", Log::DEBUG, "written 0 because channel = NULL");
1441 log->log("RRProc", Log::DEBUG, "Got channel");
1443 #if VDRVERSNUM < 10300
1444 cMutexLock MutexLock;
1445 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1447 cSchedulesLock MutexLock;
1448 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1454 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1456 log->log("RRProc", Log::DEBUG, "written 0 because Schedule!s! = NULL");
1460 log->log("RRProc", Log::DEBUG, "Got schedule!s! object");
1462 const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
1467 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1469 log->log("RRProc", Log::DEBUG, "written 0 because Schedule = NULL");
1473 log->log("RRProc", Log::DEBUG, "Got schedule object");
1475 const char* empty = "";
1476 bool atLeastOneEvent = false;
1479 ULONG thisEventTime;
1480 ULONG thisEventDuration;
1481 const char* thisEventTitle;
1482 const char* thisEventSubTitle;
1483 const char* thisEventDescription;
1485 #if VDRVERSNUM < 10300
1487 const cEventInfo *event;
1488 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1490 event = Schedule->GetEventNumber(eventNumber);
1492 thisEventID = event->GetEventID();
1493 thisEventTime = event->GetTime();
1494 thisEventDuration = event->GetDuration();
1495 thisEventTitle = event->GetTitle();
1496 thisEventSubTitle = event->GetSubtitle();
1497 thisEventDescription = event->GetExtendedDescription();
1501 for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
1503 thisEventID = event->EventID();
1504 thisEventTime = event->StartTime();
1505 thisEventDuration = event->Duration();
1506 thisEventTitle = event->Title();
1507 thisEventSubTitle = NULL;
1508 thisEventDescription = event->Description();
1512 //in the past filter
1513 if ((thisEventTime + thisEventDuration) < (ULONG)time(NULL)) continue;
1516 if ((thisEventTime + thisEventDuration) <= startTime) continue;
1519 if (thisEventTime >= (startTime + duration)) continue;
1521 if (!thisEventTitle) thisEventTitle = empty;
1522 if (!thisEventSubTitle) thisEventSubTitle = empty;
1523 if (!thisEventDescription) thisEventDescription = empty;
1525 resp->addULONG(thisEventID);
1526 resp->addULONG(thisEventTime);
1527 resp->addULONG(thisEventDuration);
1529 resp->addString(x.charconvsys->Convert(thisEventTitle));
1530 resp->addString(x.charconvsys->Convert(thisEventSubTitle));
1531 resp->addString(x.charconvsys->Convert(thisEventDescription));
1533 atLeastOneEvent = true;
1536 log->log("RRProc", Log::DEBUG, "Got all event data");
1538 if (!atLeastOneEvent)
1541 log->log("RRProc", Log::DEBUG, "Written 0 because no data");
1545 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1547 log->log("RRProc", Log::DEBUG, "written schedules packet");
1552 int VompClientRRProc::processGetTimers()
1555 int numTimers = Timers.Count();
1557 resp->addULONG(numTimers);
1559 for (int i = 0; i < numTimers; i++)
1561 timer = Timers.Get(i);
1563 #if VDRVERSNUM < 10300
1564 resp->addULONG(timer->Active());
1566 resp->addULONG(timer->HasFlags(tfActive));
1568 resp->addULONG(timer->Recording());
1569 resp->addULONG(timer->Pending());
1570 resp->addULONG(timer->Priority());
1571 resp->addULONG(timer->Lifetime());
1572 resp->addULONG(timer->Channel()->Number());
1573 resp->addULONG(timer->StartTime());
1574 resp->addULONG(timer->StopTime());
1575 resp->addULONG(timer->Day());
1576 resp->addULONG(timer->WeekDays());
1577 resp->addString(timer->File()); //Filename is system specific and not visible by user
1581 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1583 log->log("RRProc", Log::DEBUG, "Written timers list");
1588 int VompClientRRProc::processSetTimer()
1590 char* timerString = new char[strlen((char*)req->data) + 1];
1591 strcpy(timerString, (char*)req->data);
1593 #if VDRVERSNUM < 10300
1595 // If this is VDR 1.2 the date part of the timer string must be reduced
1596 // to just DD rather than YYYY-MM-DD
1598 int s = 0; // source
1599 int d = 0; // destination
1601 while(c != 2) // copy up to date section, including the second ':'
1603 timerString[d] = req->data[s];
1604 if (req->data[s] == ':') c++;
1608 // now it has copied up to the date section
1610 while(c != 2) // waste YYYY-MM-
1612 if (req->data[s] == '-') c++;
1615 // now source is at the DD
1616 memcpy(&timerString[d], &req->data[s], req->dataLength - s);
1617 d += req->dataLength - s;
1618 timerString[d] = '\0';
1620 log->log("RRProc", Log::DEBUG, "Timer string after 1.2 conversion:");
1623 log->log("RRProc", Log::DEBUG, "%s", timerString);
1625 cTimer *timer = new cTimer;
1626 if (timer->Parse((char*)timerString))
1628 cTimer *t = Timers.GetTimer(timer);
1632 #if VDRVERSNUM < 10300
1635 Timers.SetModified();
1639 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1640 return 1; // FIXME - cTimer* timer is leaked here!
1646 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1653 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1659 int VompClientRRProc::processDeleteTimer()
1661 log->log("RRProc", Log::DEBUG, "Delete timer called");
1666 INT delChannel = ntohl(*(ULONG*)&req->data[position]); position += 4;
1667 INT delWeekdays = ntohl(*(ULONG*)&req->data[position]); position += 4;
1668 INT delDay = ntohl(*(ULONG*)&req->data[position]); position += 4;
1669 INT delStart = ntohl(*(ULONG*)&req->data[position]); position += 4;
1670 INT delStop = ntohl(*(ULONG*)&req->data[position]); position += 4;
1673 for (ti = Timers.First(); ti; ti = Timers.Next(ti))
1675 if ( (ti->Channel()->Number() == delChannel)
1676 && ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
1677 && (ti->StartTime() == delStart)
1678 && (ti->StopTime() == delStop) )
1686 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1690 if (!Timers.BeingEdited())
1692 if (!ti->Recording())
1695 Timers.SetModified();
1698 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1703 log->log("RRProc", Log::ERR, "Unable to delete timer - timer is running");
1706 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1712 log->log("RRProc", Log::ERR, "Unable to delete timer - timers being edited at VDR");
1715 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1720 int VompClientRRProc::processGetRecInfo()
1722 // data is a pointer to the fileName string
1724 cRecordings Recordings;
1725 Recordings.Load(); // probably have to do this
1727 cRecording *recording = Recordings.GetByName((char*)req->data);
1729 time_t timerStart = 0;
1730 time_t timerStop = 0;
1731 char* summary = NULL;
1732 char* shorttext = NULL;
1733 char* description = NULL;
1735 bool newsummary=false;
1736 ULONG resumePoint = 0;
1740 log->log("RRProc", Log::ERR, "GetRecInfo found no recording");
1743 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1748 4 bytes: start time for timer
1749 4 bytes: end time for timer
1750 4 bytes: resume point
1752 4 bytes: num components
1759 8 bytes: frames per second
1762 // Get current timer
1764 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
1767 timerStart = rc->Timer()->StartTime();
1768 timerStop = rc->Timer()->StopTime();
1769 log->log("RRProc", Log::DEBUG, "GRI: RC: %lu %lu", timerStart, timerStop);
1772 resp->addULONG(timerStart);
1773 resp->addULONG(timerStop);
1777 /* char* value = x.config.getValueString("ResumeData", (char*)req->data);
1780 resumePoint = strtoul(value, NULL, 10);
1784 char* ResumeIdC = x.config.getValueString("General", "ResumeId");
1787 ResumeId = atoi(ResumeIdC);
1791 ResumeId = 0; //default if not defined in vomp-MAC.conf
1793 while (ResumeIDLock)
1794 cCondWait::SleepMs(100);
1795 ResumeIDLock = true;
1796 int OldSetupResumeID = Setup.ResumeID;
1797 Setup.ResumeID = ResumeId; //UGLY: quickly change resumeid
1798 #if VDRVERSNUM < 10703
1799 cResumeFile ResumeFile(recording->FileName()); //get corresponding resume file
1801 cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording()); //get corresponding resume file
1803 Setup.ResumeID = OldSetupResumeID; //and restore it back
1804 ResumeIDLock = false;
1806 int resume = ResumeFile.Read();
1807 //isyslog("VOMPDEBUG: resumePoint = %i, resume = %i, ResumeId = %i",resumePoint, resume, ResumeId);
1809 resumePoint = ResumeFile.Read();
1811 log->log("RRProc", Log::DEBUG, "GRI: RP: %lu", resumePoint);
1813 resp->addULONG(resumePoint);
1817 #if VDRVERSNUM < 10300
1818 summary = (char*)recording->Summary();
1820 const cRecordingInfo *Info = recording->Info();
1821 shorttext = (char*)Info->ShortText();
1822 description = (char*) (char*)Info->Description();
1823 if (isempty(shorttext)) summary=description;
1824 else if (isempty(description)) summary=shorttext;
1826 int length=strlen(description)+strlen(shorttext)+4;
1827 summary=new char[length];
1828 snprintf(summary,length,"%s\n\n%s",shorttext,description);
1832 if (isempty(summary)) summary = (char*)Info->Description();
1834 log->log("RRProc", Log::DEBUG, "GRI: S: %s", summary);
1837 resp->addString(x.charconvsys->Convert(summary));
1838 if (newsummary) delete [] summary;
1842 resp->addString("");
1847 #if VDRVERSNUM < 10300
1849 // Send 0 for numchannels - this signals the client this info is not available
1853 const cComponents* components = Info->Components();
1855 log->log("RRProc", Log::DEBUG, "GRI: D1: %p", components);
1863 resp->addULONG(components->NumComponents());
1865 tComponent* component;
1866 for (int i = 0; i < components->NumComponents(); i++)
1868 component = components->Component(i);
1870 log->log("RRProc", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
1872 resp->addUCHAR(component->stream);
1873 resp->addUCHAR(component->type);
1875 if (component->language)
1877 resp->addString(x.charconvsys->Convert(component->language));
1881 resp->addString("");
1883 if (component->description)
1885 resp->addString(x.charconvsys->Convert(component->description));
1889 resp->addString("");
1895 double framespersec;
1896 #if VDRVERSNUM < 10703
1897 framespersec = FRAMESPERSEC;
1899 framespersec = Info->FramesPerSecond();
1901 resp->adddouble(framespersec);
1902 title = (char*)Info->Title();
1905 resp->addString(x.charconvsys->Convert(title));
1909 resp->addString(x.charconvsys->Convert(recording->Name()));
1915 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1917 log->log("RRProc", Log::DEBUG, "Written getrecinfo");
1927 int VompClientRRProc::processReScanRecording()
1931 log->log("RRProc", Log::DEBUG, "Rescan recording called when no recording being played!");
1935 x.recplayer->scan();
1937 resp->addULLONG(x.recplayer->getLengthBytes());
1938 resp->addULONG(x.recplayer->getLengthFrames());
1940 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1941 log->log("RRProc", Log::DEBUG, "Rescan recording, wrote new length to client");
1945 // FIXME without client calling rescan, getblock wont work even tho more data is avail
1947 int VompClientRRProc::processGetMarks()
1949 // data is a pointer to the fileName string
1952 cRecordings Recordings;
1953 Recordings.Load(); // probably have to do this
1955 cRecording *recording = Recordings.GetByName((char*)req->data);
1957 log->log("RRProc", Log::DEBUG, "recording pointer %p", recording);
1961 #if VDRVERSNUM < 10703
1962 Marks.Load(recording->FileName());
1964 Marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording());
1968 for (const cMark *m = Marks.First(); m; m = Marks.Next(m))
1970 #if VDRVERSNUM < 10721
1971 ULLONG mposition = m->position;
1973 ULLONG mposition = m->Position();
1975 log->log("RRProc", Log::DEBUG, "found Mark %i", mposition);
1977 resp->addULONG(mposition);
1982 log->log("RRProc", Log::DEBUG, "no marks found, sending 0-mark");
1988 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
1990 log->log("RRProc", Log::DEBUG, "Written Marks list");
1995 int VompClientRRProc::processVDRShutdown()
1997 log->log("RRProc", Log::DEBUG, "Trying to shutdown VDR");
1998 VompClient::decClients(); // Temporarily make this client disappear
1999 cRemote::Put(kPower);
2000 VompClient::incClients();
2002 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2006 int VompClientRRProc::processGetRecScraperEventType()
2008 Recordings.Load(); // probably have to do this
2010 cRecording *recording = Recordings.GetByName((char*)req->data);
2011 ScraperGetEventType call;
2014 if (recording && x.scraper)
2016 call.recording = recording;
2017 x.scraper->Service("GetEventType",&call);
2019 resp->addUCHAR(call.type);
2020 if (call.type == tMovie)
2022 resp->addLONG(call.movieId);
2023 } else if (call.type == tSeries){
2024 resp->addLONG(call.seriesId);
2025 resp->addLONG(call.episodeId);
2028 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2033 #define ADDSTRING_TO_PAKET(y) if ((y)!=0) resp->addString(x.charconvutf8->Convert(y)); else resp->addString("");
2035 int VompClientRRProc::processGetScraperMovieInfo()
2039 movie.movieId = ntohl(*(ULONG*)req->data);
2041 log->log("RRProc", Log::DEBUG, "No Scraper, get SeriesInfo");
2042 return 0; //stupid, I have no scraper why are you still asking
2044 x.scraper->Service("GetMovie",&movie);
2047 ADDSTRING_TO_PAKET(movie.title.c_str());
2048 ADDSTRING_TO_PAKET(movie.originalTitle.c_str());
2049 ADDSTRING_TO_PAKET(movie.tagline.c_str());
2050 ADDSTRING_TO_PAKET(movie.overview.c_str());
2051 resp->addUCHAR(movie.adult);
2052 ADDSTRING_TO_PAKET(movie.collectionName.c_str());
2054 resp->addLONG(movie.budget);
2055 resp->addLONG(movie.revenue);
2056 ADDSTRING_TO_PAKET(movie.genres.c_str());
2057 ADDSTRING_TO_PAKET(movie.homepage.c_str());
2058 ADDSTRING_TO_PAKET(movie.releaseDate.c_str());
2059 resp->addLONG(movie.runtime);
2060 resp->adddouble(movie.popularity);
2061 resp->adddouble(movie.voteAverage);
2062 resp->addULONG(movie.poster.width);
2063 resp->addULONG(movie.poster.height);
2064 resp->addULONG(movie.fanart.width);
2065 resp->addULONG(movie.fanart.height);
2066 resp->addULONG(movie.collectionPoster.width);
2067 resp->addULONG(movie.collectionPoster.height);
2068 resp->addULONG(movie.collectionFanart.width);
2069 resp->addULONG(movie.collectionFanart.height);
2070 resp->addULONG(movie.actors.size());
2071 for (ULONG acty=0; acty < movie.actors.size(); acty++) {
2072 ADDSTRING_TO_PAKET(movie.actors[acty].name.c_str());
2073 ADDSTRING_TO_PAKET(movie.actors[acty].role.c_str());
2074 resp->addULONG(movie.actors[acty].actorThumb.width);
2075 resp->addULONG(movie.actors[acty].actorThumb.height);
2079 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2086 int VompClientRRProc::processGetScraperSeriesInfo()
2089 series.seriesId = ntohl(*(ULONG*)req->data);
2090 series.episodeId = ntohl(*(ULONG*)(req->data+4));
2092 log->log("RRProc", Log::DEBUG, "No Scraper, get SeriesInfo");
2093 return 0; //stupid, I have no scraper why are you still asking
2095 x.scraper->Service("GetSeries",&series);
2097 ADDSTRING_TO_PAKET(series.name.c_str());
2098 ADDSTRING_TO_PAKET(series.overview.c_str());
2099 ADDSTRING_TO_PAKET(series.firstAired.c_str());
2100 ADDSTRING_TO_PAKET(series.network.c_str());
2101 ADDSTRING_TO_PAKET(series.genre.c_str());
2102 resp->adddouble(series.rating);
2103 ADDSTRING_TO_PAKET(series.status.c_str());
2105 resp->addLONG(series.episode.number);
2106 resp->addLONG(series.episode.season);
2107 ADDSTRING_TO_PAKET(series.episode.name.c_str());
2108 ADDSTRING_TO_PAKET(series.episode.firstAired.c_str());
2109 ADDSTRING_TO_PAKET(series.episode.guestStars.c_str());
2110 ADDSTRING_TO_PAKET(series.episode.overview.c_str());
2111 resp->adddouble(series.episode.rating);
2112 resp->addULONG(series.episode.episodeImage.width);
2113 resp->addULONG(series.episode.episodeImage.height);
2115 ULONG num_actors = series.actors.size();
2116 resp->addULONG(num_actors);
2117 for (ULONG acty=0; acty < num_actors; acty++) {
2118 ADDSTRING_TO_PAKET(series.actors[acty].name.c_str());
2119 ADDSTRING_TO_PAKET(series.actors[acty].role.c_str());
2120 resp->addULONG(series.actors[acty].actorThumb.width);
2121 resp->addULONG(series.actors[acty].actorThumb.height);
2123 ULONG num_posters = series.posters.size();
2124 resp->addULONG(num_posters);
2125 for (ULONG medias = 0; medias < num_posters; medias++ ) {
2126 cTvMedia media=series.posters[medias];
2127 resp->addULONG(media.width);
2128 resp->addULONG(media.height);
2131 ULONG num_banners = series.banners.size();
2132 resp->addULONG(num_banners);
2133 for (ULONG medias = 0; medias < num_banners; medias++ ) {
2134 cTvMedia media=series.banners[medias];
2135 resp->addULONG(media.width);
2136 resp->addULONG(media.height);
2138 ULONG num_fanarts = series.fanarts.size();
2139 resp->addULONG(num_fanarts);
2140 for (ULONG medias = 0; medias < num_fanarts; medias++ ) {
2141 cTvMedia media=series.fanarts[medias];
2142 resp->addULONG(media.width);
2143 resp->addULONG(media.height);
2145 resp->addULONG(series.seasonPoster.width);
2146 resp->addULONG(series.seasonPoster.height);
2150 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2155 int VompClientRRProc::processLoadTvMedia()
2157 TVMediaRequest tvreq;
2158 tvreq.streamID = req->requestID;
2159 tvreq.type = ntohl(*(ULONG*)req->data);
2160 tvreq.primary_id = ntohl(*(ULONG*)(req->data+4));
2161 tvreq.secondary_id = ntohl(*(ULONG*)(req->data+8));
2162 tvreq.type_pict = ntohl(*(ULONG*)(req->data+12));
2163 tvreq.container = ntohl(*(ULONG*)(req->data+16));
2164 tvreq.container_member = ntohl(*(ULONG*)(req->data+20));
2165 log->log("RRProc", Log::DEBUG, "TVMedia request %d",req->requestID);
2166 x.pict->addTVMediaRequest(tvreq);
2171 x.tcp.sendPacket(resp->getPtr(), resp->getLen());
2179 #endif // !VOMPSTANDALONE