-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAgrippinaAudioESPlayer.h
128 lines (110 loc) · 4.92 KB
/
AgrippinaAudioESPlayer.h
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
/*
* (c) 1997-2016 Netflix, Inc. All content herein is protected by
* U.S. copyright and other applicable intellectual property laws and
* may not be copied without the express permission of Netflix, Inc.,
* which reserves all rights. Reuse of any of this content for any
* purpose without the permission of Netflix, Inc. is strictly
* prohibited.
*/
#ifndef AGRIPPINA_AUDIOESPLAYER_H
#define AGRIPPINA_AUDIOESPLAYER_H
/** @file AgrippinaAudioESPlayer.h - Reference implementation of the audio
* IElementaryStreamPlayer.
*
* AgrippinaAudioESPlayer is the reference application's implementation of an audio
* elementary stream player. It implements the IElementaryStreamPlayer interface
* (see IElementaryStreamPlayer.h). A device partner may use or modify this
* header and accompanying .cpp as needed.
*
* An AgrippinaAudioESPlayer is created by the
* AgrippinaPlaybackGroup::createStreamPlayer() method each time a movie is loaded
* for viewing and persists until the movie is unloaded. When it's created, the
* player spawns a decoder thread and creates an audio renderer which in turn
* spawns a renderer thread. The decoder thread uses the IESPlayerCallback
* object it receives when it is created to pull audio samples from the netlix
* application. When it receives a sample, it decrypts it decodes the sample and
* adds it to the renderer's input queue. The renderer thread uses the
* AgrippinaPlaybackGroup's ReferenceClock and the PTS timestamps on the decoded
* frames to determine when to remove decoded frames from its input queue and
* write them to the audio driver.
*
* In the reference application, there there are several different options for
* the audio renderer that is used. The AudioESPlayer uses the ESManager (which
* is available via the AgrippinaPlaybackGroup) to get the RendererManager that
* provides the audio renderer that was selected at run time.
*/
#include "AgrippinaESPlayer.h"
/* include from nero include dir */
#include "NeroSTC.h"
#include "NeroAudioDecoder.h"
#include "NeroConstants.h"
namespace netflix {
namespace device {
namespace esplayer {
class DeviceThread;
class NRDP_EXPORTABLE AgrippinaAudioESPlayer : public AgrippinaESPlayer
{
public:
AgrippinaAudioESPlayer(NeroAudioDecoder* NeroAudioDecoder_ptr,NeroSTC* stc_ptr);
virtual ~AgrippinaAudioESPlayer();
virtual NFErr init(const struct StreamPlayerInitData& initData,
std::shared_ptr<IESPlayerCallback> callback,
AgrippinaPlaybackGroup* playbackGroup);
virtual void flush();
virtual void close();
virtual void DecoderTask();
virtual void EventTask();
virtual void EventHandling(NeroEvents_t *event);
virtual bool inputsAreExhausted();
virtual MediaType getMediaType();
virtual bool readyForPlaybackStart();
virtual void enable();
virtual void underflowReporter();
bool isDisabledOrPending();
class DecodedAudioBuffer
{
public:
DecodedAudioBuffer() : size_(0) {}
unsigned char* data() { assert(size_ > 0); return data_; }
uint32_t size() { return size_; }
void setDataBytes(uint32_t bytes) { assert(size_ > 0 && bytes <= size_); dataBytes_ = bytes; }
void setTimestamp(llong timestamp) { assert(size_ > 0); timestamp_ = timestamp; }
llong& getTimestamp() { return timestamp_;}
private:
unsigned char* data_;
uint32_t size_;
uint32_t dataBytes_;
llong timestamp_;
};
private:
friend class AgrippinaPlaybackGroup;
Nero_audio_codec_t Nrd2NeroAudioCodec_Remap(const char* nrd_audio_codec);
AgrippinaAudioESPlayer();
virtual void beginFlush();
virtual void endFlush();
bool playbackPending();
void setPlaybackPending(bool);
std::shared_ptr<AgrippinaSampleWriter> mSampleWriter;
std::auto_ptr<DeviceThread> mAudioDecoderThread;
std::shared_ptr<DeviceThread> mAudioEventThread;
// During on-the-fly audio switch, the audio player is disabled, then
// flushed, then re-enabled -- all while the PlaybackGroup's is in the PLAY
// state. When the player is re-enabled, it might not have actually decoded
// enough audio frames to ensure that it can immediately begin playing back
// without underflowing. The mPlaybackPending flag ensures that rendering
// only begins when enough frames are available for playback.
//
// mPlaybackPending is modified on the decoder and SDK pumping loop threads
// and read on the audio renderer thread. Access is protected with the
// mDecoderTaskMutex.
bool mPlaybackPending;
bool mInputExhausted;
bool mIsFlushing;
Nero_audio_codec_t NeroAudioFMT;
NeroAudioDecoder* m_NeroAudioDecoder;
NeroSTC* m_stc;
};
} // namespace esplayer
} // namespace device
} // namespace netflix
#endif /* AGRIPPINA_AUDIOESPLAYER_H */