diff options
author | Jacques SAMAIN <jsamain+fdio@cisco.com> | 2018-06-01 19:56:33 +0200 |
---|---|---|
committer | Jacques SAMAIN <jsamain+fdio@cisco.com> | 2018-06-04 12:16:30 +0000 |
commit | 872b2e96a111d6da5f821a6dc61b923f9913b3f3 (patch) | |
tree | 9dbae9fb4cf3ed4a35a0698e0cf7f4b446ffeedb /MPD | |
parent | 6120adcbd955c072f560ba3918ed566088374fa0 (diff) |
Several corrections:
*effectively take into account live MPD
*Fix several bugs
Change-Id: I9b925f222653d2d196b09b4e96cb15119ec8af44
Signed-off-by: Jacques SAMAIN <jsamain+fdio@cisco.com>
Diffstat (limited to 'MPD')
-rw-r--r-- | MPD/AbstractRepresentationStream.h | 2 | ||||
-rw-r--r-- | MPD/IRepresentationStream.h | 2 | ||||
-rw-r--r-- | MPD/MPDWrapper.cpp | 262 | ||||
-rw-r--r-- | MPD/MPDWrapper.h | 9 | ||||
-rw-r--r-- | MPD/SegmentListStream.cpp | 8 | ||||
-rw-r--r-- | MPD/SegmentListStream.h | 2 | ||||
-rw-r--r-- | MPD/SegmentTemplateStream.cpp | 5 | ||||
-rw-r--r-- | MPD/SegmentTemplateStream.h | 2 | ||||
-rw-r--r-- | MPD/SingleMediaSegmentStream.cpp | 2 | ||||
-rw-r--r-- | MPD/SingleMediaSegmentStream.h | 2 |
10 files changed, 157 insertions, 139 deletions
diff --git a/MPD/AbstractRepresentationStream.h b/MPD/AbstractRepresentationStream.h index da847c3c..113720ed 100644 --- a/MPD/AbstractRepresentationStream.h +++ b/MPD/AbstractRepresentationStream.h @@ -43,7 +43,7 @@ public: 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; diff --git a/MPD/IRepresentationStream.h b/MPD/IRepresentationStream.h index 124216ba..bf8b08c4 100644 --- a/MPD/IRepresentationStream.h +++ b/MPD/IRepresentationStream.h @@ -35,7 +35,7 @@ public: 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; diff --git a/MPD/MPDWrapper.cpp b/MPD/MPDWrapper.cpp index 0b1d9596..1dca34fb 100644 --- a/MPD/MPDWrapper.cpp +++ b/MPD/MPDWrapper.cpp @@ -28,8 +28,7 @@ MPDWrapper::MPDWrapper(IMPD *mpd): videoSegmentOffset (0), audioSegmentOffset (0), videoSegmentNumber (0), - audioSegmentNumber (0), - hasReachedEndOfList (false) + audioSegmentNumber (0) { InitializeConditionVariable (&this->mpdUpdate); @@ -52,7 +51,7 @@ void MPDWrapper::updateMPD (IMPD* mpd) //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); @@ -61,7 +60,7 @@ void MPDWrapper::updateMPD (IMPD* mpd) delete(this->mpd); this->mpd = mpd; WakeAllConditionVariable(&this->mpdUpdate); - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); } void MPDWrapper::findVideoAdaptationSet (IMPD* mpd) @@ -186,16 +185,16 @@ void MPDWrapper::findAudioRepresentation (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: @@ -215,30 +214,30 @@ void MPDWrapper::reInit (viper::managers::StreamType type) 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; } @@ -281,7 +280,7 @@ void MPDWrapper::initializeAdaptationSetStream (viper::managers::StreamType type { IAdaptationSet *adaptationSet = NULL; std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations = NULL; - EnterCriticalSection(&this->monitorMutex); + this->acquireLock(); switch(type) { @@ -311,7 +310,7 @@ void MPDWrapper::initializeAdaptationSetStream (viper::managers::StreamType 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) @@ -549,7 +548,7 @@ void MPDWrapper::releaseLock () void MPDWrapper::setSegmentOffset(viper::managers::StreamType type, uint32_t segmentOffset) { - EnterCriticalSection(&this->monitorMutex); + this->acquireLock(); switch(type) { case viper::managers::StreamType::AUDIO: @@ -563,31 +562,28 @@ void MPDWrapper::setSegmentOffset(viper::managers::StreamType type, uint32_t seg 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; @@ -614,7 +610,7 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool default: break; } - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return NULL; } } @@ -624,105 +620,53 @@ MediaObject* MPDWrapper::getNextSegment (viper::managers::StreamType type, bool 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; } @@ -730,7 +674,7 @@ MediaObject* MPDWrapper::getSegment (viper::managers::StreamType type, uint32_t { IRepresentation* representation; std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations; - EnterCriticalSection(&this->monitorMutex); + this->acquireLock(); switch(type) { @@ -743,7 +687,7 @@ MediaObject* MPDWrapper::getSegment (viper::managers::StreamType type, uint32_t representations = this->videoRepresentations; break; default: - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return NULL; } @@ -751,19 +695,17 @@ MediaObject* MPDWrapper::getSegment (viper::managers::StreamType type, uint32_t 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; } @@ -771,7 +713,7 @@ MediaObject* MPDWrapper::getInitSegment (viper::managers::StreamType type) { IRepresentation* representation; std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations; - EnterCriticalSection(&this->monitorMutex); + this->acquireLock(); switch(type) { @@ -784,7 +726,7 @@ MediaObject* MPDWrapper::getInitSegment (viper::managers::StreamType type) representations = this->videoRepresentations; break; default: - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return NULL; } @@ -795,10 +737,10 @@ MediaObject* MPDWrapper::getInitSegment (viper::managers::StreamType type) if(seg != NULL) { MediaObject *media = new MediaObject(seg, representation); - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return media; } - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return NULL; } @@ -822,7 +764,7 @@ void MPDWrapper::setAudioQuality (IPeriod *period, IAdaptationSet *adaptationSet bool periodChanged = false; if (this->audioRepresentation == representation) { - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return; } @@ -848,7 +790,7 @@ void MPDWrapper::setVideoQuality (IPeriod *period, IAdaptationSet *adaptationSet bool periodChanged = false; if (this->videoRepresentation == representation) { - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return; } @@ -873,7 +815,7 @@ uint32_t MPDWrapper::calculateSegmentOffset (viper::managers::StreamType type, u { IRepresentation* representation; std::map<dash::mpd::IRepresentation *, IRepresentationStream *> *representations; - EnterCriticalSection(&this->monitorMutex); + this->acquireLock(); switch(type) { @@ -886,13 +828,13 @@ uint32_t MPDWrapper::calculateSegmentOffset (viper::managers::StreamType type, u 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; @@ -900,14 +842,14 @@ uint32_t MPDWrapper::calculateSegmentOffset (viper::managers::StreamType type, u 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) { @@ -920,23 +862,23 @@ std::string MPDWrapper::getRepresentationID (viper::managers::StreamType 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; } @@ -1079,7 +1021,7 @@ uint32_t MPDWrapper::getFetchTime () 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); @@ -1103,14 +1045,14 @@ void MPDWrapper::settingsChanged (int period, int videoAdaptationSet, int videoR 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 { @@ -1164,8 +1106,26 @@ float MPDWrapper::onFirstDownloadMPD (viper::IViperGui *gui) 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) { @@ -1173,7 +1133,7 @@ float MPDWrapper::onFirstDownloadMPD (viper::IViperGui *gui) gui->setListSegmentSize(0); } } - LeaveCriticalSection(&this->monitorMutex); + this->releaseLock(); return segmentDuration; } @@ -1182,3 +1142,59 @@ void MPDWrapper::setIsStopping (bool isStopping) 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; + } +} diff --git a/MPD/MPDWrapper.h b/MPD/MPDWrapper.h index cf6275d8..75ade085 100644 --- a/MPD/MPDWrapper.h +++ b/MPD/MPDWrapper.h @@ -106,6 +106,10 @@ public: 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); @@ -124,8 +128,11 @@ private: uint32_t audioSegmentOffset; size_t videoSegmentNumber; size_t audioSegmentNumber; + bool videoSegmentIsSet; + bool audioSegmentIsSet; + int videoSegmentQuality; + int audioSegmentQuality; bool isStopping; - bool hasReachedEndOfList; }; } } diff --git a/MPD/SegmentListStream.cpp b/MPD/SegmentListStream.cpp index 86d36e68..0ab67570 100644 --- a/MPD/SegmentListStream.cpp +++ b/MPD/SegmentListStream.cpp @@ -53,15 +53,11 @@ ISegment* SegmentListStream::getIndexSegment(size_t segmentNumber) 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; } diff --git a/MPD/SegmentListStream.h b/MPD/SegmentListStream.h index 589896ff..a9658748 100644 --- a/MPD/SegmentListStream.h +++ b/MPD/SegmentListStream.h @@ -33,7 +33,7 @@ public: 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(); diff --git a/MPD/SegmentTemplateStream.cpp b/MPD/SegmentTemplateStream.cpp index 5a6dd67c..b8f08530 100644 --- a/MPD/SegmentTemplateStream.cpp +++ b/MPD/SegmentTemplateStream.cpp @@ -64,14 +64,13 @@ ISegment* SegmentTemplateStream::getIndexSegment(size_t segmentNumber) 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 @@ -228,7 +227,7 @@ uint64_t SegmentTemplateStream::getTime(size_t segmentNumber) 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) diff --git a/MPD/SegmentTemplateStream.h b/MPD/SegmentTemplateStream.h index 8485b56b..8325a387 100644 --- a/MPD/SegmentTemplateStream.h +++ b/MPD/SegmentTemplateStream.h @@ -34,7 +34,7 @@ public: 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(); diff --git a/MPD/SingleMediaSegmentStream.cpp b/MPD/SingleMediaSegmentStream.cpp index 3eccbefe..39301928 100644 --- a/MPD/SingleMediaSegmentStream.cpp +++ b/MPD/SingleMediaSegmentStream.cpp @@ -51,7 +51,7 @@ ISegment* SingleMediaSegmentStream::getIndexSegment(size_t segmentNumber) 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) diff --git a/MPD/SingleMediaSegmentStream.h b/MPD/SingleMediaSegmentStream.h index 44fead38..e619a7f8 100644 --- a/MPD/SingleMediaSegmentStream.h +++ b/MPD/SingleMediaSegmentStream.h @@ -31,7 +31,7 @@ public: 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(); |