diff options
author | Luca Muscariello <lumuscar+fdio@cisco.com> | 2017-02-25 23:42:31 +0100 |
---|---|---|
committer | Luca Muscariello <lumuscar+fdio@cisco.com> | 2017-02-25 23:42:31 +0100 |
commit | 05c1a838c881ea502888659848d8792843b28718 (patch) | |
tree | cf0b05b58bd725a1eb6c80325ba986c63dea42aa /MPD/SegmentListStream.cpp | |
parent | 9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff) |
Initial commit: video player - viper
Change-Id: Id5aa33598ce34659bad4a7a9ae5006bfb84f9bd1
Signed-off-by: Luca Muscariello <lumuscar+fdio@cisco.com>
Diffstat (limited to 'MPD/SegmentListStream.cpp')
-rw-r--r-- | MPD/SegmentListStream.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/MPD/SegmentListStream.cpp b/MPD/SegmentListStream.cpp new file mode 100644 index 00000000..3a475e71 --- /dev/null +++ b/MPD/SegmentListStream.cpp @@ -0,0 +1,88 @@ +/* + * SegmentListStream.cpp + ***************************************************************************** + * Copyright (C) 2012, bitmovin Softwareentwicklung OG, All Rights Reserved + * + * Email: libdash-dev@vicky.bitmovin.net + * + * This source code and its use and distribution, is subject to the terms + * and conditions of the applicable license agreement. + *****************************************************************************/ + +#include "SegmentListStream.h" + +using namespace dash::mpd; +using namespace libdash::framework::mpd; + +SegmentListStream::SegmentListStream(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation) : + AbstractRepresentationStream (mpd, period, adaptationSet, representation) +{ + this->baseUrls = BaseUrlResolver::resolveBaseUrl(mpd, period, adaptationSet, 0, 0, 0); + this->segmentList = findSegmentList(); +} + +SegmentListStream::~SegmentListStream() +{ +} + +ISegment* SegmentListStream::getInitializationSegment() +{ + if (this->segmentList->GetInitialization()) + return this->segmentList->GetInitialization()->ToSegment(this->baseUrls); + + return NULL; +} + +ISegment* SegmentListStream::getIndexSegment(size_t segmentNumber) +{ + if (this->segmentList->GetSegmentURLs().size() > segmentNumber) + return this->segmentList->GetSegmentURLs().at(segmentNumber)->ToIndexSegment(this->baseUrls); + + return NULL; +} + +ISegment* SegmentListStream::getMediaSegment(size_t segmentNumber) +{ + if (this->segmentList->GetSegmentURLs().size() > segmentNumber) + return this->segmentList->GetSegmentURLs().at(segmentNumber)->ToMediaSegment(this->baseUrls); + + return NULL; +} + +ISegment* SegmentListStream::getBitstreamSwitchingSegment () +{ + if (this->segmentList->GetBitstreamSwitching()) + return this->segmentList->GetBitstreamSwitching()->ToSegment(baseUrls); + + return NULL; +} + +RepresentationStreamType SegmentListStream::getStreamType() +{ + return SegmentList; +} + +uint32_t SegmentListStream::getSize() +{ + return this->segmentList->GetSegmentURLs().size(); +} + +ISegmentList* SegmentListStream::findSegmentList() +{ + if (this->representation->GetSegmentList()) + return this->representation->GetSegmentList(); + + if (this->adaptationSet->GetSegmentList()) + return this->adaptationSet->GetSegmentList(); + + if (this->period->GetSegmentList()) + return this->period->GetSegmentList(); + + return NULL; +} + +uint32_t SegmentListStream::getAverageSegmentDuration() +{ + /* TODO calculate average segment durations for SegmentTimeline */ + return this->segmentList->GetDuration(); +} |