| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_audio_decoder.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 ReleaseFFmpegResources(); | 140 ReleaseFFmpegResources(); |
| 141 ResetTimestampState(); | 141 ResetTimestampState(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 std::string FFmpegAudioDecoder::GetDisplayName() const { | 145 std::string FFmpegAudioDecoder::GetDisplayName() const { |
| 146 return "FFmpegAudioDecoder"; | 146 return "FFmpegAudioDecoder"; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, | 149 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, |
| 150 const InitCB& init_cb, | 150 const PipelineStatusCB& status_cb, |
| 151 const OutputCB& output_cb) { | 151 const OutputCB& output_cb) { |
| 152 DCHECK(task_runner_->BelongsToCurrentThread()); | 152 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 153 DCHECK(!config.is_encrypted()); | 153 DCHECK(!config.is_encrypted()); |
| 154 | 154 |
| 155 FFmpegGlue::InitializeFFmpeg(); | 155 FFmpegGlue::InitializeFFmpeg(); |
| 156 | 156 |
| 157 config_ = config; | 157 config_ = config; |
| 158 InitCB bound_init_cb = BindToCurrentLoop(init_cb); | 158 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); |
| 159 | 159 |
| 160 if (!config.IsValidConfig() || !ConfigureDecoder()) { | 160 if (!config.IsValidConfig() || !ConfigureDecoder()) { |
| 161 bound_init_cb.Run(false); | 161 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Success! | 165 // Success! |
| 166 output_cb_ = BindToCurrentLoop(output_cb); | 166 output_cb_ = BindToCurrentLoop(output_cb); |
| 167 state_ = kNormal; | 167 state_ = kNormal; |
| 168 bound_init_cb.Run(true); | 168 initialize_cb.Run(PIPELINE_OK); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void FFmpegAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 171 void FFmpegAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 172 const DecodeCB& decode_cb) { | 172 const DecodeCB& decode_cb) { |
| 173 DCHECK(task_runner_->BelongsToCurrentThread()); | 173 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 174 DCHECK(!decode_cb.is_null()); | 174 DCHECK(!decode_cb.is_null()); |
| 175 CHECK_NE(state_, kUninitialized); | 175 CHECK_NE(state_, kUninitialized); |
| 176 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); | 176 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); |
| 177 | 177 |
| 178 if (state_ == kError) { | 178 if (state_ == kError) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 ResetTimestampState(); | 388 ResetTimestampState(); |
| 389 return true; | 389 return true; |
| 390 } | 390 } |
| 391 | 391 |
| 392 void FFmpegAudioDecoder::ResetTimestampState() { | 392 void FFmpegAudioDecoder::ResetTimestampState() { |
| 393 discard_helper_->Reset(config_.codec_delay()); | 393 discard_helper_->Reset(config_.codec_delay()); |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace media | 396 } // namespace media |
| OLD | NEW |