Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 10669022: Add status parameter to DemuxerStream::ReadCB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix seek_tester build buster Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 void FFmpegVideoDecoder::ReadFromDemuxerStream() { 273 void FFmpegVideoDecoder::ReadFromDemuxerStream() {
274 DCHECK_NE(state_, kUninitialized); 274 DCHECK_NE(state_, kUninitialized);
275 DCHECK_NE(state_, kDecodeFinished); 275 DCHECK_NE(state_, kDecodeFinished);
276 DCHECK(!read_cb_.is_null()); 276 DCHECK(!read_cb_.is_null());
277 277
278 demuxer_stream_->Read(base::Bind(&FFmpegVideoDecoder::DecodeBuffer, this)); 278 demuxer_stream_->Read(base::Bind(&FFmpegVideoDecoder::DecodeBuffer, this));
279 } 279 }
280 280
281 void FFmpegVideoDecoder::DecodeBuffer( 281 void FFmpegVideoDecoder::DecodeBuffer(
282 const scoped_refptr<DecoderBuffer>& buffer) { 282 DemuxerStream::Status status, const scoped_refptr<DecoderBuffer>& buffer) {
283 DCHECK_EQ(status != DemuxerStream::kOk, !buffer);
284
283 // TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read 285 // TODO(scherkus): fix FFmpegDemuxerStream::Read() to not execute our read
284 // callback on the same execution stack so we can get rid of forced task post. 286 // callback on the same execution stack so we can get rid of forced task post.
285 message_loop_->PostTask(FROM_HERE, base::Bind( 287 message_loop_->PostTask(FROM_HERE, base::Bind(
286 &FFmpegVideoDecoder::DoDecodeBuffer, this, buffer)); 288 &FFmpegVideoDecoder::DoDecodeBuffer, this, status, buffer));
287 } 289 }
288 290
289 void FFmpegVideoDecoder::DoDecodeBuffer( 291 void FFmpegVideoDecoder::DoDecodeBuffer(
290 const scoped_refptr<DecoderBuffer>& buffer) { 292 DemuxerStream::Status status, const scoped_refptr<DecoderBuffer>& buffer) {
291 DCHECK_EQ(MessageLoop::current(), message_loop_); 293 DCHECK_EQ(MessageLoop::current(), message_loop_);
292 DCHECK_NE(state_, kUninitialized); 294 DCHECK_NE(state_, kUninitialized);
293 DCHECK_NE(state_, kDecodeFinished); 295 DCHECK_NE(state_, kDecodeFinished);
294 DCHECK(!read_cb_.is_null()); 296 DCHECK(!read_cb_.is_null());
295 297
296 if (!reset_cb_.is_null()) { 298 if (!reset_cb_.is_null()) {
297 DeliverFrame(NULL); 299 DeliverFrame(NULL);
298 DoReset(); 300 DoReset();
299 return; 301 return;
300 } 302 }
301 303
302 if (!buffer) { 304 if (status != DemuxerStream::kOk) {
303 DeliverFrame(NULL); 305 DecoderStatus decoder_status =
306 (status == DemuxerStream::kAborted) ? kOk : kDecodeError;
307 base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL);
Ami GONE FROM CHROMIUM 2012/07/12 17:10:26 IWBN to have a uniform approach to read_cb_.Run.
acolwell GONE FROM CHROMIUM 2012/07/12 21:59:58 Done. Removed DeliverFrame().
304 return; 308 return;
305 } 309 }
306 310
307 // During decode, because reads are issued asynchronously, it is possible to 311 // During decode, because reads are issued asynchronously, it is possible to
308 // receive multiple end of stream buffers since each read is acked. When the 312 // receive multiple end of stream buffers since each read is acked. When the
309 // first end of stream buffer is read, FFmpeg may still have frames queued 313 // first end of stream buffer is read, FFmpeg may still have frames queued
310 // up in the decoder so we need to go through the decode loop until it stops 314 // up in the decoder so we need to go through the decode loop until it stops
311 // giving sensible data. After that, the decoder should output empty 315 // giving sensible data. After that, the decoder should output empty
312 // frames. There are three states the decoder can be in: 316 // frames. There are three states the decoder can be in:
313 // 317 //
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 av_free(codec_context_); 484 av_free(codec_context_);
481 codec_context_ = NULL; 485 codec_context_ = NULL;
482 } 486 }
483 if (av_frame_) { 487 if (av_frame_) {
484 av_free(av_frame_); 488 av_free(av_frame_);
485 av_frame_ = NULL; 489 av_frame_ = NULL;
486 } 490 }
487 } 491 }
488 492
489 } // namespace media 493 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698