aboutsummaryrefslogtreecommitdiffstats
path: root/Managers
diff options
context:
space:
mode:
Diffstat (limited to 'Managers')
-rw-r--r--Managers/IMultimediaManagerBase.h8
-rw-r--r--Managers/IMultimediaManagerObserver.h1
-rw-r--r--Managers/IStreamObserver.h2
-rw-r--r--Managers/MultimediaManager.cpp176
-rw-r--r--Managers/MultimediaManager.h129
-rw-r--r--Managers/MultimediaStream.cpp33
-rw-r--r--Managers/MultimediaStream.h32
7 files changed, 243 insertions, 138 deletions
diff --git a/Managers/IMultimediaManagerBase.h b/Managers/IMultimediaManagerBase.h
index f08803ba..1ef0b101 100644
--- a/Managers/IMultimediaManagerBase.h
+++ b/Managers/IMultimediaManagerBase.h
@@ -16,7 +16,7 @@
#ifndef VIPER_MANAGERS_IMULTIMEDIAMANAGERBASE_H_
#define VIPER_MANAGERS_IMULTIMEDIAMANAGERBASE_H_
-#include "IMPD.h"
+#include "MPD/MPDWrapper.h"
namespace viper
{
@@ -25,8 +25,10 @@ namespace managers
class IMultimediaManagerBase
{
public:
- virtual bool setVideoQuality(dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation) = 0;
- virtual bool setAudioQuality(dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation) = 0;
+// virtual bool setVideoQuality(dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation) = 0;
+// virtual bool setAudioQuality(dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation) = 0;
+ virtual bool setVideoQuality() = 0;
+ virtual bool setAudioQuality() = 0;
virtual bool isStarted() = 0;
virtual bool isStopping() = 0;
virtual void shouldAbort(bool isVideo) = 0;
diff --git a/Managers/IMultimediaManagerObserver.h b/Managers/IMultimediaManagerObserver.h
index eea0bfb1..24ce8d08 100644
--- a/Managers/IMultimediaManagerObserver.h
+++ b/Managers/IMultimediaManagerObserver.h
@@ -29,6 +29,7 @@ public:
virtual void onEOS() = 0;
virtual void notifyStatistics(int, uint32_t, int, uint32_t) = 0;
virtual void notifyQualityDownloading(uint32_t) = 0;
+ virtual void setMPDWrapper(libdash::framework::mpd::MPDWrapper*) = 0;
};
}
}
diff --git a/Managers/IStreamObserver.h b/Managers/IStreamObserver.h
index d6e8a19c..1d628d51 100644
--- a/Managers/IStreamObserver.h
+++ b/Managers/IStreamObserver.h
@@ -38,7 +38,7 @@ 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 faab66cf..23118464 100644
--- a/Managers/MultimediaManager.cpp
+++ b/Managers/MultimediaManager.cpp
@@ -14,6 +14,7 @@
#include <fstream>
using namespace libdash::framework::adaptation;
+using namespace libdash::framework::mpd;
using namespace libdash::framework::buffer;
using namespace viper::managers;
using namespace dash::mpd;
@@ -25,17 +26,11 @@ MultimediaManager::MultimediaManager(ViperGui *viperGui, int segBufSize, std::st
segmentBufferSize (segBufSize),
downloadPath (downloadPath),
offset (offset),
- mpd (NULL),
- period (NULL),
- videoAdaptationSet (NULL),
- videoRepresentation (NULL),
videoLogic (NULL),
videoStream (NULL),
- audioAdaptationSet (NULL),
- audioRepresentation (NULL),
audioLogic (NULL),
- videoRendererHandle (NULL),
- audioRendererHandle (NULL),
+ videoRendererHandle (NULL),
+ audioRendererHandle (NULL),
audioStream (NULL),
started (false),
stopping (false),
@@ -45,7 +40,8 @@ MultimediaManager::MultimediaManager(ViperGui *viperGui, int segBufSize, std::st
isAudioRendering (false),
eos (false),
playing (false),
- noDecoding (nodecoding)
+ noDecoding (nodecoding),
+ mpdWrapper (NULL)
{
InitializeCriticalSection (&this->monitorMutex);
InitializeCriticalSection (&this->monitorBufferMutex);
@@ -71,28 +67,39 @@ MultimediaManager::~MultimediaManager ()
IMPD* MultimediaManager::getMPD()
{
- return this->mpd;
+ return this->mpdWrapper->getMPD();
+}
+
+MPDWrapper* MultimediaManager::getMPDWrapper()
+{
+ return this->mpdWrapper;
}
bool MultimediaManager::init(const std::string& url)
{
+ this->url = url;
EnterCriticalSection(&this->monitorMutex);
- this->mpd = this->manager->Open((char *)url.c_str());
+ IMPD* mpd = this->manager->Open((char *)url.c_str());
Debug("url : %s\n", url.c_str());
- if(this->mpd == NULL)
+ if(mpd == NULL)
{
LeaveCriticalSection(&this->monitorMutex);
return false;
}
Debug("Done DL the mpd\n");
+ this->mpdWrapper->setIsStopping(false);
+ this->mpdWrapper->updateMPD(mpd);
+ for (size_t i = 0; i < this->managerObservers.size(); i++)
+ this->managerObservers.at(i)->setMPDWrapper(this->mpdWrapper);
LeaveCriticalSection(&this->monitorMutex);
return true;
}
bool MultimediaManager::initICN(const std::string& url)
{
+ this->url = url;
EnterCriticalSection(&this->monitorMutex);
- libdash::framework::input::IICNConnection* icnConn = new libdash::framework::input::ICNConnectionConsumerApi(20.0, this->beta, this->drop);
+ this->icnConn = new libdash::framework::input::ICNConnectionConsumerApi(20.0, this->beta, this->drop);
icnConn->InitForMPD(url);
int ret = 0;
char * data = (char *)malloc(4096);
@@ -123,22 +130,69 @@ bool MultimediaManager::initICN(const std::string& url)
ret = icnConn->Read((uint8_t*)data,4096);
}
fclose(fp);
- this->mpd = this->manager->Open(const_cast<char*>(downloadFile.c_str()), url);
- if(this->mpd == NULL)
+ IMPD* mpd = this->manager->Open(const_cast<char*>(downloadFile.c_str()), url);
+ remove(downloadFile.c_str());
+ free(data);
+ if(mpd == NULL)
{
- remove(downloadFile.c_str());
- free(data);
delete icnConn;
LeaveCriticalSection(&this->monitorMutex);
return false;
}
- remove(downloadFile.c_str());
- free(data);
- delete icnConn;
+ this->mpdWrapper->setIsStopping(false);
+ this->mpdWrapper->updateMPD(mpd);
+ for (size_t i = 0; i < this->managerObservers.size(); i++)
+ this->managerObservers.at(i)->setMPDWrapper(this->mpdWrapper);
+ if( !strcmp(this->mpdWrapper->getType().c_str(), "static") )
+ {
+ delete icnConn;
+ }
+
LeaveCriticalSection(&this->monitorMutex);
return true;
}
+void MultimediaManager::updateMPD()
+{
+ this->mpdWrapper->updateMPD(this->manager->Open((char *)url.c_str()));
+}
+
+void MultimediaManager::updateMPDICN()
+{
+ this->icnConn->InitForMPD(this->url);
+ int ret = 0;
+ char * data = (char *)malloc(4096);
+ int pos = this->url.find_last_of("/");
+ if(pos == std::string::npos)
+ {
+ pos = strlen(this->url.c_str());
+ }
+ else
+ {
+ pos = pos + 1;
+ }
+
+ std::string downloadFile(this->downloadPath + this->url.substr(pos).c_str());
+ FILE *fp;
+ fp = fopen(downloadFile.c_str(), "w");
+ if(fp == NULL)
+ {
+ free(data);
+ return;
+ }
+ ret = icnConn->Read((uint8_t*)data, 4096);
+ while(ret)
+ {
+ fwrite(data, sizeof(char), ret, fp);
+ ret = icnConn->Read((uint8_t*)data,4096);
+ }
+ fclose(fp);
+ this->mpdWrapper->updateMPD(this->manager->Open(const_cast<char*>(downloadFile.c_str()), this->url));
+
+ remove(downloadFile.c_str());
+ free(data);
+}
+
bool MultimediaManager::isStarted()
{
return this->started;
@@ -154,6 +208,11 @@ bool MultimediaManager::isICN()
return this->icn;
}
+void MultimediaManager::setMPDWrapper(MPDWrapper* mpdWrapper)
+{
+ this->mpdWrapper = mpdWrapper;
+}
+
void MultimediaManager::start(bool icnEnabled, double icnAlpha, uint32_t nextOffset)
{
this->icn = icnEnabled;
@@ -168,7 +227,7 @@ void MultimediaManager::start(bool icnEnabled, double icnAlpha, uint32_t nextOff
qDebug("normal rate estimation\n");
}
EnterCriticalSection(&this->monitorMutex);
- if (this->videoAdaptationSet && this->videoRepresentation)
+ if(this->mpdWrapper->hasVideoAdaptationSetAndVideoRepresentation())
{
this->initVideoRendering(nextOffset);
this->videoStream->setAdaptationLogic(this->videoLogic);
@@ -185,6 +244,8 @@ void MultimediaManager::stop()
{
if (!this->started)
return;
+
+ this->mpdWrapper->setIsStopping(true);
this->stopping = true;
EnterCriticalSection(&this->monitorMutex);
this->stopVideo();
@@ -192,10 +253,8 @@ void MultimediaManager::stop()
this->started = false;
LeaveCriticalSection(&this->monitorMutex);
Debug("VIDEO STOPPED\n");
- this->period = this->mpd->GetPeriods().at(0);
- this->videoAdaptationSet = this->period->GetAdaptationSets().at(0);
- this->videoRepresentation = this->videoAdaptationSet->GetRepresentation().at(0);
-
+ this->mpdWrapper->reInit(viper::managers::StreamType::VIDEO);
+ this->mpdWrapper->reInit(viper::managers::StreamType::AUDIO);
}
void MultimediaManager::stopVideo()
@@ -219,30 +278,18 @@ void MultimediaManager::stopAudio()
}
}
-bool MultimediaManager::setVideoQuality(IPeriod* period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+bool MultimediaManager::setVideoQuality()
{
- EnterCriticalSection(&this->monitorMutex);
- this->period = period;
- this->videoAdaptationSet = adaptationSet;
- this->videoRepresentation = representation;
if (this->videoStream)
- this->videoStream->setRepresentation(this->period, this->videoAdaptationSet, this->videoRepresentation);
-
- LeaveCriticalSection(&this->monitorMutex);
+ this->videoStream->setRepresentation();
return true;
}
-bool MultimediaManager::setAudioQuality(IPeriod* period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+bool MultimediaManager::setAudioQuality()
{
- EnterCriticalSection(&this->monitorMutex);
-
- this->period = period;
- this->audioAdaptationSet = adaptationSet;
- this->audioRepresentation = representation;
if (this->audioStream)
- this->audioStream->setRepresentation(this->period, this->audioAdaptationSet, this->audioRepresentation);
- LeaveCriticalSection(&this->monitorMutex);
+ this->audioStream->setRepresentation();
return true;
}
@@ -256,11 +303,11 @@ bool MultimediaManager::isUserDependent()
bool MultimediaManager::setVideoAdaptationLogic(libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params)
{
- if(this->videoAdaptationSet)
+ if(this->mpdWrapper->hasVideoAdaptationSetAndVideoRepresentation())
{
if(this->videoLogic)
delete(this->videoLogic);
- this->videoLogic = AdaptationLogicFactory::create(type, this->mpd, this->period, this->videoAdaptationSet, 1, params);
+ this->videoLogic = AdaptationLogicFactory::create(type, viper::managers::StreamType::VIDEO, this->mpdWrapper, params);
this->logicName = LogicType_string[type];
}
else
@@ -297,9 +344,11 @@ void MultimediaManager::setTargetDownloadingTime(bool isVideo, double target)
bool MultimediaManager::setAudioAdaptationLogic(libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params)
{
- if(this->audioAdaptationSet)
+ if(this->mpdWrapper->hasAudioAdaptationSetAndAudioRepresentation())
{
- this->audioLogic = AdaptationLogicFactory::create(type, this->mpd, this->period, this->audioAdaptationSet, 0, params);
+ if(this->audioLogic)
+ delete(this->audioLogic);
+ this->audioLogic = AdaptationLogicFactory::create(type, viper::managers::StreamType::AUDIO, this->mpdWrapper, params);
this->logicName = LogicType_string[type];
}
else
@@ -344,17 +393,15 @@ void MultimediaManager::notifyAudioBufferObservers(uint32_t fillstateInPercent)
void MultimediaManager::initVideoRendering(uint32_t offset)
{
- this->videoStream = new MultimediaStream(viper::managers::VIDEO, this->mpd, this->segmentBufferSize, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
+ this->videoStream = new MultimediaStream(viper::managers::VIDEO, this->mpdWrapper, this->segmentBufferSize, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
this->videoStream->attachStreamObserver(this);
- this->videoStream->setRepresentation(this->period, this->videoAdaptationSet, this->videoRepresentation);
this->videoStream->setPosition(offset);
}
void MultimediaManager::initAudioPlayback(uint32_t offset)
{
- this->audioStream = new MultimediaStream(viper::managers::AUDIO, this->mpd, this->segmentBufferSize, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
+ this->audioStream = new MultimediaStream(viper::managers::AUDIO, this->mpdWrapper, this->segmentBufferSize, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
this->audioStream->attachStreamObserver(this);
- this->audioStream->setRepresentation(this->period, this->audioAdaptationSet, this->audioRepresentation);
this->audioStream->setPosition(offset);
}
@@ -506,14 +553,12 @@ void* MultimediaManager::pushVideoNoOut(void *data)
{
Debug("MANAGER:\tRebuffered %d ms\n", actualPosition *(-1));
manager->lastPointInTime = timeOfInsertion;
- //TODO Replace the 2 by a variable with segmentDuration
- manager->bufferingLimit = manager->lastPointInTime + std::chrono::seconds(2);
+ manager->bufferingLimit = manager->lastPointInTime + std::chrono::seconds(((int)manager->getSegmentDuration() / 1000));
}
else
{
- //TODO Replace the 2 by a variable with segmentDuration
Debug("MANAGER: INSERT TO BUFFER old_fillness: %f, new_fillness: %f\n", (double)((double)actualPosition/1000.0) / (double) this->segmentBufferSize, (double)((double)(actualPosition + 2000)/1000.0) / (double) manager->segmentBufferSize);
- manager->bufferingLimit = manager->bufferingLimit + std::chrono::seconds(2);
+ manager->bufferingLimit = manager->bufferingLimit + std::chrono::seconds(((int)manager->getSegmentDuration() /1000));
manager->lastPointInTime = timeOfInsertion;
}
delete segment;
@@ -566,7 +611,7 @@ int MultimediaManager::getBufferLevel()
uint32_t MultimediaManager::getUBufferLevel()
{
int mBufferLevel = 0;
- int segmentDurationInMs = 2000;
+ int segmentDurationInMs = (int) this->segmentDuration;
if(noDecoding)
{
@@ -587,7 +632,7 @@ uint32_t MultimediaManager::getUBufferLevel()
bool MultimediaManager::canPush()
{
- int segmentDurationInMs = 2000;
+ int segmentDurationInMs = (int)this->segmentDuration;
while(this->getUBufferLevel() >= 100 && !this->stopping)
{
sleep(segmentDurationInMs / 1000);
@@ -599,7 +644,7 @@ void* MultimediaManager::pushVideo(void *data)
{
MultimediaManager *manager = (MultimediaManager*) data;
libdash::framework::input::MediaObject *segment = manager->videoStream->getSegment();
- long int segmentDurationInMs = 2000;
+ int segmentDurationInMs = (int)manager->getSegmentDuration();
while(manager->isVideoRendering)
{
if (segment)
@@ -627,3 +672,22 @@ void MultimediaManager::setDrop(float drop)
{
this->drop = drop;
}
+
+void MultimediaManager::fetchMPD()
+{
+ if(this->icn)
+ this->updateMPDICN();
+ else
+ this->updateMPD();
+}
+
+//SegmentDuration is in ms
+void MultimediaManager::setSegmentDuration(float segDuration)
+{
+ this->segmentDuration = segDuration;
+}
+
+float MultimediaManager::getSegmentDuration()
+{
+ return this->segmentDuration;
+}
diff --git a/Managers/MultimediaManager.h b/Managers/MultimediaManager.h
index b4187486..ade2b767 100644
--- a/Managers/MultimediaManager.h
+++ b/Managers/MultimediaManager.h
@@ -35,50 +35,52 @@ public:
MultimediaManager(ViperGui *viperGui, int segmentBufferSize, std::string downloadPath, bool noDecoding = false);
virtual ~MultimediaManager();
- bool init (const std::string& url);
- bool initICN (const std::string& url);
- void start (bool icnEnabled, double icnAlpha, uint32_t nextOffset);
- void stop ();
- dash::mpd::IMPD* getMPD ();
-
- bool setVideoQuality (dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
- bool setAudioQuality (dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
-
- bool setVideoAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
- bool setAudioAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
-
- void attachManagerObserver (IMultimediaManagerObserver *observer);
-
- void setFrameRate (double frameRate);
+ bool init (const std::string& url);
+ bool initICN (const std::string& url);
+ void start (bool icnEnabled, double icnAlpha, uint32_t nextOffset);
+ void stop ();
+ dash::mpd::IMPD* getMPD ();
+ bool setVideoQuality ();
+ bool setAudioQuality ();
+ bool setVideoAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
+ bool setAudioAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
+ void attachManagerObserver (IMultimediaManagerObserver *observer);
+ void setFrameRate (double frameRate);
+ void setSegmentDuration (float segDuration);
+ float getSegmentDuration ();
/* IStreamObserver */
- void onSegmentDownloaded ();
- void onSegmentBufferStateChanged (StreamType type, uint32_t fillstateInPercent, int maxC);
- void onVideoBufferStateChanged (uint32_t fillstateInPercent);
- void onAudioBufferStateChanged (uint32_t fillstateInPercent);
- bool isUserDependent ();
- bool isStarted ();
- bool isStopping ();
- bool isICN ();
- void setEOS (bool value);
- void shouldAbort (bool isVideo);
- void setTargetDownloadingTime (bool isVid, double time);
- bool isPlaying ();
- void onPausePressed ();
- void notifyStatistics (int segNum, uint32_t bitrate, int fps, uint32_t quality);
- void notifyQualityDownloading (uint32_t quality);
- uint32_t getUBufferLevel ();
- int getBufferLevel ();
- void setLooping (bool looping);
- void setOffset(int offset);
- void setBeta(float beta);
- void setDrop(float drop);
- bool canPush ();
- CRITICAL_SECTION monitorBufferMutex;
+ void onSegmentDownloaded ();
+ void onSegmentBufferStateChanged (StreamType type, uint32_t fillstateInPercent, int maxC);
+ void onVideoBufferStateChanged (uint32_t fillstateInPercent);
+ void onAudioBufferStateChanged (uint32_t fillstateInPercent);
+ bool isUserDependent ();
+ bool isStarted ();
+ bool isStopping ();
+ bool isICN ();
+ void setEOS (bool value);
+ void shouldAbort (bool isVideo);
+ void setTargetDownloadingTime (bool isVid, double time);
+ bool isPlaying ();
+ void onPausePressed ();
+ void notifyStatistics (int segNum, uint32_t bitrate, int fps, uint32_t quality);
+ void notifyQualityDownloading (uint32_t quality);
+ uint32_t getUBufferLevel ();
+ int getBufferLevel ();
+ void setLooping (bool looping);
+ libdash::framework::mpd::MPDWrapper* getMPDWrapper ();
+ void setMPDWrapper (libdash::framework::mpd::MPDWrapper* mpdWrapper);
+ void setOffset (int offset);
+ void setBeta (float beta);
+ void setDrop (float drop);
+ bool canPush ();
+ void fetchMPD ();
+
- int offset;
- std::chrono::time_point<std::chrono::system_clock> lastPointInTime;
- std::chrono::time_point<std::chrono::system_clock> bufferingLimit;
+ CRITICAL_SECTION monitorBufferMutex;
+ int offset;
+ std::chrono::time_point<std::chrono::system_clock> lastPointInTime;
+ std::chrono::time_point<std::chrono::system_clock> bufferingLimit;
private:
float beta;
@@ -87,14 +89,9 @@ private:
int segmentBufferSize;
ViperGui *viperGui;
dash::IDASHManager *manager;
- dash::mpd::IMPD *mpd;
- dash::mpd::IPeriod *period;
- dash::mpd::IAdaptationSet *videoAdaptationSet;
- dash::mpd::IRepresentation *videoRepresentation;
+ libdash::framework::mpd::MPDWrapper *mpdWrapper;
libdash::framework::adaptation::IAdaptationLogic *videoLogic;
MultimediaStream *videoStream;
- dash::mpd::IAdaptationSet *audioAdaptationSet;
- dash::mpd::IRepresentation *audioRepresentation;
libdash::framework::adaptation::IAdaptationLogic *audioLogic;
MultimediaStream *audioStream;
std::vector<IMultimediaManagerObserver *> managerObservers;
@@ -102,6 +99,7 @@ private:
bool stopping;
bool icn;
double icnAlpha;
+ libdash::framework::input::IICNConnection *icnConn;
uint64_t framesDisplayed;
uint64_t segmentsDownloaded;
CRITICAL_SECTION monitorMutex;
@@ -117,22 +115,27 @@ private:
mutable CRITICAL_SECTION monitor_playing_audio_mutex;
mutable CONDITION_VARIABLE playingAudioStatusChanged;
const char *logicName;
- bool noDecoding;
- void notifyBufferChange ();
- bool startVideoRenderingThread ();
- void stopVideoRenderingThread ();
- static void* pushVideo (void *data);
- static void* pushVideoNoOut (void *data);
- bool startAudioRenderingThread ();
- void stopAudioRenderingThread ();
- void initVideoRendering (uint32_t offset);
- void initAudioPlayback (uint32_t offset);
- void stopVideo ();
- void stopAudio ();
- void notifyVideoBufferObservers (uint32_t fillstateInPercent);
- void notifyVideoSegmentBufferObservers (uint32_t fillstateInPercent);
- void notifyAudioBufferObservers (uint32_t fillstateInPercent);
- void notifyAudioSegmentBufferObservers (uint32_t fillstateInPercent);
+ bool noDecoding;
+ std::string url;
+ float segmentDuration;
+
+ void notifyBufferChange ();
+ bool startVideoRenderingThread ();
+ void stopVideoRenderingThread ();
+ static void* pushVideo (void *data);
+ static void* pushVideoNoOut (void *data);
+ bool startAudioRenderingThread ();
+ void stopAudioRenderingThread ();
+ void initVideoRendering (uint32_t offset);
+ void initAudioPlayback (uint32_t offset);
+ void stopVideo ();
+ void stopAudio ();
+ void notifyVideoBufferObservers (uint32_t fillstateInPercent);
+ void notifyVideoSegmentBufferObservers (uint32_t fillstateInPercent);
+ void notifyAudioBufferObservers (uint32_t fillstateInPercent);
+ void notifyAudioSegmentBufferObservers (uint32_t fillstateInPercent);
+ void updateMPD ();
+ void updateMPDICN ();
};
}
}
diff --git a/Managers/MultimediaStream.cpp b/Managers/MultimediaStream.cpp
index ed0d967c..4b5b66fe 100644
--- a/Managers/MultimediaStream.cpp
+++ b/Managers/MultimediaStream.cpp
@@ -15,23 +15,26 @@ using namespace viper::managers;
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::buffer;
+using namespace libdash::framework::mpd;
using namespace dash::mpd;
-MultimediaStream::MultimediaStream(StreamType type, IMPD *mpd, uint32_t bufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
+MultimediaStream::MultimediaStream(StreamType type, MPDWrapper *mpdWrapper, uint32_t bufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
type (type),
segmentBufferSize (bufferSize),
dashManager (NULL),
- mpd (mpd),
- icn (icnEnabled),
+ mpdWrapper (mpdWrapper),
+ icn (icnEnabled),
icnAlpha (icnAlpha),
noDecoding (nodecoding),
- beta (beta),
- drop (drop)
+ beta (beta),
+ drop (drop)
{
+// InitializeCriticalSection (&this->monitorMutex);
this->init();
}
MultimediaStream::~MultimediaStream ()
{
+// DestroyCriticalSection (&this->monitorMutex);
this->stop();
delete this->dashManager;
}
@@ -68,7 +71,7 @@ void MultimediaStream::setPositionInMsec(uint32_t milliSecs)
void MultimediaStream::init()
{
- this->dashManager = new DASHManager(this->type, this->segmentBufferSize, this, this->mpd, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
+ this->dashManager = new DASHManager(this->type, this->segmentBufferSize, this, this->mpdWrapper, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
}
bool MultimediaStream::start()
@@ -117,9 +120,9 @@ void MultimediaStream::attachStreamObserver(IStreamObserver *observer)
this->observers.push_back(observer);
}
-void MultimediaStream::setRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+void MultimediaStream::setRepresentation()
{
- this->dashManager->setRepresentation(period, adaptationSet, representation);
+ this->dashManager->setRepresentation();
}
void MultimediaStream::enqueueRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
@@ -206,3 +209,17 @@ void MultimediaStream::notifyBufferChange(uint32_t bufferfill, int maxC)
{
this->dashManager->onBufferStateChanged(libdash::framework::buffer::VIDEO, bufferfill, maxC);
}
+
+void MultimediaStream::updateMPD (IMPD* mpd)
+{
+// this->mpd = mpd;
+// this->dashManager->updateMPD(mpd);
+}
+
+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 6918f639..d9db5f66 100644
--- a/Managers/MultimediaStream.h
+++ b/Managers/MultimediaStream.h
@@ -14,6 +14,7 @@
#include "IMPD.h"
#include "IStreamObserver.h"
+#include "../MPD/MPDWrapper.h"
#include "../Input/DASHManager.h"
#include "../Buffer/IBufferObserver.h"
#include "../Adaptation/IAdaptationLogic.h"
@@ -22,6 +23,20 @@
#include "../Buffer/Buffer.h"
#include <QImage>
+namespace libdash
+{
+namespace framework
+{
+namespace mpd
+{
+class MPDWrapper;
+}
+namespace input
+{
+class DASHManager;
+}
+}
+}
namespace viper
{
namespace managers
@@ -29,7 +44,7 @@ namespace managers
class MultimediaStream : public libdash::framework::input::IDASHManagerObserver, public libdash::framework::buffer::IBufferObserver
{
public:
- MultimediaStream(StreamType type, dash::mpd::IMPD *mpd, uint32_t segmentBufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop);
+ MultimediaStream(StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, uint32_t segmentBufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop);
virtual ~MultimediaStream();
bool start();
@@ -50,7 +65,8 @@ public:
void notifyBufferChange(uint32_t bufferfill, int maxC);
- void setRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
+// void setRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
+ void setRepresentation();
void enqueueRepresentation(dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
void setAdaptationLogic(libdash::framework::adaptation::IAdaptationLogic *logic);
@@ -65,20 +81,22 @@ public:
int getBufferLevel();
bool isICN();
void shouldAbort();
-
void setTargetDownloadingTime(double);
+ void updateMPD(dash::mpd::IMPD* mpd);
+ void fetchMPD();
private:
float beta;
float drop;
std::vector<IStreamObserver *> observers;
- dash::mpd::IMPD *mpd;
- libdash::framework::adaptation::IAdaptationLogic *logic;
+ libdash::framework::mpd::MPDWrapper *mpdWrapper;
+ libdash::framework::adaptation::IAdaptationLogic *logic;
libdash::framework::input::DASHManager *dashManager;
- uint32_t segmentBufferSize;
- StreamType type;
+ uint32_t segmentBufferSize;
+ StreamType type;
bool icn;
double icnAlpha;
+ mutable CRITICAL_SECTION monitorMutex;
bool noDecoding;
void init ();