aboutsummaryrefslogtreecommitdiffstats
path: root/MPD/AbstractRepresentationStream.cpp
diff options
context:
space:
mode:
authorLuca Muscariello <lumuscar+fdio@cisco.com>2017-02-25 23:42:31 +0100
committerLuca Muscariello <lumuscar+fdio@cisco.com>2017-02-25 23:42:31 +0100
commit05c1a838c881ea502888659848d8792843b28718 (patch)
treecf0b05b58bd725a1eb6c80325ba986c63dea42aa /MPD/AbstractRepresentationStream.cpp
parent9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff)
Initial commit: video player - viper
Change-Id: Id5aa33598ce34659bad4a7a9ae5006bfb84f9bd1 Signed-off-by: Luca Muscariello <lumuscar+fdio@cisco.com>
Diffstat (limited to 'MPD/AbstractRepresentationStream.cpp')
-rw-r--r--MPD/AbstractRepresentationStream.cpp84
1 files changed, 84 insertions, 0 deletions
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<dash::mpd::IBaseUrl *> 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;
+}