aboutsummaryrefslogtreecommitdiffstats
path: root/Adaptation
diff options
context:
space:
mode:
Diffstat (limited to 'Adaptation')
-rw-r--r--Adaptation/AbstractAdaptationLogic.cpp29
-rw-r--r--Adaptation/AbstractAdaptationLogic.h38
-rw-r--r--Adaptation/AdaptationLogicFactory.cpp20
-rw-r--r--Adaptation/AdaptationLogicFactory.h4
-rw-r--r--Adaptation/AlwaysLowestLogic.cpp6
-rw-r--r--Adaptation/AlwaysLowestLogic.h3
-rw-r--r--Adaptation/Bola.cpp46
-rw-r--r--Adaptation/Bola.h73
-rw-r--r--Adaptation/BufferBasedAdaptation.cpp33
-rw-r--r--Adaptation/BufferBasedAdaptation.h17
-rw-r--r--Adaptation/BufferBasedAdaptationWithRateBased.cpp34
-rw-r--r--Adaptation/BufferBasedAdaptationWithRateBased.h25
-rw-r--r--Adaptation/BufferBasedThreeThresholdAdaptation.cpp151
-rw-r--r--Adaptation/BufferBasedThreeThresholdAdaptation.h27
-rw-r--r--Adaptation/IAdaptationLogic.h7
-rw-r--r--Adaptation/Panda.cpp35
-rw-r--r--Adaptation/Panda.h53
-rw-r--r--Adaptation/RateBasedAdaptation.cpp22
-rw-r--r--Adaptation/RateBasedAdaptation.h11
19 files changed, 335 insertions, 299 deletions
diff --git a/Adaptation/AbstractAdaptationLogic.cpp b/Adaptation/AbstractAdaptationLogic.cpp
index 4f578958..ada388b7 100644
--- a/Adaptation/AbstractAdaptationLogic.cpp
+++ b/Adaptation/AbstractAdaptationLogic.cpp
@@ -14,17 +14,16 @@
using namespace libdash::framework::adaptation;
using namespace dash::mpd;
-AbstractAdaptationLogic::AbstractAdaptationLogic(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid) :
- mpd (mpd),
- period (period),
- adaptationSet (adaptationSet),
- representation (NULL),
- isVideo (isVid)
+AbstractAdaptationLogic::AbstractAdaptationLogic(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper) :
+ mpdWrapper (mpdWrapper),
+ type (type)
{
+ InitializeCriticalSection (&this->monitorLock);
}
AbstractAdaptationLogic::~AbstractAdaptationLogic()
{
+ DeleteCriticalSection (&this->monitorLock);
}
uint32_t AbstractAdaptationLogic::getPosition()
@@ -39,15 +38,19 @@ void AbstractAdaptationLogic::setPosition(uint32_t segmentNumber)
IRepresentation* AbstractAdaptationLogic::getRepresentation()
{
- return this->representation;
+// return this->representation;
}
-void AbstractAdaptationLogic::setRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
-{
- this->period = period;
- this->adaptationSet = adaptationSet;
- this->representation = representation;
-}
+//void AbstractAdaptationLogic::setRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
+//{
+// this->period = period;
+// this->adaptationSet = adaptationSet;
+// this->representation = representation;
+//}
+
+//void AbstractAdaptationLogic::updateMPD(IMPD* mpd)
+//{
+//}
void AbstractAdaptationLogic::dLTimeUpdate(double time)
{
diff --git a/Adaptation/AbstractAdaptationLogic.h b/Adaptation/AbstractAdaptationLogic.h
index 24fab91d..c407f01b 100644
--- a/Adaptation/AbstractAdaptationLogic.h
+++ b/Adaptation/AbstractAdaptationLogic.h
@@ -24,33 +24,37 @@ namespace adaptation
class AbstractAdaptationLogic : public IAdaptationLogic
{
public:
- AbstractAdaptationLogic(dash::mpd::IMPD *mpd, dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, bool isVideo);
+// AbstractAdaptationLogic(dash::mpd::IMPD *mpd, dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, bool isVideo);
+ AbstractAdaptationLogic(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper);
virtual ~AbstractAdaptationLogic();
virtual uint32_t getPosition();
virtual void setPosition(uint32_t segmentNumber);
virtual dash::mpd::IRepresentation* getRepresentation ();
- virtual void setRepresentation(dash::mpd::IPeriod *period,
- dash::mpd::IAdaptationSet *adaptationSet,
- dash::mpd::IRepresentation *representation);
+// virtual void setRepresentation(dash::mpd::IPeriod *period,
+// dash::mpd::IAdaptationSet *adaptationSet,
+// dash::mpd::IRepresentation *representation);
+// virtual void updateMPD(dash::mpd::IMPD* mpd);
- virtual LogicType getType() = 0;
- virtual bool isUserDependent() = 0;
- virtual bool isRateBased() = 0;
- virtual bool isBufferBased() = 0;
+ virtual LogicType getType() = 0;
+ virtual bool isUserDependent() = 0;
+ virtual bool isRateBased() = 0;
+ virtual bool isBufferBased() = 0;
virtual void bitrateUpdate(uint64_t, uint32_t) = 0;
- virtual void bufferUpdate(uint32_t, int) = 0;
- virtual void onEOS(bool value)= 0;
- virtual void dLTimeUpdate(double) = 0;
+ virtual void bufferUpdate(uint32_t, int) = 0;
+ virtual void onEOS(bool value) = 0;
+ virtual void dLTimeUpdate(double) = 0;
+ virtual void checkedByDASHReceiver() = 0;
- virtual void checkedByDASHReceiver() = 0;
protected:
- dash::mpd::IMPD *mpd;
- dash::mpd::IPeriod *period;
- dash::mpd::IAdaptationSet *adaptationSet;
- dash::mpd::IRepresentation *representation;
+ libdash::framework::mpd::MPDWrapper *mpdWrapper;
+// dash::mpd::IPeriod *period;
+// dash::mpd::IAdaptationSet *adaptationSet;
+// dash::mpd::IRepresentation *representation;
uint32_t segmentNumber;
- bool isVideo;
+// bool isVideo;
+ viper::managers::StreamType type;
+ mutable CRITICAL_SECTION monitorLock;
};
}
}
diff --git a/Adaptation/AdaptationLogicFactory.cpp b/Adaptation/AdaptationLogicFactory.cpp
index 6901a597..b2cae9c1 100644
--- a/Adaptation/AdaptationLogicFactory.cpp
+++ b/Adaptation/AdaptationLogicFactory.cpp
@@ -13,36 +13,36 @@
#include<stdio.h>
using namespace libdash::framework::adaptation;
+using namespace libdash::framework::mpd;
using namespace dash::mpd;
-IAdaptationLogic* AdaptationLogicFactory::create(LogicType logic, IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet,bool isVid, struct AdaptationParameters* paramsForAdaptation)
+IAdaptationLogic* AdaptationLogicFactory::create(LogicType logic, viper::managers::StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters* paramsForAdaptation)
{
- Debug("Adaptation Logic for %s: ", isVid ? "video" : "audio");
switch(logic)
{
case AlwaysLowest:
Debug("Always lowest\n");
- return new AlwaysLowestLogic(mpd, period, adaptationSet, isVid, paramsForAdaptation);
+ return new AlwaysLowestLogic(type, mpdWrapper, paramsForAdaptation);
case RateBased:
Debug("Rate based\n");
- return new RateBasedAdaptation(mpd,period,adaptationSet, isVid, paramsForAdaptation);
+ return new RateBasedAdaptation(type, mpdWrapper, paramsForAdaptation);
case BufferBased:
Debug("Buffer based\n");
- return new BufferBasedAdaptation(mpd,period,adaptationSet, isVid, paramsForAdaptation);
+ return new BufferBasedAdaptation(type, mpdWrapper, paramsForAdaptation);
case BufferRateBased:
Debug("Buffer Rate based\n");
- return new BufferBasedAdaptationWithRateBased(mpd,period,adaptationSet, isVid, paramsForAdaptation);
+ return new BufferBasedAdaptationWithRateBased(type, mpdWrapper, paramsForAdaptation);
case BufferBasedThreeThreshold:
Debug("Buffer based 3 threshold\n");
- return new BufferBasedThreeThresholdAdaptation(mpd,period,adaptationSet, isVid, paramsForAdaptation);
+ return new BufferBasedThreeThresholdAdaptation(type, mpdWrapper, paramsForAdaptation);
case Panda:
Debug("Panda\n");
- return new PandaAdaptation(mpd, period, adaptationSet, isVid, paramsForAdaptation);
+ return new PandaAdaptation(type, mpdWrapper, paramsForAdaptation);
case Bola:
Debug("Bola\n");
- return new BolaAdaptation(mpd, period, adaptationSet, isVid, paramsForAdaptation);
+ return new BolaAdaptation(type, mpdWrapper, paramsForAdaptation);
default:
Debug("default => return Always Lowest\n");
- return new AlwaysLowestLogic(mpd, period, adaptationSet, isVid, paramsForAdaptation);
+ return new AlwaysLowestLogic(type, mpdWrapper, paramsForAdaptation);
}
}
diff --git a/Adaptation/AdaptationLogicFactory.h b/Adaptation/AdaptationLogicFactory.h
index 0f1616a7..e78d2865 100644
--- a/Adaptation/AdaptationLogicFactory.h
+++ b/Adaptation/AdaptationLogicFactory.h
@@ -30,8 +30,8 @@ namespace adaptation
class AdaptationLogicFactory
{
public:
- static IAdaptationLogic* create(libdash::framework::adaptation::LogicType logic,
- dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ static IAdaptationLogic* create(libdash::framework::adaptation::LogicType logic, viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
+// static IAdaptationLogic* create(libdash::framework::adaptation::LogicType logic, dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
};
}
}
diff --git a/Adaptation/AlwaysLowestLogic.cpp b/Adaptation/AlwaysLowestLogic.cpp
index 54409bfd..1f318867 100644
--- a/Adaptation/AlwaysLowestLogic.cpp
+++ b/Adaptation/AlwaysLowestLogic.cpp
@@ -14,12 +14,12 @@
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
+using namespace libdash::framework::mpd;
using namespace dash::mpd;
-AlwaysLowestLogic::AlwaysLowestLogic(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic(mpd, period, adaptationSet, isVid)
+AlwaysLowestLogic::AlwaysLowestLogic(viper::managers::StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic(type, mpdWrapper)
{
- this->representation = this->adaptationSet->GetRepresentation().at(0);
}
AlwaysLowestLogic::~AlwaysLowestLogic()
diff --git a/Adaptation/AlwaysLowestLogic.h b/Adaptation/AlwaysLowestLogic.h
index 782a8b29..f8b50e37 100644
--- a/Adaptation/AlwaysLowestLogic.h
+++ b/Adaptation/AlwaysLowestLogic.h
@@ -24,7 +24,8 @@ namespace adaptation
class AlwaysLowestLogic : public AbstractAdaptationLogic
{
public:
- AlwaysLowestLogic(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// AlwaysLowestLogic(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ AlwaysLowestLogic(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~AlwaysLowestLogic();
virtual LogicType getType();
diff --git a/Adaptation/Bola.cpp b/Adaptation/Bola.cpp
index 6477e0f5..f7acc72e 100644
--- a/Adaptation/Bola.cpp
+++ b/Adaptation/Bola.cpp
@@ -47,8 +47,8 @@ using std::placeholders::_2;
using duration_in_seconds = std::chrono::duration<double, std::ratio<1, 1> >;
-BolaAdaptation::BolaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic (mpd, period, adaptationSet, isVid)
+BolaAdaptation::BolaAdaptation(viper::managers::StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic (type, mpdWrapper)
{
this->bufferMaxSizeSeconds =(double) params->segmentBufferSize * params->segmentDuration;
this->alphaRate = params->Bola_Alpha;
@@ -62,11 +62,12 @@ BolaAdaptation::BolaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adapt
this->currentDownloadTimeInstant = 0.0;
//this->lastSegmentDownloadTime = 0.0;
this->currentQuality = 0;
-
+ this->representation = NULL;
this->bufferTargetPerc = (uint32_t) ( round(this->bufferTargetSeconds / this->bufferMaxSizeSeconds)*100 );
+ this->mpdWrapper->acquireLock();
/// Retrieve available bitrates
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
+ std::vector<IRepresentation* > representations = this->mpdWrapper->getRepresentations(this->type);
this->availableBitrates.clear();
Debug("BOLA Available Bitrates...\n");
@@ -85,8 +86,8 @@ BolaAdaptation::BolaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adapt
// return 0; // Check if exit with a message is necessary
}
- // Check if the following is correct
- this->totalDuration = TimeResolver::getDurationInSec(this->mpd->GetMediaPresentationDuration());
+ // Check if the following is correct XXX Maybe useless
+ this->totalDuration = TimeResolver::getDurationInSec(this->mpdWrapper->getMediaPresentationDuration());
// this->segmentDuration = (double) (representations.at(0)->GetSegmentTemplate()->GetDuration() / representations.at(0)->GetSegmentTemplate()->GetTimescale() );
this->segmentDuration = 2.0;
Debug("Total Duration - BOLA:\t%f\nSegment Duration - BOLA:\t%f\n",this->totalDuration, this->segmentDuration);
@@ -169,6 +170,7 @@ BolaAdaptation::BolaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adapt
this->representation = representations.at(0);
this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
+ this->mpdWrapper->releaseLock();
Debug("BOLA Init Params - \tAlpha: %f \t BufferTarget: %f\n",this->alphaRate, this->bufferTargetSeconds);
Debug("BOLA Init Current BitRate - %I64u\n",this->currentBitrate);
Debug("Buffer Adaptation BOLA: STARTED\n");
@@ -204,16 +206,20 @@ void BolaAdaptation::setMultimediaManager(viper::managers::IMultimediaManagerBas
void BolaAdaptation::notifyBitrateChange()
{
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
if(this->multimediaManager)
if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
+ if(type==viper::managers::VIDEO)
+ this->multimediaManager->setVideoQuality();
+// this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
+ this->multimediaManager->setAudioQuality();
+// this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
//Should Abort is done here to avoid race condition with DASHReceiver::DoBuffering()
if(this->shouldAbort)
{
- this->multimediaManager->shouldAbort(this->isVideo);
+ this->multimediaManager->shouldAbort(1);
+// this->multimediaManager->shouldAbort((this->type == viper::managers::StreamType::VIDEO));
}
this->shouldAbort = false;
}
@@ -263,10 +269,10 @@ void BolaAdaptation::setBitrate(uint32_t bufferFill)
}
//this->representation = this->availableBitrates[this->currentQuality];
//this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
- this->representation = this->adaptationSet->GetRepresentation().at(this->currentQuality);
+ this->representation = this->mpdWrapper->getRepresentationAt(this->type, this->currentQuality);
this->currentBitrate = (uint64_t) this->availableBitrates[this->currentQuality];
Debug("INIT - Current Bitrate:\t%I64u\n", this->currentBitrate);
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
this->lastBufferFill = bufferFill;
return;
}
@@ -275,10 +281,10 @@ void BolaAdaptation::setBitrate(uint32_t bufferFill)
this->currentQuality = 0;
//this->representation = this->availableBitrates[this->currentQuality];
//this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
- this->representation = this->adaptationSet->GetRepresentation().at(this->currentQuality);
+ this->representation = this->mpdWrapper->getRepresentationAt(this->type,this->currentQuality);
this->currentBitrate = (uint64_t) this->availableBitrates[this->currentQuality];
Debug("ONE BITRATE - Current Bitrate:\t%I64u\n", this->currentBitrate);
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
this->lastBufferFill = bufferFill;
return;
}
@@ -384,10 +390,10 @@ void BolaAdaptation::setBitrate(uint32_t bufferFill)
this->currentQuality = quality;
//this->representation = this->availableBitrates[this->currentQuality];
//this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
- this->representation = this->adaptationSet->GetRepresentation().at(this->currentQuality);
+ this->representation = this->mpdWrapper->getRepresentationAt(this->type, this->currentQuality);
this->currentBitrate = (uint64_t) this->availableBitrates[this->currentQuality];
Debug("STILL IN STARTUP - Current Bitrate:\t%I64u\n", this->currentBitrate);
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
this->lastBufferFill = bufferFill;
return;
}
@@ -434,15 +440,15 @@ void BolaAdaptation::setBitrate(uint32_t bufferFill)
// streamProcessor.getScheduleController().setTimeToLoadDelay(1000.0 * delaySeconds);
// NEED TO CHECK THIS
Debug("STEADY -- DELAY DOWNLOAD OF:\t%f\n", delaySeconds);
- this->multimediaManager->setTargetDownloadingTime(this->isVideo, delaySeconds);
+ this->multimediaManager->setTargetDownloadingTime((this->type == viper::managers::StreamType::VIDEO), delaySeconds);
}
this->currentQuality = bolaQuality;
//this->representation = this->availableBitrates[this->currentQuality];
- this->representation = this->adaptationSet->GetRepresentation().at(this->currentQuality);
+ this->representation = this->mpdWrapper->getRepresentationAt(this->type, this->currentQuality);
this->currentBitrate = (uint64_t) this->availableBitrates[this->currentQuality];
Debug("STEADY - Current Bitrate:\t%I64u\n", this->currentBitrate);
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->currentQuality);
this->lastBufferFill = bufferFill;
}
@@ -501,6 +507,8 @@ void BolaAdaptation::checkedByDASHReceiver()
}
void BolaAdaptation::bufferUpdate(uint32_t bufferFill, int maxC)
{
+ this->mpdWrapper->acquireLock();
this->setBitrate(bufferFill);
this->notifyBitrateChange();
+ this->mpdWrapper->releaseLock();
}
diff --git a/Adaptation/Bola.h b/Adaptation/Bola.h
index 29011664..404e9968 100644
--- a/Adaptation/Bola.h
+++ b/Adaptation/Bola.h
@@ -29,7 +29,8 @@ namespace adaptation
class BolaAdaptation : public AbstractAdaptationLogic
{
public:
- BolaAdaptation (dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// BolaAdaptation (dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ BolaAdaptation (viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~BolaAdaptation();
virtual LogicType getType();
@@ -58,58 +59,54 @@ private:
STEADY // The buffer is primed (should be above bufferTarget)
};
- bool initState;
- double bufferMaxSizeSeconds; // Usually set to 30s
- double bufferTargetSeconds; // It is passed as an init parameter.
+ bool initState;
+ double bufferMaxSizeSeconds; // Usually set to 30s
+ double bufferTargetSeconds; // It is passed as an init parameter.
// It states the difference between STARTUP and STEADY
// 12s following dash.js implementation
- double bolaBufferTargetSeconds; // BOLA introduces a virtual buffer level in order to make quality decisions
+ double bolaBufferTargetSeconds; // BOLA introduces a virtual buffer level in order to make quality decisions
// as it was filled (instead of the actual bufferTargetSeconds)
- double bolaBufferMaxSeconds; // When using the virtual buffer, it must be capped.
-
- uint32_t bufferTargetPerc; // Computed considering a bufferSize = 30s
- double totalDuration; // Total video duration in seconds (taken from MPD)
- double segmentDuration; // Segment duration in seconds
+ double bolaBufferMaxSeconds; // When using the virtual buffer, it must be capped.
+ uint32_t bufferTargetPerc; // Computed considering a bufferSize = 30s
+ double totalDuration; // Total video duration in seconds (taken from MPD)
+ double segmentDuration; // Segment duration in seconds
std::vector<uint64_t> availableBitrates;
std::vector<double> utilityVector;
- uint32_t bitrateCount; // Number of available bitrates
- BolaState bolaState; // Keeps track of Bola state
+ uint32_t bitrateCount; // Number of available bitrates
+ BolaState bolaState; // Keeps track of Bola state
// Bola Vp and gp (multiplied by the segment duration 'p')
// They are dimensioned such that log utility would always prefer
// - the lowest bitrate when bufferLevel = segmentDuration
// - the highest bitrate when bufferLevel = bufferTarget
- double Vp;
- double gp;
-
- bool safetyGuarantee;
- double maxRtt;
-
- double virtualBuffer;
-
- uint64_t currentBitrate;
- int currentQuality;
- uint64_t batchBw;
- int batchBwCount;
+ double Vp;
+ double gp;
+ bool safetyGuarantee;
+ double maxRtt;
+ double virtualBuffer;
+
+ uint64_t currentBitrate;
+ int currentQuality;
+ uint64_t batchBw;
+ int batchBwCount;
std::vector<uint64_t> batchBwSamples;
- uint64_t instantBw;
- uint64_t averageBw;
-
- double lastDownloadTimeInstant;
- double currentDownloadTimeInstant;
- double lastSegmentDownloadTime;
-
- uint32_t lastBufferFill;
- bool bufferEOS;
- bool shouldAbort;
- double alphaRate;
- bool isCheckedForReceiver;
-
+ uint64_t instantBw;
+ uint64_t averageBw;
+
+ double lastDownloadTimeInstant;
+ double currentDownloadTimeInstant;
+ double lastSegmentDownloadTime;
+
+ uint32_t lastBufferFill;
+ bool bufferEOS;
+ bool shouldAbort;
+ double alphaRate;
+ bool isCheckedForReceiver;
viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
+ dash::mpd::IRepresentation *representation;
};
}
}
diff --git a/Adaptation/BufferBasedAdaptation.cpp b/Adaptation/BufferBasedAdaptation.cpp
index 18d4a592..eea7ef36 100644
--- a/Adaptation/BufferBasedAdaptation.cpp
+++ b/Adaptation/BufferBasedAdaptation.cpp
@@ -22,15 +22,13 @@ using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::mpd;
-BufferBasedAdaptation::BufferBasedAdaptation (IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic (mpd, period, adaptationSet, isVid)
+BufferBasedAdaptation::BufferBasedAdaptation (viper::managers::StreamType type, MPDWrapper *mpd, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic (type, mpdWrapper)
{
this->reservoirThreshold = params->BufferBased_reservoirThreshold;
this->maxThreshold = params->BufferBased_maxThreshold;
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
-
- this->representation = this->adaptationSet->GetRepresentation().at(0);
+// this->representation = this->adaptationSet->GetRepresentation().at(0);
this->multimediaManager = NULL;
this->lastBufferFill = 0;
this->bufferEOS = false;
@@ -69,18 +67,19 @@ void BufferBasedAdaptation::setMultimediaManager (viper::managers::IMultimediaMa
void BufferBasedAdaptation::notifyBitrateChange()
{
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
if(this->multimediaManager)
if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
+ if(this->type == viper::managers::StreamType::VIDEO)
+ this->multimediaManager->setVideoQuality();
else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
+ this->multimediaManager->setAudioQuality();
- if(this->shouldAbort)
- {
- this->multimediaManager->shouldAbort(this->isVideo);
- }
- this->shouldAbort = false;
+// if(this->shouldAbort)
+// {
+// this->multimediaManager->shouldAbort((this->type == viper::managers::StreamType::VIDEO));
+// }
+// this->shouldAbort = false;
}
uint64_t BufferBasedAdaptation::getBitrate()
@@ -90,8 +89,8 @@ uint64_t BufferBasedAdaptation::getBitrate()
void BufferBasedAdaptation::setBitrate(uint32_t bufferFill)
{
- std::vector<IRepresentation *> representations;
- representations = this->adaptationSet->GetRepresentation();
+ std::vector<IRepresentation *> representations = this->mpdWrapper->getRepresentations(this->type);
+ this->representation = representations.at(0);
size_t i = 0;
if(representations.size() == 1)
@@ -112,7 +111,7 @@ void BufferBasedAdaptation::setBitrate(uint32_t bufferFill)
{
this->shouldAbort = true;
}
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, choice: %lu, should_trigger_abort: %s\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, i, this->shouldAbort ? "YES" : "NO");
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, choice: %lu, should_trigger_abort: %s\n", (this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, i, this->shouldAbort ? "YES" : "NO");
this->lastBufferFill = bufferFill;
}
@@ -136,6 +135,8 @@ void BufferBasedAdaptation::checkedByDASHReceiver()
void BufferBasedAdaptation::bufferUpdate(uint32_t bufferFill, int maxC)
{
+ this->mpdWrapper->acquireLock();
this->setBitrate(bufferFill);
this->notifyBitrateChange();
+ this->mpdWrapper->releaseLock();
}
diff --git a/Adaptation/BufferBasedAdaptation.h b/Adaptation/BufferBasedAdaptation.h
index 32ad8045..f610064f 100644
--- a/Adaptation/BufferBasedAdaptation.h
+++ b/Adaptation/BufferBasedAdaptation.h
@@ -29,7 +29,8 @@ namespace adaptation
class BufferBasedAdaptation : public AbstractAdaptationLogic
{
public:
- BufferBasedAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// BufferBasedAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ BufferBasedAdaptation(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~BufferBasedAdaptation();
virtual LogicType getType();
@@ -47,15 +48,15 @@ public:
void checkedByDASHReceiver();
private:
- uint64_t currentBitrate;
+ uint64_t currentBitrate;
std::vector<uint64_t> availableBitrates;
viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
- uint32_t reservoirThreshold;
- uint32_t maxThreshold;
- uint32_t lastBufferFill;
- bool bufferEOS;
- bool shouldAbort;
+ dash::mpd::IRepresentation *representation;
+ uint32_t reservoirThreshold;
+ uint32_t maxThreshold;
+ uint32_t lastBufferFill;
+ bool bufferEOS;
+ bool shouldAbort;
};
}
}
diff --git a/Adaptation/BufferBasedAdaptationWithRateBased.cpp b/Adaptation/BufferBasedAdaptationWithRateBased.cpp
index 3a1895c0..3df1cf84 100644
--- a/Adaptation/BufferBasedAdaptationWithRateBased.cpp
+++ b/Adaptation/BufferBasedAdaptationWithRateBased.cpp
@@ -21,8 +21,8 @@ using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::mpd;
-BufferBasedAdaptationWithRateBased::BufferBasedAdaptationWithRateBased(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic(mpd, period, adaptationSet, isVid)
+BufferBasedAdaptationWithRateBased::BufferBasedAdaptationWithRateBased(viper::managers::StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic(type, mpdWrapper)
{
this->alphaRate = params->Adaptech_Alpha;
this->reservoirThreshold = params->Adaptech_FirstThreshold;
@@ -30,18 +30,18 @@ BufferBasedAdaptationWithRateBased::BufferBasedAdaptationWithRateBased(IMPD *mpd
this->switchUpThreshold = params->Adaptech_SwitchUpThreshold;
this->slackParam = params->Adaptech_SlackParameter;
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
-
this->m_count = 0;
this->instantBw = 0;
this->averageBw = 0;
- this->representation = this->adaptationSet->GetRepresentation().at(0);
+// this->representation = this->adaptationSet->GetRepresentation().at(0);
+
this->multimediaManager = NULL;
this->lastBufferFill = 0;
this->bufferEOS = false;
this->shouldAbort = false;
this->isCheckedForReceiver = false;
this->myQuality = 0;
+ this->currentBitrate = 0;
Debug("BufferRateBasedParams:\talpha:%f\tfirst threshold: %f\tsecond threshold: %f\tswitch-up margin: %d\tSlack: %f\n",this->alphaRate, (double)reservoirThreshold/100, (double)maxThreshold/100, this->switchUpThreshold, this->slackParam);
Debug("Buffer Adaptation: STARTED\n");
}
@@ -75,18 +75,19 @@ void BufferBasedAdaptationWithRateBased::setMultimediaManager(viper::managers::I
void BufferBasedAdaptationWithRateBased::notifyBitrateChange()
{
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
if(this->multimediaManager)
if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
+ if(this->type==viper::managers::StreamType::VIDEO)
+ this->multimediaManager->setVideoQuality();
else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
+ this->multimediaManager->setAudioQuality();
//Should Abort is done here to avoid race condition with DASHReceiver::DoBuffering()
- if(this->shouldAbort)
- {
- this->multimediaManager->shouldAbort(this->isVideo);
- }
- this->shouldAbort = false;
+// if(this->shouldAbort)
+// {
+// this->multimediaManager->shouldAbort((this->type == viper::managers::StreamType::VIDEO));
+// }
+// this->shouldAbort = false;
}
uint64_t BufferBasedAdaptationWithRateBased::getBitrate()
@@ -98,7 +99,7 @@ void BufferBasedAdaptationWithRateBased::setBitrate(uint32_t bufferFill)
{
uint32_t phi1, phi2;
std::vector<IRepresentation *> representations;
- representations = this->adaptationSet->GetRepresentation();
+ representations = this->mpdWrapper->getRepresentations(this->type);
size_t i = 0;
Debug("bufferlevel: %u, instant rate %lu, average rate %lu\n", bufferFill, this->instantBw, this->averageBw);
@@ -167,7 +168,7 @@ void BufferBasedAdaptationWithRateBased::setBitrate(uint32_t bufferFill)
}
this->representation = representations.at(this->myQuality);
this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->myQuality);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->averageBw , this->myQuality);
}
void BufferBasedAdaptationWithRateBased::bitrateUpdate(uint64_t bps, uint32_t segNum)
@@ -196,11 +197,14 @@ void BufferBasedAdaptationWithRateBased::checkedByDASHReceiver()
void BufferBasedAdaptationWithRateBased::bufferUpdate(uint32_t bufferFill, int maxC)
{
Debug("buffer update: %u\n", bufferFill);
+ EnterCriticalSection(&this->monitorLock);
this->setBitrate(bufferFill);
this->notifyBitrateChange();
+ LeaveCriticalSection(&this->monitorLock);
}
void BufferBasedAdaptationWithRateBased::dLTimeUpdate(double time)
{
}
+
diff --git a/Adaptation/BufferBasedAdaptationWithRateBased.h b/Adaptation/BufferBasedAdaptationWithRateBased.h
index 5c787d30..45147ed2 100644
--- a/Adaptation/BufferBasedAdaptationWithRateBased.h
+++ b/Adaptation/BufferBasedAdaptationWithRateBased.h
@@ -29,7 +29,8 @@ namespace adaptation
class BufferBasedAdaptationWithRateBased : public AbstractAdaptationLogic
{
public:
- BufferBasedAdaptationWithRateBased(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// BufferBasedAdaptationWithRateBased(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ BufferBasedAdaptationWithRateBased(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~BufferBasedAdaptationWithRateBased();
virtual LogicType getType();
@@ -48,22 +49,22 @@ public:
private:
uint64_t currentBitrate;
- std::vector<uint64_t> availableBitrates;
- viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
+ std::vector<uint64_t> availableBitrates;
+ viper::managers::IMultimediaManagerBase *multimediaManager;
+ dash::mpd::IRepresentation *representation;
uint32_t reservoirThreshold;
uint32_t maxThreshold;
uint32_t lastBufferFill;
- int m_count;
- int switchUpThreshold;
- bool bufferEOS;
- bool shouldAbort;
- double alphaRate;
+ int m_count;
+ int switchUpThreshold;
+ bool bufferEOS;
+ bool shouldAbort;
+ double alphaRate;
uint64_t averageBw;
uint64_t instantBw;
- int myQuality;
- double slackParam;
- bool isCheckedForReceiver;
+ int myQuality;
+ double slackParam;
+ bool isCheckedForReceiver;
};
}
}
diff --git a/Adaptation/BufferBasedThreeThresholdAdaptation.cpp b/Adaptation/BufferBasedThreeThresholdAdaptation.cpp
index 021e7b7c..7efab53a 100644
--- a/Adaptation/BufferBasedThreeThresholdAdaptation.cpp
+++ b/Adaptation/BufferBasedThreeThresholdAdaptation.cpp
@@ -20,23 +20,24 @@ using namespace dash::mpd;
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::mpd;
+using namespace viper::managers;
-BufferBasedThreeThresholdAdaptation::BufferBasedThreeThresholdAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic(mpd, period, adaptationSet, isVid)
+BufferBasedThreeThresholdAdaptation::BufferBasedThreeThresholdAdaptation(viper::managers::StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic(type, mpdWrapper)
{
- this->firstThreshold = params->BufferThreeThreshold_FirstThreshold;
- this->secondThreshold = params->BufferThreeThreshold_SecondThreshold;
- this->thirdThreshold = params->BufferThreeThreshold_ThirdThreshold;
- this->slackParam = params->BufferThreeThreshold_slackParameter;
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
- this->representation = this->adaptationSet->GetRepresentation().at(0);
- this->multimediaManager = NULL;
- this->lastBufferFill = 0;
- this->bufferEOS = false;
- this->shouldAbort = false;
- this->isCheckedForReceiver = false;
- Debug("BufferRateBasedParams:\t%f\t%f\t%f\n",(double)this->firstThreshold/100, (double)secondThreshold/100, (double)thirdThreshold/100);
- Debug("Buffer Adaptation: STARTED\n");
+ this->firstThreshold = params->BufferThreeThreshold_FirstThreshold;
+ this->secondThreshold = params->BufferThreeThreshold_SecondThreshold;
+ this->thirdThreshold = params->BufferThreeThreshold_ThirdThreshold;
+ this->slackParam = params->BufferThreeThreshold_slackParameter;
+// this->representation = this->adaptationSet->GetRepresentation().at(0);
+ this->multimediaManager = NULL;
+ this->lastBufferFill = 0;
+ this->bufferEOS = false;
+ this->shouldAbort = false;
+ this->isCheckedForReceiver = false;
+ this->currentBitrate = 0;
+ Debug("BufferRateBasedParams:\t%f\t%f\t%f\n",(double)this->firstThreshold/100, (double)secondThreshold/100, (double)thirdThreshold/100);
+ Debug("Buffer Adaptation: STARTED\n");
}
BufferBasedThreeThresholdAdaptation::~BufferBasedThreeThresholdAdaptation()
@@ -70,18 +71,19 @@ void BufferBasedThreeThresholdAdaptation::setMultimediaManager(viper::managers::
void BufferBasedThreeThresholdAdaptation::notifyBitrateChange()
{
- if(this->multimediaManager)
- if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
- else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
- //Should Abort is done here to avoid race condition with DASHReceiver::DoBuffering()
- if(this->shouldAbort)
- {
- this->multimediaManager->shouldAbort(this->isVideo);
- }
- this->shouldAbort = false;
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
+ if(this->multimediaManager)
+ if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
+ if(this->type == viper::managers::StreamType::VIDEO)
+ this->multimediaManager->setVideoQuality();
+ else
+ this->multimediaManager->setAudioQuality();
+ //Should Abort is done here to avoid race condition with DASHReceiver::DoBuffering()
+// if(this->shouldAbort)
+// {
+// this->multimediaManager->shouldAbort((this->type == viper::managers::StreamType::VIDEO));
+// }
+// this->shouldAbort = false;
}
uint64_t BufferBasedThreeThresholdAdaptation::getBitrate()
@@ -91,52 +93,53 @@ uint64_t BufferBasedThreeThresholdAdaptation::getBitrate()
void BufferBasedThreeThresholdAdaptation::setBitrate(uint32_t bufferFill)
{
- uint32_t phi1, phi2;
- std::vector<IRepresentation *> representations;
- representations = this->adaptationSet->GetRepresentation();
- size_t i = 0;
-
- if(this->isCheckedForReceiver)
- {
- return;
- }
- this->isCheckedForReceiver = true;
-
-
- if(bufferFill < this->firstThreshold)
- {
- this->myQuality = 0;
- }
- else
- {
- if(bufferFill < this->secondThreshold)
- {
- if(this->currentBitrate >= this->instantBw)
- {
- if(this->myQuality > 0)
- {
- this->myQuality--;
- }
- }
- }
- else
- {
- if(bufferFill < this->thirdThreshold)
- {
- }
- else
- {// bufferLevel > thirdThreshold
- if(this->currentBitrate <= this->instantBw)
- {
- if(this->myQuality < representations.size() - 1)
- this->myQuality++;
- }
- }
- }
- }
- this->representation = representations.at(this->myQuality);
- this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->myQuality);
+ uint32_t phi1, phi2;
+ std::vector<IRepresentation *> representations;
+ representations = this->mpdWrapper->getRepresentations(this->type);
+ this->representation = representations.at(0);
+ size_t i = 0;
+
+ if(this->isCheckedForReceiver)
+ {
+ return;
+ }
+ this->isCheckedForReceiver = true;
+
+
+ if(bufferFill < this->firstThreshold)
+ {
+ this->myQuality = 0;
+ }
+ else
+ {
+ if(bufferFill < this->secondThreshold)
+ {
+ if(this->currentBitrate >= this->instantBw)
+ {
+ if(this->myQuality > 0)
+ {
+ this->myQuality--;
+ }
+ }
+ }
+ else
+ {
+ if(bufferFill < this->thirdThreshold)
+ {
+ }
+ else
+ {// bufferLevel > thirdThreshold
+ if(this->currentBitrate <= this->instantBw)
+ {
+ if(this->myQuality < representations.size() - 1)
+ this->myQuality++;
+ }
+ }
+ }
+ }
+ this->representation = representations.at(this->myQuality);
+ this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, choice: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio",(double)lastBufferFill/100 , (double)bufferFill/100, this->instantBw, this->myQuality);
}
void BufferBasedThreeThresholdAdaptation::bitrateUpdate(uint64_t bps, uint32_t segNum)
@@ -155,8 +158,10 @@ void BufferBasedThreeThresholdAdaptation::checkedByDASHReceiver()
}
void BufferBasedThreeThresholdAdaptation::bufferUpdate(uint32_t bufferFill, int maxC)
{
+ this->mpdWrapper->acquireLock();
this->setBitrate(bufferFill);
this->notifyBitrateChange();
+ this->mpdWrapper->releaseLock();
}
void BufferBasedThreeThresholdAdaptation::dLTimeUpdate(double time)
diff --git a/Adaptation/BufferBasedThreeThresholdAdaptation.h b/Adaptation/BufferBasedThreeThresholdAdaptation.h
index 62160bc3..1448bae2 100644
--- a/Adaptation/BufferBasedThreeThresholdAdaptation.h
+++ b/Adaptation/BufferBasedThreeThresholdAdaptation.h
@@ -29,7 +29,8 @@ namespace adaptation
class BufferBasedThreeThresholdAdaptation : public AbstractAdaptationLogic
{
public:
- BufferBasedThreeThresholdAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// BufferBasedThreeThresholdAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ BufferBasedThreeThresholdAdaptation(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~BufferBasedThreeThresholdAdaptation();
virtual LogicType getType();
@@ -47,20 +48,20 @@ public:
void checkedByDASHReceiver();
private:
- uint64_t currentBitrate;
+ uint64_t currentBitrate;
std::vector<uint64_t> availableBitrates;
viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
- uint32_t secondThreshold;
- uint32_t thirdThreshold;
- uint32_t lastBufferFill;
- bool bufferEOS;
- bool shouldAbort;
- uint32_t firstThreshold;
- uint64_t instantBw;
- int myQuality;
- double slackParam;
- bool isCheckedForReceiver;
+ dash::mpd::IRepresentation *representation;
+ uint32_t secondThreshold;
+ uint32_t thirdThreshold;
+ uint32_t lastBufferFill;
+ bool bufferEOS;
+ bool shouldAbort;
+ uint32_t firstThreshold;
+ uint64_t instantBw;
+ int myQuality;
+ double slackParam;
+ bool isCheckedForReceiver;
};
}
}
diff --git a/Adaptation/IAdaptationLogic.h b/Adaptation/IAdaptationLogic.h
index bfe980c7..081366dd 100644
--- a/Adaptation/IAdaptationLogic.h
+++ b/Adaptation/IAdaptationLogic.h
@@ -58,9 +58,9 @@ public:
virtual uint32_t getPosition() = 0;
virtual void setPosition(uint32_t segmentNumber) = 0;
virtual dash::mpd::IRepresentation* getRepresentation() = 0;
- virtual void setRepresentation(dash::mpd::IPeriod *period,
- dash::mpd::IAdaptationSet *adaptationSet,
- dash::mpd::IRepresentation *representation)= 0;
+// virtual void setRepresentation(dash::mpd::IPeriod *period,
+// dash::mpd::IAdaptationSet *adaptationSet,
+// dash::mpd::IRepresentation *representation)= 0;
virtual LogicType getType() = 0;
virtual bool isUserDependent()= 0;
virtual void bitrateUpdate(uint64_t bps, uint32_t segNum) = 0;
@@ -71,6 +71,7 @@ public:
virtual void setMultimediaManager(viper::managers::IMultimediaManagerBase *mmManager)= 0;
virtual void onEOS(bool value) = 0;
virtual void checkedByDASHReceiver() = 0;
+// virtual void updateMPD(dash::mpd::IMPD* mpd) = 0;
};
struct AdaptationParameters
diff --git a/Adaptation/Panda.cpp b/Adaptation/Panda.cpp
index cb2ec660..e0c19b27 100644
--- a/Adaptation/Panda.cpp
+++ b/Adaptation/Panda.cpp
@@ -21,9 +21,10 @@ using namespace dash::mpd;
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::mpd;
+using namespace viper::managers;
-PandaAdaptation::PandaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic (mpd, period, adaptationSet, isVid)
+PandaAdaptation::PandaAdaptation(StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic (type, mpdWrapper)
{
this->param_Alpha = params->Panda_Alpha;
this->param_Beta = params->Panda_Beta;
@@ -52,17 +53,17 @@ PandaAdaptation::PandaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *ada
this->downloadTime = 0.0;
- this->isVideo = isVid;
- this->mpd = mpd;
- this->adaptationSet = adaptationSet;
- this->period = period;
+// this->mpd = mpd;
+// this->adaptationSet = adaptationSet;
+// this->period = period;
this->multimediaManager = NULL;
this->representation = NULL;
this->currentBitrate = 0;
this->current = 0;
// Retrieve the available bitrates
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
+ this->mpdWrapper->acquireLock();
+ std::vector<IRepresentation* > representations = this->mpdWrapper->getRepresentations(this->type);
this->availableBitrates.clear();
Debug("PANDA Available Bitrates...\n");
@@ -72,7 +73,7 @@ PandaAdaptation::PandaAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *ada
Debug("%d - %I64u bps\n", i+1, this->availableBitrates[i]);
}
- this->representation = this->adaptationSet->GetRepresentation().at(0);
+ this->representation = representations.at(0);
this->currentBitrate = (uint64_t) this->representation->GetBandwidth();
Debug("Panda parameters: K= %f, Bmin = %f, alpha = %f, beta = %f, W = %f\n", param_K, param_Bmin, param_Alpha, param_Beta, param_W);
@@ -108,11 +109,12 @@ void PandaAdaptation::setMultimediaManager (viper::managers::IMultimediaManagerB
void PandaAdaptation::notifyBitrateChange()
{
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
+ if(this->type == viper::managers::StreamType::VIDEO)
+ this->multimediaManager->setVideoQuality();
else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
+ this->multimediaManager->setAudioQuality();
}
uint64_t PandaAdaptation::getBitrate()
@@ -133,7 +135,7 @@ void PandaAdaptation::quantizer()
Debug("** Smooth-BW UP:\t%d\t Smooth-BW DOWN:\t%d\n", smoothBw_UP, smoothBw_DOWN);
std::vector<IRepresentation *> representations;
- representations = this->adaptationSet->GetRepresentation();
+ representations = this->mpdWrapper->getRepresentations(this->type);
uint32_t numQualLevels = representations.size();
// We have to find bitrateMin and bitrateMax
@@ -188,7 +190,7 @@ void PandaAdaptation::quantizer()
this->currentBitrate = bitrateDown;
this->current = iDown;
}
- this->representation = this->adaptationSet->GetRepresentation().at(this->current);
+ this->representation = representations.at(this->current);
}
void PandaAdaptation::setBitrate(uint64_t bps)
@@ -220,7 +222,7 @@ void PandaAdaptation::setBitrate(uint64_t bps)
// 3. Quantization
this->quantizer();
- Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",isVideo ? "video" : "audio",(double)lastBufferLevel/100 , (double)bufferLevel/100, this->instantBw, this->averageBw , this->current);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tlast_buffer: %f\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu, choice: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio",(double)lastBufferLevel/100 , (double)bufferLevel/100, this->instantBw, this->averageBw , this->current);
this->lastBufferLevel = this->bufferLevel;
// 4. Computing the "actual inter time"
@@ -233,7 +235,7 @@ void PandaAdaptation::setBitrate(uint64_t bps)
this->interTime = this->interTime > 3 ? 3 : this->interTime;
Debug("** ACTUAL INTER TIME:\t%f\n", this->interTime);
- this->multimediaManager->setTargetDownloadingTime(this->isVideo, interTime);
+ this->multimediaManager->setTargetDownloadingTime((this->type == viper::managers::StreamType::VIDEO), interTime);
}
void PandaAdaptation::bitrateUpdate(uint64_t bps, uint32_t segNum)
@@ -249,9 +251,10 @@ void PandaAdaptation::bitrateUpdate(uint64_t bps, uint32_t segNum)
{
this->averageBw = this->alpha_ewma*this->averageBw + (1 - this->alpha_ewma)*bps;
}
-
+ this->mpdWrapper->acquireLock();
this->setBitrate(bps);
this->notifyBitrateChange();
+ this->mpdWrapper->releaseLock();
}
void PandaAdaptation::dLTimeUpdate(double time)
diff --git a/Adaptation/Panda.h b/Adaptation/Panda.h
index 000131a1..37b397fe 100644
--- a/Adaptation/Panda.h
+++ b/Adaptation/Panda.h
@@ -29,7 +29,8 @@ namespace adaptation
class PandaAdaptation : public AbstractAdaptationLogic
{
public:
- PandaAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// PandaAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ PandaAdaptation(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~PandaAdaptation();
virtual LogicType getType();
@@ -48,38 +49,36 @@ public:
void quantizer();
private:
- uint64_t currentBitrate;
+ uint64_t currentBitrate;
std::vector<uint64_t> availableBitrates;
viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
+ dash::mpd::IRepresentation *representation;
- uint64_t averageBw; // Classic EWMA
- uint64_t instantBw;
- uint64_t smoothBw; // Panda paper smoothed y[n]
- uint64_t targetBw; // Panda paper x[n] bw estimation
+ uint64_t averageBw; // Classic EWMA
+ uint64_t instantBw;
+ uint64_t smoothBw; // Panda paper smoothed y[n]
+ uint64_t targetBw; // Panda paper x[n] bw estimation
+ double param_Alpha;
+ double alpha_ewma;
+ double param_Epsilon;
+ double param_K;
+ double param_W;
+ double param_Beta;
+ double param_Bmin;
+ double interTime; // Actual inter time
+ double targetInterTime; // Target inter time
+ double downloadTime;
- double param_Alpha;
- double alpha_ewma;
- double param_Epsilon;
- double param_K;
- double param_W;
- double param_Beta;
- double param_Bmin;
+ uint32_t bufferLevel;
+ uint32_t lastBufferLevel;
+ double bufferMaxSizeSeconds; // Usually set to 60s
+ double bufferLevelSeconds; // Current buffer level [s]
- double interTime; // Actual inter time
- double targetInterTime; // Target inter time
- double downloadTime;
-
- uint32_t bufferLevel;
- uint32_t lastBufferLevel;
- double bufferMaxSizeSeconds; // Usually set to 60s
- double bufferLevelSeconds; // Current buffer level [s]
-
- double segmentDuration;
- double deltaUp;
- double deltaDown;
- size_t current;
+ double segmentDuration;
+ double deltaUp;
+ double deltaDown;
+ size_t current;
};
} /* namespace adaptation */
diff --git a/Adaptation/RateBasedAdaptation.cpp b/Adaptation/RateBasedAdaptation.cpp
index 73d4ee9b..14b3f3d6 100644
--- a/Adaptation/RateBasedAdaptation.cpp
+++ b/Adaptation/RateBasedAdaptation.cpp
@@ -19,11 +19,13 @@ using namespace dash::mpd;
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::mpd;
+using namespace viper::managers;
-RateBasedAdaptation::RateBasedAdaptation(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params) :
- AbstractAdaptationLogic(mpd, period, adaptationSet, isVid)
+RateBasedAdaptation::RateBasedAdaptation(StreamType type, MPDWrapper *mpdWrapper, struct AdaptationParameters *params) :
+ AbstractAdaptationLogic(type, mpdWrapper)
{
- std::vector<IRepresentation* > representations = this->adaptationSet->GetRepresentation();
+ this->mpdWrapper->acquireLock();
+ std::vector<IRepresentation* > representations = this->mpdWrapper->getRepresentations(type);
this->availableBitrates.clear();
for(size_t i = 0; i < representations.size(); i++)
@@ -32,6 +34,7 @@ RateBasedAdaptation::RateBasedAdaptation(IMPD *mpd, IPeriod *period, IAdaptation
}
this->currentBitrate = this->availableBitrates.at(0);
this->representation = representations.at(0);
+ this->mpdWrapper->releaseLock();
this->multimediaManager = NULL;
this->alpha = params->Rate_Alpha;
Debug("RateBasedParams:\t%f\n",alpha);
@@ -69,11 +72,12 @@ void RateBasedAdaptation::setMultimediaManager(viper::managers::IMultimediaManag
void RateBasedAdaptation::notifyBitrateChange()
{
+ this->mpdWrapper->setRepresentation(this->type, this->representation);
if(this->multimediaManager->isStarted() && !this->multimediaManager->isStopping())
- if(this->isVideo)
- this->multimediaManager->setVideoQuality(this->period, this->adaptationSet, this->representation);
+ if(this->type == viper::managers::StreamType::VIDEO)
+ this->multimediaManager->setVideoQuality();
else
- this->multimediaManager->setAudioQuality(this->period, this->adaptationSet, this->representation);
+ this->multimediaManager->setAudioQuality();
}
uint64_t RateBasedAdaptation::getBitrate()
@@ -84,7 +88,7 @@ uint64_t RateBasedAdaptation::getBitrate()
void RateBasedAdaptation::setBitrate(uint64_t bps)
{
std::vector<IRepresentation *> representations;
- representations = this->adaptationSet->GetRepresentation();
+ representations = this->mpdWrapper->getRepresentations(this->type);
size_t i = 0;
this->ewma(bps);
for(i = 0;i < representations.size();i++)
@@ -99,7 +103,7 @@ void RateBasedAdaptation::setBitrate(uint64_t bps)
if((size_t)i == (size_t)(representations.size()))
i = i-1;
- Debug("ADAPTATION_LOGIC:\tFor %s:\tBW_estimation(ewma): %lu, choice: %lu\n", (this->isVideo ? "video" : "audio"), this->averageBw, i);
+ Debug("ADAPTATION_LOGIC:\tFor %s:\tBW_estimation(ewma): %lu, choice: %lu\n", ((this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio"), this->averageBw, i);
this->representation = representations.at(i);
this->currentBitrate = this->representation->GetBandwidth();
}
@@ -107,8 +111,10 @@ void RateBasedAdaptation::setBitrate(uint64_t bps)
void RateBasedAdaptation::bitrateUpdate(uint64_t bps, uint32_t segNum)
{
Debug("Rate Based adaptation: speed received: %lu\n", bps);
+ this->mpdWrapper->acquireLock();
this->setBitrate(bps);
this->notifyBitrateChange();
+ this->mpdWrapper->releaseLock();
}
void RateBasedAdaptation::ewma(uint64_t bps)
diff --git a/Adaptation/RateBasedAdaptation.h b/Adaptation/RateBasedAdaptation.h
index cbf7471c..670bc031 100644
--- a/Adaptation/RateBasedAdaptation.h
+++ b/Adaptation/RateBasedAdaptation.h
@@ -29,7 +29,8 @@ namespace adaptation
class RateBasedAdaptation : public AbstractAdaptationLogic
{
public:
- RateBasedAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+// RateBasedAdaptation(dash::mpd::IMPD *mpd, dash::mpd::IPeriod *period, dash::mpd::IAdaptationSet *adaptationSet, bool isVid, struct AdaptationParameters *params);
+ RateBasedAdaptation(viper::managers::StreamType type, libdash::framework::mpd::MPDWrapper *mpdWrapper, struct AdaptationParameters *params);
virtual ~RateBasedAdaptation();
virtual LogicType getType();
@@ -47,12 +48,12 @@ public:
void ewma(uint64_t bps);
void checkedByDASHReceiver();
private:
- uint64_t currentBitrate;
+ uint64_t currentBitrate;
std::vector<uint64_t> availableBitrates;
viper::managers::IMultimediaManagerBase *multimediaManager;
- dash::mpd::IRepresentation *representation;
- double alpha;
- uint64_t averageBw;
+ dash::mpd::IRepresentation *representation;
+ double alpha;
+ uint64_t averageBw;
};
}
}