blob: 449c6aa80f1bf1c092f9b78b11d42479acde2049 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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;
}
|