aboutsummaryrefslogtreecommitdiffstats
path: root/Managers
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
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')
-rw-r--r--Managers/IStreamObserver.h1
-rw-r--r--Managers/MultimediaManager.cpp39
-rw-r--r--Managers/MultimediaManager.h2
-rw-r--r--Managers/MultimediaStream.cpp8
-rw-r--r--Managers/MultimediaStream.h1
5 files changed, 40 insertions, 11 deletions
diff --git a/Managers/IStreamObserver.h b/Managers/IStreamObserver.h
index 1d628d51..31baca68 100644
--- a/Managers/IStreamObserver.h
+++ b/Managers/IStreamObserver.h
@@ -38,7 +38,6 @@ public:
virtual void notifyQualityDownloading(uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
- virtual void fetchMPD() = 0;
};
}
}
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());
+ }
+}
diff --git a/Managers/MultimediaManager.h b/Managers/MultimediaManager.h
index ade2b767..c00ff866 100644
--- a/Managers/MultimediaManager.h
+++ b/Managers/MultimediaManager.h
@@ -106,6 +106,7 @@ private:
double frameRate;
THREAD_HANDLE videoRendererHandle;
THREAD_HANDLE audioRendererHandle;
+ THREAD_HANDLE mpdFetcherThread;
bool isVideoRendering;
bool isAudioRendering;
bool eos;
@@ -136,6 +137,7 @@ private:
void notifyAudioSegmentBufferObservers (uint32_t fillstateInPercent);
void updateMPD ();
void updateMPDICN ();
+ static void* DoMPDFetching (void* manager);
};
}
}
diff --git a/Managers/MultimediaStream.cpp b/Managers/MultimediaStream.cpp
index 86cde35d..f70eabfb 100644
--- a/Managers/MultimediaStream.cpp
+++ b/Managers/MultimediaStream.cpp
@@ -198,11 +198,3 @@ void MultimediaStream::notifyBufferChange(uint32_t bufferfill, int maxC)
{
this->dashManager->onBufferStateChanged(libdash::framework::buffer::VIDEO, bufferfill, maxC);
}
-
-void MultimediaStream::fetchMPD()
-{
- for(size_t i=0; i < this->observers.size(); i++)
- {
- this->observers.at(i)->fetchMPD();
- }
-}
diff --git a/Managers/MultimediaStream.h b/Managers/MultimediaStream.h
index 454cca23..52a7ac9d 100644
--- a/Managers/MultimediaStream.h
+++ b/Managers/MultimediaStream.h
@@ -75,7 +75,6 @@ public:
bool isICN();
void shouldAbort();
void setTargetDownloadingTime(double);
- void fetchMPD();
private:
float beta;