| 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_video_decoder.h" | 5 #include "media/filters/ffmpeg_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 0); | 155 0); |
| 156 return 0; | 156 return 0; |
| 157 } | 157 } |
| 158 | 158 |
| 159 std::string FFmpegVideoDecoder::GetDisplayName() const { | 159 std::string FFmpegVideoDecoder::GetDisplayName() const { |
| 160 return "FFmpegVideoDecoder"; | 160 return "FFmpegVideoDecoder"; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, | 163 void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 164 bool low_delay, | 164 bool low_delay, |
| 165 const InitCB& init_cb, | 165 const PipelineStatusCB& status_cb, |
| 166 const OutputCB& output_cb) { | 166 const OutputCB& output_cb) { |
| 167 DCHECK(task_runner_->BelongsToCurrentThread()); | 167 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 168 DCHECK(!config.is_encrypted()); | 168 DCHECK(!config.is_encrypted()); |
| 169 DCHECK(!output_cb.is_null()); | 169 DCHECK(!output_cb.is_null()); |
| 170 | 170 |
| 171 FFmpegGlue::InitializeFFmpeg(); | 171 FFmpegGlue::InitializeFFmpeg(); |
| 172 | 172 |
| 173 config_ = config; | 173 config_ = config; |
| 174 InitCB bound_init_cb = BindToCurrentLoop(init_cb); | 174 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); |
| 175 | 175 |
| 176 if (!config.IsValidConfig() || !ConfigureDecoder(low_delay)) { | 176 if (!config.IsValidConfig() || !ConfigureDecoder(low_delay)) { |
| 177 bound_init_cb.Run(false); | 177 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 output_cb_ = BindToCurrentLoop(output_cb); | 181 output_cb_ = BindToCurrentLoop(output_cb); |
| 182 | 182 |
| 183 // Success! | 183 // Success! |
| 184 state_ = kNormal; | 184 state_ = kNormal; |
| 185 bound_init_cb.Run(true); | 185 initialize_cb.Run(PIPELINE_OK); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 188 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 189 const DecodeCB& decode_cb) { | 189 const DecodeCB& decode_cb) { |
| 190 DCHECK(task_runner_->BelongsToCurrentThread()); | 190 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 191 DCHECK(buffer.get()); | 191 DCHECK(buffer.get()); |
| 192 DCHECK(!decode_cb.is_null()); | 192 DCHECK(!decode_cb.is_null()); |
| 193 CHECK_NE(state_, kUninitialized); | 193 CHECK_NE(state_, kUninitialized); |
| 194 | 194 |
| 195 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); | 195 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 354 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 355 ReleaseFFmpegResources(); | 355 ReleaseFFmpegResources(); |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 | 358 |
| 359 av_frame_.reset(av_frame_alloc()); | 359 av_frame_.reset(av_frame_alloc()); |
| 360 return true; | 360 return true; |
| 361 } | 361 } |
| 362 | 362 |
| 363 } // namespace media | 363 } // namespace media |
| OLD | NEW |