MythTV  master
audiooutputsettings.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  *
3  * Copyright (C) foobum@gmail.com 2010
4  * Copyright (C) Jean-Yves Avenard 2010
5  *
6  * Licensed under the GPL v2 or a later version at your choosing.
7  */
8 
9 #ifndef AUDIO_OUTPUT_SETTINGS_H
10 #define AUDIO_OUTPUT_SETTINGS_H
11 
12 #include <array>
13 #include <vector>
14 
15 #include "mythexp.h"
16 #include "mythconfig.h"
17 
18 #include <QString>
19 
20 extern "C" {
21 #include "libavcodec/avcodec.h" // to get codec id
22 }
23 #include "eldutils.h"
24 
33 };
34 
37  FEATURE_AC3 = 1 << 0,
38  FEATURE_DTS = 1 << 1,
39  FEATURE_LPCM = 1 << 2,
40  FEATURE_EAC3 = 1 << 3,
41  FEATURE_TRUEHD = 1 << 4,
42  FEATURE_DTSHD = 1 << 5,
43  FEATURE_AAC = 1 << 6,
44 };
45 
46 static const int srs[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
47  48000, 88200, 96000, 176400, 192000 };
48 
51 
53 {
54  public:
55  explicit AudioOutputSettings(bool invalid = false);
58  AudioOutputSettings& operator=(const AudioOutputSettings& /*rhs*/);
59  AudioOutputSettings *GetCleaned(bool newcopy = false);
60  AudioOutputSettings *GetUsers(bool newcopy = false);
61 
62  int GetNextRate();
63  void AddSupportedRate(int rate);
64  bool IsSupportedRate(int rate);
65  int NearestSupportedRate(int rate);
66  int BestSupportedRate();
67  AudioFormat GetNextFormat();
68  void AddSupportedFormat(AudioFormat format);
69  bool IsSupportedFormat(AudioFormat format);
70  AudioFormat BestSupportedFormat();
71  static int FormatToBits(AudioFormat format);
72  static const char* FormatToString(AudioFormat format);
73  static int SampleSize(AudioFormat format);
74  static AudioFormat AVSampleFormatToFormat(AVSampleFormat format, int bits = 0);
75  static AVSampleFormat FormatToAVSampleFormat(AudioFormat format);
76  void AddSupportedChannels(int channels);
77  bool IsSupportedChannels(int channels);
78  int BestSupportedChannels();
79 
80  void setPassthrough(int val) { m_passthrough = val; };
81  int canPassthrough() const { return m_passthrough; };
93  { return (m_features & arg) != 0U; };
94  bool canFeature(unsigned int arg) const
95  { return (m_features & arg) != 0U; };
96 
101  bool canAC3() const { return canFeature(FEATURE_AC3); };
106  bool canDTS() const { return canFeature(FEATURE_DTS); };
111  bool canLPCM() const { return canFeature(FEATURE_LPCM); };
117  bool IsInvalid() const { return m_invalid; };
118 
129  void setFeature(DigitalFeature arg) { m_features |= arg; };
130  void setFeature(unsigned int arg) { m_features |= arg; };
131 
135  void setFeature(bool val, DigitalFeature arg);
136  void setFeature(bool val, int arg);
137 
142  void SetBestSupportedChannels(int channels);
143 
148  int GetMaxHDRate() const;
149 
154  static QString FeaturesToString(DigitalFeature arg);
155  QString FeaturesToString(void) const
156  { return FeaturesToString((DigitalFeature)m_features); };
157 
161  static QString GetPassthroughParams(int codec, int codec_profile,
162  int &samplerate, int &channels,
163  bool canDTSHDMA);
164 
165  // ELD related methods
166 
170  bool hasELD() const;
171  bool hasValidELD();
175  void setELD(QByteArray *ba);
179  ELD &getELD(void) { return m_eld; };
183  int BestSupportedChannelsELD();
187  int BestSupportedPCMChannelsELD();
188 
189  private:
190  void SortSupportedChannels();
191 
197  int m_passthrough {-1};
198 
199  unsigned int m_features {FEATURE_NONE};
200 
201  bool m_invalid {false};
208  bool m_hasEld {false};
210 
211  std::vector<int> m_sr, m_rates, m_channels;
212  std::vector<AudioFormat> m_sf, m_formats;
213  std::vector<int>::iterator m_srIt;
214  std::vector<AudioFormat>::iterator m_sfIt;
215 };
216 
217 #endif // AUDIO_OUTPUT_SETTINGS_H
FORMAT_U8
@ FORMAT_U8
Definition: audiooutputsettings.h:27
FORMAT_NONE
@ FORMAT_NONE
Definition: audiooutputsettings.h:26
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
AudioOutputSettings::m_sfIt
std::vector< AudioFormat >::iterator m_sfIt
Definition: audiooutputsettings.h:214
AudioOutputSettings::setPassthrough
void setPassthrough(int val)
Definition: audiooutputsettings.h:80
AudioOutputSettings::m_srIt
std::vector< int >::iterator m_srIt
Definition: audiooutputsettings.h:213
FORMAT_S16
@ FORMAT_S16
Definition: audiooutputsettings.h:28
fmts
static const AudioFormat fmts[]
Definition: audiooutputsettings.h:49
mythexp.h
AudioOutputSettings::FeaturesToString
QString FeaturesToString(void) const
Definition: audiooutputsettings.h:155
FEATURE_AC3
@ FEATURE_AC3
Definition: audiooutputsettings.h:37
arg
arg(title).arg(filename).arg(doDelete))
FEATURE_TRUEHD
@ FEATURE_TRUEHD
Definition: audiooutputsettings.h:41
AudioOutputSettings::m_sf
std::vector< AudioFormat > m_sf
Definition: audiooutputsettings.h:212
FEATURE_EAC3
@ FEATURE_EAC3
Definition: audiooutputsettings.h:40
eldutils.h
ELD
Definition: eldutils.h:40
FEATURE_NONE
@ FEATURE_NONE
Definition: audiooutputsettings.h:36
AudioOutputSettings::canPassthrough
int canPassthrough() const
Definition: audiooutputsettings.h:81
FEATURE_DTS
@ FEATURE_DTS
Definition: audiooutputsettings.h:38
FORMAT_S24
@ FORMAT_S24
Definition: audiooutputsettings.h:30
srs
static const int srs[]
Definition: audiooutputsettings.h:46
FEATURE_AAC
@ FEATURE_AAC
Definition: audiooutputsettings.h:43
FORMAT_FLT
@ FORMAT_FLT
Definition: audiooutputsettings.h:32
FEATURE_LPCM
@ FEATURE_LPCM
Definition: audiooutputsettings.h:39
FORMAT_S32
@ FORMAT_S32
Definition: audiooutputsettings.h:31
AudioOutputSettings::canDTS
bool canDTS() const
return true if device can or may support DTS (deprecated, see canFeature())
Definition: audiooutputsettings.h:106
AudioOutputSettings::canFeature
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
Definition: audiooutputsettings.h:92
AudioOutputSettings::setFeature
void setFeature(unsigned int arg)
Definition: audiooutputsettings.h:130
AudioOutputSettings::setFeature
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
Definition: audiooutputsettings.h:129
AudioOutputSettings::IsInvalid
bool IsInvalid() const
return true if class instance is marked invalid.
Definition: audiooutputsettings.h:117
AudioOutputSettings::canFeature
bool canFeature(unsigned int arg) const
Definition: audiooutputsettings.h:94
AudioOutputSettings
Definition: audiooutputsettings.h:53
DigitalFeature
DigitalFeature
Definition: audiooutputsettings.h:35
AudioOutputSettings::getELD
ELD & getELD(void)
retrieve ELD data
Definition: audiooutputsettings.h:179
AudioOutputSettings::canLPCM
bool canLPCM() const
return true if device supports multichannels PCM (deprecated, see canFeature())
Definition: audiooutputsettings.h:111
AudioOutputSettings::m_eld
ELD m_eld
Definition: audiooutputsettings.h:209
AudioOutputSettings::m_sr
std::vector< int > m_sr
Definition: audiooutputsettings.h:211
AudioFormat
AudioFormat
Definition: audiooutputsettings.h:25
FEATURE_DTSHD
@ FEATURE_DTSHD
Definition: audiooutputsettings.h:42
FORMAT_S24LSB
@ FORMAT_S24LSB
Definition: audiooutputsettings.h:29
AudioOutputSettings::AudioOutputSettings
AudioOutputSettings(const AudioOutputSettings &)=default
AudioOutputSettings::canAC3
bool canAC3() const
return true if device can or may support AC3 (deprecated, see canFeature())
Definition: audiooutputsettings.h:101