aboutsummaryrefslogtreecommitdiffstats
path: root/Managers/MultimediaManager.cpp
diff options
context:
space:
mode:
authorJacques Samain <jsamain+fdio@cisco.com>2017-07-24 15:11:58 +0200
committerJacques Samain <jsamain+fdio@cisco.com>2017-07-24 15:11:58 +0200
commitce4d018aa8185da0bbf5445eaf54d88700f1a381 (patch)
tree161b3977d2c7a9cf265e9fde739ccae25882908b /Managers/MultimediaManager.cpp
parent04424399a22c592a95b19dad95a958cb1566a8e2 (diff)
moving MPDFetching to MultimediaManager class, DASHReceiver might have two instances (video + audio)
Change-Id: Ifae7dab2db80d8b1a17ff7749cdfb879958cfee1 Signed-off-by: Jacques Samain <jsamain+fdio@cisco.com>
Diffstat (limited to 'Managers/MultimediaManager.cpp')
-rw-r--r--Managers/MultimediaManager.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/Managers/MultimediaManager.cpp b/Managers/MultimediaManager.cpp
index 23118464..18061238 100644
--- a/Managers/MultimediaManager.cpp
+++ b/Managers/MultimediaManager.cpp
@@ -41,7 +41,8 @@ MultimediaManager::MultimediaManager(ViperGui *viperGui, int segBufSize, std::st
eos (false),
playing (false),
noDecoding (nodecoding),
- mpdWrapper (NULL)
+ mpdWrapper (NULL),
+ mpdFetcherThread (NULL)
{
InitializeCriticalSection (&this->monitorMutex);
InitializeCriticalSection (&this->monitorBufferMutex);
@@ -237,6 +238,15 @@ void MultimediaManager::start(bool icnEnabled, double icnAlpha, uint32_t nextOff
}
this->started = true;
this->playing = true;
+
+ if(!strcmp(this->mpdWrapper->getType().c_str(), "dynamic"))
+ {
+ this->mpdFetcherThread = createThreadPortable(DoMPDFetching, this);
+ if(this->mpdFetcherThread == NULL)
+ {
+ std::cout << "mpd Fetcher thread is NULL. Need to think of how to handle this?" << std::endl;
+ }
+ }
LeaveCriticalSection(&this->monitorMutex);
}
@@ -255,6 +265,11 @@ void MultimediaManager::stop()
Debug("VIDEO STOPPED\n");
this->mpdWrapper->reInit(viper::managers::StreamType::VIDEO);
this->mpdWrapper->reInit(viper::managers::StreamType::AUDIO);
+ if(this->mpdFetcherThread != NULL)
+ {
+ JoinThread(this->mpdFetcherThread);
+ destroyThreadPortable(this->mpdFetcherThread);
+ }
}
void MultimediaManager::stopVideo()
@@ -691,3 +706,25 @@ float MultimediaManager::getSegmentDuration()
{
return this->segmentDuration;
}
+
+static void* MultimediaManager::DoMPDFetching (void* data)
+{
+ MultimediaManager *manager = (MultimediaManager*) data;
+ uint32_t currTime = TimeResolver::getCurrentTimeInSec();
+ uint32_t publishedTime = manager->mpdWrapper->getFetchTime();
+// To avoid clock synchronisation issues: using fetching time instead of publish time
+// uint32_t publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ uint32_t periodUpdate = TimeResolver::getDurationInSec(manager->mpdWrapper->getMinimumUpdatePeriod());
+ while(manager->isStarted())
+ {
+ while(manager->isStarted() && currTime < publishedTime + periodUpdate)
+ {
+ usleep(((publishedTime + periodUpdate) - currTime) * 1000000);
+ currTime = TimeResolver::getCurrentTimeInSec();
+ }
+ manager->fetchMPD();
+ publishedTime = manager->mpdWrapper->getFetchTime();
+// publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ periodUpdate = TimeResolver::getDurationInSec(manager->mpdWrapper->getMinimumUpdatePeriod());
+ }
+}