OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/me2me_single_window_desktop_environment.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "remoting/host/single_window_input_injector.h" |
| 10 #include "remoting/host/window_capturer_screen_wrapper.h" |
| 11 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 13 |
| 14 namespace remoting { |
| 15 |
| 16 SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() { |
| 17 } |
| 18 |
| 19 scoped_ptr<webrtc::ScreenCapturer> |
| 20 SingleWindowDesktopEnvironment::CreateVideoCapturer() { |
| 21 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 22 |
| 23 // Use the default capturing options with the WindowCapturer |
| 24 webrtc::DesktopCaptureOptions options = |
| 25 webrtc::DesktopCaptureOptions::CreateDefault(); |
| 26 options.set_use_update_notifications(true); |
| 27 |
| 28 // Create a WindowCapturer |
| 29 scoped_ptr<webrtc::WindowCapturer>window_capturer( |
| 30 webrtc::WindowCapturer::Create(options)); |
| 31 window_capturer->SelectWindow(window_id_); |
| 32 |
| 33 // Wrap WindowCapturer in a ScreenCapturer interface |
| 34 scoped_ptr<WindowCapturerScreenWrapper>window_capturer_wrapper( |
| 35 new WindowCapturerScreenWrapper(window_capturer.Pass())); |
| 36 |
| 37 return window_capturer_wrapper.PassAs<webrtc::ScreenCapturer>(); |
| 38 } |
| 39 |
| 40 scoped_ptr<InputInjector> |
| 41 SingleWindowDesktopEnvironment::CreateInputInjector() { |
| 42 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 43 |
| 44 scoped_ptr<InputInjector>input_injector( |
| 45 InputInjector::Create(input_task_runner(), |
| 46 ui_task_runner())); |
| 47 return SingleWindowInputInjector::Create(window_id_, input_injector.Pass()); |
| 48 /* |
| 49 return InputInjector::CreateForWindow(input_task_runner(), |
| 50 ui_task_runner(), |
| 51 window_id_); |
| 52 */ |
| 53 } |
| 54 |
| 55 SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment( |
| 56 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 57 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 58 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
| 59 : BasicDesktopEnvironment(caller_task_runner, |
| 60 input_task_runner, |
| 61 ui_task_runner) { |
| 62 } |
| 63 |
| 64 void SingleWindowDesktopEnvironment::SetWindowId( |
| 65 webrtc::WindowId windowIdEnvironment) { |
| 66 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 67 window_id_ = windowIdEnvironment; |
| 68 } |
| 69 |
| 70 SingleWindowDesktopEnvironmentFactory::SingleWindowDesktopEnvironmentFactory( |
| 71 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 72 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 73 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 74 webrtc::WindowId windowId) |
| 75 : BasicDesktopEnvironmentFactory(caller_task_runner, |
| 76 input_task_runner, |
| 77 ui_task_runner) { |
| 78 window_id_ = windowId; |
| 79 } |
| 80 |
| 81 SingleWindowDesktopEnvironmentFactory:: |
| 82 ~SingleWindowDesktopEnvironmentFactory() { |
| 83 } |
| 84 |
| 85 scoped_ptr<DesktopEnvironment> SingleWindowDesktopEnvironmentFactory::Create( |
| 86 base::WeakPtr<ClientSessionControl> client_session_control) { |
| 87 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 88 |
| 89 scoped_ptr<SingleWindowDesktopEnvironment> desktop_environment( |
| 90 new SingleWindowDesktopEnvironment(caller_task_runner(), |
| 91 input_task_runner(), |
| 92 ui_task_runner())); |
| 93 desktop_environment->SetWindowId(window_id_); |
| 94 return desktop_environment.PassAs<DesktopEnvironment>(); |
| 95 } |
| 96 |
| 97 } // namespace remoting |
OLD | NEW |