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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 configs.audio_extra_data.begin()); | 137 configs.audio_extra_data.begin()); |
136 } | 138 } |
137 | 139 |
138 bool AudioDecoderJob::CreateMediaCodecBridgeInternal() { | 140 bool AudioDecoderJob::CreateMediaCodecBridgeInternal() { |
139 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); | 141 media_codec_bridge_.reset(AudioCodecBridge::Create(audio_codec_)); |
140 if (!media_codec_bridge_) | 142 if (!media_codec_bridge_) |
141 return false; | 143 return false; |
142 | 144 |
143 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get()))->Start( | 145 if (!(static_cast<AudioCodecBridge*>(media_codec_bridge_.get()))->Start( |
144 audio_codec_, config_sampling_rate_, num_channels_, &audio_extra_data_[0], | 146 audio_codec_, config_sampling_rate_, num_channels_, &audio_extra_data_[0], |
145 audio_extra_data_.size(), true, GetMediaCrypto().obj())) { | 147 audio_extra_data_.size(), audio_codec_delay_ns_, audio_seek_preroll_ns_, |
| 148 true, GetMediaCrypto().obj())) { |
146 media_codec_bridge_.reset(); | 149 media_codec_bridge_.reset(); |
147 return false; | 150 return false; |
148 } | 151 } |
149 | 152 |
150 SetVolumeInternal(); | 153 SetVolumeInternal(); |
151 | 154 |
152 // Reset values used to track codec bridge output | 155 // Reset values used to track codec bridge output |
153 frame_count_ = 0; | 156 frame_count_ = 0; |
154 ResetTimestampHelper(); | 157 ResetTimestampHelper(); |
155 | 158 |
(...skipping 10 matching lines...) Expand all Loading... |
166 void AudioDecoderJob::OnOutputFormatChanged() { | 169 void AudioDecoderJob::OnOutputFormatChanged() { |
167 DCHECK(media_codec_bridge_); | 170 DCHECK(media_codec_bridge_); |
168 | 171 |
169 int old_sampling_rate = output_sampling_rate_; | 172 int old_sampling_rate = output_sampling_rate_; |
170 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 173 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
171 if (output_sampling_rate_ != old_sampling_rate) | 174 if (output_sampling_rate_ != old_sampling_rate) |
172 ResetTimestampHelper(); | 175 ResetTimestampHelper(); |
173 } | 176 } |
174 | 177 |
175 } // namespace media | 178 } // namespace media |
OLD | NEW |