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 <vector>
13 
14 #include "mythexp.h"
15 #include "mythconfig.h"
16 
17 #include <QString>
18 
19 extern "C" {
20 #include "libavcodec/avcodec.h" // to get codec id
21 }
22 #include "eldutils.h"
23 
32 };
33 
36  FEATURE_AC3 = 1 << 0,
37  FEATURE_DTS = 1 << 1,
38  FEATURE_LPCM = 1 << 2,
39  FEATURE_EAC3 = 1 << 3,
40  FEATURE_TRUEHD = 1 << 4,
41  FEATURE_DTSHD = 1 << 5,
42  FEATURE_AAC = 1 << 6,
43 };
44 
45 static const int srs[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
46  48000, 88200, 96000, 176400, 192000 };
47 
50 
52 {
53  public:
54  explicit AudioOutputSettings(bool invalid = false);
55  AudioOutputSettings(const AudioOutputSettings&) = default;
57  AudioOutputSettings& operator=(const AudioOutputSettings& /*rhs*/);
58  AudioOutputSettings *GetCleaned(bool newcopy = false);
59  AudioOutputSettings *GetUsers(bool newcopy = false);
60 
61  int GetNextRate();
62  void AddSupportedRate(int rate);
63  bool IsSupportedRate(int rate);
64  int NearestSupportedRate(int rate);
65  int BestSupportedRate();
66  AudioFormat GetNextFormat();
67  void AddSupportedFormat(AudioFormat format);
68  bool IsSupportedFormat(AudioFormat format);
69  AudioFormat BestSupportedFormat();
70  static int FormatToBits(AudioFormat format);
71  static const char* FormatToString(AudioFormat format);
72  static int SampleSize(AudioFormat format);
73  static AudioFormat AVSampleFormatToFormat(AVSampleFormat format, int bits = 0);
74  static AVSampleFormat FormatToAVSampleFormat(AudioFormat format);
75  void AddSupportedChannels(int channels);
76  bool IsSupportedChannels(int channels);
77  int BestSupportedChannels();
78 
79  void setPassthrough(int val) { m_passthrough = val; };
80  int canPassthrough() const { return m_passthrough; };
91  bool canFeature(DigitalFeature arg) const
92  { return (m_features & arg) != 0U; };
93  bool canFeature(unsigned int arg) const
94  { return (m_features & arg) != 0U; };
95 
100  bool canAC3() const { return canFeature(FEATURE_AC3); };
105  bool canDTS() const { return canFeature(FEATURE_DTS); };
110  bool canLPCM() const { return canFeature(FEATURE_LPCM); };
116  bool IsInvalid() const { return m_invalid; };
117 
128  void setFeature(DigitalFeature arg) { m_features |= arg; };
129  void setFeature(unsigned int arg) { m_features |= arg; };
130 
134  void setFeature(bool val, DigitalFeature arg);
135  void setFeature(bool val, int arg);
136 
141  void SetBestSupportedChannels(int channels);
142 
147  int GetMaxHDRate() const;
148 
153  static QString FeaturesToString(DigitalFeature arg);
154  QString FeaturesToString(void) const
155  { return FeaturesToString((DigitalFeature)m_features); };
156 
160  static QString GetPassthroughParams(int codec, int codec_profile,
161  int &samplerate, int &channels,
162  bool canDTSHDMA);
163 
164  // ELD related methods
165 
169  bool hasELD() const;
170  bool hasValidELD();
174  void setELD(QByteArray *ba);
178  ELD &getELD(void) { return m_eld; };
182  int BestSupportedChannelsELD();
186  int BestSupportedPCMChannelsELD();
187 
188  private:
189  void SortSupportedChannels();
190 
196  int m_passthrough {-1};
197 
198  unsigned int m_features {FEATURE_NONE};
199 
200  bool m_invalid {false};
207  bool m_hasEld {false};
209 
210  std::vector<int> m_sr, m_rates, m_channels;
211  std::vector<AudioFormat> m_sf, m_formats;
212  std::vector<int>::iterator m_srIt;
213  std::vector<AudioFormat>::iterator m_sfIt;
214 };
215 
216 #endif // AUDIO_OUTPUT_SETTINGS_H
static const AudioFormat fmts[]
#define MPUBLIC
Definition: mythexp.h:10
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
Definition: eldutils.h:39
void setPassthrough(int val)
bool canAC3() const
return true if device can or may support AC3 (deprecated, see canFeature())
void setFeature(unsigned int arg)
std::vector< AudioFormat >::iterator m_sfIt
static const int srs[]
std::vector< AudioFormat > m_sf
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
ELD & getELD(void)
retrieve ELD data
bool canDTS() const
return true if device can or may support DTS (deprecated, see canFeature())
std::vector< int > m_sr
bool canLPCM() const
return true if device supports multichannels PCM (deprecated, see canFeature())
DigitalFeature
bool canFeature(unsigned int arg) const
QString FeaturesToString(void) const
std::vector< int >::iterator m_srIt
bool IsInvalid() const
return true if class instance is marked invalid.