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

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

Issue 23551011: From Video Capture, abolish OnFrameInfo and enable resolution changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes from bbudge Created 7 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 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
11 RtcVideoCaptureDelegate::RtcVideoCaptureDelegate( 11 RtcVideoCaptureDelegate::RtcVideoCaptureDelegate(
12 const media::VideoCaptureSessionId id, 12 const media::VideoCaptureSessionId id,
13 VideoCaptureImplManager* vc_manager) 13 VideoCaptureImplManager* vc_manager)
14 : session_id_(id), 14 : session_id_(id),
15 vc_manager_(vc_manager), 15 vc_manager_(vc_manager),
16 capture_engine_(NULL), 16 capture_engine_(NULL),
17 got_first_frame_(false), 17 got_first_frame_(false),
18 error_occured_(false) { 18 error_occured_(false) {
19 DVLOG(3) << " RtcVideoCaptureDelegate::ctor"; 19 DVLOG(3) << " RtcVideoCaptureDelegate::ctor";
20 capture_engine_ = vc_manager_->AddDevice(session_id_, this); 20 capture_engine_ = vc_manager_->AddDevice(session_id_, this);
21 } 21 }
22 22
23 RtcVideoCaptureDelegate::~RtcVideoCaptureDelegate() { 23 RtcVideoCaptureDelegate::~RtcVideoCaptureDelegate() {
24 DVLOG(3) << " RtcVideoCaptureDelegate::dtor"; 24 DVLOG(3) << " RtcVideoCaptureDelegate::dtor";
25 vc_manager_->RemoveDevice(session_id_, this); 25 vc_manager_->RemoveDevice(session_id_, this);
26 } 26 }
27 27
28 void RtcVideoCaptureDelegate::StartCapture( 28 void RtcVideoCaptureDelegate::StartCapture(
29 const media::VideoCaptureCapability& capability, 29 const media::VideoCaptureParams& params,
30 const FrameCapturedCallback& captured_callback, 30 const FrameCapturedCallback& captured_callback,
31 const StateChangeCallback& state_callback) { 31 const StateChangeCallback& state_callback) {
32 DVLOG(3) << " RtcVideoCaptureDelegate::StartCapture "; 32 DVLOG(3) << " RtcVideoCaptureDelegate::StartCapture ";
33 message_loop_proxy_ = base::MessageLoopProxy::current(); 33 message_loop_proxy_ = base::MessageLoopProxy::current();
34 captured_callback_ = captured_callback; 34 captured_callback_ = captured_callback;
35 state_callback_ = state_callback; 35 state_callback_ = state_callback;
36 got_first_frame_ = false; 36 got_first_frame_ = false;
37 error_occured_ = false; 37 error_occured_ = false;
38 38
39 // Increase the reference count to ensure we are not deleted until 39 // Increase the reference count to ensure we are not deleted until
40 // The we are unregistered in RtcVideoCaptureDelegate::OnRemoved. 40 // The we are unregistered in RtcVideoCaptureDelegate::OnRemoved.
41 AddRef(); 41 AddRef();
42 capture_engine_->StartCapture(this, capability); 42 capture_engine_->StartCapture(this, params);
43 } 43 }
44 44
45 void RtcVideoCaptureDelegate::StopCapture() { 45 void RtcVideoCaptureDelegate::StopCapture() {
46 // Immediately make sure we don't provide more frames. 46 // Immediately make sure we don't provide more frames.
47 captured_callback_.Reset(); 47 captured_callback_.Reset();
48 state_callback_.Reset(); 48 state_callback_.Reset();
49 capture_engine_->StopCapture(this); 49 capture_engine_->StopCapture(this);
50 } 50 }
51 51
52 void RtcVideoCaptureDelegate::OnStarted(media::VideoCapture* capture) { 52 void RtcVideoCaptureDelegate::OnStarted(media::VideoCapture* capture) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 media::VideoCapture* capture, 85 media::VideoCapture* capture,
86 const scoped_refptr<media::VideoFrame>& frame) { 86 const scoped_refptr<media::VideoFrame>& frame) {
87 message_loop_proxy_->PostTask( 87 message_loop_proxy_->PostTask(
88 FROM_HERE, 88 FROM_HERE,
89 base::Bind(&RtcVideoCaptureDelegate::OnFrameReadyOnCaptureThread, 89 base::Bind(&RtcVideoCaptureDelegate::OnFrameReadyOnCaptureThread,
90 this, 90 this,
91 capture, 91 capture,
92 frame)); 92 frame));
93 } 93 }
94 94
95 void RtcVideoCaptureDelegate::OnDeviceInfoReceived(
96 media::VideoCapture* capture,
97 const media::VideoCaptureParams& device_info) {
98 }
99
100 void RtcVideoCaptureDelegate::OnDeviceInfoChanged(
101 media::VideoCapture* capture,
102 const media::VideoCaptureParams& device_info) {
103 }
104
105 void RtcVideoCaptureDelegate::OnFrameReadyOnCaptureThread( 95 void RtcVideoCaptureDelegate::OnFrameReadyOnCaptureThread(
106 media::VideoCapture* capture, 96 media::VideoCapture* capture,
107 const scoped_refptr<media::VideoFrame>& frame) { 97 const scoped_refptr<media::VideoFrame>& frame) {
108 if (!captured_callback_.is_null()) { 98 if (!captured_callback_.is_null()) {
109 if (!got_first_frame_) { 99 if (!got_first_frame_) {
110 got_first_frame_ = true; 100 got_first_frame_ = true;
111 if (!state_callback_.is_null()) 101 if (!state_callback_.is_null())
112 state_callback_.Run(CAPTURE_RUNNING); 102 state_callback_.Run(CAPTURE_RUNNING);
113 } 103 }
114 104
115 captured_callback_.Run(frame); 105 captured_callback_.Run(frame);
116 } 106 }
117 } 107 }
118 108
119 void RtcVideoCaptureDelegate::OnErrorOnCaptureThread( 109 void RtcVideoCaptureDelegate::OnErrorOnCaptureThread(
120 media::VideoCapture* capture) { 110 media::VideoCapture* capture) {
121 error_occured_ = true; 111 error_occured_ = true;
122 if (!state_callback_.is_null()) 112 if (!state_callback_.is_null())
123 state_callback_.Run(CAPTURE_FAILED); 113 state_callback_.Run(CAPTURE_FAILED);
124 } 114 }
125 115
126 116
127 void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread( 117 void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread(
128 media::VideoCapture* capture) { 118 media::VideoCapture* capture) {
129 if (!error_occured_ && !state_callback_.is_null()) 119 if (!error_occured_ && !state_callback_.is_null())
130 state_callback_.Run(CAPTURE_STOPPED); 120 state_callback_.Run(CAPTURE_STOPPED);
131 } 121 }
132 122
133 } // namespace content 123 } // namespace content
OLDNEW
« 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