00001 #ifndef AUDIOPLAYER_H
00002 #define AUDIOPLAYER_H
00003
00004 #include <stdint.h>
00005
00006 class MythPlayer;
00007 class AudioOutput;
00008
00009 namespace MythTV
00010 {
00011 class Visual;
00012 }
00013
00014 class MTV_PUBLIC AudioPlayer
00015 {
00016 public:
00017 AudioPlayer(MythPlayer *parent, bool muted);
00018 ~AudioPlayer();
00019
00020 void addVisual(MythTV::Visual *vis);
00021 void removeVisual(MythTV::Visual *vis);
00022
00023 void Reset(void);
00024 void DeleteOutput(void);
00025 QString ReinitAudio(void);
00026 void SetAudioOutput(AudioOutput *ao);
00027 void SetAudioInfo(const QString &main_device,
00028 const QString &passthru_device,
00029 uint samplerate,
00030 int bitrate = -1);
00031 void SetAudioParams(AudioFormat format, int orig_channels, int channels,
00032 int codec, int samplerate, bool passthru,
00033 int bitrate = -1);
00034 void SetEffDsp(int dsprate);
00035
00036 void CheckFormat(void);
00037 void SetNoAudio(void) { m_no_audio_out = true; }
00038 bool HasAudioIn(void) const { return !m_no_audio_in; }
00039 bool HasAudioOut(void) const { return !m_no_audio_out; }
00040 bool ControlsVolume(void) const { return m_controls_volume; }
00041
00042 bool Pause(bool pause);
00043 bool IsPaused(void);
00044 void PauseAudioUntilBuffered(void);
00045 int GetCodec(void) const { return m_codec; }
00046 int GetNumChannels(void) const { return m_channels; }
00047 int GetOrigChannels(void) const { return m_orig_channels; }
00048 int GetSampleRate(void) const { return m_samplerate; }
00049 uint GetVolume(void);
00050 uint AdjustVolume(int change);
00051 uint SetVolume(int newvolume);
00052 float GetStretchFactor(void) const { return m_stretchfactor; }
00053 void SetStretchFactor(float factor);
00054 bool IsUpmixing(void);
00055 bool EnableUpmix(bool enable, bool toggle = false);
00056 bool CanUpmix(void);
00057 bool CanPassthrough(int samplerate, int channels, int codec, int profile);
00058 bool CanDownmix(void);
00059 bool CanAC3(void);
00060 bool CanDTS(void);
00061 bool CanEAC3(void);
00062 bool CanTrueHD(void);
00063 bool CanDTSHD(void);
00064 uint GetMaxChannels(void);
00065 int GetMaxHDRate(void);
00066 int64_t GetAudioTime(void);
00067
00068 bool IsMuted(void) { return GetMuteState() == kMuteAll; }
00069 bool SetMuted(bool mute);
00070 MuteState GetMuteState(void);
00071 MuteState SetMuteState(MuteState);
00072 MuteState IncrMuteState(void);
00073
00074 void AddAudioData(char *buffer, int len, int64_t timecode, int frames);
00075 bool NeedDecodingBeforePassthrough(void);
00076 int64_t LengthLastData(void);
00077 bool GetBufferStatus(uint &fill, uint &total);
00078 bool IsBufferAlmostFull(void);
00079
00080 private:
00081 void AddVisuals(void);
00082 void RemoveVisuals(void);
00083 void ResetVisuals(void);
00084
00085 private:
00086 MythPlayer *m_parent;
00087 AudioOutput *m_audioOutput;
00088 int m_channels;
00089 int m_orig_channels;
00090 int m_codec;
00091 AudioFormat m_format;
00092 int m_samplerate;
00093 int m_codec_profile;
00094 float m_stretchfactor;
00095 bool m_passthru;
00096 QMutex m_lock;
00097 bool m_muted_on_creation;
00098 QString m_main_device;
00099 QString m_passthru_device;
00100 bool m_no_audio_in;
00101 bool m_no_audio_out;
00102 bool m_controls_volume;
00103 vector<MythTV::Visual*> m_visuals;
00104 };
00105
00106 #endif // AUDIOPLAYER_H