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

Unified Diff: media/filters/vpx_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, 7 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
Index: media/filters/vpx_video_decoder.cc
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 894f8712c70fbf8c27efdd20f3c82d898ab86910..51995924b8225368627e33b8ef1311ff7295f254 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -215,7 +215,8 @@ VpxVideoDecoder::~VpxVideoDecoder() {
void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config,
bool low_delay,
- const PipelineStatusCB& status_cb) {
+ const PipelineStatusCB& status_cb,
+ const OutputCB& output_cb) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(config.IsValidConfig());
DCHECK(!config.is_encrypted());
@@ -229,6 +230,7 @@ void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config,
// Success!
config_ = config;
state_ = kNormal;
+ output_cb_ = output_cb;
status_cb.Run(PIPELINE_OK);
}
@@ -314,13 +316,13 @@ void VpxVideoDecoder::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());
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
return;
}
@@ -352,24 +354,22 @@ void VpxVideoDecoder::DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer) {
// Transition to kDecodeFinished on the first end of stream buffer.
if (state_ == kNormal && buffer->end_of_stream()) {
state_ = kDecodeFinished;
- base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEOSFrame());
+ output_cb_.Run(VideoFrame::CreateEOSFrame());
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
return;
}
scoped_refptr<VideoFrame> video_frame;
if (!VpxDecode(buffer, &video_frame)) {
state_ = kError;
- base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL);
+ base::ResetAndReturn(&decode_cb_).Run(kDecodeError);
return;
}
- // If we didn't get a frame we need more data.
- if (!video_frame.get()) {
- base::ResetAndReturn(&decode_cb_).Run(kNotEnoughData, NULL);
- return;
- }
+ base::ResetAndReturn(&decode_cb_).Run(kOk);
- base::ResetAndReturn(&decode_cb_).Run(kOk, video_frame);
+ if (video_frame)
+ output_cb_.Run(video_frame);
}
bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
« media/filters/video_frame_stream_unittest.cc ('K') | « media/filters/vpx_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698