From 9d953a2888486727d04d06d3a1151ed41118d8d3 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 30 May 2009 14:22:59 +0000 Subject: [PATCH] VDR 1.7.7 compatibility --- Makefile | 1 + recplayer.c | 36 +++++++++++++++++++++++++++++++++--- vompclient.c | 34 +++++++++++++++++++++++++++++----- vompclient.h | 2 +- vompclientrrproc.c | 43 +++++++++++++++++++++++++++++++++++++++++-- vompclientrrproc.h | 2 ++ 6 files changed, 107 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index bb492dd..4e83ec3 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,7 @@ PACKAGE = vdr-$(ARCHIVE) INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DVOMPSERVER +DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE ### The object files (add further files here): diff --git a/recplayer.c b/recplayer.c index 1504b6e..82c056d 100644 --- a/recplayer.c +++ b/recplayer.c @@ -33,8 +33,11 @@ RecPlayer::RecPlayer(cRecording* rec) for(int i = 1; i < 1000; i++) segments[i] = NULL; // FIXME find out max file path / name lengths - +#if VDRVERSNUM < 10703 indexFile = new cIndexFile(recording->FileName(), false); +#else + indexFile = new cIndexFile(recording->FileName(), false, recording->IsPesRecording()); +#endif if (!indexFile) log->log("RecPlayer", Log::ERR, "Failed to create indexfile!"); scan(); @@ -51,9 +54,18 @@ void RecPlayer::scan() while(segments[i++]) delete segments[i]; char fileName[2048]; - for(i = 1; i < 1000; i++) +#if VDRVERSNUM < 10703 + for(i = 1; i < 255; i++)//maximum is 255 files instead of 1000, according to VDR HISTORY file... { snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), i); +#else + for(i = 1; i < 65535; i++) + { + if (recording->IsPesRecording()) + snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), i); + else + snprintf(fileName, 2047, "%s/%05i.ts", recording->FileName(), i); +#endif log->log("RecPlayer", Log::DEBUG, "FILENAME: %s", fileName); file = fopen(fileName, "r"); if (!file) break; @@ -84,7 +96,14 @@ int RecPlayer::openFile(int index) if (file) fclose(file); char fileName[2048]; +#if VDRVERSNUM < 10703 snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), index); +#else + if (recording->IsPesRecording()) + snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), index); + else + snprintf(fileName, 2047, "%s/%05i.ts", recording->FileName(), index); +#endif log->log("RecPlayer", Log::DEBUG, "openFile called for index %i string:%s", index, fileName); file = fopen(fileName, "r"); @@ -192,12 +211,18 @@ cRecording* RecPlayer::getCurrentRecording() ULLONG RecPlayer::positionFromFrameNumber(ULONG frameNumber) { if (!indexFile) return 0; - +#if VDRVERSNUM < 10703 uchar retFileNumber; int retFileOffset; uchar retPicType; +#else + uint16_t retFileNumber; + off_t retFileOffset; + bool retPicType; +#endif int retLength; + if (!indexFile->Get((int)frameNumber, &retFileNumber, &retFileOffset, &retPicType, &retLength)) { return 0; @@ -240,8 +265,13 @@ bool RecPlayer::getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfileP if (!indexFile) return false; +#if VDRVERSNUM < 10703 uchar waste1; int waste2; +#else + uint16_t waste1; + off_t waste2; +#endif int iframeLength; int indexReturnFrameNumber; diff --git a/vompclient.c b/vompclient.c index 8963b4c..acfa62b 100644 --- a/vompclient.c +++ b/vompclient.c @@ -78,7 +78,7 @@ VompClient::~VompClient() recordingManager = NULL; } #endif - if (loggedIn) cleanConfig(); + //if (loggedIn) cleanConfig(); decClients(); delete media; @@ -108,7 +108,7 @@ int VompClient::getNrClients() return nrClients; } - +/* void VompClient::cleanConfig() { log->log("Client", Log::DEBUG, "Clean config"); @@ -143,7 +143,7 @@ void VompClient::cleanConfig() delete[] resumes; #endif -} +} */ void VompClientStartThread(void* arg) { @@ -334,9 +334,33 @@ cChannel* VompClient::channelFromNumber(ULONG channelNumber) void VompClient::writeResumeData() { - config.setValueLong("ResumeData", + /*config.setValueLong("ResumeData", (char*)recplayer->getCurrentRecording()->FileName(), - recplayer->frameNumberFromPosition(recplayer->getLastPosition()) ); + recplayer->frameNumberFromPosition(recplayer->getLastPosition()) );*/ + + /* write to vdr resume file */ + int resume = recplayer->frameNumberFromPosition(recplayer->getLastPosition()); + char* ResumeIdC = config.getValueString("General", "ResumeId"); + int ResumeId; + if (ResumeIdC) + ResumeId = atoi(ResumeIdC); + else + ResumeId = 0; + + while (ResumeIDLock) + cCondWait::SleepMs(100); + ResumeIDLock = true; + int OldSetupResumeID = Setup.ResumeID; + Setup.ResumeID = ResumeId; //UGLY: quickly change resumeid +#if VDRVERSNUM < 10703 + cResumeFile ResumeFile((char*)recplayer->getCurrentRecording()->FileName()); //get corresponding resume file +#else + cResumeFile ResumeFile((char*)recplayer->getCurrentRecording()->FileName(),(char*)recplayer->getCurrentRecording()->IsPesRecording()); //get corresponding resume file +#endif + Setup.ResumeID = OldSetupResumeID; //and restore it back + ResumeIDLock = false; + ResumeFile.Save(resume); + //isyslog("VOMPDEBUG: Saving resume = %i, ResumeId = %i",resume, ResumeId); } #endif diff --git a/vompclient.h b/vompclient.h index 6906dd2..bd43790 100644 --- a/vompclient.h +++ b/vompclient.h @@ -95,7 +95,7 @@ class VompClient bool loggedIn; char* configDir; - void cleanConfig(); + //void cleanConfig(); #ifndef VOMPSTANDALONE cChannel* channelFromNumber(ULONG channelNumber); diff --git a/vompclientrrproc.c b/vompclientrrproc.c index 0074b46..9477d09 100644 --- a/vompclientrrproc.c +++ b/vompclientrrproc.c @@ -40,6 +40,8 @@ #include "i18n.h" #include "vdrcommand.h" +bool ResumeIDLock; + VompClientRRProc::VompClientRRProc(VompClient& x) : x(x) { @@ -1123,6 +1125,12 @@ int VompClientRRProc::processStartStreamingRecording() resp->addULLONG(x.recplayer->getLengthBytes()); resp->addULONG(x.recplayer->getLengthFrames()); +#if VDRVERSNUM < 10703 + resp->addUCHAR(true);//added for TS +#else + resp->addUCHAR(recording->IsPesRecording());//added for TS +#endif + resp->finalise(); x.tcp.sendPacket(resp->getPtr(), resp->getLen()); @@ -1580,17 +1588,44 @@ int VompClientRRProc::processGetRecInfo() // Get resume point - char* value = x.config.getValueString("ResumeData", (char*)req->data); +/* char* value = x.config.getValueString("ResumeData", (char*)req->data); if (value) { resumePoint = strtoul(value, NULL, 10); delete[] value; + }*/ + + char* ResumeIdC = x.config.getValueString("General", "ResumeId"); + int ResumeId; + if (ResumeIdC) { + ResumeId = atoi(ResumeIdC); + delete[] ResumeIdC; } + else + ResumeId = 0; //default if not defined in vomp-MAC.conf + + while (ResumeIDLock) + cCondWait::SleepMs(100); + ResumeIDLock = true; + int OldSetupResumeID = Setup.ResumeID; + Setup.ResumeID = ResumeId; //UGLY: quickly change resumeid +#if VDRVERSNUM < 10703 + cResumeFile ResumeFile(recording->FileName()); //get corresponding resume file +#else + cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording()); //get corresponding resume file +#endif + Setup.ResumeID = OldSetupResumeID; //and restore it back + ResumeIDLock = false; + + int resume = ResumeFile.Read(); + //isyslog("VOMPDEBUG: resumePoint = %i, resume = %i, ResumeId = %i",resumePoint, resume, ResumeId); + if (resume >= 0) + resumePoint = ResumeFile.Read(); + log->log("RRProc", Log::DEBUG, "GRI: RP: %lu", resumePoint); resp->addULONG(resumePoint); - // Get summary #if VDRVERSNUM < 10300 @@ -1710,7 +1745,11 @@ int VompClientRRProc::processGetMarks() if (recording) { +#if VDRVERSNUM < 10703 Marks.Load(recording->FileName()); +#else + Marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording()); +#endif if (Marks.Count()) { for (const cMark *m = Marks.First(); m; m = Marks.Next(m)) diff --git a/vompclientrrproc.h b/vompclientrrproc.h index 856bd9c..72bf0c9 100644 --- a/vompclientrrproc.h +++ b/vompclientrrproc.h @@ -26,6 +26,8 @@ #include #include "serialize.h" +extern bool ResumeIDLock; + using namespace std; class VompClient; -- 2.39.5