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
3 // found in the LICENSE file.
5 // ChromotingClient is the controller for the Client implementation.
7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_
8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "remoting/client/chromoting_stats.h"
15 #include "remoting/protocol/client_stub.h"
16 #include "remoting/protocol/clipboard_stub.h"
17 #include "remoting/protocol/connection_to_host.h"
18 #include "remoting/protocol/input_stub.h"
19 #include "remoting/protocol/video_stub.h"
22 class SingleThreadTaskRunner
;
28 class TransportFactory
;
29 } // namespace protocol
31 class AudioDecodeScheduler
;
34 class ClientUserInterface
;
35 class FrameConsumerProxy
;
40 class ChromotingClient
: public protocol::ConnectionToHost::HostEventCallback
,
41 public protocol::ClientStub
{
43 // |audio_player| may be null, in which case audio will not be requested.
44 ChromotingClient(ClientContext
* client_context
,
45 ClientUserInterface
* user_interface
,
46 VideoRenderer
* video_renderer
,
47 scoped_ptr
<AudioPlayer
> audio_player
);
49 virtual ~ChromotingClient();
51 // Start the client. Must be called on the main thread. |signal_strategy|
52 // must outlive the client.
53 void Start(SignalStrategy
* signal_strategy
,
54 scoped_ptr
<protocol::Authenticator
> authenticator
,
55 scoped_ptr
<protocol::TransportFactory
> transport_factory
,
56 const std::string
& host_jid
,
57 const std::string
& capabilities
);
59 protocol::ConnectionToHost::State
connection_state() const {
60 return connection_
.state();
63 protocol::ClipboardStub
* clipboard_forwarder() {
64 return connection_
.clipboard_forwarder();
66 protocol::HostStub
* host_stub() { return connection_
.host_stub(); }
67 protocol::InputStub
* input_stub() { return connection_
.input_stub(); }
69 // ClientStub implementation.
70 virtual void SetCapabilities(
71 const protocol::Capabilities
& capabilities
) OVERRIDE
;
72 virtual void SetPairingResponse(
73 const protocol::PairingResponse
& pairing_response
) OVERRIDE
;
74 virtual void DeliverHostMessage(
75 const protocol::ExtensionMessage
& message
) OVERRIDE
;
77 // ClipboardStub implementation for receiving clipboard data from host.
78 virtual void InjectClipboardEvent(
79 const protocol::ClipboardEvent
& event
) OVERRIDE
;
81 // CursorShapeStub implementation for receiving cursor shape updates.
82 virtual void SetCursorShape(
83 const protocol::CursorShapeInfo
& cursor_shape
) OVERRIDE
;
85 // ConnectionToHost::HostEventCallback implementation.
86 virtual void OnConnectionState(
87 protocol::ConnectionToHost::State state
,
88 protocol::ErrorCode error
) OVERRIDE
;
89 virtual void OnConnectionReady(bool ready
) OVERRIDE
;
90 virtual void OnRouteChanged(const std::string
& channel_name
,
91 const protocol::TransportRoute
& route
) OVERRIDE
;
94 // Called when the connection is authenticated.
95 void OnAuthenticated();
97 // Called when all channels are connected.
98 void OnChannelsConnected();
100 // The following are not owned by this class.
101 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
102 ClientUserInterface
* user_interface_
;
103 VideoRenderer
* video_renderer_
;
105 protocol::ConnectionToHost connection_
;
107 scoped_ptr
<AudioDecodeScheduler
> audio_decode_scheduler_
;
109 std::string local_capabilities_
;
111 // The set of all capabilities supported by the host.
112 std::string host_capabilities_
;
114 // True if |protocol::Capabilities| message has been received.
115 bool host_capabilities_received_
;
117 // Record the statistics of the connection.
118 ChromotingStats stats_
;
120 DISALLOW_COPY_AND_ASSIGN(ChromotingClient
);
123 } // namespace remoting
125 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_