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

Unified Diff: media/filters/decrypting_video_decoder.cc

Issue 297553002: Add callback in VideoDecoder and AudioDecoder to return decoded frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/decrypting_video_decoder.h ('k') | media/filters/decrypting_video_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/decrypting_video_decoder.cc
diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc
index fdc960eefa1429778f980553c1a6adc08620c5d5..05ed3c4a0d61f3ab789be75c6d493c33d1c6b981 100644
--- a/media/filters/decrypting_video_decoder.cc
+++ b/media/filters/decrypting_video_decoder.cc
@@ -32,7 +32,8 @@ DecryptingVideoDecoder::DecryptingVideoDecoder(
void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
bool live_mode,
- const PipelineStatusCB& status_cb) {
+ const PipelineStatusCB& status_cb,
+ const OutputCB& output_cb) {
DVLOG(2) << "Initialize()";
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ == kUninitialized ||
@@ -44,6 +45,7 @@ void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config,
DCHECK(config.is_encrypted());
init_cb_ = BindToCurrentLoop(status_cb);
+ output_cb_ = BindToCurrentLoop(output_cb);
weak_this_ = weak_factory_.GetWeakPtr();
config_ = config;
@@ -74,13 +76,14 @@ void DecryptingVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
decode_cb_ = BindToCurrentLoop(decode_cb);
if (state_ == kError) {
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
return;
}
// Return empty frames if decoding has finished.
if (state_ == kDecodeFinished) {
- base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEOSFrame());
+ output_cb_.Run(VideoFrame::CreateEOSFrame());
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
return;
}
@@ -116,7 +119,7 @@ void DecryptingVideoDecoder::Reset(const base::Closure& closure) {
if (state_ == kWaitingForKey) {
DCHECK(!decode_cb_.is_null());
pending_buffer_to_decode_ = NULL;
- base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted);
}
DCHECK(decode_cb_.is_null());
@@ -145,7 +148,7 @@ void DecryptingVideoDecoder::Stop() {
if (!init_cb_.is_null())
base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
if (!decode_cb_.is_null())
- base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted);
if (!reset_cb_.is_null())
base::ResetAndReturn(&reset_cb_).Run();
@@ -241,7 +244,7 @@ void DecryptingVideoDecoder::DeliverFrame(
pending_buffer_to_decode_ = NULL;
if (!reset_cb_.is_null()) {
- base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kAborted);
DoReset();
return;
}
@@ -251,7 +254,7 @@ void DecryptingVideoDecoder::DeliverFrame(
if (status == Decryptor::kError) {
DVLOG(2) << "DeliverFrame() - kError";
state_ = kError;
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
return;
}
@@ -275,13 +278,11 @@ void DecryptingVideoDecoder::DeliverFrame(
DVLOG(2) << "DeliverFrame() - kNeedMoreData";
if (scoped_pending_buffer_to_decode->end_of_stream()) {
state_ = kDecodeFinished;
- base::ResetAndReturn(&decode_cb_).Run(
- kOk, media::VideoFrame::CreateEOSFrame());
- return;
+ output_cb_.Run(media::VideoFrame::CreateEOSFrame());
+ } else {
+ state_ = kIdle;
}
-
- state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kNotEnoughData, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
return;
}
@@ -289,7 +290,8 @@ void DecryptingVideoDecoder::DeliverFrame(
// No frame returned with kSuccess should be end-of-stream frame.
DCHECK(!frame->end_of_stream());
state_ = kIdle;
- base::ResetAndReturn(&decode_cb_).Run(kOk, frame);
+ output_cb_.Run(frame);
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
}
void DecryptingVideoDecoder::OnKeyAdded() {
« no previous file with comments | « media/filters/decrypting_video_decoder.h ('k') | media/filters/decrypting_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698