1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
6 #define CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_
11 #include "stream_id.h"
13 namespace chromecast
{
16 // Maximum audio bytes per sample.
17 static const int kMaxBytesPerSample
= 4;
19 // Maximum audio sampling rate.
20 static const int kMaxSampleRate
= 192000;
23 kAudioCodecUnknown
= 0,
34 kAudioCodecMin
= kAudioCodecUnknown
,
35 kAudioCodecMax
= kCodecDTS
,
39 kUnknownSampleFormat
= 0,
40 kSampleFormatU8
, // Unsigned 8-bit w/ bias of 128.
41 kSampleFormatS16
, // Signed 16-bit.
42 kSampleFormatS32
, // Signed 32-bit.
43 kSampleFormatF32
, // Float 32-bit.
44 kSampleFormatPlanarS16
, // Signed 16-bit planar.
45 kSampleFormatPlanarF32
, // Float 32-bit planar.
46 kSampleFormatPlanarS32
, // Signed 32-bit planar.
48 kSampleFormatMin
= kUnknownSampleFormat
,
49 kSampleFormatMax
= kSampleFormatPlanarS32
,
53 kVideoCodecUnknown
= 0,
63 kVideoCodecMin
= kVideoCodecUnknown
,
64 kVideoCodecMax
= kCodecHEVC
,
67 // Profile for Video codec.
69 kVideoProfileUnknown
= 0,
76 kH264High444Predictive
,
77 kH264ScalableBaseline
,
84 kVideoProfileMin
= kVideoProfileUnknown
,
85 kVideoProfileMax
= kVP9ProfileAny
,
88 // TODO(erickung): Remove constructor once CMA backend implementation does't
89 // create a new object to reset the configuration and use IsValidConfig() to
90 // determine if the configuration is still valid or not.
94 codec(kAudioCodecUnknown
),
95 sample_format(kUnknownSampleFormat
),
98 samples_per_second(0),
101 is_encrypted(false) {}
107 // The format of each audio sample.
108 SampleFormat sample_format
;
109 // Number of bytes in each channel.
110 int bytes_per_channel
;
111 // Number of channels in this audio stream.
113 // Number of audio samples per second.
114 int samples_per_second
;
115 // Pointer to extra data buffer for certain codec initialization. The memory
116 // is allocated outside this structure. Consumers of the structure should make
117 // a copy if it is expected to be used beyond the function ends.
118 const uint8_t* extra_data
;
119 // Size of extra data in bytes.
121 // content is encrypted or not.
125 // TODO(erickung): Remove constructor once CMA backend implementation does't
126 // create a new object to reset the configuration and use IsValidConfig() to
127 // determine if the configuration is still valid or not.
131 codec(kVideoCodecUnknown
),
132 profile(kVideoProfileUnknown
),
133 additional_config(nullptr),
136 is_encrypted(false) {}
142 // Video codec profile.
143 VideoProfile profile
;
144 // Both |additional_config| and |extra_data| are the pointers to the object
145 // memory that are allocated outside this structure. Consumers of the
146 // structure should make a copy if it is expected to be used beyond the
148 // Additional video config for the video stream if available.
149 VideoConfig
* additional_config
;
150 // Pointer to extra data buffer for certain codec initialization.
151 const uint8_t* extra_data
;
152 // Size of extra data in bytes.
154 // content is encrypted or not.
158 // TODO(erickung): Remove following two inline IsValidConfig() functions. These
159 // are to keep existing CMA backend implementation consistent until the clean up
160 // is done. These SHOULD NOT be used in New CMA backend implementation.
161 inline bool IsValidConfig(const AudioConfig
& config
) {
162 return config
.codec
>= kAudioCodecMin
&&
163 config
.codec
<= kAudioCodecMax
&&
164 config
.codec
!= kAudioCodecUnknown
&&
165 config
.sample_format
>= kSampleFormatMin
&&
166 config
.sample_format
<= kSampleFormatMax
&&
167 config
.sample_format
!= kUnknownSampleFormat
&&
168 config
.channel_number
> 0 &&
169 config
.bytes_per_channel
> 0 &&
170 config
.bytes_per_channel
<= kMaxBytesPerSample
&&
171 config
.samples_per_second
> 0 &&
172 config
.samples_per_second
<= kMaxSampleRate
;
175 inline bool IsValidConfig(const VideoConfig
& config
) {
176 return config
.codec
>= kVideoCodecMin
&&
177 config
.codec
<= kVideoCodecMax
&&
178 config
.codec
!= kVideoCodecUnknown
;
182 } // namespace chromecast
184 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_