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/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 // Enables capturing and streaming of windows. |
| 17 class SingleWindowDesktopEnvironment : public BasicDesktopEnvironment { |
| 18 |
| 19 public: |
| 20 virtual ~SingleWindowDesktopEnvironment(); |
| 21 |
| 22 // DesktopEnvironment interface. |
| 23 virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE; |
| 24 virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; |
| 25 |
| 26 protected: |
| 27 friend class SingleWindowDesktopEnvironmentFactory; |
| 28 SingleWindowDesktopEnvironment( |
| 29 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 30 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 31 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 32 webrtc::WindowId window_id); |
| 33 |
| 34 private: |
| 35 webrtc::WindowId window_id_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(SingleWindowDesktopEnvironment); |
| 38 }; |
| 39 |
| 40 SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() { |
| 41 } |
| 42 |
| 43 scoped_ptr<webrtc::ScreenCapturer> |
| 44 SingleWindowDesktopEnvironment::CreateVideoCapturer() { |
| 45 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 46 |
| 47 webrtc::DesktopCaptureOptions options = |
| 48 webrtc::DesktopCaptureOptions::CreateDefault(); |
| 49 options.set_use_update_notifications(true); |
| 50 |
| 51 scoped_ptr<webrtc::WindowCapturer>window_capturer( |
| 52 webrtc::WindowCapturer::Create(options)); |
| 53 window_capturer->SelectWindow(window_id_); |
| 54 |
| 55 // Wrap WindowCapturer in a ScreenCapturer interface because |
| 56 // for now, DesktopEnvironment returns a ScreenCapturer |
| 57 // and remoting_me2me_host depends on a ScreenCapturer interface. |
| 58 // In the future, we will not need to do this because we will |
| 59 // update the remoting_me2me_host to depend on a DesktopCapturer |
| 60 // interface. |
| 61 scoped_ptr<WindowCapturerScreenWrapper> window_capturer_wrapper( |
| 62 new WindowCapturerScreenWrapper(window_capturer.Pass())); |
| 63 |
| 64 return window_capturer_wrapper.PassAs<webrtc::ScreenCapturer>(); |
| 65 } |
| 66 |
| 67 scoped_ptr<InputInjector> |
| 68 SingleWindowDesktopEnvironment::CreateInputInjector() { |
| 69 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 70 |
| 71 scoped_ptr<InputInjector> input_injector( |
| 72 InputInjector::Create(input_task_runner(), |
| 73 ui_task_runner())); |
| 74 return SingleWindowInputInjector::Create(window_id_, input_injector.Pass()); |
| 75 } |
| 76 |
| 77 SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment( |
| 78 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 79 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 80 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 81 webrtc::WindowId window_id) |
| 82 : BasicDesktopEnvironment(caller_task_runner, |
| 83 input_task_runner, |
| 84 ui_task_runner), |
| 85 window_id_(window_id) { |
| 86 } |
| 87 |
| 88 SingleWindowDesktopEnvironmentFactory::SingleWindowDesktopEnvironmentFactory( |
| 89 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 90 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 91 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 92 webrtc::WindowId window_id) |
| 93 : BasicDesktopEnvironmentFactory(caller_task_runner, |
| 94 input_task_runner, |
| 95 ui_task_runner), |
| 96 window_id_(window_id) { |
| 97 } |
| 98 |
| 99 SingleWindowDesktopEnvironmentFactory:: |
| 100 ~SingleWindowDesktopEnvironmentFactory() { |
| 101 } |
| 102 |
| 103 scoped_ptr<DesktopEnvironment> SingleWindowDesktopEnvironmentFactory::Create( |
| 104 base::WeakPtr<ClientSessionControl> client_session_control) { |
| 105 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 106 |
| 107 scoped_ptr<SingleWindowDesktopEnvironment> desktop_environment( |
| 108 new SingleWindowDesktopEnvironment(caller_task_runner(), |
| 109 input_task_runner(), |
| 110 ui_task_runner(), |
| 111 window_id_)); |
| 112 return desktop_environment.PassAs<DesktopEnvironment>(); |
| 113 } |
| 114 |
| 115 } // namespace remoting |
OLD | NEW |