| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 volume_(-1.0), | 44 volume_(-1.0), |
| 45 bytes_per_frame_(0) { | 45 bytes_per_frame_(0) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 AudioDecoderJob::~AudioDecoderJob() {} | 48 AudioDecoderJob::~AudioDecoderJob() {} |
| 49 | 49 |
| 50 bool AudioDecoderJob::HasStream() const { | 50 bool AudioDecoderJob::HasStream() const { |
| 51 return audio_codec_ != kUnknownAudioCodec; | 51 return audio_codec_ != kUnknownAudioCodec; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AudioDecoderJob::SetDemuxerConfigs(const DemuxerConfigs& configs) { |
| 55 // TODO(qinmin): split DemuxerConfig for audio and video separately so we |
| 56 // can simply store the stucture here. |
| 57 audio_codec_ = configs.audio_codec; |
| 58 num_channels_ = configs.audio_channels; |
| 59 sampling_rate_ = configs.audio_sampling_rate; |
| 60 set_is_content_encrypted(configs.is_audio_encrypted); |
| 61 audio_extra_data_ = configs.audio_extra_data; |
| 62 bytes_per_frame_ = kBytesPerAudioOutputSample * num_channels_; |
| 63 } |
| 64 |
| 54 void AudioDecoderJob::SetVolume(double volume) { | 65 void AudioDecoderJob::SetVolume(double volume) { |
| 55 volume_ = volume; | 66 volume_ = volume; |
| 56 SetVolumeInternal(); | 67 SetVolumeInternal(); |
| 57 } | 68 } |
| 58 | 69 |
| 59 void AudioDecoderJob::SetBaseTimestamp(base::TimeDelta base_timestamp) { | 70 void AudioDecoderJob::SetBaseTimestamp(base::TimeDelta base_timestamp) { |
| 60 DCHECK(!is_decoding()); | 71 DCHECK(!is_decoding()); |
| 61 base_timestamp_ = base_timestamp; | 72 base_timestamp_ = base_timestamp; |
| 62 if (audio_timestamp_helper_) | 73 if (audio_timestamp_helper_) |
| 63 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); | 74 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 media_codec_bridge_->ReleaseOutputBuffer(output_buffer_index, false); | 98 media_codec_bridge_->ReleaseOutputBuffer(output_buffer_index, false); |
| 88 | 99 |
| 89 callback.Run(current_presentation_timestamp, | 100 callback.Run(current_presentation_timestamp, |
| 90 audio_timestamp_helper_->GetTimestamp()); | 101 audio_timestamp_helper_->GetTimestamp()); |
| 91 } | 102 } |
| 92 | 103 |
| 93 bool AudioDecoderJob::ComputeTimeToRender() const { | 104 bool AudioDecoderJob::ComputeTimeToRender() const { |
| 94 return false; | 105 return false; |
| 95 } | 106 } |
| 96 | 107 |
| 97 void AudioDecoderJob::UpdateDemuxerConfigs(const DemuxerConfigs& configs) { | |
| 98 // TODO(qinmin): split DemuxerConfig for audio and video separately so we | |
| 99 // can simply store the stucture here. | |
| 100 audio_codec_ = configs.audio_codec; | |
| 101 num_channels_ = configs.audio_channels; | |
| 102 sampling_rate_ = configs.audio_sampling_rate; | |
| 103 set_is_content_encrypted(configs.is_audio_encrypted); | |
| 104 audio_extra_data_ = configs.audio_extra_data; | |
| 105 bytes_per_frame_ = kBytesPerAudioOutputSample * num_channels_; | |
| 106 } | |
| 107 | |
| 108 bool AudioDecoderJob::AreDemuxerConfigsChanged( | 108 bool AudioDecoderJob::AreDemuxerConfigsChanged( |
| 109 const DemuxerConfigs& configs) const { | 109 const DemuxerConfigs& configs) const { |
| 110 return audio_codec_ != configs.audio_codec || | 110 return audio_codec_ != configs.audio_codec || |
| 111 num_channels_ != configs.audio_channels || | 111 num_channels_ != configs.audio_channels || |
| 112 sampling_rate_ != configs.audio_sampling_rate || | 112 sampling_rate_ != configs.audio_sampling_rate || |
| 113 is_content_encrypted() != configs.is_audio_encrypted || | 113 is_content_encrypted() != configs.is_audio_encrypted || |
| 114 audio_extra_data_.size() != configs.audio_extra_data.size() || | 114 audio_extra_data_.size() != configs.audio_extra_data.size() || |
| 115 !std::equal(audio_extra_data_.begin(), | 115 !std::equal(audio_extra_data_.begin(), |
| 116 audio_extra_data_.end(), | 116 audio_extra_data_.end(), |
| 117 configs.audio_extra_data.begin()); | 117 configs.audio_extra_data.begin()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 void AudioDecoderJob::SetVolumeInternal() { | 142 void AudioDecoderJob::SetVolumeInternal() { |
| 143 if (media_codec_bridge_) { | 143 if (media_codec_bridge_) { |
| 144 static_cast<AudioCodecBridge*>(media_codec_bridge_.get())->SetVolume( | 144 static_cast<AudioCodecBridge*>(media_codec_bridge_.get())->SetVolume( |
| 145 volume_); | 145 volume_); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace media | 149 } // namespace media |
| OLD | NEW |