| 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 "media/base/android/media_codec_audio_decoder.h" | 5 #include "media/base/android/media_codec_audio_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "media/base/android/media_codec_bridge.h" | |
| 10 #include "media/base/android/media_statistics.h" | 9 #include "media/base/android/media_statistics.h" |
| 10 #include "media/base/android/sdk_media_codec_bridge.h" |
| 11 #include "media/base/audio_timestamp_helper.h" | 11 #include "media/base/audio_timestamp_helper.h" |
| 12 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Use 16bit PCM for audio output. Keep this value in sync with the output | 16 // Use 16bit PCM for audio output. Keep this value in sync with the output |
| 17 // format we passed to AudioTrack in MediaCodecBridge. | 17 // format we passed to AudioTrack in MediaCodecBridge. |
| 18 const int kBytesPerAudioOutputSample = 2; | 18 const int kBytesPerAudioOutputSample = 2; |
| 19 } | 19 } |
| 20 | 20 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 DVLOG(0) << class_name() << "::" << __FUNCTION__ | 137 DVLOG(0) << class_name() << "::" << __FUNCTION__ |
| 138 << " configuration parameters are required"; | 138 << " configuration parameters are required"; |
| 139 return kConfigFailure; | 139 return kConfigFailure; |
| 140 } | 140 } |
| 141 | 141 |
| 142 media_codec_bridge_.reset(AudioCodecBridge::Create(configs_.audio_codec)); | 142 media_codec_bridge_.reset(AudioCodecBridge::Create(configs_.audio_codec)); |
| 143 if (!media_codec_bridge_) | 143 if (!media_codec_bridge_) |
| 144 return kConfigFailure; | 144 return kConfigFailure; |
| 145 | 145 |
| 146 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) | 146 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 147 ->Start( | 147 ->ConfigureAndStart( |
| 148 configs_.audio_codec, | 148 configs_.audio_codec, configs_.audio_sampling_rate, |
| 149 configs_.audio_sampling_rate, | 149 configs_.audio_channels, &configs_.audio_extra_data[0], |
| 150 configs_.audio_channels, | 150 configs_.audio_extra_data.size(), configs_.audio_codec_delay_ns, |
| 151 &configs_.audio_extra_data[0], | 151 configs_.audio_seek_preroll_ns, true, media_crypto)) { |
| 152 configs_.audio_extra_data.size(), | |
| 153 configs_.audio_codec_delay_ns, | |
| 154 configs_.audio_seek_preroll_ns, | |
| 155 true, | |
| 156 media_crypto)) { | |
| 157 DVLOG(0) << class_name() << "::" << __FUNCTION__ | 152 DVLOG(0) << class_name() << "::" << __FUNCTION__ |
| 158 << " failed: cannot start audio codec"; | 153 << " failed: cannot start audio codec"; |
| 159 | 154 |
| 160 media_codec_bridge_.reset(); | 155 media_codec_bridge_.reset(); |
| 161 return kConfigFailure; | 156 return kConfigFailure; |
| 162 } | 157 } |
| 163 | 158 |
| 164 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded"; | 159 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded"; |
| 165 | 160 |
| 166 SetVolumeInternal(); | 161 SetVolumeInternal(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 if (audio_timestamp_helper_) | 280 if (audio_timestamp_helper_) |
| 286 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); | 281 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); |
| 287 | 282 |
| 288 audio_timestamp_helper_.reset( | 283 audio_timestamp_helper_.reset( |
| 289 new AudioTimestampHelper(configs_.audio_sampling_rate)); | 284 new AudioTimestampHelper(configs_.audio_sampling_rate)); |
| 290 | 285 |
| 291 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); | 286 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); |
| 292 } | 287 } |
| 293 | 288 |
| 294 } // namespace media | 289 } // namespace media |
| OLD | NEW |