| 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 "remoting/host/ipc_video_frame_capturer.h" | 5 #include "remoting/host/ipc_video_frame_capturer.h" |
| 6 | 6 |
| 7 #include "media/video/capture/screen/mouse_cursor_shape.h" | 7 #include "media/video/capture/screen/mouse_cursor_shape.h" |
| 8 #include "media/video/capture/screen/screen_capture_data.h" | |
| 9 #include "remoting/host/desktop_session_proxy.h" | 8 #include "remoting/host/desktop_session_proxy.h" |
| 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 10 | 10 |
| 11 namespace remoting { | 11 namespace remoting { |
| 12 | 12 |
| 13 IpcVideoFrameCapturer::IpcVideoFrameCapturer( | 13 IpcVideoFrameCapturer::IpcVideoFrameCapturer( |
| 14 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) | 14 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) |
| 15 : delegate_(NULL), | 15 : callback_(NULL), |
| 16 mouse_shape_observer_(NULL), |
| 16 desktop_session_proxy_(desktop_session_proxy), | 17 desktop_session_proxy_(desktop_session_proxy), |
| 18 capture_pending_(false), |
| 17 weak_factory_(this) { | 19 weak_factory_(this) { |
| 18 } | 20 } |
| 19 | 21 |
| 20 IpcVideoFrameCapturer::~IpcVideoFrameCapturer() { | 22 IpcVideoFrameCapturer::~IpcVideoFrameCapturer() { |
| 21 } | 23 } |
| 22 | 24 |
| 23 void IpcVideoFrameCapturer::Start(Delegate* delegate) { | 25 void IpcVideoFrameCapturer::Start(Callback* callback) { |
| 24 delegate_ = delegate; | 26 DCHECK(!callback_); |
| 27 DCHECK(callback); |
| 28 callback_ = callback; |
| 25 desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr()); | 29 desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr()); |
| 26 } | 30 } |
| 27 | 31 |
| 28 void IpcVideoFrameCapturer::CaptureFrame() { | 32 void IpcVideoFrameCapturer::SetMouseShapeObserver( |
| 33 MouseShapeObserver* mouse_shape_observer) { |
| 34 DCHECK(!mouse_shape_observer_); |
| 35 DCHECK(mouse_shape_observer); |
| 36 mouse_shape_observer_ = mouse_shape_observer; |
| 37 } |
| 38 |
| 39 void IpcVideoFrameCapturer::Capture(const webrtc::DesktopRegion& region) { |
| 40 DCHECK(!capture_pending_); |
| 41 capture_pending_ = true; |
| 29 desktop_session_proxy_->CaptureFrame(); | 42 desktop_session_proxy_->CaptureFrame(); |
| 30 } | 43 } |
| 31 | 44 |
| 32 void IpcVideoFrameCapturer::OnCaptureCompleted( | 45 void IpcVideoFrameCapturer::OnCaptureCompleted( |
| 33 scoped_refptr<media::ScreenCaptureData> capture_data) { | 46 scoped_ptr<webrtc::DesktopFrame> frame) { |
| 34 if (delegate_) | 47 DCHECK(capture_pending_); |
| 35 delegate_->OnCaptureCompleted(capture_data); | 48 capture_pending_ = false; |
| 49 callback_->OnCaptureCompleted(frame.release()); |
| 36 } | 50 } |
| 37 | 51 |
| 38 void IpcVideoFrameCapturer::OnCursorShapeChanged( | 52 void IpcVideoFrameCapturer::OnCursorShapeChanged( |
| 39 scoped_ptr<media::MouseCursorShape> cursor_shape) { | 53 scoped_ptr<media::MouseCursorShape> cursor_shape) { |
| 40 if (delegate_) | 54 if (mouse_shape_observer_) |
| 41 delegate_->OnCursorShapeChanged(cursor_shape.Pass()); | 55 mouse_shape_observer_->OnCursorShapeChanged(cursor_shape.Pass()); |
| 42 } | 56 } |
| 43 | 57 |
| 44 } // namespace remoting | 58 } // namespace remoting |
| OLD | NEW |