diff options
author | thlo <smarttv640@gmail.com> | 2014-01-03 11:16:32 +0100 |
---|---|---|
committer | thlo <smarttv640@gmail.com> | 2014-01-03 11:16:32 +0100 |
commit | 397f7c0d3e03178fd71d5c9546a9560eece426a6 (patch) | |
tree | 937a511ae74723deac0c19543c13816fae5a4d99 | |
parent | 28fbcd863c0d65134a22356e062a8e1426283f29 (diff) | |
download | vdr-plugin-smarttvweb-397f7c0d3e03178fd71d5c9546a9560eece426a6.tar.gz vdr-plugin-smarttvweb-397f7c0d3e03178fd71d5c9546a9560eece426a6.tar.bz2 |
Plugin support for marks. Improved Logging.
-rwxr-xr-x | responsememblk.c | 75 | ||||
-rwxr-xr-x | responsememblk.h | 1 |
2 files changed, 74 insertions, 2 deletions
diff --git a/responsememblk.c b/responsememblk.c index c590816..8ab1e4e 100755 --- a/responsememblk.c +++ b/responsememblk.c @@ -47,13 +47,13 @@ #include <dirent.h> #endif - //#define MAXLEN 32768 -#define DEBUGPREFIX "mReqId= " << mRequest->mReqId << " fd= " << mRequest->mFd +#define DEBUGPREFIX mLog->getTimeString() << ": mReqId= " << mRequest->mReqId << " fd= " << mRequest->mFd #define OKAY 0 #define ERROR (-1) #define DEBUG + class cResumeEntry { public: string mFilename; @@ -434,6 +434,76 @@ int cResponseMemBlk::sendResumeXml () { } +int cResponseMemBlk::sendMarksXml () { + if (isHeadRequest()) + return OKAY; +#ifndef STANDALONE + + mResponseMessage = new string(); + *mResponseMessage = ""; + mResponseMessagePos = 0; + + mRequest->mConnState = SERVING; + + char f[400]; + + cResumeEntry entry; + string id; + + // obsolete? + parseResume(entry, id); + + vector<sQueryAVP> avps; + mRequest->parseQueryLine(&avps); + string guid; + + if (mRequest->getQueryAttributeValue(&avps, "guid", guid) == OKAY){ + entry.mFilename = cUrlEncode::doUrlSaveDecode(guid); + + *(mLog->log() )<< DEBUGPREFIX + << " Found guid: " << guid + << " filename: " << entry.mFilename + << endl; + } + + cRecording *rec = Recordings.GetByName(entry.mFilename.c_str()); + if (rec == NULL) { + *(mLog->log())<< DEBUGPREFIX + << " ERROR in sendResume: recording not found - filename= " << entry.mFilename << endl; + sendError(400, "Bad Request", NULL, "007 Failed to find the recording."); + return OKAY; + } + + cMarks marks; + marks.Load(rec->FileName(), rec->FramesPerSecond(), rec->IsPesRecording()); + + if (marks.Count() == 0) { + *(mLog->log())<< DEBUGPREFIX + << " sendMark: No Mark Found " << endl; + sendError(400, "Bad Request", NULL, "0xx No Mark Found."); + return OKAY; + } + + *(mLog->log())<< DEBUGPREFIX + << " marks request for " << entry.mFilename + << endl; + + *mResponseMessage += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + *mResponseMessage += "<marks>"; + + for (const cMark *m = marks.First(); m; m = marks.Next(m)) { + snprintf(f, sizeof(f), "<mark>%.02f</mark>\n", m->Position() / rec->FramesPerSecond()); + *mResponseMessage += f; + } + *mResponseMessage += "</marks>\n"; + + sendHeaders(200, "OK", NULL, "application/xml", mResponseMessage->size(), -1); +#endif + + return OKAY; +} + + int cResponseMemBlk::receiveDelRecReq() { if (isHeadRequest()) @@ -483,6 +553,7 @@ int cResponseMemBlk::receiveDelRecReq() { } + //*************************** //**** Creade index.html **** //*************************** diff --git a/responsememblk.h b/responsememblk.h index 80e953d..1895ad2 100755 --- a/responsememblk.h +++ b/responsememblk.h @@ -60,6 +60,7 @@ class cResponseMemBlk : public cResponseBase { int sendRecordingsXml (struct stat *statbuf); int sendChannelsXml (struct stat *statbuf); int sendResumeXml (); + int sendMarksXml (); int sendVdrStatusXml (struct stat *statbuf); void sendServerNameXml (); int sendYtBookmarkletJs(); |