OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ | |
6 #define CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ | |
7 | |
8 #include <stdint.h> | |
9 #include <vector> | |
10 | |
11 namespace chromecast { | |
12 namespace media { | |
13 | |
14 namespace { | |
15 | |
16 // Maximum audio bytes per sample. | |
17 static const int kMaxBytesPerSample = 4; | |
18 | |
19 // Maximum audio sampling rate. | |
20 static const int kMaxSampleRate = 192000; | |
21 | |
22 } // namespace | |
23 | |
24 enum AudioCodec { | |
25 kAudioCodecUnknown = -1, | |
26 | |
27 kAudioCodecMin = 0, | |
28 kCodecAAC = kAudioCodecMin, | |
29 kCodecMP3, | |
30 kCodecPCM, | |
31 kCodecPCM_S16BE, | |
32 kCodecVorbis, | |
33 kCodecOpus, | |
34 kCodecEAC3, | |
35 kCodecAC3, | |
36 kCodecDTS, | |
37 kAudioCodecMax = kCodecDTS, | |
38 }; | |
39 | |
40 enum VideoCodec { | |
41 kVideoCodecUnknown = -1, | |
42 | |
43 kVideoCodecMin = 0, | |
44 kCodecH264 = kVideoCodecMin, | |
45 kCodecVC1, | |
46 kCodecMPEG2, | |
47 kCodecMPEG4, | |
48 kCodecTheora, | |
49 kCodecVP8, | |
50 kCodecVP9, | |
51 kCodecHEVC, | |
52 kVideoCodecMax = kCodecHEVC, | |
53 }; | |
54 | |
55 // Profile for Video codec. | |
56 enum VideoProfile { | |
57 kVideoProfileUnknown = -1, | |
58 | |
59 kVideoProfileMin = 0, | |
60 kH264Baseline = kVideoProfileMin, | |
61 kH264Main, | |
62 kH264Extended, | |
63 kH264High, | |
64 kH264High10, | |
65 kH264High422, | |
66 kH264High444Predictive, | |
67 kH264ScalableBaseline, | |
68 kH264ScalableHigh, | |
69 kH264Stereohigh, | |
70 kH264MultiviewHigh, | |
71 kVP8ProfileAny, | |
72 kVP9ProfileAny, | |
73 kVideoProfileMax = kVP9ProfileAny, | |
74 }; | |
75 | |
76 struct AudioConfig { | |
77 AudioConfig() | |
78 : codec(kAudioCodecUnknown), | |
79 bytes_per_channel(0), | |
80 channel_number(0), | |
81 samples_per_second(0), | |
82 extra_data(nullptr), | |
83 extra_data_size(0), | |
84 is_encrypted(false) {} | |
85 | |
86 // Audio codec. | |
87 AudioCodec codec; | |
88 // Number of bytes in each channel. | |
89 int bytes_per_channel; | |
90 // Number of channels in this audio stream. | |
91 int channel_number; | |
92 // Number of audio samples per second. | |
93 int samples_per_second; | |
94 // Pointer to extra data buffer for certain codec initialization. The memory | |
95 // is allocated outside this structure. Consumers of the structure should make | |
96 // a copy if it is expected to be used beyond the function ends. | |
97 const uint8_t* extra_data; | |
98 // Size of extra data in bytes. | |
99 int extra_data_size; | |
100 // content is encrypted or not. | |
101 bool is_encrypted; | |
102 }; | |
103 | |
104 struct VideoConfig { | |
105 VideoConfig() | |
106 : codec(kVideoCodecUnknown), | |
107 profile(kVideoProfileUnknown), | |
108 additional_config(nullptr), | |
109 extra_data(nullptr), | |
110 extra_data_size(0), | |
111 is_encrypted(false) {} | |
112 | |
113 // Video codec. | |
114 VideoCodec codec; | |
115 // Video codec profile. | |
116 VideoProfile profile; | |
117 // Both |additional_config| and |extra_data| are the pointers to the object | |
118 // memory that are allocated outside this structure. Consumers of the | |
119 // structure should make a copy if it is expected to be used beyond the | |
120 // function ends. | |
121 // Additional video config for the video stream if available. | |
122 VideoConfig* additional_config; | |
123 // Pointer to extra data buffer for certain codec initialization. | |
124 const uint8_t* extra_data; | |
125 // Size of extra data in bytes. | |
126 int extra_data_size; | |
127 // content is encrypted or not. | |
128 bool is_encrypted; | |
129 }; | |
130 | |
131 // TODO(erickung): Remove following two inline IsValidConfig() functions. These | |
132 // are to keep existing CMA backend implementation consistent until the clean up | |
133 // is done. These SHOULD NOT be used in New CMA backend implementation. | |
gunsch-google
2015/05/06 01:32:42
Per your response to my earlier comments, please a
| |
134 inline bool IsValidConfig(const AudioConfig& config) { | |
135 return config.codec >= kAudioCodecMin && | |
136 config.codec <= kAudioCodecMax && | |
137 config.channel_number > 0 && | |
138 config.bytes_per_channel > 0 && | |
139 config.bytes_per_channel <= kMaxBytesPerSample && | |
140 config.samples_per_second > 0 && | |
141 config.samples_per_second <= kMaxSampleRate; | |
142 } | |
143 | |
144 inline bool IsValidConfig(const VideoConfig& config) { | |
145 return config.codec >= kVideoCodecMin && config.codec <= kVideoCodecMax; | |
146 } | |
147 | |
148 } // namespace media | |
149 } // namespace chromecast | |
150 | |
151 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ | |
OLD | NEW |