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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/*
* MultimediaStream.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 "MultimediaStream.h"
using namespace viper::managers;
using namespace libdash::framework::adaptation;
using namespace libdash::framework::input;
using namespace libdash::framework::buffer;
using namespace libdash::framework::mpd;
using namespace dash::mpd;
MultimediaStream::MultimediaStream(StreamType type, MPDWrapper *mpdWrapper, uint32_t bufferSize, bool icnEnabled, double icnAlpha, bool nodecoding, float beta, float drop) :
type (type),
segmentBufferSize (bufferSize),
dashManager (NULL),
mpdWrapper (mpdWrapper),
icn (icnEnabled),
icnAlpha (icnAlpha),
noDecoding (nodecoding),
beta (beta),
drop (drop)
{
this->init();
}
MultimediaStream::~MultimediaStream ()
{
this->stop();
delete this->dashManager;
}
bool MultimediaStream::isICN()
{
return this->icn;
}
void MultimediaStream::shouldAbort()
{
this->dashManager->shouldAbort();
}
uint32_t MultimediaStream::getPosition()
{
return this->dashManager->getPosition();
}
void MultimediaStream::setLooping(bool looping)
{
this->dashManager->setLooping(looping);
}
void MultimediaStream::setPosition(uint32_t segmentNumber)
{
this->dashManager->setPosition(segmentNumber);
}
void MultimediaStream::setPositionInMsec(uint32_t milliSecs)
{
this->dashManager->setPositionInMsec(milliSecs);
}
void MultimediaStream::init()
{
this->dashManager = new DASHManager(this->type, this->segmentBufferSize, this, this->mpdWrapper, this->isICN(), this->icnAlpha, this->noDecoding, this->beta, this->drop);
}
bool MultimediaStream::start()
{
if(!this->startDownload())
return false;
return true;
}
bool MultimediaStream::startDownload()
{
dashManager->setAdaptationLogic(this->logic);
if(!dashManager->start())
return false;
return true;
}
void MultimediaStream::stop()
{
this->stopDownload();
}
void MultimediaStream::stopDownload()
{
this->dashManager->stop();
}
void MultimediaStream::clear()
{
this->dashManager->clear();
}
void MultimediaStream::attachStreamObserver(IStreamObserver *observer)
{
this->observers.push_back(observer);
}
void MultimediaStream::setRepresentation()
{
this->dashManager->setRepresentation();
}
void MultimediaStream::enqueueRepresentation(IPeriod *period, IAdaptationSet *adaptationSet, IRepresentation *representation)
{
this->dashManager->enqueueRepresentation(period, adaptationSet, representation);
}
void MultimediaStream::setAdaptationLogic(libdash::framework::adaptation::IAdaptationLogic *logic)
{
this->logic = logic;
}
void MultimediaStream::onSegmentBufferStateChanged(uint32_t fillstateInPercent, int maxC)
{
for (size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->onSegmentBufferStateChanged(this->type, fillstateInPercent, maxC);
}
void MultimediaStream::onBufferStateChanged(BufferType type, uint32_t fillstateInPercent, int maxC)
{
switch(type)
{
case libdash::framework::buffer::AUDIO:
for (size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->onAudioBufferStateChanged(fillstateInPercent);
break;
case libdash::framework::buffer::VIDEO:
for (size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->onVideoBufferStateChanged(fillstateInPercent);
default:
break;
}
}
void MultimediaStream::setEOS(bool value)
{
for(size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->setEOS(value);
}
void MultimediaStream::setTargetDownloadingTime(double target)
{
this->dashManager->setTargetDownloadingTime(target);
}
void MultimediaStream::notifyStatistics(int segNum, uint32_t bitrate, int fps, uint32_t quality)
{
for(size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->notifyStatistics(segNum, bitrate, fps, quality);
}
void MultimediaStream::notifyQualityDownloading(uint32_t quality)
{
for(size_t i = 0; i < observers.size(); i++)
this->observers.at(i)->notifyQualityDownloading(quality);
}
int MultimediaStream::getBufferLevel()
{
int bufferFill = 0;
for(size_t i=0; i < observers.size(); i++)
{
bufferFill = this->observers.at(i)->getBufferLevel();
}
return bufferFill;
}
bool MultimediaStream::canPush()
{
bool flag = false;
for(size_t i=0; i < observers.size(); i++)
{
flag = flag || this->observers.at(i)->canPush();
}
return flag;
}
libdash::framework::input::MediaObject* MultimediaStream::getSegment()
{
return this->dashManager->getSegment();
}
void MultimediaStream::notifyBufferChange(uint32_t bufferfill, int maxC)
{
this->dashManager->onBufferStateChanged(libdash::framework::buffer::VIDEO, bufferfill, maxC);
}
void MultimediaStream::fetchMPD()
{
for(size_t i=0; i < this->observers.size(); i++)
{
this->observers.at(i)->fetchMPD();
}
}
|