From f8907f0a7a84928800adbbfd8e66e500794aa5d5 Mon Sep 17 00:00:00 2001 From: jacko Date: Thu, 8 Jun 2017 19:54:24 +0200 Subject: Adding handling for different kind of MPDs (previously the front end could only handle MPD with SegmentList) Now can handle: MPD with SegmentTemplate in Representation (VOD) MPD with SegmentTemplate and SegmentTimeline (live) Change-Id: Ie32e0e1823c94b1412990192595b16d3e2df1cfd Plus: removed some printf Signed-off-by: jacko --- UI/DASHPlayer.cpp | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'UI/DASHPlayer.cpp') diff --git a/UI/DASHPlayer.cpp b/UI/DASHPlayer.cpp index b87dde74..0f1db8cc 100644 --- a/UI/DASHPlayer.cpp +++ b/UI/DASHPlayer.cpp @@ -26,10 +26,11 @@ DASHPlayer::DASHPlayer(ViperGui &gui, Config *config) : { InitializeCriticalSection(&this->monitorMutex); this->offset = 0; - this->url = NULL; - this->icn = false; + this->url = NULL; + this->icn = false; this->adaptLogic = LogicType::RateBased; - this->seek = false; + this->seek = false; + this->isLive = false; this->reloadParameters(); this->setSettings(0, 0, 0, 0, 0); this->multimediaManager = new MultimediaManager(this->gui, this->parametersAdaptation->segmentBufferSize, config->getConfigPath().toStdString() + QString::fromLatin1("/").toStdString()); @@ -207,13 +208,39 @@ bool DASHPlayer::downloadMPD(const QString &url, const QString &adaptationLogic, IPeriod *period = this->multimediaManager->getMPD()->GetPeriods().at(0); IAdaptationSet *adaptation = period->GetAdaptationSets().at(0); IRepresentation *representation = adaptation->GetRepresentation().at(0); - uint32_t duration = representation->GetSegmentList()->GetDuration(); - uint32_t timescale = representation->GetSegmentList()->GetTimescale(); - this->gui->setListSegmentSize(representation->GetSegmentList()->GetSegmentURLs().size()); - this->segmentDuration = 1.0*duration/(1.0*timescale) * 1000; - this->gui->setSegmentDuration(this->segmentDuration); - this->parametersAdaptation->segmentDuration = this->segmentDuration; - this->parametersAdaptation->segmentDuration = 1.0*duration/(1.0*timescale) * 1000; + if(!strcmp(this->multimediaManager->getMPD()->GetType().c_str(), "static")) // VOD MPD + { + if(representation->GetSegmentList()) + { + uint32_t duration = representation->GetSegmentList()->GetDuration(); + uint32_t timescale = representation->GetSegmentList()->GetTimescale(); + this->gui->setListSegmentSize(representation->GetSegmentList()->GetSegmentURLs().size()); + this->segmentDuration = 1.0*duration/(1.0*timescale) * 1000; + this->gui->setSegmentDuration(this->segmentDuration); + this->parametersAdaptation->segmentDuration = this->segmentDuration; + } + else //SegmentTemplate + { + uint32_t duration = representation->GetSegmentTemplate()->GetDuration(); + uint32_t timescale = representation->GetSegmentTemplate()->GetTimescale(); + this->segmentDuration = 1.0*duration/(1.0*timescale) * 1000; + this->gui->setSegmentDuration(this->segmentDuration); + this->gui->setListSegmentSize(TimeResolver::getDurationInSec(period->GetDuration())*1000/this->segmentDuration + 1); + this->parametersAdaptation->segmentDuration = this->segmentDuration; + } + } + else //Live MPD + { + //SegmentTemplate->SegmentTimeline + this->isLive = true; + //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(); + this->segmentDuration = 1.0*duration/(1.0*timescale) * 1000; + this->gui->setSegmentDuration(this->segmentDuration); + this->gui->setListSegmentSize(1); + this->parametersAdaptation->segmentDuration = this->segmentDuration; + } this->onSettingsChanged(0,0,0,0,0); int j =0; std::string temp = adaptationLogic.toStdString(); -- cgit 1.2.3-korg