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