Chromium Code Reviews| Index: chromecast/public/media/decoder_config.h |
| diff --git a/chromecast/public/media/decoder_config.h b/chromecast/public/media/decoder_config.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1e0998fe69da42a7735854984c63050f08c5925b |
| --- /dev/null |
| +++ b/chromecast/public/media/decoder_config.h |
| @@ -0,0 +1,146 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ |
| +#define CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ |
| + |
| +#include <stdint.h> |
| +#include <vector> |
| + |
| +namespace chromecast { |
| +namespace media { |
| + |
| +namespace { |
| + |
| +// Maximum audio bytes per sample. |
| +static const int kMaxBytesPerSample = 4; |
| + |
| +// Maximum audio sampling rate. |
| +static const int kMaxSampleRate = 192000; |
| + |
| +} // namespace |
| + |
| +enum AudioCodec { |
| + kAudioCodecUnknown = -1, |
| + |
| + kAudioCodecMin = 0, |
| + kCodecAAC = kAudioCodecMin, |
| + kCodecMP3, |
| + kCodecPCM, |
| + kCodecPCM_S16BE, |
| + kCodecVorbis, |
| + kCodecOpus, |
| + kCodecEAC3, |
| + kCodecAC3, |
| + kCodecDTS, |
| + kAudioCodecMax = kCodecDTS, |
| +}; |
| + |
| +enum VideoCodec { |
| + kVideoCodecUnknown = -1, |
| + |
| + kVideoCodecMin = 0, |
| + kCodecH264 = kVideoCodecMin, |
| + kCodecVC1, |
| + kCodecMPEG2, |
| + kCodecMPEG4, |
| + kCodecTheora, |
| + kCodecVP8, |
| + kCodecVP9, |
| + kCodecHEVC, |
| + kVideoCodecMax = kCodecHEVC, |
| +}; |
| + |
| +// Profile for Video codec. |
| +enum VideoProfile { |
| + kVideoProfileUnknown = -1, |
| + |
| + kVideoProfileMin = 0, |
| + kH264Baseline = kVideoProfileMin, |
| + kH264Main = 1, |
| + kH264Extended = 2, |
| + kH264High = 3, |
| + kH264High10 = 4, |
| + kH264High422 = 5, |
| + kH264High444Predictive = 6, |
| + kH264ScalableBaseline = 7, |
| + kH264ScalableHigh = 8, |
| + kH264Stereohigh = 9, |
| + kH264MultiviewHigh = 10, |
| + kVP8ProfileAny = 11, |
| + kVP9ProfileAny = 12, |
| + kVideoProfileMax = kVP9ProfileAny, |
| +}; |
| + |
| +struct AudioConfig { |
| + AudioConfig() |
| + : codec(kAudioCodecUnknown), |
| + bytes_per_channel(0), |
| + channel_number(0), |
| + samples_per_second(0), |
| + extra_data(nullptr), |
| + extra_data_size(0), |
| + 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
|
| + |
| + // Audio codec. |
| + AudioCodec codec; |
| + // Number of bytes in each channel. |
| + int bytes_per_channel; |
| + // Number of channels in this audio stream. |
| + int channel_number; |
| + // Number of audio samples per second. |
| + int samples_per_second; |
| + // Pointer to extra data buffer for certain codec initialization. Note the |
| + // structure only passes the pointer of data buffer and does not own memory |
| + // responsibility. |
| + const uint8_t* extra_data; |
| + // 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
|
| + int extra_data_size; |
| + // content is encrypted or not. |
| + bool is_encrypted; |
| +}; |
| + |
| +struct VideoConfig { |
| + VideoConfig() |
| + : codec(kVideoCodecUnknown), |
| + profile(kVideoProfileUnknown), |
| + additional_config(nullptr), |
| + extra_data(nullptr), |
| + extra_data_size(0), |
| + is_encrypted(false) {} |
| + |
| + // Video codec. |
| + VideoCodec codec; |
| + // Video codec profile. |
| + VideoProfile profile; |
| + // Additional video config for the video stream if available. |
| + VideoConfig* additional_config; |
| + // Pointer to extra data buffer for certain codec initialization. Note the |
| + // structure only passes the pointer of data buffer and does not own memory |
| + // responsibility. |
| + const uint8_t* extra_data; |
| + // Size of extra data in bytes. |
| + int extra_data_size; |
| + // content is encrypted or not. |
| + bool is_encrypted; |
| +}; |
| + |
| +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.
|
| + return config.codec >= kAudioCodecMin && |
| + config.codec <= kAudioCodecMax && |
| + config.channel_number > 0 && |
| + config.bytes_per_channel > 0 && |
| + config.bytes_per_channel <= kMaxBytesPerSample && |
| + config.samples_per_second > 0 && |
| + config.samples_per_second <= kMaxSampleRate; |
| +} |
| + |
| +inline bool IsValidConfig(const VideoConfig& config) { |
| + return config.codec >= kVideoCodecMin && config.codec <= kVideoCodecMax; |
| +} |
| + |
| +} // namespace media |
| +} // namespace chromecast |
| + |
| +#endif // CHROMECAST_PUBLIC_MEDIA_DECODER_CONFIG_H_ |