| Index: remoting/host/ipc_desktop_environment.cc
|
| diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc
|
| index 699f06ad62f5aae31a4f88dcb7ec2143a4a84f47..b15ce633b41fdaa064ba0e6a174c0d63c676324e 100644
|
| --- a/remoting/host/ipc_desktop_environment.cc
|
| +++ b/remoting/host/ipc_desktop_environment.cc
|
| @@ -13,6 +13,8 @@
|
| #include "ipc/ipc_message_macros.h"
|
| #include "remoting/capturer/capture_data.h"
|
| #include "remoting/capturer/video_frame_capturer.h"
|
| +#include "remoting/codec/audio_encoder.h"
|
| +#include "remoting/codec/video_encoder.h"
|
| #include "remoting/host/audio_capturer.h"
|
| #include "remoting/host/chromoting_messages.h"
|
| #include "remoting/host/client_session.h"
|
| @@ -20,7 +22,6 @@
|
| #include "remoting/host/desktop_session_proxy.h"
|
| #include "remoting/host/event_executor.h"
|
| #include "remoting/host/ipc_audio_capturer.h"
|
| -#include "remoting/host/ipc_event_executor.h"
|
| #include "remoting/host/ipc_video_frame_capturer.h"
|
|
|
| #if defined(OS_WIN)
|
| @@ -30,47 +31,116 @@
|
| namespace remoting {
|
|
|
| IpcDesktopEnvironment::IpcDesktopEnvironment(
|
| - scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
|
| - scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
|
| - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
| - DesktopSessionConnector* desktop_session_connector,
|
| - scoped_refptr<DesktopSessionProxy> desktop_session_proxy)
|
| - : DesktopEnvironment(
|
| - scoped_ptr<AudioCapturer>(
|
| - new IpcAudioCapturer(desktop_session_proxy)),
|
| - scoped_ptr<EventExecutor>(
|
| - new IpcEventExecutor(desktop_session_proxy)),
|
| - scoped_ptr<VideoFrameCapturer>(
|
| - new IpcVideoFrameCapturer(desktop_session_proxy))),
|
| - network_task_runner_(network_task_runner),
|
| + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
|
| + const std::string& client_jid,
|
| + const base::Closure& disconnect_callback,
|
| + base::WeakPtr<DesktopSessionConnector> desktop_session_connector)
|
| + : caller_task_runner_(caller_task_runner),
|
| + connected_(false),
|
| desktop_session_connector_(desktop_session_connector),
|
| - desktop_session_proxy_(desktop_session_proxy),
|
| - connected_(false) {
|
| + desktop_session_proxy_(new DesktopSessionProxy(caller_task_runner,
|
| + client_jid,
|
| + disconnect_callback)) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| }
|
|
|
| IpcDesktopEnvironment::~IpcDesktopEnvironment() {
|
| - if (connected_) {
|
| - connected_ = false;
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + if (connected_ && desktop_session_connector_)
|
| desktop_session_connector_->DisconnectTerminal(desktop_session_proxy_);
|
| - }
|
| +
|
| + connected_ = false;
|
| + desktop_session_proxy_->Stop();
|
| }
|
|
|
| -void IpcDesktopEnvironment::Start(
|
| - scoped_ptr<protocol::ClipboardStub> client_clipboard,
|
| - const std::string& client_jid,
|
| - const base::Closure& disconnect_callback) {
|
| - DCHECK(network_task_runner_->BelongsToCurrentThread());
|
| - DCHECK(!connected_);
|
| +void IpcDesktopEnvironment::InjectClipboardEvent(
|
| + const protocol::ClipboardEvent& event) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
|
|
| - desktop_session_proxy_->Initialize(client_jid, disconnect_callback);
|
| + desktop_session_proxy_->InjectClipboardEvent(event);
|
| +}
|
|
|
| - // Register the proxy to receive AttachToDesktop() and DetachFromDesktop()
|
| - // notifications.
|
| - connected_ = true;
|
| - desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
|
| +void IpcDesktopEnvironment::InjectKeyEvent(const protocol::KeyEvent& event) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + desktop_session_proxy_->InjectKeyEvent(event);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::InjectMouseEvent(
|
| + const protocol::MouseEvent& event) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + desktop_session_proxy_->InjectMouseEvent(event);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::StartAudio(
|
| + scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
|
| + scoped_ptr<AudioEncoder> audio_encoder,
|
| + protocol::AudioStub* audio_stub) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + RegisterDesktopSessionProxy();
|
| + desktop_session_proxy_->StartAudio(audio_task_runner, audio_encoder.Pass(),
|
| + audio_stub);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::PauseAudio(bool pause) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + desktop_session_proxy_->PauseAudio(pause);
|
| +}
|
|
|
| - DesktopEnvironment::Start(client_clipboard.Pass(), client_jid,
|
| - disconnect_callback);
|
| +void IpcDesktopEnvironment::StartInput(
|
| + scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
| + protocol::ClipboardStub* clipboard_stub) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + RegisterDesktopSessionProxy();
|
| + desktop_session_proxy_->StartInput(input_task_runner, ui_task_runner,
|
| + clipboard_stub);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::StartVideo(
|
| + scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
|
| + scoped_ptr<VideoEncoder> video_encoder,
|
| + protocol::CursorShapeStub* cursor_shape_stub,
|
| + protocol::VideoStub* video_stub) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + RegisterDesktopSessionProxy();
|
| + desktop_session_proxy_->StartVideo(capture_task_runner,
|
| + encode_task_runner,
|
| + video_encoder.Pass(),
|
| + cursor_shape_stub,
|
| + video_stub);
|
| +}
|
| +
|
| +SkISize IpcDesktopEnvironment::GetScreenSize() const {
|
| + return desktop_session_proxy_->GetScreenSize();
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::PauseVideo(bool pause) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + desktop_session_proxy_->PauseVideo(pause);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::UpdateSequenceNumber(int64 sequence_number) {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + desktop_session_proxy_->UpdateSequenceNumber(sequence_number);
|
| +}
|
| +
|
| +void IpcDesktopEnvironment::RegisterDesktopSessionProxy() {
|
| + DCHECK(caller_task_runner_->BelongsToCurrentThread());
|
| +
|
| + if (!connected_) {
|
| + connected_ = true;
|
| + desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
|
| + }
|
| }
|
|
|
| } // namespace remoting
|
|
|