00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _AUDIO_OUTPUT_SETTINGS_H_
00010 #define _AUDIO_OUTPUT_SETTINGS_H_
00011
00012 #include <vector>
00013
00014 #include "mythexp.h"
00015 #include <QString>
00016
00017 extern "C" {
00018 #include "libavcodec/avcodec.h"
00019 }
00020 #include "eldutils.h"
00021
00022 using namespace std;
00023
00024 typedef enum {
00025 FORMAT_NONE = 0,
00026 FORMAT_U8,
00027 FORMAT_S16,
00028 FORMAT_S24LSB,
00029 FORMAT_S24,
00030 FORMAT_S32,
00031 FORMAT_FLT
00032 } AudioFormat;
00033
00034 typedef enum {
00035 FEATURE_NONE = 0,
00036 FEATURE_AC3 = 1 << 0,
00037 FEATURE_DTS = 1 << 1,
00038 FEATURE_LPCM = 1 << 2,
00039 FEATURE_EAC3 = 1 << 3,
00040 FEATURE_TRUEHD = 1 << 4,
00041 FEATURE_DTSHD = 1 << 5,
00042 FEATURE_AAC = 1 << 6,
00043 } DigitalFeature;
00044
00045 static const int srs[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
00046 48000, 88200, 96000, 176400, 192000 };
00047
00048 static const AudioFormat fmts[] = { FORMAT_U8, FORMAT_S16, FORMAT_S24LSB,
00049 FORMAT_S24, FORMAT_S32, FORMAT_FLT };
00050
00051 class MPUBLIC AudioOutputSettings
00052 {
00053 public:
00054 AudioOutputSettings(bool invalid = false);
00055 ~AudioOutputSettings();
00056 AudioOutputSettings& operator=(const AudioOutputSettings&);
00057 AudioOutputSettings *GetCleaned(bool newcopy = false);
00058 AudioOutputSettings *GetUsers(bool newcopy = false);
00059
00060 int GetNextRate();
00061 void AddSupportedRate(int rate);
00062 bool IsSupportedRate(int rate);
00063 int NearestSupportedRate(int rate);
00064 int BestSupportedRate();
00065 AudioFormat GetNextFormat();
00066 void AddSupportedFormat(AudioFormat format);
00067 bool IsSupportedFormat(AudioFormat format);
00068 AudioFormat BestSupportedFormat();
00069 static int FormatToBits(AudioFormat format);
00070 static const char* FormatToString(AudioFormat format);
00071 static int SampleSize(AudioFormat format);
00072 void AddSupportedChannels(int channels);
00073 bool IsSupportedChannels(int channels);
00074 int BestSupportedChannels();
00075
00076 void setPassthrough(int val) { m_passthrough = val; };
00077 int canPassthrough() { return m_passthrough; };
00088 bool canFeature(DigitalFeature arg)
00089 { return m_features & arg; };
00090 bool canFeature(unsigned int arg)
00091 { return m_features & arg; };
00092
00097 bool canAC3() { return m_features & FEATURE_AC3; };
00102 bool canDTS() { return m_features & FEATURE_DTS; };
00107 bool canLPCM() { return m_features & FEATURE_LPCM; };
00113 bool IsInvalid() { return m_invalid; };
00114
00125 void setFeature(DigitalFeature arg) { m_features |= arg; };
00126 void setFeature(unsigned int arg) { m_features |= arg; };
00127
00131 void setFeature(bool val, DigitalFeature arg);
00132 void setFeature(bool val, int arg);
00133
00138 void SetBestSupportedChannels(int channels);
00139
00144 int GetMaxHDRate();
00145
00150 QString FeaturesToString(DigitalFeature arg);
00151 QString FeaturesToString(void)
00152 { return FeaturesToString((DigitalFeature)m_features); };
00153
00157 static QString GetPassthroughParams(int codec, int codec_profile,
00158 int &samplerate, int &channels,
00159 bool canDTSHDMA);
00160
00161
00162
00166 bool hasELD();
00167 bool hasValidELD();
00171 void setELD(QByteArray *ba);
00175 ELD &getELD(void) { return m_eld; };
00179 int BestSupportedChannelsELD();
00183 int BestSupportedPCMChannelsELD();
00184
00185 private:
00186 void SortSupportedChannels();
00187
00193 int m_passthrough;
00194
00195 unsigned int m_features;
00196
00197 bool m_invalid;
00204 bool m_has_eld;
00205 ELD m_eld;
00206
00207 vector<int> m_sr, m_rates, m_channels;
00208 vector<AudioFormat> m_sf, m_formats;
00209 vector<int>::iterator m_sr_it;
00210 vector<AudioFormat>::iterator m_sf_it;
00211 };
00212
00213 #endif // _AUDIO_OUTPUT_SETTINGS_H_