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 "remoting/host/desktop_session_proxy.h" | 7 #include "remoting/host/desktop_session_proxy.h" |
8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
9 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.h" | 9 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_shape.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 : callback_(NULL), | 15 : callback_(NULL), |
16 mouse_shape_observer_(NULL), | |
17 desktop_session_proxy_(desktop_session_proxy), | 16 desktop_session_proxy_(desktop_session_proxy), |
18 capture_pending_(false), | 17 capture_pending_(false), |
19 weak_factory_(this) { | 18 weak_factory_(this) { |
20 } | 19 } |
21 | 20 |
22 IpcVideoFrameCapturer::~IpcVideoFrameCapturer() { | 21 IpcVideoFrameCapturer::~IpcVideoFrameCapturer() { |
23 } | 22 } |
24 | 23 |
25 void IpcVideoFrameCapturer::Start(Callback* callback) { | 24 void IpcVideoFrameCapturer::Start(Callback* callback) { |
26 DCHECK(!callback_); | 25 DCHECK(!callback_); |
27 DCHECK(callback); | 26 DCHECK(callback); |
28 callback_ = callback; | 27 callback_ = callback; |
29 desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr()); | 28 desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr()); |
30 } | 29 } |
31 | 30 |
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 bool IpcVideoFrameCapturer::GetScreenList(ScreenList* screens) { | |
40 NOTIMPLEMENTED(); | |
41 return false; | |
42 } | |
43 | |
44 bool IpcVideoFrameCapturer::SelectScreen(webrtc::ScreenId id) { | |
45 NOTIMPLEMENTED(); | |
46 return false; | |
47 } | |
48 | |
49 void IpcVideoFrameCapturer::Capture(const webrtc::DesktopRegion& region) { | 31 void IpcVideoFrameCapturer::Capture(const webrtc::DesktopRegion& region) { |
50 DCHECK(!capture_pending_); | 32 DCHECK(!capture_pending_); |
51 capture_pending_ = true; | 33 capture_pending_ = true; |
52 desktop_session_proxy_->CaptureFrame(); | 34 desktop_session_proxy_->CaptureFrame(); |
53 } | 35 } |
54 | 36 |
55 void IpcVideoFrameCapturer::OnCaptureCompleted( | 37 void IpcVideoFrameCapturer::OnCaptureCompleted( |
56 scoped_ptr<webrtc::DesktopFrame> frame) { | 38 scoped_ptr<webrtc::DesktopFrame> frame) { |
57 DCHECK(capture_pending_); | 39 DCHECK(capture_pending_); |
58 capture_pending_ = false; | 40 capture_pending_ = false; |
59 callback_->OnCaptureCompleted(frame.release()); | 41 callback_->OnCaptureCompleted(frame.release()); |
60 } | 42 } |
61 | 43 |
62 void IpcVideoFrameCapturer::OnCursorShapeChanged( | |
63 scoped_ptr<webrtc::MouseCursorShape> cursor_shape) { | |
64 if (mouse_shape_observer_) | |
65 mouse_shape_observer_->OnCursorShapeChanged(cursor_shape.release()); | |
66 } | |
67 | |
68 } // namespace remoting | 44 } // namespace remoting |
OLD | NEW |