| Index: content/renderer/media/rtc_video_capture_delegate.cc
|
| diff --git a/content/renderer/media/rtc_video_capture_delegate.cc b/content/renderer/media/rtc_video_capture_delegate.cc
|
| index 33a1917fc2d1b672818663813a2a8d479c3afa67..975cfde1bf043ba35adf7b53749868cf18058a77 100644
|
| --- a/content/renderer/media/rtc_video_capture_delegate.cc
|
| +++ b/content/renderer/media/rtc_video_capture_delegate.cc
|
| @@ -14,7 +14,8 @@ RtcVideoCaptureDelegate::RtcVideoCaptureDelegate(
|
| : session_id_(id),
|
| vc_manager_(vc_manager),
|
| capture_engine_(NULL),
|
| - got_first_frame_(false) {
|
| + got_first_frame_(false),
|
| + error_occured_(false) {
|
| DVLOG(3) << " RtcVideoCaptureDelegate::ctor";
|
| capture_engine_ = vc_manager_->AddDevice(session_id_, this);
|
| }
|
| @@ -32,6 +33,8 @@ void RtcVideoCaptureDelegate::StartCapture(
|
| message_loop_proxy_ = base::MessageLoopProxy::current();
|
| captured_callback_ = captured_callback;
|
| state_callback_ = state_callback;
|
| + got_first_frame_ = false;
|
| + error_occured_ = false;
|
|
|
| // Increase the reference count to ensure we are not deleted until
|
| // The we are unregistered in RtcVideoCaptureDelegate::OnRemoved.
|
| @@ -59,14 +62,20 @@ void RtcVideoCaptureDelegate::OnPaused(media::VideoCapture* capture) {
|
|
|
| void RtcVideoCaptureDelegate::OnError(media::VideoCapture* capture,
|
| int error_code) {
|
| + DVLOG(3) << " RtcVideoCaptureDelegate::OnError";
|
| message_loop_proxy_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&RtcVideoCaptureDelegate::OnErrorOnCaptureThread,
|
| - this, capture, error_code));
|
| + this, capture));
|
| }
|
|
|
| void RtcVideoCaptureDelegate::OnRemoved(media::VideoCapture* capture) {
|
| DVLOG(3) << " RtcVideoCaptureDelegate::OnRemoved";
|
| + message_loop_proxy_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&RtcVideoCaptureDelegate::OnRemovedOnCaptureThread,
|
| + this, capture));
|
| +
|
| // Balance the AddRef in StartCapture.
|
| // This means we are no longer registered as an event handler and can safely
|
| // be deleted.
|
| @@ -104,9 +113,17 @@ void RtcVideoCaptureDelegate::OnBufferReadyOnCaptureThread(
|
| }
|
|
|
| void RtcVideoCaptureDelegate::OnErrorOnCaptureThread(
|
| - media::VideoCapture* capture, int error_code) {
|
| + media::VideoCapture* capture) {
|
| + error_occured_ = true;
|
| if (!state_callback_.is_null())
|
| - state_callback_.Run(got_first_frame_ ? CAPTURE_STOPPED : CAPTURE_FAILED);
|
| + state_callback_.Run(CAPTURE_FAILED);
|
| +}
|
| +
|
| +
|
| +void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread(
|
| + media::VideoCapture* capture) {
|
| + if (!error_occured_ && !state_callback_.is_null())
|
| + state_callback_.Run(CAPTURE_STOPPED);
|
| }
|
|
|
| } // namespace content
|
|
|