MythTV  master
audioplayer.h
Go to the documentation of this file.
1 #ifndef AUDIOPLAYER_H
2 #define AUDIOPLAYER_H
3 
4 #include "audiooutputsettings.h"
5 #include "mythtvexp.h"
6 #include "volumebase.h" // MuteState
7 
8 #include <QCoreApplication>
9 #include <QMutex>
10 
11 #include <cstdint>
12 #include <vector>
13 
14 using std::vector;
15 
16 class MythPlayer;
17 class AudioOutput;
18 struct AVCodecContext;
19 struct AVPacket;
20 
21 namespace MythTV
22 {
23  class Visual;
24 }
25 
27 {
28  Q_DECLARE_TR_FUNCTIONS(AudioPlayer);
29 
30  public:
31  AudioPlayer(MythPlayer *parent, bool muted);
32  ~AudioPlayer();
33 
34  void addVisual(MythTV::Visual *vis);
35  void removeVisual(MythTV::Visual *vis);
36 
37  void Reset(void);
38  void DeleteOutput(void);
39  QString ReinitAudio(void);
40  void SetAudioOutput(AudioOutput *ao);
41  void SetAudioInfo(const QString &main_device,
42  const QString &passthru_device,
43  uint samplerate,
44  int codec_profile = -1);
45  void SetAudioParams(AudioFormat format, int orig_channels, int channels,
46  AVCodecID codec, int samplerate, bool passthru,
47  int codec_profile = -1);
48  void SetEffDsp(int dsprate);
49 
50  void CheckFormat(void);
51  void SetNoAudio(void) { m_no_audio_out = true; }
52  bool HasAudioIn(void) const { return !m_no_audio_in; }
53  bool HasAudioOut(void) const { return !m_no_audio_out; }
54  bool ControlsVolume(void) const { return m_controls_volume; }
55 
56  bool Pause(bool pause);
57  bool IsPaused(void);
58  void PauseAudioUntilBuffered(void);
59  AVCodecID GetCodec(void) const { return m_codec; }
60  int GetNumChannels(void) const { return m_channels; }
61  int GetOrigChannels(void) const { return m_orig_channels; }
62  int GetSampleRate(void) const { return m_samplerate; }
63  uint GetVolume(void);
64  uint AdjustVolume(int change);
65  uint SetVolume(int newvolume);
66  float GetStretchFactor(void) const { return m_stretchfactor; }
67  void SetStretchFactor(float factor);
68  bool IsUpmixing(void);
69  bool EnableUpmix(bool enable, bool toggle = false);
70  bool CanUpmix(void);
71  bool CanPassthrough(int samplerate, int channels, AVCodecID codec, int profile);
72  bool CanDownmix(void);
73  bool CanAC3(void);
74  bool CanDTS(void);
75  bool CanEAC3(void);
76  bool CanTrueHD(void);
77  bool CanDTSHD(void);
78  uint GetMaxChannels(void);
79  int GetMaxHDRate(void);
80  int64_t GetAudioTime(void);
81  AudioFormat GetFormat(void) const { return m_format; }
82  bool CanProcess(AudioFormat fmt);
83  uint32_t CanProcess(void);
84  int DecodeAudio(AVCodecContext *ctx,
85  uint8_t *buffer, int &data_size,
86  const AVPacket *pkt);
87 
88  bool IsMuted(void) { return GetMuteState() == kMuteAll; }
89  bool SetMuted(bool mute);
90  MuteState GetMuteState(void);
91  MuteState SetMuteState(MuteState);
92  MuteState IncrMuteState(void);
93 
94  void AddAudioData(char *buffer, int len, int64_t timecode, int frames);
95  bool NeedDecodingBeforePassthrough(void);
96  int64_t LengthLastData(void);
97  bool GetBufferStatus(uint &fill, uint &total);
98  bool IsBufferAlmostFull(void);
99  int64_t GetAudioBufferedTime(void);
100 
104  AudioOutput *GetAudioOutput(void) const { return m_audioOutput; }
105 
106  private:
107  void AddVisuals(void);
108  void RemoveVisuals(void);
109  void ResetVisuals(void);
110 
111  private:
112  MythPlayer *m_parent {nullptr};
113  AudioOutput *m_audioOutput {nullptr};
114  int m_channels {-1};
115  int m_orig_channels {-1};
116  AVCodecID m_codec {AV_CODEC_ID_NONE};
118  int m_samplerate {44100};
119  int m_codec_profile {0};
120  float m_stretchfactor {1.0F};
121  bool m_passthru {false};
122  QMutex m_lock {QMutex::Recursive};
124  QString m_main_device;
126  bool m_no_audio_in {false};
127  bool m_no_audio_out {true};
128  bool m_controls_volume {true};
129  vector<MythTV::Visual*> m_visuals;
130 };
131 
132 #endif // AUDIOPLAYER_H
int GetOrigChannels(void) const
Definition: audioplayer.h:61
float GetStretchFactor(void) const
Definition: audioplayer.h:66
QString m_passthru_device
Definition: audioplayer.h:125
bool m_muted_on_creation
Definition: audioplayer.h:123
MuteState
Definition: volumebase.h:6
void SetNoAudio(void)
Definition: audioplayer.h:51
unsigned int uint
Definition: compat.h:140
QString m_main_device
Definition: audioplayer.h:124
vector< MythTV::Visual * > m_visuals
Definition: audioplayer.h:129
#define MTV_PUBLIC
Definition: mythtvexp.h:15
bool ControlsVolume(void) const
Definition: audioplayer.h:54
bool HasAudioOut(void) const
Definition: audioplayer.h:53
AudioOutput * GetAudioOutput(void) const
Return internal AudioOutput object.
Definition: audioplayer.h:104
AVCodecID GetCodec(void) const
Definition: audioplayer.h:59
int GetSampleRate(void) const
Definition: audioplayer.h:62
AudioFormat GetFormat(void) const
Definition: audioplayer.h:81
int GetNumChannels(void) const
Definition: audioplayer.h:60
bool HasAudioIn(void) const
Definition: audioplayer.h:52
bool IsMuted(void)
Definition: audioplayer.h:88
const char * frames[3]
Definition: element.c:46
Definition: output.h:25