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
|
/*
* MultimediaManager.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef VIPER_MANAGERS_MULTIMEDIAMANAGER_H_
#define VIPER_MANAGERS_MULTIMEDIAMANAGER_H_
#include "IMPD.h"
#include "MultimediaStream.h"
#include "IMultimediaManagerBase.h"
#include "IMultimediaManagerObserver.h"
#include "../Adaptation/IAdaptationLogic.h"
#include "../Adaptation/AdaptationLogicFactory.h"
#include "../Portable/MultiThreading.h"
#include <QtMultimedia/qaudiooutput.h>
#include <cstring>
#include <QtAV/QtAV.h>
#include "Common/ViperBuffer.h"
#include "UI/ViperGui.h"
namespace viper
{
namespace managers
{
class MultimediaManager : public IStreamObserver, public IMultimediaManagerBase
{
public:
MultimediaManager(ViperGui *viperGui, int segmentBufferSize, std::string downloadPath, bool noDecoding = false);
virtual ~MultimediaManager();
bool init (const std::string& url);
bool initICN (const std::string& url);
void start (bool icnEnabled, double icnAlpha, uint32_t nextOffset);
void stop ();
dash::mpd::IMPD* getMPD ();
bool setVideoQuality (dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
bool setAudioQuality (dash::mpd::IPeriod* period, dash::mpd::IAdaptationSet *adaptationSet, dash::mpd::IRepresentation *representation);
bool setVideoAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
bool setAudioAdaptationLogic (libdash::framework::adaptation::LogicType type, struct libdash::framework::adaptation::AdaptationParameters *params);
void attachManagerObserver (IMultimediaManagerObserver *observer);
void setFrameRate (double frameRate);
/* IStreamObserver */
void onSegmentDownloaded ();
void onSegmentBufferStateChanged (StreamType type, uint32_t fillstateInPercent, int maxC);
void onVideoBufferStateChanged (uint32_t fillstateInPercent);
void onAudioBufferStateChanged (uint32_t fillstateInPercent);
bool isUserDependent ();
bool isStarted ();
bool isStopping ();
bool isICN ();
void setEOS (bool value);
void shouldAbort (bool isVideo);
void setTargetDownloadingTime (bool isVid, double time);
bool isPlaying ();
void onPausePressed ();
void notifyStatistics (int segNum, uint32_t bitrate, int fps, uint32_t quality);
void notifyQualityDownloading (uint32_t quality);
uint32_t getUBufferLevel ();
int getBufferLevel ();
void setLooping (bool looping);
void setOffset(int offset);
void setBeta(float beta);
void setDrop(float drop);
bool canPush ();
CRITICAL_SECTION monitorBufferMutex;
int offset;
std::chrono::time_point<std::chrono::system_clock> lastPointInTime;
std::chrono::time_point<std::chrono::system_clock> bufferingLimit;
private:
float beta;
float drop;
std::string downloadPath;
int segmentBufferSize;
ViperGui *viperGui;
dash::IDASHManager *manager;
dash::mpd::IMPD *mpd;
dash::mpd::IPeriod *period;
dash::mpd::IAdaptationSet *videoAdaptationSet;
dash::mpd::IRepresentation *videoRepresentation;
libdash::framework::adaptation::IAdaptationLogic *videoLogic;
MultimediaStream *videoStream;
dash::mpd::IAdaptationSet *audioAdaptationSet;
dash::mpd::IRepresentation *audioRepresentation;
libdash::framework::adaptation::IAdaptationLogic *audioLogic;
MultimediaStream *audioStream;
std::vector<IMultimediaManagerObserver *> managerObservers;
bool started;
bool stopping;
bool icn;
double icnAlpha;
uint64_t framesDisplayed;
uint64_t segmentsDownloaded;
CRITICAL_SECTION monitorMutex;
double frameRate;
THREAD_HANDLE videoRendererHandle;
THREAD_HANDLE audioRendererHandle;
bool isVideoRendering;
bool isAudioRendering;
bool eos;
bool playing;
mutable CRITICAL_SECTION monitor_playing_video_mutex;
mutable CONDITION_VARIABLE playingVideoStatusChanged;
mutable CRITICAL_SECTION monitor_playing_audio_mutex;
mutable CONDITION_VARIABLE playingAudioStatusChanged;
const char *logicName;
bool noDecoding;
void notifyBufferChange ();
bool startVideoRenderingThread ();
void stopVideoRenderingThread ();
static void* pushVideo (void *data);
static void* pushVideoNoOut (void *data);
bool startAudioRenderingThread ();
void stopAudioRenderingThread ();
void initVideoRendering (uint32_t offset);
void initAudioPlayback (uint32_t offset);
void stopVideo ();
void stopAudio ();
void notifyVideoBufferObservers (uint32_t fillstateInPercent);
void notifyVideoSegmentBufferObservers (uint32_t fillstateInPercent);
void notifyAudioBufferObservers (uint32_t fillstateInPercent);
void notifyAudioSegmentBufferObservers (uint32_t fillstateInPercent);
};
}
}
#endif /* VIPER_MANAGERS_MULTIMEDIAMANAGER_H_ */
|