aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Samain <jsamain+fdio@cisco.com>2017-10-16 14:12:04 +0200
committerJacques SAMAIN <jsamain+fdio@cisco.com>2017-10-16 12:17:10 +0000
commit4b187a7b0e223104653bd4af0555110db1f8471e (patch)
tree9616e8ee7c83841804e20378756f7f8044c85ce7
parent0e275345e28c34f2c6b91a75f44ac93034ae477c (diff)
Addressing issue about different position of the segmentTemplate in MPD
Change-Id: Ic6c5f286db2ca6ab0ed061609d03ab1b4310be0a Signed-off-by: Jacques Samain <jsamain+fdio@cisco.com>
-rw-r--r--MPD/MPDWrapper.cpp62
-rw-r--r--MPD/SegmentTemplateStream.cpp7
2 files changed, 64 insertions, 5 deletions
diff --git a/MPD/MPDWrapper.cpp b/MPD/MPDWrapper.cpp
index c7bdee9f..1e085546 100644
--- a/MPD/MPDWrapper.cpp
+++ b/MPD/MPDWrapper.cpp
@@ -568,6 +568,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)
@@ -575,10 +576,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);
@@ -632,11 +635,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:
@@ -651,6 +656,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++;
switch(type)
@@ -1072,9 +1106,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);
diff --git a/MPD/SegmentTemplateStream.cpp b/MPD/SegmentTemplateStream.cpp
index 50801896..b0043d29 100644
--- a/MPD/SegmentTemplateStream.cpp
+++ b/MPD/SegmentTemplateStream.cpp
@@ -113,9 +113,10 @@ ISegment* SegmentTemplateStream::getMediaSegment(size_t segmentNumber, uint64_t&
}
/* number-based template */
- uint32_t duration = representation->GetSegmentTemplate()->GetDuration();
- uint32_t timescale = representation->GetSegmentTemplate()->GetTimescale();
- segmentDuration = (uint64_t)(((float)duration/(float)timescale) * 1000);
+//SEGMENT DURATION IS CALCULATED AT MPDWRAPPER SIDE
+// uint32_t duration = representation->GetSegmentTemplate()->GetDuration();
+// uint32_t timescale = representation->GetSegmentTemplate()->GetTimescale();
+// segmentDuration = (uint64_t)(((float)duration/(float)timescale) * 1000);
return this->segmentTemplate->GetMediaSegmentFromNumber(baseUrls, representation->GetId(), representation->GetBandwidth(),
this->segmentTemplate->GetStartNumber() + segmentNumber);