| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 std::string FFmpegVideoDecoder::GetDisplayName() const { | 179 std::string FFmpegVideoDecoder::GetDisplayName() const { |
| 180 return "FFmpegVideoDecoder"; | 180 return "FFmpegVideoDecoder"; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, | 183 void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 184 bool low_delay, | 184 bool low_delay, |
| 185 CdmContext* /* cdm_context */, | 185 CdmContext* /* cdm_context */, |
| 186 const InitCB& init_cb, | 186 const InitCB& init_cb, |
| 187 const OutputCB& output_cb) { | 187 const OutputCB& output_cb) { |
| 188 DCHECK(thread_checker_.CalledOnValidThread()); | 188 DCHECK(thread_checker_.CalledOnValidThread()); |
| 189 DCHECK(config.IsValidConfig()); | 189 DCHECK(config.IsValidConfig()) << config.AsHumanReadableString(); |
| 190 DCHECK(!output_cb.is_null()); | 190 DCHECK(!output_cb.is_null()); |
| 191 | 191 |
| 192 InitCB bound_init_cb = BindToCurrentLoop(init_cb); | 192 InitCB bound_init_cb = BindToCurrentLoop(init_cb); |
| 193 | 193 |
| 194 if (config.is_encrypted()) { | 194 if (config.is_encrypted()) { |
| 195 bound_init_cb.Run(false); | 195 bound_init_cb.Run(false); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 FFmpegGlue::InitializeFFmpeg(); | 199 FFmpegGlue::InitializeFFmpeg(); |
| 200 config_ = config; | 200 config_ = config; |
| 201 | 201 |
| 202 // TODO(xhwang): Only set |config_| after we successfully configure the | 202 // TODO(xhwang): Only set |config_| after we successfully configure the |
| 203 // decoder. | 203 // decoder. |
| 204 if (!ConfigureDecoder(low_delay)) { | 204 if (!ConfigureDecoder(low_delay)) { |
| 205 bound_init_cb.Run(false); | 205 bound_init_cb.Run(false); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 | 208 |
| 209 output_cb_ = output_cb; | 209 output_cb_ = output_cb; |
| 210 | 210 |
| 211 // Success! | 211 // Success! |
| 212 state_ = kNormal; | 212 state_ = kNormal; |
| 213 bound_init_cb.Run(true); | 213 bound_init_cb.Run(true); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 216 void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 217 const DecodeCB& decode_cb) { | 217 const DecodeCB& decode_cb) { |
| 218 VLOG(0) << __FUNCTION__; |
| 218 DCHECK(thread_checker_.CalledOnValidThread()); | 219 DCHECK(thread_checker_.CalledOnValidThread()); |
| 219 DCHECK(buffer.get()); | 220 DCHECK(buffer.get()); |
| 220 DCHECK(!decode_cb.is_null()); | 221 DCHECK(!decode_cb.is_null()); |
| 221 CHECK_NE(state_, kUninitialized); | 222 CHECK_NE(state_, kUninitialized); |
| 222 | 223 |
| 223 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); | 224 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); |
| 224 | 225 |
| 225 if (state_ == kError) { | 226 if (state_ == kError) { |
| 226 decode_cb_bound.Run(DecodeStatus::DECODE_ERROR); | 227 decode_cb_bound.Run(DecodeStatus::DECODE_ERROR); |
| 227 return; | 228 return; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 387 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
| 387 ReleaseFFmpegResources(); | 388 ReleaseFFmpegResources(); |
| 388 return false; | 389 return false; |
| 389 } | 390 } |
| 390 | 391 |
| 391 av_frame_.reset(av_frame_alloc()); | 392 av_frame_.reset(av_frame_alloc()); |
| 392 return true; | 393 return true; |
| 393 } | 394 } |
| 394 | 395 |
| 395 } // namespace media | 396 } // namespace media |
| OLD | NEW |