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