Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
gunsch
2015/04/13 23:46:20
update
erickung1
2015/04/15 22:13:18
Done. merge both VideoConfig/AudioConfig into sing
| |
| 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_MEDIA_CMA_PUBLIC_AUDIO_CONFIG_H_ | |
|
gunsch
2015/04/13 23:46:20
move to chromecast/public/media/audio_config.h
erickung1
2015/04/15 22:13:18
Done.
| |
| 6 #define CHROMECAST_MEDIA_CMA_PUBLIC_AUDIO_CONFIG_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "media/base/channel_layout.h" | |
| 14 #include "media/base/media_export.h" | |
| 15 | |
| 16 namespace chromecast { | |
| 17 namespace media { | |
| 18 | |
| 19 class AudioConfig { | |
|
lcwu1
2015/04/13 23:55:42
A high-level comment: I would prefer the cast audi
erickung1
2015/04/15 22:13:18
Done the first part, leave CMA interface refactori
| |
| 20 public: | |
| 21 // It maps to ::media::AudioCodec in src/media/base/audio_decoder_config.h | |
| 22 enum Codec { | |
| 23 kUnknownAudioCodec = 0, | |
|
gunsch
2015/04/13 23:46:20
I'd rather stick with only the things that we have
erickung1
2015/04/15 22:13:18
Done.
| |
| 24 kCodecAAC = 1, | |
| 25 kCodecMP3 = 2, | |
| 26 kCodecPCM = 3, | |
| 27 kCodecVorbis = 4, | |
| 28 kCodecFLAC = 5, | |
| 29 kCodecAMR_NB = 6, | |
| 30 kCodecAMR_WB = 7, | |
| 31 kCodecPCM_MULAW = 8, | |
| 32 kCodecGSM_MS = 9, | |
| 33 kCodecPCM_S16BE = 10, | |
| 34 kCodecPCM_S24BE = 11, | |
| 35 kCodecOpus = 12, | |
| 36 // kCodecEAC3 = 13, | |
| 37 kCodecPCM_ALAW = 14, | |
| 38 kCodecALAC = 15, | |
| 39 kAudioCodecMax = kCodecALAC, | |
| 40 }; | |
| 41 | |
| 42 // It maps to ::media::ChannelLayout in src/media/base/channel_layout.h | |
| 43 enum ChannelLayout { | |
| 44 CHANNEL_LAYOUT_NONE = 0, | |
| 45 CHANNEL_LAYOUT_UNSUPPORTED = 1, | |
| 46 // Front C | |
| 47 CHANNEL_LAYOUT_MONO = 2, | |
| 48 // Front L, Front R | |
| 49 CHANNEL_LAYOUT_STEREO = 3, | |
| 50 // Front L, Front R, Back C | |
| 51 CHANNEL_LAYOUT_2_1 = 4, | |
| 52 // Front L, Front R, Front C | |
| 53 CHANNEL_LAYOUT_SURROUND = 5, | |
| 54 // Front L, Front R, Front C, Back C | |
| 55 CHANNEL_LAYOUT_4_0 = 6, | |
| 56 // Front L, Front R, Side L, Side R | |
| 57 CHANNEL_LAYOUT_2_2 = 7, | |
| 58 // Front L, Front R, Back L, Back R | |
| 59 CHANNEL_LAYOUT_QUAD = 8, | |
| 60 // Front L, Front R, Front C, Side L, Side R | |
| 61 CHANNEL_LAYOUT_5_0 = 9, | |
| 62 // Front L, Front R, Front C, Side L, Side R, LFE | |
| 63 CHANNEL_LAYOUT_5_1 = 10, | |
| 64 // Front L, Front R, Front C, Back L, Back R | |
| 65 CHANNEL_LAYOUT_5_0_BACK = 11, | |
| 66 // Front L, Front R, Front C, Back L, Back R, LFE | |
| 67 CHANNEL_LAYOUT_5_1_BACK = 12, | |
| 68 // Front L, Front R, Front C, Side L, Side R, Back L, Back R | |
| 69 CHANNEL_LAYOUT_7_0 = 13, | |
| 70 // Front L, Front R, Front C, Side L, Side R, LFE, Back L, Back R | |
| 71 CHANNEL_LAYOUT_7_1 = 14, | |
| 72 // Front L, Front R, Front C, Side L, Side R, LFE, Front LofC, Front RofC | |
| 73 CHANNEL_LAYOUT_7_1_WIDE = 15, | |
| 74 // Stereo L, Stereo R | |
| 75 CHANNEL_LAYOUT_STEREO_DOWNMIX = 16, | |
| 76 // Stereo L, Stereo R, LFE | |
| 77 CHANNEL_LAYOUT_2POINT1 = 17, | |
| 78 // Stereo L, Stereo R, Front C, LFE | |
| 79 CHANNEL_LAYOUT_3_1 = 18, | |
| 80 // Stereo L, Stereo R, Front C, Rear C, LFE | |
| 81 CHANNEL_LAYOUT_4_1 = 19, | |
| 82 // Stereo L, Stereo R, Front C, Side L, Side R, Back C | |
| 83 CHANNEL_LAYOUT_6_0 = 20, | |
| 84 // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC | |
| 85 CHANNEL_LAYOUT_6_0_FRONT = 21, | |
| 86 // Stereo L, Stereo R, Side L, Side R, Front C, Rear C. | |
| 87 CHANNEL_LAYOUT_HEXAGONAL = 22, | |
| 88 // Stereo L, Stereo R, Side L, Side R, Front C, Rear Center, LFE | |
| 89 CHANNEL_LAYOUT_6_1 = 23, | |
| 90 // Stereo L, Stereo R, Back L, Back R, Front C, Rear Center, LFE | |
| 91 CHANNEL_LAYOUT_6_1_BACK = 24, | |
| 92 // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE | |
| 93 CHANNEL_LAYOUT_6_1_FRONT = 25, | |
| 94 // Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC | |
| 95 CHANNEL_LAYOUT_7_0_FRONT = 26, | |
| 96 // Front L, Front R, Front C, Back L, Back R, LFE, Front LofC, Front RofC | |
| 97 CHANNEL_LAYOUT_7_1_WIDE_BACK = 27, | |
| 98 // Front L, Front R, Front C, Side L, Side R, Rear C, Back L, Back R. | |
| 99 CHANNEL_LAYOUT_OCTAGONAL = 28, | |
| 100 // Channels are not explicitly mapped to speakers. | |
| 101 CHANNEL_LAYOUT_DISCRETE = 29, | |
| 102 // Front L, Front R, Front C. Front C contains the keyboard mic audio. This | |
| 103 // layout is only intended for input for WebRTC. The Front C channel | |
| 104 // is stripped away in the WebRTC audio input pipeline and never seen | |
| 105 // outside of that. | |
| 106 CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30, | |
| 107 // Front L, Front R, Side L, Side R, LFE | |
| 108 CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31, | |
| 109 // Max value, must always equal the largest entry ever logged. | |
| 110 CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_4_1_QUAD_SIDE | |
| 111 }; | |
| 112 | |
| 113 public: | |
| 114 AudioConfig(); | |
| 115 AudioConfig(Codec codec, | |
| 116 ChannelLayout channel_layout, | |
| 117 int channel_number, | |
| 118 int bytes_per_channel, | |
| 119 int samples_per_second, | |
| 120 const uint8* extra_data, | |
| 121 size_t extra_data_size, | |
| 122 bool is_encrypted); | |
| 123 ~AudioConfig(); | |
| 124 | |
| 125 void Initialize(Codec codec, | |
|
gunsch
2015/04/13 23:46:20
I don't like all the copies of methods from media/
erickung1
2015/04/15 22:13:18
Done.
| |
| 126 ChannelLayout channel_layout, | |
| 127 int channel_number, | |
| 128 int bytes_per_channel, | |
| 129 int samples_per_second, | |
| 130 const uint8* extra_data, | |
| 131 size_t extra_data_size, | |
| 132 bool is_encrypted); | |
| 133 | |
| 134 // Returns true if this object has appropriate configuration values, false | |
| 135 // otherwise. | |
| 136 bool IsValidConfig() const; | |
| 137 | |
| 138 // Returns true if all fields in |config| match this config. | |
| 139 // Note: The contents of |extra_data_| are compared not the raw pointers. | |
| 140 bool Matches(const AudioConfig& config) const; | |
| 141 | |
| 142 // Returns a human-readable string describing |*this|. For debugging & test | |
| 143 // output only. | |
| 144 std::string AsHumanReadableString() const; | |
| 145 std::string GetHumanReadableCodecName() const; | |
| 146 | |
| 147 Codec codec() const { return codec_; } | |
| 148 ChannelLayout channel_layout() const { return channel_layout_; } | |
| 149 int channel_number() const { return channel_number_; } | |
| 150 int bytes_per_channel() const { return bytes_per_channel_; } | |
| 151 int samples_per_second() const { return samples_per_second_; } | |
| 152 | |
| 153 // Optional byte data required to initialize audio decoders such as Vorbis | |
| 154 // codebooks. | |
| 155 const uint8* extra_data() const { | |
| 156 return extra_data_.empty() ? NULL : &extra_data_[0]; | |
| 157 } | |
| 158 size_t extra_data_size() const { return extra_data_.size(); } | |
| 159 | |
| 160 // Whether the audio stream is potentially encrypted. | |
| 161 // Note that in a potentially encrypted audio stream, individual buffers | |
| 162 // can be encrypted or not encrypted. | |
| 163 bool is_encrypted() const { return is_encrypted_; } | |
| 164 | |
| 165 private: | |
| 166 Codec codec_; | |
| 167 int bytes_per_channel_; | |
| 168 ChannelLayout channel_layout_; | |
| 169 int channel_number_; | |
| 170 int samples_per_second_; | |
| 171 std::vector<uint8> extra_data_; | |
| 172 bool is_encrypted_; | |
| 173 | |
| 174 // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler | |
| 175 // generated copy constructor and assignment operator. Since the extra data is | |
| 176 // typically small, the performance impact is minimal. | |
| 177 }; | |
| 178 | |
| 179 } // namespace media | |
| 180 } // namespace chromecast | |
| 181 | |
| 182 #endif // CHROMECAST_MEDIA_CMA_PUBLIC_AUDIO_CONFIG_H_ | |
| OLD | NEW |