forked from popcornmix/omxplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OMXPlayerAudio.h
122 lines (114 loc) · 4.26 KB
/
OMXPlayerAudio.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
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#ifndef _OMX_PLAYERAUDIO_H_
#define _OMX_PLAYERAUDIO_H_
#include "DllAvUtil.h"
#include "DllAvFormat.h"
#include "DllAvFilter.h"
#include "DllAvCodec.h"
#include "utils/PCMRemap.h"
#include "OMXReader.h"
#include "OMXClock.h"
#include "OMXStreamInfo.h"
#include "OMXAudio.h"
#include "OMXAudioCodecOMX.h"
#include "OMXThread.h"
#include <deque>
#include <string>
#include <sys/types.h>
using namespace std;
class OMXPlayerAudio : public OMXThread
{
protected:
AVStream *m_pStream;
int m_stream_id;
std::deque<OMXPacket *> m_packets;
DllAvUtil m_dllAvUtil;
DllAvCodec m_dllAvCodec;
DllAvFormat m_dllAvFormat;
bool m_open;
COMXStreamInfo m_hints;
double m_iCurrentPts;
pthread_cond_t m_packet_cond;
pthread_cond_t m_audio_cond;
pthread_mutex_t m_lock;
pthread_mutex_t m_lock_decoder;
OMXClock *m_av_clock;
OMXReader *m_omx_reader;
COMXAudio *m_decoder;
std::string m_codec_name;
std::string m_device;
bool m_use_passthrough;
bool m_use_hw_decode;
bool m_passthrough;
bool m_hw_decode;
bool m_boost_on_downmix;
bool m_bAbort;
bool m_use_thread;
bool m_flush;
bool m_live;
enum PCMLayout m_layout;
unsigned int m_cached_size;
unsigned int m_max_data_size;
float m_fifo_size;
COMXAudioCodecOMX *m_pAudioCodec;
float m_CurrentVolume;
long m_amplification;
bool m_mute;
bool m_player_error;
void Lock();
void UnLock();
void LockDecoder();
void UnLockDecoder();
private:
public:
OMXPlayerAudio();
~OMXPlayerAudio();
bool Open(COMXStreamInfo &hints, OMXClock *av_clock, OMXReader *omx_reader,
std::string device, bool passthrough, bool hw_decode,
bool boost_on_downmix, bool use_thread, bool is_live, enum PCMLayout layout, float queue_size, float fifo_size);
bool Close();
bool Decode(OMXPacket *pkt);
void Process();
void Flush();
bool AddPacket(OMXPacket *pkt);
bool OpenAudioCodec();
void CloseAudioCodec();
bool IsPassthrough(COMXStreamInfo hints);
bool OpenDecoder();
bool CloseDecoder();
double GetDelay();
double GetCacheTime();
double GetCacheTotal();
double GetCurrentPTS() { return m_iCurrentPts; };
void SubmitEOS();
bool IsEOS();
void WaitCompletion();
unsigned int GetCached() { return m_cached_size; };
unsigned int GetMaxCached() { return m_max_data_size; };
unsigned int GetLevel() { return m_max_data_size ? 100 * m_cached_size / m_max_data_size : 0; };
void SetVolume(float fVolume) { m_CurrentVolume = fVolume; if(m_decoder) m_decoder->SetVolume(fVolume); }
float GetVolume() { return m_CurrentVolume; }
void SetMute(bool bOnOff) { m_mute = bOnOff; if(m_decoder) m_decoder->SetMute(bOnOff); }
void SetDynamicRangeCompression(long drc) { m_amplification = drc; if(m_decoder) m_decoder->SetDynamicRangeCompression(drc); }
bool Error() { return !m_player_error; };
};
#endif