Chromium Code Reviews| 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 = 1, | |
| 62 kH264Extended = 2, | |
| 63 kH264High = 3, | |
| 64 kH264High10 = 4, | |
| 65 kH264High422 = 5, | |
| 66 kH264High444Predictive = 6, | |
| 67 kH264ScalableBaseline = 7, | |
| 68 kH264ScalableHigh = 8, | |
| 69 kH264Stereohigh = 9, | |
| 70 kH264MultiviewHigh = 10, | |
| 71 kVP8ProfileAny = 11, | |
| 72 kVP9ProfileAny = 12, | |
| 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) {} | |
|
gunsch
2015/05/05 16:54:22
Hmm, do we need these ctors? Would prefer not to d
erickung1
2015/05/05 17:23:45
please see my next comment. I think we should, how
| |
| 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. Note the | |
| 95 // structure only passes the pointer of data buffer and does not own memory | |
| 96 // responsibility. | |
| 97 const uint8_t* extra_data; | |
| 98 // Size of extra data in bytes. | |
|
gunsch
2015/05/06 02:52:35
Whoa, I just noticed this change... why did we cha
erickung1
2015/05/06 03:01:33
using std:vector will require constructor/destruct
gunsch
2015/05/06 03:08:44
I'm probably going to insist. The OEM implementati
| |
| 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 // Additional video config for the video stream if available. | |
| 118 VideoConfig* additional_config; | |
| 119 // Pointer to extra data buffer for certain codec initialization. Note the | |
| 120 // structure only passes the pointer of data buffer and does not own memory | |
| 121 // responsibility. | |
| 122 const uint8_t* extra_data; | |
| 123 // Size of extra data in bytes. | |
| 124 int extra_data_size; | |
| 125 // content is encrypted or not. | |
| 126 bool is_encrypted; | |
| 127 }; | |
| 128 | |
| 129 inline bool IsValidConfig(const AudioConfig& config) { | |
|
gunsch
2015/05/05 16:54:22
Per Le-Chun's earlier question, do we actually nee
erickung1
2015/05/05 17:23:44
Existing OEM implementaion tends do following
1. k
gunsch
2015/05/05 17:30:35
I'm hearing arguments that it makes migration easi
erickung1
2015/05/05 20:18:05
Done.
| |
| 130 return config.codec >= kAudioCodecMin && | |
| 131 config.codec <= kAudioCodecMax && | |
| 132 config.channel_number > 0 && | |
| 133 config.bytes_per_channel > 0 && | |
| 134 config.bytes_per_channel <= kMaxBytesPerSample && | |
| 135 config.samples_per_second > 0 && | |
| 136 config.samples_per_second <= kMaxSampleRate; | |
| 137 } | |
| 138 | |
| 139 inline bool IsValidConfig(const VideoConfig& config) { | |
| 140 return config.codec >= kVideoCodecMin && config.codec <= kVideoCodecMax; | |
| 141 } | |
| 142 | |
| 143 } // namespace media | |
| 144 } // namespace chromecast | |
| 145 | |
| 146 #endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ | |
| OLD | NEW |