OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/cast/audio_receiver/audio_decoder.h" | 5 #include "media/cast/receiver/audio_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/sys_byteorder.h" | 12 #include "base/sys_byteorder.h" |
13 #include "media/cast/cast_defines.h" | 13 #include "media/cast/cast_defines.h" |
14 #include "third_party/opus/src/include/opus.h" | 14 #include "third_party/opus/src/include/opus.h" |
15 | 15 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 audio_bus = AudioBus::Create(num_channels_, num_samples).Pass(); | 193 audio_bus = AudioBus::Create(num_channels_, num_samples).Pass(); |
194 audio_bus->FromInterleaved(pcm_data, num_samples, sizeof(int16)); | 194 audio_bus->FromInterleaved(pcm_data, num_samples, sizeof(int16)); |
195 return audio_bus.Pass(); | 195 return audio_bus.Pass(); |
196 } | 196 } |
197 | 197 |
198 DISALLOW_COPY_AND_ASSIGN(Pcm16Impl); | 198 DISALLOW_COPY_AND_ASSIGN(Pcm16Impl); |
199 }; | 199 }; |
200 | 200 |
201 AudioDecoder::AudioDecoder( | 201 AudioDecoder::AudioDecoder( |
202 const scoped_refptr<CastEnvironment>& cast_environment, | 202 const scoped_refptr<CastEnvironment>& cast_environment, |
203 const FrameReceiverConfig& audio_config) | 203 int channels, |
| 204 int sampling_rate, |
| 205 transport::AudioCodec codec) |
204 : cast_environment_(cast_environment) { | 206 : cast_environment_(cast_environment) { |
205 switch (audio_config.codec.audio) { | 207 switch (codec) { |
206 case transport::kOpus: | 208 case transport::kOpus: |
207 impl_ = new OpusImpl(cast_environment, | 209 impl_ = new OpusImpl(cast_environment, channels, sampling_rate); |
208 audio_config.channels, | |
209 audio_config.frequency); | |
210 break; | 210 break; |
211 case transport::kPcm16: | 211 case transport::kPcm16: |
212 impl_ = new Pcm16Impl(cast_environment, | 212 impl_ = new Pcm16Impl(cast_environment, channels, sampling_rate); |
213 audio_config.channels, | |
214 audio_config.frequency); | |
215 break; | 213 break; |
216 default: | 214 default: |
217 NOTREACHED() << "Unknown or unspecified codec."; | 215 NOTREACHED() << "Unknown or unspecified codec."; |
218 break; | 216 break; |
219 } | 217 } |
220 } | 218 } |
221 | 219 |
222 AudioDecoder::~AudioDecoder() {} | 220 AudioDecoder::~AudioDecoder() {} |
223 | 221 |
224 CastInitializationStatus AudioDecoder::InitializationResult() const { | 222 CastInitializationStatus AudioDecoder::InitializationResult() const { |
(...skipping 14 matching lines...) Expand all Loading... |
239 cast_environment_->PostTask(CastEnvironment::AUDIO, | 237 cast_environment_->PostTask(CastEnvironment::AUDIO, |
240 FROM_HERE, | 238 FROM_HERE, |
241 base::Bind(&AudioDecoder::ImplBase::DecodeFrame, | 239 base::Bind(&AudioDecoder::ImplBase::DecodeFrame, |
242 impl_, | 240 impl_, |
243 base::Passed(&encoded_frame), | 241 base::Passed(&encoded_frame), |
244 callback)); | 242 callback)); |
245 } | 243 } |
246 | 244 |
247 } // namespace cast | 245 } // namespace cast |
248 } // namespace media | 246 } // namespace media |
OLD | NEW |