From 05c1a838c881ea502888659848d8792843b28718 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Sat, 25 Feb 2017 23:42:31 +0100 Subject: Initial commit: video player - viper Change-Id: Id5aa33598ce34659bad4a7a9ae5006bfb84f9bd1 Signed-off-by: Luca Muscariello --- MPD/AbstractRepresentationStream.cpp | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 MPD/AbstractRepresentationStream.cpp (limited to 'MPD/AbstractRepresentationStream.cpp') diff --git a/MPD/AbstractRepresentationStream.cpp b/MPD/AbstractRepresentationStream.cpp new file mode 100644 index 00000000..449c6aa8 --- /dev/null +++ b/MPD/AbstractRepresentationStream.cpp @@ -0,0 +1,84 @@ +/* + * AbstractRepresentationStream.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 "AbstractRepresentationStream.h" + +using namespace libdash::framework::mpd; +using namespace dash::mpd; + +AbstractRepresentationStream::AbstractRepresentationStream(IMPD *mpd, IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation) : + mpd (mpd), + period (period), + adaptationSet (adaptationSet), + representation (representation) +{ +} +AbstractRepresentationStream::~AbstractRepresentationStream() +{ +} + +void AbstractRepresentationStream::setBaseUrls(const std::vector baseurls) +{ + this->baseUrls.clear(); + + for (size_t i = 0; i < baseurls.size(); i++) + this->baseUrls.push_back(baseurls.at(i)); +} + +uint32_t AbstractRepresentationStream::getSize() +{ + return UINT32_MAX - 1; +} + +uint32_t AbstractRepresentationStream::getFirstSegmentNumber() +{ + if (this->mpd->GetType() == "dynamic") + { + uint32_t currTime = TimeResolver::getCurrentTimeInSec(); + uint32_t availStT = TimeResolver::getUTCDateTimeInSec(this->mpd->GetAvailabilityStarttime()); + uint32_t duration = this->getAverageSegmentDuration(); + uint32_t timeshift = TimeResolver::getDurationInSec(this->mpd->GetTimeShiftBufferDepth()); + return (currTime - duration - availStT - timeshift ) / duration; + } + return 0; +} + +uint32_t AbstractRepresentationStream::getCurrentSegmentNumber() +{ + if (this->mpd->GetType() == "dynamic") + { + uint32_t currTime = TimeResolver::getCurrentTimeInSec(); + uint32_t duration = this->getAverageSegmentDuration(); + uint32_t availStT = TimeResolver::getUTCDateTimeInSec(this->mpd->GetAvailabilityStarttime()); + + return (currTime - duration - availStT) / duration; + } + return 0; +} + +uint32_t AbstractRepresentationStream::getLastSegmentNumber () +{ + if (this->mpd->GetType() == "dynamic") + { + uint32_t currTime = TimeResolver::getCurrentTimeInSec(); + uint32_t duration = this->getAverageSegmentDuration(); + uint32_t availStT = TimeResolver::getUTCDateTimeInSec(this->mpd->GetAvailabilityStarttime()); + uint32_t checkTime = mpd->GetFetchTime() + + TimeResolver::getDurationInSec(this->mpd->GetMinimumUpdatePeriod()); + return ( ((checkTime > currTime) ? currTime : checkTime) - duration - availStT) / duration; + } + return 0; +} + +uint32_t AbstractRepresentationStream::getAverageSegmentDuration() +{ + return 1; +} -- cgit 1.2.3-korg