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
85
86
87
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();
}
|