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 "libmyth/mythexp.h"
16
17#include <QString>
18
19extern "C" {
20#include "libavcodec/avcodec.h" // to get codec id
21}
22#include "eldutils.h"
23
24enum AudioFormat : std::uint8_t {
32};
33
34enum DigitalFeature : std::uint8_t {
36 FEATURE_AC3 = 1 << 0,
37 FEATURE_DTS = 1 << 1,
38 FEATURE_LPCM = 1 << 2,
39 FEATURE_EAC3 = 1 << 3,
41 FEATURE_DTSHD = 1 << 5,
42 FEATURE_AAC = 1 << 6,
43};
44
45using rate_array = std::array<const int,12>;
46using format_array = std::array<const AudioFormat,6>;
47
49{
50 public:
51 explicit AudioOutputSettings(bool invalid = false);
54 AudioOutputSettings& operator=(const AudioOutputSettings& /*rhs*/);
55 AudioOutputSettings *GetCleaned(bool newcopy = false);
56 AudioOutputSettings *GetUsers(bool newcopy = false);
57
58 int GetNextRate();
59 void AddSupportedRate(int rate);
60 bool IsSupportedRate(int rate);
61 int NearestSupportedRate(int rate);
62 int BestSupportedRate();
63 AudioFormat GetNextFormat();
64 void AddSupportedFormat(AudioFormat format);
65 bool IsSupportedFormat(AudioFormat format);
66 AudioFormat BestSupportedFormat();
67 static int FormatToBits(AudioFormat format);
68 static const char* FormatToString(AudioFormat format);
69 static int SampleSize(AudioFormat format);
70 static AudioFormat AVSampleFormatToFormat(AVSampleFormat format, int bits = 0);
71 static AVSampleFormat FormatToAVSampleFormat(AudioFormat format);
72 void AddSupportedChannels(int channels);
73 bool IsSupportedChannels(int channels);
74 int BestSupportedChannels();
75
76 void setPassthrough(int val) { m_passthrough = val; };
77 int canPassthrough() const { return m_passthrough; };
88 bool canFeature(DigitalFeature arg) const
89 { return (m_features & arg) != 0U; };
90 bool canFeature(unsigned int arg) const
91 { return (m_features & arg) != 0U; };
92
97 bool canAC3() const { return canFeature(FEATURE_AC3); };
102 bool canDTS() const { return canFeature(FEATURE_DTS); };
107 bool canLPCM() const { return canFeature(FEATURE_LPCM); };
113 bool IsInvalid() const { return m_invalid; };
114
125 void setFeature(DigitalFeature arg) { m_features |= arg; };
126 void setFeature(unsigned int arg) { m_features |= arg; };
127
131 void setFeature(bool val, DigitalFeature arg);
132 void setFeature(bool val, int arg);
133
138 void SetBestSupportedChannels(int channels);
139
144 int GetMaxHDRate() const;
145
150 static QString FeaturesToString(DigitalFeature arg);
151 QString FeaturesToString(void) const
152 { return FeaturesToString((DigitalFeature)m_features); };
153
157 static QString GetPassthroughParams(int codec, int codec_profile,
158 int &samplerate, int &channels,
159 bool canDTSHDMA);
160
161 // ELD related methods
162
166 bool hasELD() const;
167 bool hasValidELD();
171 void setELD(QByteArray *ba);
175 eld &getELD(void) { return m_eld; };
179 int BestSupportedChannelsELD();
183 int BestSupportedPCMChannelsELD();
184
185 private:
186 void SortSupportedChannels();
187
193 int m_passthrough {-1};
194
195 unsigned int m_features {FEATURE_NONE};
196
197 bool m_invalid {false};
204 bool m_hasEld {false};
206
207 std::vector<int> m_rates;
208 std::vector<int> m_channels;
209 std::vector<AudioFormat> m_formats;
210 rate_array::iterator m_srIt { };
211 format_array::iterator m_sfIt { };
212
213 static const rate_array kStdRates;
215};
216
217#endif // AUDIO_OUTPUT_SETTINGS_H
std::array< const int, 12 > rate_array
std::array< const AudioFormat, 6 > format_array
@ FORMAT_U8
@ FORMAT_S32
@ FORMAT_S24
@ FORMAT_NONE
@ FORMAT_FLT
@ FORMAT_S16
@ FORMAT_S24LSB
DigitalFeature
@ FEATURE_DTS
@ FEATURE_AC3
@ FEATURE_DTSHD
@ FEATURE_NONE
@ FEATURE_EAC3
@ FEATURE_LPCM
@ FEATURE_TRUEHD
@ FEATURE_AAC
QString FeaturesToString(void) const
eld & getELD(void)
retrieve ELD data
AudioOutputSettings(const AudioOutputSettings &)=default
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
std::vector< AudioFormat > m_formats
bool canLPCM() const
return true if device supports multichannels PCM (deprecated, see canFeature())
bool canAC3() const
return true if device can or may support AC3 (deprecated, see canFeature())
bool canFeature(unsigned int arg) const
static const format_array kStdFormats
void setFeature(unsigned int arg)
std::vector< int > m_rates
std::vector< int > m_channels
void setPassthrough(int val)
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
bool canDTS() const
return true if device can or may support DTS (deprecated, see canFeature())
static const rate_array kStdRates
bool IsInvalid() const
return true if class instance is marked invalid.
Definition: eldutils.h:38
#define MPUBLIC
Definition: mythexp.h:10