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 // TODO(erickung): Remove constructor once CMA backend implementation does't |
| 77 // create a new object to reset the configuration and use IsValidConfig() to |
| 78 // determine if the configuration is still valid or not. |
| 79 struct AudioConfig { |
| 80 AudioConfig() |
| 81 : codec(kAudioCodecUnknown), |
| 82 bytes_per_channel(0), |
| 83 channel_number(0), |
| 84 samples_per_second(0), |
| 85 extra_data(nullptr), |
| 86 extra_data_size(0), |
| 87 is_encrypted(false) {} |
| 88 |
| 89 // Audio codec. |
| 90 AudioCodec codec; |
| 91 // Number of bytes in each channel. |
| 92 int bytes_per_channel; |
| 93 // Number of channels in this audio stream. |
| 94 int channel_number; |
| 95 // Number of audio samples per second. |
| 96 int samples_per_second; |
| 97 // Pointer to extra data buffer for certain codec initialization. The memory |
| 98 // is allocated outside this structure. Consumers of the structure should make |
| 99 // a copy if it is expected to be used beyond the function ends. |
| 100 const uint8_t* extra_data; |
| 101 // Size of extra data in bytes. |
| 102 int extra_data_size; |
| 103 // content is encrypted or not. |
| 104 bool is_encrypted; |
| 105 }; |
| 106 |
| 107 // TODO(erickung): Remove constructor once CMA backend implementation does't |
| 108 // create a new object to reset the configuration and use IsValidConfig() to |
| 109 // determine if the configuration is still valid or not. |
| 110 struct VideoConfig { |
| 111 VideoConfig() |
| 112 : codec(kVideoCodecUnknown), |
| 113 profile(kVideoProfileUnknown), |
| 114 additional_config(nullptr), |
| 115 extra_data(nullptr), |
| 116 extra_data_size(0), |
| 117 is_encrypted(false) {} |
| 118 |
| 119 // Video codec. |
| 120 VideoCodec codec; |
| 121 // Video codec profile. |
| 122 VideoProfile profile; |
| 123 // Both |additional_config| and |extra_data| are the pointers to the object |
| 124 // memory that are allocated outside this structure. Consumers of the |
| 125 // structure should make a copy if it is expected to be used beyond the |
| 126 // function ends. |
| 127 // Additional video config for the video stream if available. |
| 128 VideoConfig* additional_config; |
| 129 // Pointer to extra data buffer for certain codec initialization. |
| 130 const uint8_t* extra_data; |
| 131 // Size of extra data in bytes. |
| 132 int extra_data_size; |
| 133 // content is encrypted or not. |
| 134 bool is_encrypted; |
| 135 }; |
| 136 |
| 137 // TODO(erickung): Remove following two inline IsValidConfig() functions. These |
| 138 // are to keep existing CMA backend implementation consistent until the clean up |
| 139 // is done. These SHOULD NOT be used in New CMA backend implementation. |
| 140 inline bool IsValidConfig(const AudioConfig& config) { |
| 141 return config.codec >= kAudioCodecMin && |
| 142 config.codec <= kAudioCodecMax && |
| 143 config.channel_number > 0 && |
| 144 config.bytes_per_channel > 0 && |
| 145 config.bytes_per_channel <= kMaxBytesPerSample && |
| 146 config.samples_per_second > 0 && |
| 147 config.samples_per_second <= kMaxSampleRate; |
| 148 } |
| 149 |
| 150 inline bool IsValidConfig(const VideoConfig& config) { |
| 151 return config.codec >= kVideoCodecMin && config.codec <= kVideoCodecMax; |
| 152 } |
| 153 |
| 154 } // namespace media |
| 155 } // namespace chromecast |
| 156 |
| 157 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ |
OLD | NEW |