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

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

Issue 13616004: Switch event type when a capture device has been stopped from the render process. This make sure th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed code review comments. Created 7 years, 8 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 | « content/renderer/media/rtc_video_capture_delegate.h ('k') | content/renderer/media/rtc_video_capturer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/renderer/media/rtc_video_capture_delegate.h ('k') | content/renderer/media/rtc_video_capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698