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

Side by Side Diff: content/renderer/media/capture_video_decoder.cc

Issue 10391065: handle the case when device is closed before media pipeline is fully initialized. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 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 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 "content/renderer/media/capture_video_decoder.h" 5 #include "content/renderer/media/capture_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 "content/renderer/media/video_capture_impl_manager.h" 9 #include "content/renderer/media/video_capture_impl_manager.h"
10 #include "media/base/demuxer_stream.h" 10 #include "media/base/demuxer_stream.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 void CaptureVideoDecoder::OnStopped(media::VideoCapture* capture) { 71 void CaptureVideoDecoder::OnStopped(media::VideoCapture* capture) {
72 message_loop_proxy_->PostTask( 72 message_loop_proxy_->PostTask(
73 FROM_HERE, 73 FROM_HERE,
74 base::Bind(&CaptureVideoDecoder::OnStoppedOnDecoderThread, 74 base::Bind(&CaptureVideoDecoder::OnStoppedOnDecoderThread,
75 this, capture)); 75 this, capture));
76 } 76 }
77 77
78 void CaptureVideoDecoder::OnPaused(media::VideoCapture* capture) { 78 void CaptureVideoDecoder::OnPaused(media::VideoCapture* capture) {
79 NOTIMPLEMENTED(); 79 message_loop_proxy_->PostTask(
80 FROM_HERE,
81 base::Bind(&CaptureVideoDecoder::OnPausedOnDecoderThread,
82 this, capture));
80 } 83 }
81 84
82 void CaptureVideoDecoder::OnError(media::VideoCapture* capture, 85 void CaptureVideoDecoder::OnError(media::VideoCapture* capture,
83 int error_code) { 86 int error_code) {
84 NOTIMPLEMENTED(); 87 message_loop_proxy_->PostTask(
Ronghua Wu (Left Chromium) 2012/05/17 22:54:37 Add comment why we do OnPusedOnDecoderThread in th
wjia(left Chromium) 2012/05/23 18:46:48 This is the video capture protocol between browser
88 FROM_HERE,
89 base::Bind(&CaptureVideoDecoder::OnPausedOnDecoderThread,
90 this, capture));
85 } 91 }
86 92
87 void CaptureVideoDecoder::OnRemoved(media::VideoCapture* capture) { 93 void CaptureVideoDecoder::OnRemoved(media::VideoCapture* capture) {
88 NOTIMPLEMENTED(); 94 NOTIMPLEMENTED();
89 } 95 }
90 96
91 void CaptureVideoDecoder::OnBufferReady( 97 void CaptureVideoDecoder::OnBufferReady(
92 media::VideoCapture* capture, 98 media::VideoCapture* capture,
93 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { 99 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
94 DCHECK(buf); 100 DCHECK(buf);
(...skipping 26 matching lines...) Expand all
121 statistics_cb_ = statistics_cb; 127 statistics_cb_ = statistics_cb;
122 status_cb.Run(media::PIPELINE_OK); 128 status_cb.Run(media::PIPELINE_OK);
123 state_ = kNormal; 129 state_ = kNormal;
124 capture_engine_->StartCapture(this, capability_); 130 capture_engine_->StartCapture(this, capability_);
125 } 131 }
126 132
127 void CaptureVideoDecoder::ReadOnDecoderThread(const ReadCB& read_cb) { 133 void CaptureVideoDecoder::ReadOnDecoderThread(const ReadCB& read_cb) {
128 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 134 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
129 CHECK(read_cb_.is_null()); 135 CHECK(read_cb_.is_null());
130 read_cb_ = read_cb; 136 read_cb_ = read_cb;
137 if (state_ == kPaused) {
138 DeliverFrame(media::VideoFrame::CreateEmptyFrame());
139 }
131 } 140 }
132 141
133 void CaptureVideoDecoder::ResetOnDecoderThread(const base::Closure& closure) { 142 void CaptureVideoDecoder::ResetOnDecoderThread(const base::Closure& closure) {
134 DVLOG(1) << "ResetOnDecoderThread"; 143 DVLOG(1) << "ResetOnDecoderThread";
135 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 144 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
136 if (!read_cb_.is_null()) { 145 if (!read_cb_.is_null()) {
137 scoped_refptr<media::VideoFrame> video_frame = 146 scoped_refptr<media::VideoFrame> video_frame =
138 media::VideoFrame::CreateBlackFrame(natural_size_.width(), 147 media::VideoFrame::CreateBlackFrame(natural_size_.width(),
139 natural_size_.height()); 148 natural_size_.height());
140 DeliverFrame(video_frame); 149 DeliverFrame(video_frame);
(...skipping 11 matching lines...) Expand all
152 161
153 void CaptureVideoDecoder::OnStoppedOnDecoderThread( 162 void CaptureVideoDecoder::OnStoppedOnDecoderThread(
154 media::VideoCapture* capture) { 163 media::VideoCapture* capture) {
155 DVLOG(1) << "OnStoppedOnDecoderThread"; 164 DVLOG(1) << "OnStoppedOnDecoderThread";
156 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 165 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
157 if (!pending_stop_cb_.is_null()) 166 if (!pending_stop_cb_.is_null())
158 base::ResetAndReturn(&pending_stop_cb_).Run(); 167 base::ResetAndReturn(&pending_stop_cb_).Run();
159 vc_manager_->RemoveDevice(video_stream_id_, this); 168 vc_manager_->RemoveDevice(video_stream_id_, this);
160 } 169 }
161 170
171 void CaptureVideoDecoder::OnPausedOnDecoderThread(
172 media::VideoCapture* capture) {
173 DVLOG(1) << "OnPausedOnDecoderThread";
174 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
175 state_ = kPaused;
176 if (!read_cb_.is_null()) {
177 DeliverFrame(media::VideoFrame::CreateEmptyFrame());
178 }
179 }
180
162 void CaptureVideoDecoder::OnDeviceInfoReceivedOnDecoderThread( 181 void CaptureVideoDecoder::OnDeviceInfoReceivedOnDecoderThread(
163 media::VideoCapture* capture, 182 media::VideoCapture* capture,
164 const media::VideoCaptureParams& device_info) { 183 const media::VideoCaptureParams& device_info) {
184 DVLOG(1) << "OnDeviceInfoReceivedOnDecoderThread";
165 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 185 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
166 if (device_info.width != natural_size_.width() || 186 if (device_info.width != natural_size_.width() ||
167 device_info.height != natural_size_.height()) { 187 device_info.height != natural_size_.height()) {
168 natural_size_.SetSize(device_info.width, device_info.height); 188 natural_size_.SetSize(device_info.width, device_info.height);
169 } 189 }
170 } 190 }
171 191
172 void CaptureVideoDecoder::OnBufferReadyOnDecoderThread( 192 void CaptureVideoDecoder::OnBufferReadyOnDecoderThread(
173 media::VideoCapture* capture, 193 media::VideoCapture* capture,
174 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { 194 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 246
227 DeliverFrame(video_frame); 247 DeliverFrame(video_frame);
228 capture->FeedBuffer(buf); 248 capture->FeedBuffer(buf);
229 } 249 }
230 250
231 void CaptureVideoDecoder::DeliverFrame( 251 void CaptureVideoDecoder::DeliverFrame(
232 const scoped_refptr<media::VideoFrame>& video_frame) { 252 const scoped_refptr<media::VideoFrame>& video_frame) {
233 // Reset the callback before running to protect against reentrancy. 253 // Reset the callback before running to protect against reentrancy.
234 base::ResetAndReturn(&read_cb_).Run(kOk, video_frame); 254 base::ResetAndReturn(&read_cb_).Run(kOk, video_frame);
235 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698