aboutsummaryrefslogtreecommitdiffstats
path: root/Adaptation/BufferBasedThreeThresholdAdaptation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Adaptation/BufferBasedThreeThresholdAdaptation.cpp')
-rw-r--r--Adaptation/BufferBasedThreeThresholdAdaptation.cpp151
1 files changed, 78 insertions, 73 deletions
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)