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

Unified Diff: content/renderer/media/capture_video_decoder.cc

Issue 8528045: corresponding change in CaptureVideoDecoder and RTCVideoDecoder due to pull model used in medi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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: content/renderer/media/capture_video_decoder.cc
===================================================================
--- content/renderer/media/capture_video_decoder.cc (revision 109978)
+++ content/renderer/media/capture_video_decoder.cc (working copy)
@@ -67,6 +67,13 @@
this, callback));
}
+void CaptureVideoDecoder::Flush(const base::Closure& callback) {
+ message_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&CaptureVideoDecoder::FlushOnDecoderThread,
+ this, callback));
+}
+
void CaptureVideoDecoder::Stop(const base::Closure& callback) {
message_loop_proxy_->PostTask(
FROM_HERE,
@@ -141,8 +148,12 @@
void CaptureVideoDecoder::ReadOnDecoderThread(const ReadCB& callback) {
DCHECK(message_loop_proxy_->BelongsToCurrentThread());
- CHECK(read_cb_.is_null());
- read_cb_ = callback;
+ CHECK(!callback.is_null());
+ if (state_ != kNormal) {
scherkus (not reviewing) 2011/11/16 01:12:36 does this actually happen in practice? I'd be int
wjia(left Chromium) 2011/11/16 05:25:54 It could happen in two cases: 1. When pipeline put
+ DeliverBlackFrame(callback);
+ return;
+ }
+ read_cbs_.push(callback);
}
void CaptureVideoDecoder::PlayOnDecoderThread(const base::Closure& callback) {
@@ -158,6 +169,16 @@
media::VideoDecoder::Pause(callback);
}
+void CaptureVideoDecoder::FlushOnDecoderThread(const base::Closure& callback) {
+ DVLOG(1) << "FlushOnDecoderThread";
+ DCHECK(message_loop_proxy_->BelongsToCurrentThread());
+ while (!read_cbs_.empty()) {
+ DeliverBlackFrame(read_cbs_.front());
+ read_cbs_.pop();
+ }
+ media::VideoDecoder::Flush(callback);
+}
+
void CaptureVideoDecoder::StopOnDecoderThread(const base::Closure& callback) {
DVLOG(1) << "StopOnDecoderThread";
DCHECK(message_loop_proxy_->BelongsToCurrentThread());
@@ -201,7 +222,7 @@
scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
DCHECK(message_loop_proxy_->BelongsToCurrentThread());
- if (read_cb_.is_null() || kNormal != state_) {
+ if (read_cbs_.empty() || kNormal != state_) {
capture->FeedBuffer(buf);
return;
}
@@ -240,14 +261,16 @@
buffer += uv_width * uv_height;
CopyVPlane(buffer, uv_width, uv_height, video_frame);
- DeliverFrame(video_frame);
+ read_cbs_.front().Run(video_frame);
+ read_cbs_.pop();
capture->FeedBuffer(buf);
}
-void CaptureVideoDecoder::DeliverFrame(
- const scoped_refptr<media::VideoFrame>& video_frame) {
- // Reset the callback before running to protect against reentrancy.
- ReadCB read_cb = read_cb_;
- read_cb_.Reset();
+void CaptureVideoDecoder::DeliverBlackFrame(
+ const ReadCB& read_cb) {
+ CHECK(!read_cb.is_null());
+ scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateBlackFrame(natural_size_.width(),
+ natural_size_.height());
read_cb.Run(video_frame);
}

Powered by Google App Engine
This is Rietveld 408576698