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/desktop_environment.h" | 5 #include "remoting/host/desktop_environment.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
8 #include "remoting/host/audio_capturer.h" | 9 #include "remoting/host/audio_capturer.h" |
| 10 #include "remoting/host/video_frame_capturer.h" |
9 #include "remoting/host/chromoting_host_context.h" | 11 #include "remoting/host/chromoting_host_context.h" |
10 #include "remoting/host/desktop_environment.h" | |
11 #include "remoting/host/event_executor.h" | 12 #include "remoting/host/event_executor.h" |
12 #include "remoting/host/video_frame_capturer.h" | 13 |
| 14 #if defined(OS_WIN) |
| 15 #include "remoting/host/session_event_executor_win.h" |
| 16 #endif |
13 | 17 |
14 namespace remoting { | 18 namespace remoting { |
15 | 19 |
| 20 // static |
| 21 scoped_ptr<DesktopEnvironment> DesktopEnvironment::Create( |
| 22 ChromotingHostContext* context) { |
| 23 scoped_ptr<VideoFrameCapturer> capturer(VideoFrameCapturer::Create()); |
| 24 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
| 25 context->desktop_task_runner(), context->ui_task_runner()); |
| 26 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); |
| 27 |
| 28 if (capturer.get() == NULL || event_executor.get() == NULL) { |
| 29 LOG(ERROR) << "Unable to create DesktopEnvironment"; |
| 30 return scoped_ptr<DesktopEnvironment>(); |
| 31 } |
| 32 |
| 33 return scoped_ptr<DesktopEnvironment>( |
| 34 new DesktopEnvironment(context, |
| 35 capturer.Pass(), |
| 36 event_executor.Pass(), |
| 37 audio_capturer.Pass())); |
| 38 } |
| 39 |
| 40 // static |
| 41 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateForService( |
| 42 ChromotingHostContext* context) { |
| 43 scoped_ptr<VideoFrameCapturer> capturer(VideoFrameCapturer::Create()); |
| 44 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
| 45 context->desktop_task_runner(), context->ui_task_runner()); |
| 46 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); |
| 47 |
| 48 if (capturer.get() == NULL || event_executor.get() == NULL) { |
| 49 LOG(ERROR) << "Unable to create DesktopEnvironment"; |
| 50 return scoped_ptr<DesktopEnvironment>(); |
| 51 } |
| 52 |
| 53 #if defined(OS_WIN) |
| 54 event_executor.reset(new SessionEventExecutorWin( |
| 55 context->desktop_task_runner(), |
| 56 event_executor.Pass())); |
| 57 #endif |
| 58 |
| 59 return scoped_ptr<DesktopEnvironment>( |
| 60 new DesktopEnvironment(context, |
| 61 capturer.Pass(), |
| 62 event_executor.Pass(), |
| 63 audio_capturer.Pass())); |
| 64 } |
| 65 |
| 66 // static |
| 67 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateFake( |
| 68 ChromotingHostContext* context, |
| 69 scoped_ptr<VideoFrameCapturer> capturer, |
| 70 scoped_ptr<EventExecutor> event_executor, |
| 71 scoped_ptr<AudioCapturer> audio_capturer) { |
| 72 return scoped_ptr<DesktopEnvironment>( |
| 73 new DesktopEnvironment(context, |
| 74 capturer.Pass(), |
| 75 event_executor.Pass(), |
| 76 audio_capturer.Pass())); |
| 77 } |
| 78 |
16 DesktopEnvironment::DesktopEnvironment( | 79 DesktopEnvironment::DesktopEnvironment( |
17 scoped_ptr<AudioCapturer> audio_capturer, | 80 ChromotingHostContext* context, |
| 81 scoped_ptr<VideoFrameCapturer> capturer, |
18 scoped_ptr<EventExecutor> event_executor, | 82 scoped_ptr<EventExecutor> event_executor, |
19 scoped_ptr<VideoFrameCapturer> video_capturer) | 83 scoped_ptr<AudioCapturer> audio_capturer) |
20 : audio_capturer_(audio_capturer.Pass()), | 84 : context_(context), |
21 event_executor_(event_executor.Pass()), | 85 capturer_(capturer.Pass()), |
22 video_capturer_(video_capturer.Pass()) { | 86 audio_capturer_(audio_capturer.Pass()), |
| 87 event_executor_(event_executor.Pass()) { |
23 } | 88 } |
24 | 89 |
25 DesktopEnvironment::~DesktopEnvironment() { | 90 DesktopEnvironment::~DesktopEnvironment() { |
26 event_executor_.release()->StopAndDelete(); | |
27 } | 91 } |
28 | 92 |
29 void DesktopEnvironment::Start( | 93 void DesktopEnvironment::OnSessionStarted( |
30 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 94 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
31 event_executor_->Start(client_clipboard.Pass()); | 95 event_executor_->OnSessionStarted(client_clipboard.Pass()); |
| 96 } |
| 97 |
| 98 void DesktopEnvironment::OnSessionFinished() { |
| 99 event_executor_->OnSessionFinished(); |
32 } | 100 } |
33 | 101 |
34 } // namespace remoting | 102 } // namespace remoting |
OLD | NEW |