OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chromecast/media/cma/decoder/cast_audio_decoder.h" | 5 #include "chromecast/media/cma/decoder/cast_audio_decoder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // the decoder will report kDecodeError when decoding. | 61 // the decoder will report kDecodeError when decoding. |
62 config_.encryption_scheme = Unencrypted(); | 62 config_.encryption_scheme = Unencrypted(); |
63 | 63 |
64 if (config_.channel_number == 1) { | 64 if (config_.channel_number == 1) { |
65 // If the input is mono, create a ChannelMixer to convert mono to stereo. | 65 // If the input is mono, create a ChannelMixer to convert mono to stereo. |
66 // TODO(kmackay) Support other channel format conversions? | 66 // TODO(kmackay) Support other channel format conversions? |
67 mixer_.reset(new ::media::ChannelMixer(::media::CHANNEL_LAYOUT_MONO, | 67 mixer_.reset(new ::media::ChannelMixer(::media::CHANNEL_LAYOUT_MONO, |
68 ::media::CHANNEL_LAYOUT_STEREO)); | 68 ::media::CHANNEL_LAYOUT_STEREO)); |
69 } | 69 } |
70 base::WeakPtr<CastAudioDecoderImpl> self = weak_factory_.GetWeakPtr(); | 70 base::WeakPtr<CastAudioDecoderImpl> self = weak_factory_.GetWeakPtr(); |
71 decoder_.reset(new ::media::FFmpegAudioDecoder( | 71 decoder_.reset(new ::media::FFmpegAudioDecoder(task_runner_, &media_log_)); |
72 task_runner_, make_scoped_refptr(new ::media::MediaLog()))); | |
73 decoder_->Initialize( | 72 decoder_->Initialize( |
74 media::DecoderConfigAdapter::ToMediaAudioDecoderConfig(config_), | 73 media::DecoderConfigAdapter::ToMediaAudioDecoderConfig(config_), |
75 nullptr, base::Bind(&CastAudioDecoderImpl::OnInitialized, self), | 74 nullptr, base::Bind(&CastAudioDecoderImpl::OnInitialized, self), |
76 base::Bind(&CastAudioDecoderImpl::OnDecoderOutput, self)); | 75 base::Bind(&CastAudioDecoderImpl::OnDecoderOutput, self)); |
77 // Unfortunately there is no result from decoder_->Initialize() until later | 76 // Unfortunately there is no result from decoder_->Initialize() until later |
78 // (the pipeline status callback is posted to the task runner). | 77 // (the pipeline status callback is posted to the task runner). |
79 } | 78 } |
80 | 79 |
81 // CastAudioDecoder implementation: | 80 // CastAudioDecoder implementation: |
82 bool Decode(const scoped_refptr<media::DecoderBufferBase>& data, | 81 bool Decode(const scoped_refptr<media::DecoderBufferBase>& data, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 NOTREACHED(); | 238 NOTREACHED(); |
240 } | 239 } |
241 | 240 |
242 result->set_duration(base::TimeDelta::FromMicroseconds( | 241 result->set_duration(base::TimeDelta::FromMicroseconds( |
243 bus->frames() * base::Time::kMicrosecondsPerSecond / | 242 bus->frames() * base::Time::kMicrosecondsPerSecond / |
244 config_.samples_per_second)); | 243 config_.samples_per_second)); |
245 return make_scoped_refptr( | 244 return make_scoped_refptr( |
246 new media::DecoderBufferAdapter(config_.id, result)); | 245 new media::DecoderBufferAdapter(config_.id, result)); |
247 } | 246 } |
248 | 247 |
| 248 ::media::MediaLog media_log_; |
249 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 249 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
250 InitializedCallback initialized_callback_; | 250 InitializedCallback initialized_callback_; |
251 OutputFormat output_format_; | 251 OutputFormat output_format_; |
252 media::AudioConfig config_; | 252 media::AudioConfig config_; |
253 std::unique_ptr<::media::AudioDecoder> decoder_; | 253 std::unique_ptr<::media::AudioDecoder> decoder_; |
254 std::queue<DecodeBufferCallbackPair> decode_queue_; | 254 std::queue<DecodeBufferCallbackPair> decode_queue_; |
255 bool initialized_; | 255 bool initialized_; |
256 std::unique_ptr<::media::ChannelMixer> mixer_; | 256 std::unique_ptr<::media::ChannelMixer> mixer_; |
257 bool decode_pending_; | 257 bool decode_pending_; |
258 std::vector<scoped_refptr<::media::AudioBuffer>> decoded_chunks_; | 258 std::vector<scoped_refptr<::media::AudioBuffer>> decoded_chunks_; |
(...skipping 24 matching lines...) Expand all Loading... |
283 return 2; | 283 return 2; |
284 case CastAudioDecoder::OutputFormat::kOutputPlanarFloat: | 284 case CastAudioDecoder::OutputFormat::kOutputPlanarFloat: |
285 return 4; | 285 return 4; |
286 } | 286 } |
287 NOTREACHED(); | 287 NOTREACHED(); |
288 return 1; | 288 return 1; |
289 } | 289 } |
290 | 290 |
291 } // namespace media | 291 } // namespace media |
292 } // namespace chromecast | 292 } // namespace chromecast |
OLD | NEW |