Chromium Code Reviews| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 | 244 | 
| 245 read_cb_ = read_cb; | 245 read_cb_ = read_cb; | 
| 246 ReadFromDemuxerStream(); | 246 ReadFromDemuxerStream(); | 
| 247 } | 247 } | 
| 248 | 248 | 
| 249 void FFmpegVideoDecoder::ReadFromDemuxerStream() { | 249 void FFmpegVideoDecoder::ReadFromDemuxerStream() { | 
| 250 DCHECK_NE(state_, kUninitialized); | 250 DCHECK_NE(state_, kUninitialized); | 
| 251 DCHECK_NE(state_, kDecodeFinished); | 251 DCHECK_NE(state_, kDecodeFinished); | 
| 252 DCHECK(!read_cb_.is_null()); | 252 DCHECK(!read_cb_.is_null()); | 
| 253 | 253 | 
| 254 demuxer_stream_->Read(base::Bind(&FFmpegVideoDecoder::DecryptOrDecodeBuffer, | 254 demuxer_stream_->Read(base::Bind( | 
| 255 this)); | 255 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this)); | 
| 256 } | |
| 257 | |
| 258 void FFmpegVideoDecoder::DecryptOrDecodeBuffer( | |
| 259 DemuxerStream::Status status, | |
| 260 const scoped_refptr<DecoderBuffer>& buffer) { | |
| 261 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status; | |
| 
 
xhwang
2012/11/20 17:54:34
do we still want to keep this check?
 
scherkus (not reviewing)
2012/11/20 19:16:07
Done.
 
 | |
| 262 // TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read | |
| 263 // callback on the same execution stack so we can get rid of forced task post. | |
| 264 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 265 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this, status, buffer)); | |
| 266 } | 256 } | 
| 267 | 257 | 
| 268 void FFmpegVideoDecoder::DoDecryptOrDecodeBuffer( | 258 void FFmpegVideoDecoder::DoDecryptOrDecodeBuffer( | 
| 269 DemuxerStream::Status status, | 259 DemuxerStream::Status status, | 
| 270 const scoped_refptr<DecoderBuffer>& buffer) { | 260 const scoped_refptr<DecoderBuffer>& buffer) { | 
| 271 DCHECK(message_loop_->BelongsToCurrentThread()); | 261 if (!message_loop_->BelongsToCurrentThread()) { | 
| 262 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 263 &FFmpegVideoDecoder::DoDecryptOrDecodeBuffer, this, status, buffer)); | |
| 264 return; | |
| 265 } | |
| 266 | |
| 272 DCHECK_NE(state_, kDecodeFinished); | 267 DCHECK_NE(state_, kDecodeFinished); | 
| 273 | 268 | 
| 274 if (state_ == kUninitialized) | 269 if (state_ == kUninitialized) | 
| 275 return; | 270 return; | 
| 276 | 271 | 
| 277 DCHECK(!read_cb_.is_null()); | 272 DCHECK(!read_cb_.is_null()); | 
| 278 | 273 | 
| 279 if (!reset_cb_.is_null()) { | 274 if (!reset_cb_.is_null()) { | 
| 280 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 275 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 
| 281 DoReset(); | 276 DoReset(); | 
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { | 522 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { | 
| 528 ReleaseFFmpegResources(); | 523 ReleaseFFmpegResources(); | 
| 529 return false; | 524 return false; | 
| 530 } | 525 } | 
| 531 | 526 | 
| 532 av_frame_ = avcodec_alloc_frame(); | 527 av_frame_ = avcodec_alloc_frame(); | 
| 533 return true; | 528 return true; | 
| 534 } | 529 } | 
| 535 | 530 | 
| 536 } // namespace media | 531 } // namespace media | 
| OLD | NEW |