summaryrefslogtreecommitdiffstats
path: root/Managers/MultimediaStream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Managers/MultimediaStream.cpp')
-rw-r--r--Managers/MultimediaStream.cpp208
1 files changed, 208 insertions, 0 deletions
diff --git a/Managers/MultimediaStream.cpp b/Managers/MultimediaStream.cpp
new file mode 100644
index 00000000..ed0d967c
--- /dev/null
+++ b/Managers/MultimediaStream.cpp
@@ -0,0 +1,208 @@
+/*
+ * MultimediaStream.cpp
+ *****************************************************************************
+ * Copyright (C) 2012, bitmovin Softwareentwicklung OG, All Rights Reserved
+ *
+ * Email: libdash-dev@vicky.bitmovin.net
+ *
+ * This source code and its use and distribution, is subject to the terms
+ * and conditions of the applicable license agreement.
+ *****************************************************************************/
+
+#include "MultimediaStream.h"
+
+using namespace viper::managers;
+using namespace libdash::framework::adaptation;
+using namespace libdash::framework::input;
+using namespace libdash::framework::buffer;
+using namespace dash::mpd;
+
+MultimediaStream::MultimediaStream(StreamType type, IMPD *mpd, uint32_t bufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
+ type (type),
+ segmentBufferSize (bufferSize),
+ dashManager (NULL),
+ mpd (mpd),
+ icn (icnEnabled),
+ icnAlpha (icnAlpha),
+ noDecoding (nodecoding),
+ beta (beta),
+ drop (drop)
+{
+ this->init();
+}
+MultimediaStream::~MultimediaStream ()
+{
+ this->stop();
+ delete this->dashManager;
+}
+
+bool MultimediaStream::isICN()
+{
+ return this->icn;
+}
+
+void MultimediaStream::shouldAbort()
+{
+ this->dashManager->shouldAbort();
+}
+
+uint32_t MultimediaStream::getPosition()
+{
+ return this->dashManager->getPosition();
+}
+
+void MultimediaStream::setLooping(bool looping)
+{
+ this->dashManager->setLooping(looping);
+}
+
+void MultimediaStream::setPosition(uint32_t segmentNumber)
+{
+ this->dashManager->setPosition(segmentNumber);
+}
+
+void MultimediaStream::setPositionInMsec(uint32_t milliSecs)
+{
+ this->dashManager->setPositionInMsec(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);
+}
+
+bool MultimediaStream::start()
+{
+ if(!this->startDownload())
+ return false;
+
+ return true;
+}
+
+bool MultimediaStream::startDownload()
+{
+ dashManager->setAdaptationLogic(this->logic);
+ if(!dashManager->start())
+ return false;
+
+ return true;
+}
+
+void MultimediaStream::stop()
+{
+ this->stopDownload();
+}
+
+void MultimediaStream::stopDownload()
+{
+ this->dashManager->stop();
+}
+
+void MultimediaStream::clear()
+{
+ this->dashManager->clear();
+}
+
+void MultimediaStream::addFrame(QImage *frame)
+{
+}
+
+QImage* MultimediaStream::getFrame()
+{
+ return NULL;
+}
+
+void MultimediaStream::attachStreamObserver(IStreamObserver *observer)
+{
+ this->observers.push_back(observer);
+}
+
+void MultimediaStream::setRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+{
+ this->dashManager->setRepresentation(period, adaptationSet, representation);
+}
+
+void MultimediaStream::enqueueRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+{
+ this->dashManager->enqueueRepresentation(period, adaptationSet, representation);
+}
+
+void MultimediaStream::setAdaptationLogic(libdash::framework::adaptation::IAdaptationLogic *logic)
+{
+ this->logic = logic;
+}
+
+void MultimediaStream::onSegmentBufferStateChanged(uint32_t fillstateInPercent, int maxC)
+{
+ for (size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->onSegmentBufferStateChanged(this->type, fillstateInPercent, maxC);
+}
+
+void MultimediaStream::onBufferStateChanged(BufferType type, uint32_t fillstateInPercent, int maxC)
+{
+ switch(type)
+ {
+ case libdash::framework::buffer::AUDIO:
+ for (size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->onAudioBufferStateChanged(fillstateInPercent);
+ break;
+ case libdash::framework::buffer::VIDEO:
+ for (size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->onVideoBufferStateChanged(fillstateInPercent);
+ default:
+ break;
+ }
+}
+
+void MultimediaStream::setEOS(bool value)
+{
+ for(size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->setEOS(value);
+}
+
+void MultimediaStream::setTargetDownloadingTime(double target)
+{
+ this->dashManager->setTargetDownloadingTime(target);
+}
+
+void MultimediaStream::notifyStatistics(int segNum, uint32_t bitrate, int fps, uint32_t quality)
+{
+ for(size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->notifyStatistics(segNum, bitrate, fps, quality);
+}
+
+void MultimediaStream::notifyQualityDownloading(uint32_t quality)
+{
+ for(size_t i = 0; i < observers.size(); i++)
+ this->observers.at(i)->notifyQualityDownloading(quality);
+}
+
+int MultimediaStream::getBufferLevel()
+{
+ int bufferFill = 0;
+ for(size_t i=0; i < observers.size(); i++)
+ {
+ bufferFill = this->observers.at(i)->getBufferLevel();
+ }
+ return bufferFill;
+}
+bool MultimediaStream::canPush()
+{
+ bool flag = false;
+ for(size_t i=0; i < observers.size(); i++)
+ {
+ flag = flag || this->observers.at(i)->canPush();
+ }
+ return flag;
+}
+
+
+libdash::framework::input::MediaObject* MultimediaStream::getSegment()
+{
+ return this->dashManager->getSegment();
+}
+
+void MultimediaStream::notifyBufferChange(uint32_t bufferfill, int maxC)
+{
+ this->dashManager->onBufferStateChanged(libdash::framework::buffer::VIDEO, bufferfill, maxC);
+}