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/base/android/audio_decoder_job.h" | 5 #include "media/base/android/audio_decoder_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 void AudioDecoderJob::SetDemuxerConfigs(const DemuxerConfigs& configs) { | 61 void AudioDecoderJob::SetDemuxerConfigs(const DemuxerConfigs& configs) { |
62 // TODO(qinmin): split DemuxerConfig for audio and video separately so we | 62 // TODO(qinmin): split DemuxerConfig for audio and video separately so we |
63 // can simply store the stucture here. | 63 // can simply store the stucture here. |
64 audio_codec_ = configs.audio_codec; | 64 audio_codec_ = configs.audio_codec; |
65 num_channels_ = configs.audio_channels; | 65 num_channels_ = configs.audio_channels; |
66 config_sampling_rate_ = configs.audio_sampling_rate; | 66 config_sampling_rate_ = configs.audio_sampling_rate; |
67 set_is_content_encrypted(configs.is_audio_encrypted); | 67 set_is_content_encrypted(configs.is_audio_encrypted); |
68 audio_extra_data_ = configs.audio_extra_data; | 68 audio_extra_data_ = configs.audio_extra_data; |
| 69 audio_codec_delay_ns_ = configs.audio_codec_delay_ns; |
| 70 audio_seek_preroll_ns_ = configs.audio_seek_preroll_ns; |
69 bytes_per_frame_ = kBytesPerAudioOutputSample * num_channels_; | 71 bytes_per_frame_ = kBytesPerAudioOutputSample * num_channels_; |
70 if (!media_codec_bridge_) | 72 if (!media_codec_bridge_) |
71 output_sampling_rate_ = config_sampling_rate_; | 73 output_sampling_rate_ = config_sampling_rate_; |
72 } | 74 } |
73 | 75 |
74 void AudioDecoderJob::SetVolume(double volume) { | 76 void AudioDecoderJob::SetVolume(double volume) { |
75 volume_ = volume; | 77 volume_ = volume; |
76 SetVolumeInternal(); | 78 SetVolumeInternal(); |
77 } | 79 } |
78 | 80 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 138 } |
137 | 139 |
138 MediaDecoderJob::MediaDecoderJobStatus | 140 MediaDecoderJob::MediaDecoderJobStatus |
139 AudioDecoderJob::CreateMediaCodecBridgeInternal() { | 141 AudioDecoderJob::CreateMediaCodecBridgeInternal() { |
140 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); | 142 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); |
141 if (!media_codec_bridge_) | 143 if (!media_codec_bridge_) |
142 return STATUS_FAILURE; | 144 return STATUS_FAILURE; |
143 | 145 |
144 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get()))->Start( | 146 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get()))->Start( |
145 audio_codec_, config_sampling_rate_, num_channels_, &audio_extra_data_[0], | 147 audio_codec_, config_sampling_rate_, num_channels_, &audio_extra_data_[0], |
146 audio_extra_data_.size(), true, GetMediaCrypto().obj())) { | 148 audio_extra_data_.size(), audio_codec_delay_ns_, audio_seek_preroll_ns_, |
| 149 true, GetMediaCrypto().obj())) { |
147 media_codec_bridge_.reset(); | 150 media_codec_bridge_.reset(); |
148 return STATUS_FAILURE; | 151 return STATUS_FAILURE; |
149 } | 152 } |
150 | 153 |
151 SetVolumeInternal(); | 154 SetVolumeInternal(); |
152 | 155 |
153 // Reset values used to track codec bridge output | 156 // Reset values used to track codec bridge output |
154 frame_count_ = 0; | 157 frame_count_ = 0; |
155 ResetTimestampHelper(); | 158 ResetTimestampHelper(); |
156 | 159 |
(...skipping 10 matching lines...) Expand all Loading... |
167 void AudioDecoderJob::OnOutputFormatChanged() { | 170 void AudioDecoderJob::OnOutputFormatChanged() { |
168 DCHECK(media_codec_bridge_); | 171 DCHECK(media_codec_bridge_); |
169 | 172 |
170 int old_sampling_rate = output_sampling_rate_; | 173 int old_sampling_rate = output_sampling_rate_; |
171 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 174 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
172 if (output_sampling_rate_ != old_sampling_rate) | 175 if (output_sampling_rate_ != old_sampling_rate) |
173 ResetTimestampHelper(); | 176 ResetTimestampHelper(); |
174 } | 177 } |
175 | 178 |
176 } // namespace media | 179 } // namespace media |
OLD | NEW |