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 
24 typedef enum {
32 } AudioFormat;
33 
34 typedef enum {
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,
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() { return m_passthrough; };
92  { return (m_features & arg) != 0U; };
93  bool canFeature(unsigned int arg)
94  { return (m_features & arg) != 0U; };
95 
100  bool canAC3() { return canFeature(FEATURE_AC3); };
105  bool canDTS() { return canFeature(FEATURE_DTS); };
110  bool canLPCM() { return canFeature(FEATURE_LPCM); };
116  bool IsInvalid() { 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();
148 
153  static QString FeaturesToString(DigitalFeature arg);
154  QString FeaturesToString(void)
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();
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_has_eld {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_sr_it;
213  std::vector<AudioFormat>::iterator m_sf_it;
214 };
215 
216 #endif // _AUDIO_OUTPUT_SETTINGS_H_
static const AudioFormat fmts[]
bool IsInvalid()
return true if class instance is marked invalid.
#define MPUBLIC
Definition: mythexp.h:10
Definition: eldutils.h:39
void setPassthrough(int val)
void setFeature(unsigned int arg)
bool canFeature(unsigned int arg)
static const int srs[]
std::vector< int >::iterator m_sr_it
std::vector< AudioFormat > m_sf
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
QString FeaturesToString(void)
ELD & getELD(void)
retrieve ELD data
bool canFeature(DigitalFeature arg)
return DigitalFeature mask.
std::vector< int > m_sr
std::vector< AudioFormat >::iterator m_sf_it
bool canLPCM()
return true if device supports multichannels PCM (deprecated, see canFeature())
DigitalFeature
bool canDTS()
return true if device can or may support DTS (deprecated, see canFeature())
bool canAC3()
return true if device can or may support AC3 (deprecated, see canFeature())