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 AdapTechAdaptation::getBitrate()
}
void AdapTechAdaptation::setBitrate(uint32_t bufferFill)
+{
+ std::vector<IRepresentation *> representations;
+ representations = this->mpdWrapper->getRepresentations(this->type);
+ bool flagIsSet = this->mpdWrapper->getSegmentIsSetFlag(this->type);
+ int mySetQuality = this->mpdWrapper->getSegmentQuality(this->type);
+
+ if(flagIsSet)
+ {
+ Debug("Adaptech:\tFor %s:\tbuffer_level: %f, instantaneousBw: %lu, AverageBW: %lu,already set: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio", (double)bufferFill/100, this->instantBw, this->averageBw , this->myQuality);
+
+ if(bufferFill < this->reservoirThreshold)
+ {
+ if(mySetQuality == -1)
+ {
+ mySetQuality = this->myQuality;
+ this->myQuality = 0;
+ this->representation = representations.at(this->myQuality);
+ Debug("Adaptech:\tFor %s: buffer level too low, going to panic mode, old quality: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio", mySetQuality);
+ this->mpdWrapper->setSegmentQuality(this->type, mySetQuality);
+ }
+ }
+ else
+ {
+ if(mySetQuality != -1)
+ {
+ this->myQuality = mySetQuality;
+ Debug("AdaptechNA:\tFor %s: buffer level high enough, restoring old computed quality: %d\n",(this->type == viper::managers::StreamType::VIDEO) ? "video" : "audio", mySetQuality);
+ }
+ this->representation = representations.at(this->myQuality);
+ }
+ }
+ else
+ {
+ this->setBitrateOption1(bufferFill);
+ this->mpdWrapper->setSegmentIsSetFlag(this->type, true);
+ }
+}
+void AdapTechAdaptation::setBitrateOption1(uint32_t bufferFill)
{
uint32_t phi1, phi2;
std::vector<IRepresentation *> representations;
virtual void bufferUpdate(uint32_t bufferFill, int maxC);
virtual void dLTimeUpdate(double time);
void setBitrate(uint32_t bufferFill);
+ void setBitrateOption1(uint32_t bufferFill);
uint64_t getBitrate();
virtual void setMultimediaManager(viper::managers::IMultimediaManagerBase *_mmManager);
void notifyBitrateChange();
// Retrieve the available bitrates
this->mpdWrapper->acquireLock();
std::vector<IRepresentation* > representations = this->mpdWrapper->getRepresentations(this->type);
-
+ this->mpdWrapper->releaseLock();
this->availableBitrates.clear();
Debug("PANDA Available Bitrates...\n");
for(size_t i = 0; i < representations.size(); i++)
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);
+ Debug("Panda parameters: K= %f, Bmin = %f, alpha = %f, beta = %f, W = %f \n", param_K, param_Bmin, param_Alpha, param_Beta, param_W);
}
PandaAdaptation::~PandaAdaptation() {
if(this->adaptationLogic->isBufferBased())
this->receiver->OnSegmentBufferStateChanged(fillstateInPercent, maxC);
}
+void DASHManager::fetchMPD()
+{
+ this->multimediaStream->fetchMPD();
+}
void setTargetDownloadingTime(double);
MediaObject* getSegment();
void onBufferStateChanged(BufferType type, uint32_t fillstateInPercent, int maxC);
+ void fetchMPD();
private:
float beta;
isLooping (false),
beta (beta),
drop (drop),
- bufferingThread (NULL)
+ bufferingThread (NULL),
+ mpdFetcherThread (NULL)
{
readMax = 32768;
readBuffer = (uint8_t*)malloc(sizeof(uint8_t)*readMax);
this->isBuffering = false;
return false;
}
+ //if dynamic, set up the fetching loop
+ if(!strcmp(this->mpdWrapper->getType().c_str(), "dynamic"))
+ {
+ this->mpdFetcherThread = createThreadPortable(DoMPDFetching, this);
+ if(this->mpdFetcherThread == NULL)
+ {
+ std::cout << "mpd Fetcher thread is NULL. Need to think of how to handle this?" << std::endl;
+ }
+ }
return true;
}
void DASHReceiver::Stop()
//Is only called when this->adaptationLogic->IsBufferBased
void DASHReceiver::OnSegmentBufferStateChanged(uint32_t fillstateInPercent, int maxC)
{
- this->adaptationLogic->bufferUpdate(this->observer->getBufferLevel(), maxC);
this->bufferLevelAtUpdate = this->observer->getBufferLevel();
+ this->adaptationLogic->bufferUpdate(this->bufferLevelAtUpdate, maxC);
}
void DASHReceiver::OnEOS(bool value)
{
mediaObject->AddInitSegment(init);
//TODO the read should be in a function
- //Grab the infos for the analytics: bitrate, fps
+ //Grab the infos for the analytics: bitrate, bufferLevel
uint32_t bitrate = 0;
- int fps = 0;
+ int bufferLevel = 0;
uint32_t quality = 0;
bitrate = mediaObject->GetRepresentationBandwidth();
quality = mediaObject->GetRepresentationHeight();
- fps = this->bufferLevelAtUpdate;
- this->observer->notifyStatistics((int)this->segmentNumber - 1, bitrate, fps, quality);
+ bufferLevel = this->bufferLevelAtUpdate;
+ this->observer->notifyStatistics((int)this->segmentNumber - 1, bitrate, bufferLevel, quality);
return(this->buffer->pushBack(mediaObject));
}
return NULL;
}
+void* DASHReceiver::DoMPDFetching (void* receiver)
+{
+ DASHReceiver* dashReceiver = (DASHReceiver*) receiver;
+ uint32_t currTime = TimeResolver::getCurrentTimeInSec();
+ uint32_t publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ uint32_t period = TimeResolver::getDurationInSec(dashReceiver->mpdWrapper->getMinimumUpdatePeriod());
+ while(dashReceiver->isBuffering)
+ {
+ while(dashReceiver->isBuffering && currTime < publishedTime + period)
+ {
+ usleep(((publishedTime + period) - currTime) * 1000000);
+ currTime = TimeResolver::getCurrentTimeInSec();
+ }
+ dashReceiver->observer->fetchMPD();
+ publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
+ period = TimeResolver::getDurationInSec(dashReceiver->mpdWrapper->getMinimumUpdatePeriod());
+ }
+}
+
//can Push video to buffer in the renderer
bool DASHReceiver::CanPush ()
{
IICNConnection *conn;
IICNConnection *initConn;
THREAD_HANDLE bufferingThread;
+ THREAD_HANDLE mpdFetcherThread;
bool isBuffering;
bool icn;
double icnAlpha;
void DownloadInitSegmentWithoutLock();
bool InitSegmentExists(std::string rep);
static void* DoBuffering(void *receiver);
+ static void* DoMPDFetching(void * data);
};
}
}
virtual void notifyQualityDownloading (uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
+ virtual void fetchMPD() = 0;
};
}
}
virtual void notifyQualityDownloading(uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
+ virtual void fetchMPD() = 0;
};
}
}
virtual dash::mpd::ISegment* getInitializationSegment() = 0;
virtual dash::mpd::ISegment* getIndexSegment(size_t segmentNumber) = 0;
- virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration) = 0;
+ virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber) = 0;
virtual dash::mpd::ISegment* getBitstreamSwitchingSegment() = 0;
virtual RepresentationStreamType getStreamType() = 0;
virtual dash::mpd::ISegment* getInitializationSegment() = 0;
virtual dash::mpd::ISegment* getIndexSegment(size_t segmentNumber) = 0;
- virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration) = 0;
+ virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber) = 0;
virtual dash::mpd::ISegment* getBitstreamSwitchingSegment() = 0;
virtual RepresentationStreamType getStreamType() = 0;
virtual uint32_t getSize() = 0;
videoSegmentOffset (0),
audioSegmentOffset (0),
videoSegmentNumber (0),
- audioSegmentNumber (0),
- hasReachedEndOfList (false)
+ audioSegmentNumber (0)
{
InitializeConditionVariable (&this->mpdUpdate);
//Assumptions here:
// *only one period in the MPD
// *only triggered if using SegmentTimeline dynamic MPD
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
this->period = mpd->GetPeriods().at(0);
this->findVideoAdaptationSet(mpd);
this->findAudioAdaptationSet(mpd);
delete(this->mpd);
this->mpd = mpd;
WakeAllConditionVariable(&this->mpdUpdate);
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
}
void MPDWrapper::findVideoAdaptationSet (IMPD* mpd)
std::string MPDWrapper::getType ()
{
std::string type;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
type = this->mpd->GetType();
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return type;
}
void MPDWrapper::reInit (viper::managers::StreamType type)
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
case viper::managers::StreamType::VIDEO:
default:
break;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
}
bool MPDWrapper::hasVideoAdaptationSetAndVideoRepresentation ()
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
if(this->videoAdaptationSet && this->videoRepresentation)
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 1;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 0;
}
bool MPDWrapper::hasAudioAdaptationSetAndAudioRepresentation ()
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
if(this->audioAdaptationSet && this->audioRepresentation)
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 1;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 0;
}
{
IAdaptationSet *adaptationSet = NULL;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations = NULL;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
RepresentationStreamType typeR = determineRepresentationStreamType(representation, adaptationSet, this->period);
(*representations)[representation] = RepresentationStreamFactory::create(type, typeR, this, period, adaptationSet, representation);
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
}
void MPDWrapper::initializeAdaptationSetStreamWithoutLock (viper::managers::StreamType type)
void MPDWrapper::setSegmentOffset(viper::managers::StreamType type, uint32_t segmentOffset)
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
case viper::managers::StreamType::AUDIO:
default:
break;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
}
MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool isLooping, uint32_t &segmentNumber, bool withFeedBack)
{
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
- dash::mpd::IAdaptationSet* adaptationSet;
-
- EnterCriticalSection(&this->monitorMutex);
+
+ this->acquireLock();
switch(type)
{
case viper::managers::StreamType::AUDIO:
representation = this->audioRepresentation;
representations = this->audioRepresentations;
- adaptationSet = this->audioAdaptationSet;
break;
case viper::managers::StreamType::VIDEO:
representation = this->videoRepresentation;
representations = this->videoRepresentations;
- adaptationSet = this->videoAdaptationSet;
break;
default:
- LeaveCriticalSection(&this->monitorMutex);
- return NULL;
+ this->releaseLock();
+ return NULL;
}
ISegment* seg = NULL;
default:
break;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
}
while((this->isStopping == false) && segmentNumber >= representationStream->getSize())
{
SleepConditionVariableCS(&this->mpdUpdate, &this->monitorMutex, INFINITE);
- this->hasReachedEndOfList = true;
+
+ if(this->isStopping)
+ {
+ this->releaseLock();
+ return NULL;
+ }
+ //Need to update representationStream here as it was updated with the mpd (Live only):
switch(type)
{
case viper::managers::StreamType::AUDIO:
representation = this->audioRepresentation;
representations = this->audioRepresentations;
- adaptationSet = this->audioAdaptationSet;
- segmentNumber = this->audioSegmentNumber;
break;
case viper::managers::StreamType::VIDEO:
representation = this->videoRepresentation;
representations = this->videoRepresentations;
- adaptationSet = this->videoAdaptationSet;
- segmentNumber = this->videoSegmentNumber;
break;
default:
break;
}
representationStream = representations->find(representation)->second;
- if(this->hasReachedEndOfList)
- segmentNumber += 1;
- }
- if(this->isStopping)
- {
- LeaveCriticalSection(&this->monitorMutex);
- return NULL;
- }
-
- //Need to update representationStream here as it was updated with the mpd:
- switch(type)
- {
- case viper::managers::StreamType::AUDIO:
- segmentNumber = this->audioSegmentNumber;
- break;
- case viper::managers::StreamType::VIDEO:
- segmentNumber = this->videoSegmentNumber;
- break;
- default:
- break;
- }
- if(this->hasReachedEndOfList)
- {
- segmentNumber += 1;
- this->hasReachedEndOfList = false;
}
}
- uint64_t segDuration = 0;
- //Returns the segmentDuration in milliseconds
- seg = representationStream->getMediaSegment(segmentNumber, segDuration);
+ seg = representationStream->getMediaSegment(segmentNumber);
if(seg != NULL)
{
- MediaObject *media = new MediaObject(seg, representation, withFeedBack);
- if(segDuration == 0)
- {
- uint32_t duration = 0;
- uint32_t timescale = 0;
-
- if(representation->GetSegmentTemplate())
- {
- duration = representation->GetSegmentTemplate()->GetDuration();
- timescale = representation->GetSegmentTemplate()->GetTimescale();
- }
- else
- {
- if(adaptationSet->GetSegmentTemplate())
- {
- duration = adaptationSet->GetSegmentTemplate()->GetDuration();
- timescale = adaptationSet->GetSegmentTemplate()->GetTimescale();
- }
- else
- {
- if(this->period->GetSegmentTemplate())
- {
- duration = this->period->GetSegmentTemplate()->GetDuration();
- timescale = this->period->GetSegmentTemplate()->GetTimescale();
- }
- }
- }
- segDuration = 1.0*duration/(1.0*timescale) * 1000;
-
- }
- media->SetSegmentDuration(segDuration);
+ MediaObject *media = new MediaObject(seg, representation, withFeedBack);
segmentNumber++;
-
switch(type)
{
case viper::managers::StreamType::AUDIO:
this->audioSegmentNumber = segmentNumber;
+ this->audioSegmentIsSet = false;
+ this->audioSegmentQuality = -1;
break;
case viper::managers::StreamType::VIDEO:
this->videoSegmentNumber = segmentNumber;
+ this->videoSegmentIsSet = false;
+ this->videoSegmentQuality = -1;
break;
default:
break;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return media;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
{
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
representations = this->videoRepresentations;
break;
default:
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
IRepresentationStream* representationStream = representations->find(representation)->second;
if(segNum >= representationStream->getSize())
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
- uint64_t segDuration =0;
- seg = representationStream->getMediaSegment(segNum, segDuration);
+ seg = representationStream->getMediaSegment(segNum);
if(seg != NULL)
{
MediaObject *media = new MediaObject(seg, representation);
- media->SetSegmentDuration(segDuration);
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return media;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
{
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
representations = this->videoRepresentations;
break;
default:
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
if(seg != NULL)
{
MediaObject *media = new MediaObject(seg, representation);
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return media;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return NULL;
}
bool periodChanged = false;
if (this->audioRepresentation == representation)
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return;
}
bool periodChanged = false;
if (this->videoRepresentation == representation)
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return;
}
{
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
representations = this->videoRepresentations;
break;
default:
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 0;
}
if(!(strcmp(this->mpd->GetType().c_str(), "static")))
{
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return 0;
}
IRepresentationStream* representationStream = representations->find(representation)->second;
uint32_t currSegNum = representationStream->getCurrentSegmentNumber();
uint32_t startSegNum = currSegNum - 2*bufferSize;
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return (startSegNum > firstSegNum) ? startSegNum : firstSegNum;
}
std::string MPDWrapper::getRepresentationID (viper::managers::StreamType type)
{
std::string id = "";
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
switch(type)
{
default:
break;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return id;
}
std::string MPDWrapper::getPublishTime ()
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
std::string pubTime = this->mpd->GetPublishTime();
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return pubTime;
}
std::string MPDWrapper::getMinimumUpdatePeriod ()
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
std::string res = this->mpd->GetMinimumUpdatePeriod();
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return res;
}
void MPDWrapper::settingsChanged (int period, int videoAdaptationSet, int videoRepresentation, int audioAdaptationSet, int audioRepresentation)
{
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
this->period = this->mpd->GetPeriods().at(period);
std::vector<IAdaptationSet *> videoAdaptationSets = AdaptationSetHelper::getVideoAdaptationSets(this->period);
std::vector<IAdaptationSet *> audioAdaptationSets = AdaptationSetHelper::getAudioAdaptationSets(this->period);
this->audioAdaptationSet = NULL;
this->audioRepresentation = NULL;
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
}
//Returns the segmentDuration
float MPDWrapper::onFirstDownloadMPD (viper::IViperGui *gui)
{
float segmentDuration = 0.0;
- EnterCriticalSection(&this->monitorMutex);
+ this->acquireLock();
IRepresentation *representation = this->videoAdaptationSet->GetRepresentation().at(0);
if(!strcmp(this->mpd->GetType().c_str(), "static")) // VOD MPD
{
else //Live MPD
{
//Assuming here that the segment duration doesn't change. If so, need to do an average over all segments.
- uint32_t duration = representation->GetSegmentTemplate()->GetSegmentTimeline()->GetTimelines().at(0)->GetDuration();
- uint32_t timescale = representation->GetSegmentTemplate()->GetTimescale();
+ uint32_t duration = 0;
+ uint32_t timescale = 0;
+ if(representation->GetSegmentTemplate())
+ {
+ duration = representation->GetSegmentTemplate()->GetDuration();
+ timescale = representation->GetSegmentTemplate()->GetTimescale();
+ }
+ else
+ {
+ if(this->videoAdaptationSet->GetSegmentTemplate()) //SegmentTemplate at AdaptationSet level
+ {
+ duration = this->videoAdaptationSet->GetSegmentTemplate()->GetDuration();
+ timescale = this->videoAdaptationSet->GetSegmentTemplate()->GetTimescale();
+ }
+ else
+ { // SegmentTemplate at Period level
+ duration = this->period->GetSegmentTemplate()->GetDuration();
+ timescale = this->period->GetSegmentTemplate()->GetTimescale();
+ }
+ }
segmentDuration = 1.0*duration/(1.0*timescale) * 1000;
if(gui)
{
gui->setListSegmentSize(0);
}
}
- LeaveCriticalSection(&this->monitorMutex);
+ this->releaseLock();
return segmentDuration;
}
this->isStopping = isStopping;
WakeAllConditionVariable(&this->mpdUpdate);
}
+
+void MPDWrapper::setSegmentIsSetFlag(viper::managers::StreamType type, bool flag)
+{
+ switch(type)
+ {
+ case viper::managers::StreamType::AUDIO:
+ this->audioSegmentIsSet = flag;
+ break;
+ case viper::managers::StreamType::VIDEO:
+ this->videoSegmentIsSet = flag;
+ break;
+ default:
+ break;
+ }
+}
+
+bool MPDWrapper::getSegmentIsSetFlag(viper::managers::StreamType type)
+{
+ switch(type)
+ {
+ case viper::managers::StreamType::AUDIO:
+ return this->audioSegmentIsSet;
+ case viper::managers::StreamType::VIDEO:
+ return this->videoSegmentIsSet;
+ default:
+ return false;
+ }
+}
+
+int MPDWrapper::getSegmentQuality(viper::managers::StreamType type)
+{
+ switch(type)
+ {
+ case viper::managers::StreamType::AUDIO:
+ return this->audioSegmentQuality;
+ case viper::managers::StreamType::VIDEO:
+ return this->videoSegmentQuality;
+ default:
+ return false;
+ }
+}
+
+void MPDWrapper::setSegmentQuality(viper::managers::StreamType type, int segQuality)
+{
+ switch(type)
+ {
+ case viper::managers::StreamType::AUDIO:
+ this->audioSegmentIsSet = segQuality;
+ break;
+ case viper::managers::StreamType::VIDEO:
+ this->videoSegmentIsSet = segQuality;
+ break;
+ default:
+ break;
+ }
+}
void settingsChanged(int period, int videoAdaptationSet, int videoRepresentation, int audioAdaptationSet, int audioRepresentation);
float onFirstDownloadMPD(viper::IViperGui *gui);
void setIsStopping(bool isStopping);
+ void setSegmentIsSetFlag(viper::managers::StreamType type, bool flag);
+ bool getSegmentIsSetFlag(viper::managers::StreamType type);
+ int getSegmentQuality(viper::managers::StreamType type);
+ void setSegmentQuality(viper::managers::StreamType type, int segQuality);
private:
RepresentationStreamType determineRepresentationStreamType(dash::mpd::IRepresentation *representation, dash::mpd::IAdaptationSet* adaptationSet, dash::mpd::IPeriod* period);
uint32_t audioSegmentOffset;
size_t videoSegmentNumber;
size_t audioSegmentNumber;
+ bool videoSegmentIsSet;
+ bool audioSegmentIsSet;
+ int videoSegmentQuality;
+ int audioSegmentQuality;
bool isStopping;
- bool hasReachedEndOfList;
};
}
}
return NULL;
}
-ISegment* SegmentListStream::getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration)
+ISegment* SegmentListStream::getMediaSegment(size_t segmentNumber)
{
if (this->segmentList->GetSegmentURLs().size() > segmentNumber)
- {
- uint32_t duration = representation->GetSegmentList()->GetDuration();
- uint32_t timescale = representation->GetSegmentList()->GetTimescale();
- segmentDuration = (uint64_t)(((float)duration/(float)timescale) * 1000);
return this->segmentList->GetSegmentURLs().at(segmentNumber)->ToMediaSegment(this->baseUrls);
- }
+
return NULL;
}
virtual dash::mpd::ISegment* getInitializationSegment();
virtual dash::mpd::ISegment* getIndexSegment(size_t segmentNumber);
- virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration);
+ virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber);
virtual dash::mpd::ISegment* getBitstreamSwitchingSegment();
virtual RepresentationStreamType getStreamType();
virtual uint32_t getSize();
this->segmentTemplate->GetStartNumber() + segmentNumber);
}
-ISegment* SegmentTemplateStream::getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration)
+ISegment* SegmentTemplateStream::getMediaSegment(size_t segmentNumber)
{
/* time-based template */
if (this->segmentTemplate->GetSegmentTimeline())
{//Get the one at segmentNumber
if(this->segmentStartTimes.size() > segmentNumber)
{
- segmentDuration = (uint64_t)(((float)this->segmentDurationTimes.at(segmentNumber)/(float)this->getTimescale()) * 1000);
return this->segmentTemplate->GetMediaSegmentFromTime(baseUrls, representation->GetId(), representation->GetBandwidth(), this->segmentStartTimes.at(segmentNumber));
}
else
if(segmentNumber < this->segmentStartTimes.size())
return this->segmentStartTimes.at(segmentNumber);
else
- return this->segmentStartTimes.at(this->segmentStartTimes.size()-1);
+ return (this->segmentStartTimes.size() == 0)? 0 : this->segmentStartTimes.at(this->segmentStartTimes.size()-1);
}
size_t SegmentTemplateStream::getSegmentNumber(uint64_t time)
virtual dash::mpd::ISegment* getInitializationSegment();
virtual dash::mpd::ISegment* getIndexSegment(size_t segmentNumber);
- virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration);
+ virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber);
virtual dash::mpd::ISegment* getBitstreamSwitchingSegment();
virtual RepresentationStreamType getStreamType();
virtual uint32_t getSize();
return NULL;
}
-ISegment* SingleMediaSegmentStream::getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration)
+ISegment* SingleMediaSegmentStream::getMediaSegment(size_t segmentNumber)
{
/* segmentNumber equals the desired BaseUrl */
if (this->representation->GetBaseURLs().size() > segmentNumber)
virtual dash::mpd::ISegment* getInitializationSegment();
virtual dash::mpd::ISegment* getIndexSegment(size_t segmentNumber);
- virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber, uint64_t& segmentDuration);
+ virtual dash::mpd::ISegment* getMediaSegment(size_t segmentNumber);
virtual dash::mpd::ISegment* getBitstreamSwitchingSegment();
virtual RepresentationStreamType getStreamType();
virtual void notifyQualityDownloading(uint32_t quality) = 0;
virtual bool canPush() = 0;
virtual int getBufferLevel() = 0;
+ virtual void fetchMPD() = 0;
};
}
}
eos (false),
playing (false),
noDecoding (nodecoding),
- mpdWrapper (NULL),
- mpdFetcherThread (NULL)
+ mpdWrapper (NULL)
{
InitializeCriticalSection (&this->monitorMutex);
InitializeCriticalSection (&this->monitorBufferMutex);
this->started = true;
this->playing = true;
- if(!strcmp(this->mpdWrapper->getType().c_str(), "dynamic"))
- {
- this->mpdFetcherThread = createThreadPortable(DoMPDFetching, this);
- if(this->mpdFetcherThread == NULL)
- {
- std::cout << "mpd Fetcher thread is NULL. Need to think of how to handle this?" << std::endl;
- }
- }
LeaveCriticalSection(&this->monitorMutex);
}
Debug("VIDEO STOPPED\n");
this->mpdWrapper->reInit(viper::managers::StreamType::VIDEO);
this->mpdWrapper->reInit(viper::managers::StreamType::AUDIO);
- if(this->mpdFetcherThread != NULL)
- {
- JoinThread(this->mpdFetcherThread);
- destroyThreadPortable(this->mpdFetcherThread);
- }
}
void MultimediaManager::stopVideo()
return this->segmentDuration;
}
-void* MultimediaManager::DoMPDFetching (void* data)
-{
- MultimediaManager *manager = (MultimediaManager*) data;
- uint32_t currTime = TimeResolver::getCurrentTimeInSec();
- uint32_t publishedTime = manager->mpdWrapper->getFetchTime();
-// To avoid clock synchronisation issues: using fetching time instead of publish time
-// uint32_t publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
- uint32_t periodUpdate = TimeResolver::getDurationInSec(manager->mpdWrapper->getMinimumUpdatePeriod());
- while(manager->isStarted())
- {
- while(manager->isStarted() && currTime < publishedTime + periodUpdate)
- {
- usleep(((publishedTime + periodUpdate) - currTime) * 1000000);
- currTime = TimeResolver::getCurrentTimeInSec();
- }
- manager->fetchMPD();
- publishedTime = manager->mpdWrapper->getFetchTime();
-// publishedTime = TimeResolver::getUTCDateTimeInSec(dashReceiver->mpdWrapper->getPublishTime());
- periodUpdate = TimeResolver::getDurationInSec(manager->mpdWrapper->getMinimumUpdatePeriod());
- }
-}
double frameRate;
THREAD_HANDLE videoRendererHandle;
THREAD_HANDLE audioRendererHandle;
- THREAD_HANDLE mpdFetcherThread;
bool isVideoRendering;
bool isAudioRendering;
bool eos;
void notifyAudioSegmentBufferObservers (uint32_t fillstateInPercent);
void updateMPD ();
void updateMPDICN ();
- static void* DoMPDFetching (void* manager);
};
}
}
{
this->dashManager->onBufferStateChanged(libdash::framework::buffer::VIDEO, bufferfill, maxC);
}
+
+void MultimediaStream::fetchMPD()
+{
+ for(size_t i=0; i < this->observers.size(); i++)
+ {
+ this->observers.at(i)->fetchMPD();
+ }
+}
bool isICN();
void shouldAbort();
void setTargetDownloadingTime(double);
+ void fetchMPD();
private:
float beta;
this->segment = this->segment + 1;
if( this->segment > 0)
{
- this->bufferDuration += media->GetSegmentDuration();
+ this->bufferDuration += this->segmentDuration;
if(this->bufferDuration - this->position > 3000)
{
}
else
{
- this->bufferDuration += (this->durationMilliseconds - (media->GetSegmentDuration() * (this->listSegmentSize - 1)));
+ this->bufferDuration += (this->durationMilliseconds - (this->segmentDuration * (this->listSegmentSize - 1)));
if(this->bufferDuration - this->position >3000)
{