aboutsummaryrefslogtreecommitdiffstats
path: root/MPD/MPDWrapper.cpp
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-11-08 11:10:13 +0000
committerGerrit Code Review <gerrit@fd.io>2017-11-08 11:10:13 +0000
commit3abd95a2501be987eca0fa5c59f01e84a98cf202 (patch)
tree6f400a88963e4d8c7813b34cb792cd6b3f1c53df /MPD/MPDWrapper.cpp
parent6ab9d985a6b95ceca205918b5594e291ea48cc09 (diff)
parent4b187a7b0e223104653bd4af0555110db1f8471e (diff)
Merge "Addressing issue about different position of the segmentTemplate in MPD" into viper/master
Diffstat (limited to 'MPD/MPDWrapper.cpp')
-rw-r--r--MPD/MPDWrapper.cpp62
1 files changed, 60 insertions, 2 deletions
diff --git a/MPD/MPDWrapper.cpp b/MPD/MPDWrapper.cpp
index 6d6fa9e5..0b1d9596 100644
--- a/MPD/MPDWrapper.cpp
+++ b/MPD/MPDWrapper.cpp
@@ -570,6 +570,7 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
{
IRepresentation* representation;
std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations;
+ dash::mpd::IAdaptationSet* adaptationSet;
EnterCriticalSection(&this->monitorMutex);
switch(type)
@@ -577,10 +578,12 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
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);
@@ -627,11 +630,13 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
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:
@@ -671,6 +676,35 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool
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);
segmentNumber++;
@@ -1093,9 +1127,33 @@ float MPDWrapper::onFirstDownloadMPD (viper::IViperGui *gui)
}
else //SegmentTemplate
{
- uint32_t duration = representation->GetSegmentTemplate()->GetDuration();
- uint32_t timescale = representation->GetSegmentTemplate()->GetTimescale();
+ uint32_t duration = 0;
+ uint32_t timescale = 0;
+
+ //check if segmentTemplate is on the representation
+ if(representation->GetSegmentTemplate())
+ {
+ duration = representation->GetSegmentTemplate()->GetDuration();
+ timescale = representation->GetSegmentTemplate()->GetTimescale();
+ }
+ else //check at adaptationSet then
+ {
+ if(this->videoAdaptationSet->GetSegmentTemplate())
+ {
+ duration = this->videoAdaptationSet->GetSegmentTemplate()->GetDuration();
+ timescale = this->videoAdaptationSet->GetSegmentTemplate()->GetTimescale();
+ }
+ else //check at period
+ {
+ if(this->period->GetSegmentTemplate())
+ {
+ duration = this->period->GetSegmentTemplate()->GetDuration();
+ timescale = this->period->GetSegmentTemplate()->GetTimescale();
+ }
+ }
+ }
segmentDuration = 1.0*duration/(1.0*timescale) * 1000;
+
if(gui)
{
gui->setSegmentDuration(segmentDuration);