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

Side by Side 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: 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 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/rtc_video_capture_delegate.h" 5 #include "content/renderer/media/rtc_video_capture_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void RtcVideoCaptureDelegate::OnError(media::VideoCapture* capture, 60 void RtcVideoCaptureDelegate::OnError(media::VideoCapture* capture,
61 int error_code) { 61 int error_code) {
62 message_loop_proxy_->PostTask( 62 message_loop_proxy_->PostTask(
63 FROM_HERE, 63 FROM_HERE,
64 base::Bind(&RtcVideoCaptureDelegate::OnErrorOnCaptureThread, 64 base::Bind(&RtcVideoCaptureDelegate::OnErrorOnCaptureThread,
65 this, capture, error_code)); 65 this, capture, error_code));
66 } 66 }
67 67
68 void RtcVideoCaptureDelegate::OnRemoved(media::VideoCapture* capture) { 68 void RtcVideoCaptureDelegate::OnRemoved(media::VideoCapture* capture) {
69 DVLOG(3) << " RtcVideoCaptureDelegate::OnRemoved"; 69 DVLOG(3) << " RtcVideoCaptureDelegate::OnRemoved";
70 message_loop_proxy_->PostTask(
71 FROM_HERE,
72 base::Bind(&RtcVideoCaptureDelegate::OnRemovedOnCaptureThread,
73 this, capture));
74
70 // Balance the AddRef in StartCapture. 75 // Balance the AddRef in StartCapture.
71 // This means we are no longer registered as an event handler and can safely 76 // This means we are no longer registered as an event handler and can safely
72 // be deleted. 77 // be deleted.
73 Release(); 78 Release();
74 } 79 }
75 80
76 void RtcVideoCaptureDelegate::OnBufferReady( 81 void RtcVideoCaptureDelegate::OnBufferReady(
77 media::VideoCapture* capture, 82 media::VideoCapture* capture,
78 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { 83 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
79 message_loop_proxy_->PostTask( 84 message_loop_proxy_->PostTask(
(...skipping 16 matching lines...) Expand all
96 got_first_frame_ = true; 101 got_first_frame_ = true;
97 if (!state_callback_.is_null()) 102 if (!state_callback_.is_null())
98 state_callback_.Run(CAPTURE_RUNNING); 103 state_callback_.Run(CAPTURE_RUNNING);
99 } 104 }
100 105
101 captured_callback_.Run(*buf); 106 captured_callback_.Run(*buf);
102 } 107 }
103 capture->FeedBuffer(buf); 108 capture->FeedBuffer(buf);
104 } 109 }
105 110
111 void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread(
112 media::VideoCapture* capture) {
113 if (!state_callback_.is_null())
114 state_callback_.Run(got_first_frame_ ? CAPTURE_STOPPED : CAPTURE_FAILED);
wjia(left Chromium) 2013/04/04 17:05:11 OnRemoved could be called after either OnError or
perkj_chrome 2013/04/05 09:19:35 right - removed onerror and only listen to OnRemov
115 }
116
106 void RtcVideoCaptureDelegate::OnErrorOnCaptureThread( 117 void RtcVideoCaptureDelegate::OnErrorOnCaptureThread(
107 media::VideoCapture* capture, int error_code) { 118 media::VideoCapture* capture, int error_code) {
108 if (!state_callback_.is_null()) 119 if (!state_callback_.is_null())
109 state_callback_.Run(got_first_frame_ ? CAPTURE_STOPPED : CAPTURE_FAILED); 120 state_callback_.Run(got_first_frame_ ? CAPTURE_STOPPED : CAPTURE_FAILED);
110 } 121 }
111 122
112 } // namespace content 123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698