summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorT. Lohmar <smarttv640@gmail.com>2015-01-15 18:22:54 +0100
committerT. Lohmar <smarttv640@gmail.com>2015-01-15 18:22:54 +0100
commite0161dd12d038f22ae980deea222bef0e0920b3d (patch)
treea763da21cb742f84a61394367ccf073ab913367f
parent24b5ac0a6b6be752fa8e2f368506d67df4d48bd8 (diff)
downloadvdr-plugin-smarttvweb-e0161dd12d038f22ae980deea222bef0e0920b3d.tar.gz
vdr-plugin-smarttvweb-e0161dd12d038f22ae980deea222bef0e0920b3d.tar.bz2
check validity of media folder. Handle unknow MP4 creation times.
-rw-r--r--mp4.c16
-rwxr-xr-xresponsememblk.c7
-rwxr-xr-xstvw_cfg.c8
-rwxr-xr-xstvw_cfg.h2
4 files changed, 27 insertions, 6 deletions
diff --git a/mp4.c b/mp4.c
index eaab233..d8c5c4b 100644
--- a/mp4.c
+++ b/mp4.c
@@ -203,12 +203,17 @@ bool cMp4Metadata::parseMovieHeader (FILE* ifd, uint64_t s) {
if (m_box.mFlags == 1) {
uint32_t ts;
uint64_t dur;
+ uint64_t ct;
+
read_size += 28;
res = fread (p, 1, 28, ifd);
if (res < 28)
return false;
- mCreationTime = parseUInt64(p) - 2082844800;
+ ct = parseUInt64(p);
+ if (ct != 0) {
+ mCreationTime = ct - 2082844800;
+ }
ts = parseUInt32 (&(p[16]));
dur = parseUInt64 (&(p[20]));
@@ -219,16 +224,17 @@ bool cMp4Metadata::parseMovieHeader (FILE* ifd, uint64_t s) {
else {
uint32_t ts;
uint32_t dur;
- uint32_t c;
+ uint32_t ct;
read_size += 16;
res = fread (p, 1, 16, ifd);
if (res < 16)
return false;
- c = parseUInt32(p) - 2082844800;
- mCreationTime = c;
-
+ ct = parseUInt32(p) ;
+ if (ct != 0) {
+ mCreationTime = ct- 2082844800;
+ }
ts= parseUInt32(&(p[8]));
dur= parseUInt32(&(p[12]));
diff --git a/responsememblk.c b/responsememblk.c
index 22c3b40..92e1bc2 100755
--- a/responsememblk.c
+++ b/responsememblk.c
@@ -1818,7 +1818,9 @@ int cResponseMemBlk::parseFiles(vector<sFileEntry> *entries, string prefix, stri
<< endl;
cMp4Metadata meta(pathbuf, statbuf->st_size);
meta.parseMetadata();
- entries->push_back(sFileEntry(prefix+de->d_name, pathbuf, meta.mCreationTime, mime,
+ entries->push_back(sFileEntry(prefix+de->d_name, pathbuf,
+ ((meta.mCreationTime != 0) ? meta.mCreationTime : statbuf->st_mtime),
+ mime,
(meta.mHaveTitle) ? meta.mTitle : prefix+de->d_name,
meta.mShortDesc, meta.mLongDesc, meta.mDuration));
}
@@ -1927,6 +1929,9 @@ void cResponseMemBlk::sendServerNameXml () {
snprintf(f, sizeof(f), "<cmds>%s</cmds>\n", ((mRequest->mFactory->getConfig()->getCmds()) ? "true" : "false"));
*mResponseMessage += f;
+ snprintf(f, sizeof(f), "<mf>%s</mf>\n", ((mRequest->mFactory->getConfig()->haveMediaFolder()) ? "true" : "false"));
+ *mResponseMessage += f;
+
*mResponseMessage += "</servername>\n";
sendHeaders(200, "OK", NULL, "application/xml", mResponseMessage->size(), -1);
}
diff --git a/stvw_cfg.c b/stvw_cfg.c
index 4ca2559..7af88b7 100755
--- a/stvw_cfg.c
+++ b/stvw_cfg.c
@@ -50,6 +50,14 @@ cSmartTvConfig::cSmartTvConfig(string d): mConfigDir(d), mLog(NULL), mCfgFile(NU
mLiveChannels = 30;
readConfig();
+
+ struct stat statbuf;
+ mHaveMediaFolder = false;
+ if (stat(mMediaFolder.c_str(), &statbuf) != -1) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ mHaveMediaFolder = true;
+ }
+ }
}
cSmartTvConfig::~cSmartTvConfig() {
diff --git a/stvw_cfg.h b/stvw_cfg.h
index 3c134d0..a2c0233 100755
--- a/stvw_cfg.h
+++ b/stvw_cfg.h
@@ -47,6 +47,7 @@ class cSmartTvConfig {
string mLogFile;
string mMediaFolder;
+ bool mHaveMediaFolder;
unsigned int mSegmentDuration;
int mHasMinBufferTime;
float mHasBitrateCorrection;
@@ -71,6 +72,7 @@ class cSmartTvConfig {
string getLogFile() { return mLogFile; };
string getMediaFolder() { return mMediaFolder; };
+ bool haveMediaFolder() { return mHaveMediaFolder; };
unsigned int getSegmentDuration() {return mSegmentDuration; };
int getHasMinBufferTime() { return mHasMinBufferTime; };
float getHasBitrateCorrection() { return mHasBitrateCorrection; };