| 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" | 9 #include "media/base/android/media_codec_bridge.h" |
| 10 #include "media/base/audio_timestamp_helper.h" | 10 #include "media/base/audio_timestamp_helper.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 curr.audio_extra_data.size() != next.audio_extra_data.size() || | 100 curr.audio_extra_data.size() != next.audio_extra_data.size() || |
| 101 !std::equal(curr.audio_extra_data.begin(), curr.audio_extra_data.end(), | 101 !std::equal(curr.audio_extra_data.begin(), curr.audio_extra_data.end(), |
| 102 next.audio_extra_data.begin()); | 102 next.audio_extra_data.begin()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 MediaCodecDecoder::ConfigStatus MediaCodecAudioDecoder::ConfigureInternal() { | 105 MediaCodecDecoder::ConfigStatus MediaCodecAudioDecoder::ConfigureInternal() { |
| 106 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 106 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 107 | 107 |
| 108 DVLOG(1) << class_name() << "::" << __FUNCTION__; | 108 DVLOG(1) << class_name() << "::" << __FUNCTION__; |
| 109 | 109 |
| 110 if (configs_.audio_codec == kUnknownAudioCodec) { |
| 111 DVLOG(0) << class_name() << "::" << __FUNCTION__ |
| 112 << " configuration parameters are required"; |
| 113 return kConfigFailure; |
| 114 } |
| 115 |
| 110 media_codec_bridge_.reset(AudioCodecBridge::Create(configs_.audio_codec)); | 116 media_codec_bridge_.reset(AudioCodecBridge::Create(configs_.audio_codec)); |
| 111 if (!media_codec_bridge_) | 117 if (!media_codec_bridge_) |
| 112 return CONFIG_FAILURE; | 118 return kConfigFailure; |
| 113 | 119 |
| 114 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) | 120 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 115 ->Start( | 121 ->Start( |
| 116 configs_.audio_codec, | 122 configs_.audio_codec, |
| 117 configs_.audio_sampling_rate, | 123 configs_.audio_sampling_rate, |
| 118 configs_.audio_channels, | 124 configs_.audio_channels, |
| 119 &configs_.audio_extra_data[0], | 125 &configs_.audio_extra_data[0], |
| 120 configs_.audio_extra_data.size(), | 126 configs_.audio_extra_data.size(), |
| 121 configs_.audio_codec_delay_ns, | 127 configs_.audio_codec_delay_ns, |
| 122 configs_.audio_seek_preroll_ns, | 128 configs_.audio_seek_preroll_ns, |
| 123 true, | 129 true, |
| 124 GetMediaCrypto().obj())) { | 130 GetMediaCrypto().obj())) { |
| 125 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " failed"; | 131 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " failed"; |
| 126 | 132 |
| 127 media_codec_bridge_.reset(); | 133 media_codec_bridge_.reset(); |
| 128 return CONFIG_FAILURE; | 134 return kConfigFailure; |
| 129 } | 135 } |
| 130 | 136 |
| 131 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " succeeded"; | 137 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " succeeded"; |
| 132 | 138 |
| 133 SetVolumeInternal(); | 139 SetVolumeInternal(); |
| 134 | 140 |
| 135 bytes_per_frame_ = kBytesPerAudioOutputSample * configs_.audio_channels; | 141 bytes_per_frame_ = kBytesPerAudioOutputSample * configs_.audio_channels; |
| 136 frame_count_ = 0; | 142 frame_count_ = 0; |
| 137 ResetTimestampHelper(); | 143 ResetTimestampHelper(); |
| 138 | 144 |
| 139 return CONFIG_OK; | 145 return kConfigOk; |
| 140 } | 146 } |
| 141 | 147 |
| 142 void MediaCodecAudioDecoder::OnOutputFormatChanged() { | 148 void MediaCodecAudioDecoder::OnOutputFormatChanged() { |
| 143 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 149 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 144 | 150 |
| 145 DCHECK(media_codec_bridge_); | 151 DCHECK(media_codec_bridge_); |
| 146 | 152 |
| 147 int old_sampling_rate = output_sampling_rate_; | 153 int old_sampling_rate = output_sampling_rate_; |
| 148 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 154 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
| 149 if (output_sampling_rate_ != old_sampling_rate) | 155 if (output_sampling_rate_ != old_sampling_rate) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (audio_timestamp_helper_) | 213 if (audio_timestamp_helper_) |
| 208 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); | 214 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); |
| 209 | 215 |
| 210 audio_timestamp_helper_.reset( | 216 audio_timestamp_helper_.reset( |
| 211 new AudioTimestampHelper(configs_.audio_sampling_rate)); | 217 new AudioTimestampHelper(configs_.audio_sampling_rate)); |
| 212 | 218 |
| 213 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); | 219 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); |
| 214 } | 220 } |
| 215 | 221 |
| 216 } // namespace media | 222 } // namespace media |
| OLD | NEW |