OLD | NEW |
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 #include "base/location.h" | |
9 #include "content/renderer/media/video_capture_impl_manager.h" | |
10 #include "content/renderer/render_thread_impl.h" | |
11 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
12 | 9 |
13 namespace content { | 10 namespace content { |
14 | 11 |
15 RtcVideoCaptureDelegate::RtcVideoCaptureDelegate( | 12 RtcVideoCaptureDelegate::RtcVideoCaptureDelegate( |
16 const media::VideoCaptureSessionId id) | 13 const media::VideoCaptureSessionId id, |
| 14 VideoCaptureImplManager* vc_manager) |
17 : session_id_(id), | 15 : session_id_(id), |
| 16 vc_manager_(vc_manager), |
| 17 capture_engine_(NULL), |
18 got_first_frame_(false), | 18 got_first_frame_(false), |
19 error_occured_(false) { | 19 error_occured_(false) { |
20 DVLOG(3) << " RtcVideoCaptureDelegate::ctor"; | 20 DVLOG(3) << " RtcVideoCaptureDelegate::ctor"; |
21 capture_engine_ = | 21 capture_engine_ = vc_manager_->AddDevice(session_id_, this); |
22 RenderThreadImpl::current()->video_capture_impl_manager() | |
23 ->UseDevice(session_id_); | |
24 } | 22 } |
25 | 23 |
26 RtcVideoCaptureDelegate::~RtcVideoCaptureDelegate() { | 24 RtcVideoCaptureDelegate::~RtcVideoCaptureDelegate() { |
27 DVLOG(3) << " RtcVideoCaptureDelegate::dtor"; | 25 DVLOG(3) << " RtcVideoCaptureDelegate::dtor"; |
28 StopCapture(); | 26 vc_manager_->RemoveDevice(session_id_, this); |
29 } | 27 } |
30 | 28 |
31 void RtcVideoCaptureDelegate::StartCapture( | 29 void RtcVideoCaptureDelegate::StartCapture( |
32 const media::VideoCaptureParams& params, | 30 const media::VideoCaptureParams& params, |
33 const FrameCapturedCallback& captured_callback, | 31 const FrameCapturedCallback& captured_callback, |
34 const StateChangeCallback& state_callback) { | 32 const StateChangeCallback& state_callback) { |
35 DVLOG(3) << " RtcVideoCaptureDelegate::StartCapture "; | 33 DVLOG(3) << " RtcVideoCaptureDelegate::StartCapture "; |
36 message_loop_proxy_ = base::MessageLoopProxy::current(); | 34 message_loop_proxy_ = base::MessageLoopProxy::current(); |
37 captured_callback_ = captured_callback; | 35 captured_callback_ = captured_callback; |
38 state_callback_ = state_callback; | 36 state_callback_ = state_callback; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 115 } |
118 | 116 |
119 | 117 |
120 void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread( | 118 void RtcVideoCaptureDelegate::OnRemovedOnCaptureThread( |
121 media::VideoCapture* capture) { | 119 media::VideoCapture* capture) { |
122 if (!error_occured_ && !state_callback_.is_null()) | 120 if (!error_occured_ && !state_callback_.is_null()) |
123 state_callback_.Run(CAPTURE_STOPPED); | 121 state_callback_.Run(CAPTURE_STOPPED); |
124 } | 122 } |
125 | 123 |
126 } // namespace content | 124 } // namespace content |
OLD | NEW |