Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / remoting / client / chromoting_client.h
blob94c8f4ea9083d703b68c956a4caee1082b16b291
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_
10 #include <string>
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"
21 namespace base {
22 class SingleThreadTaskRunner;
23 } // namespace base
25 namespace remoting {
27 namespace protocol {
28 class CandidateSessionConfig;
29 class TransportFactory;
30 } // namespace protocol
32 class AudioDecodeScheduler;
33 class AudioPlayer;
34 class ClientContext;
35 class ClientUserInterface;
36 class FrameConsumerProxy;
37 class FrameProducer;
38 class VideoRenderer;
39 class SignalStrategy;
41 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
42 public protocol::ClientStub {
43 public:
44 // |client_context|, |user_interface| and |video_renderer| must outlive the
45 // client. |audio_player| may be null, in which case audio will not be
46 // requested.
47 ChromotingClient(ClientContext* client_context,
48 ClientUserInterface* user_interface,
49 VideoRenderer* video_renderer,
50 scoped_ptr<AudioPlayer> audio_player);
52 ~ChromotingClient() override;
54 void SetProtocolConfigForTests(
55 scoped_ptr<protocol::CandidateSessionConfig> config);
57 // Start the client. Must be called on the main thread. |signal_strategy|
58 // must outlive the client.
59 void Start(SignalStrategy* signal_strategy,
60 scoped_ptr<protocol::Authenticator> authenticator,
61 scoped_ptr<protocol::TransportFactory> transport_factory,
62 const std::string& host_jid,
63 const std::string& capabilities);
65 protocol::ConnectionToHost::State connection_state() const {
66 return connection_.state();
69 protocol::ClipboardStub* clipboard_forwarder() {
70 return connection_.clipboard_forwarder();
72 protocol::HostStub* host_stub() { return connection_.host_stub(); }
73 protocol::InputStub* input_stub() { return connection_.input_stub(); }
75 // ClientStub implementation.
76 void SetCapabilities(const protocol::Capabilities& capabilities) override;
77 void SetPairingResponse(
78 const protocol::PairingResponse& pairing_response) override;
79 void DeliverHostMessage(const protocol::ExtensionMessage& message) override;
81 // ClipboardStub implementation for receiving clipboard data from host.
82 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
84 // CursorShapeStub implementation for receiving cursor shape updates.
85 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
87 // ConnectionToHost::HostEventCallback implementation.
88 void OnConnectionState(protocol::ConnectionToHost::State state,
89 protocol::ErrorCode error) override;
90 void OnConnectionReady(bool ready) override;
91 void OnRouteChanged(const std::string& channel_name,
92 const protocol::TransportRoute& route) override;
94 private:
95 // Called when the connection is authenticated.
96 void OnAuthenticated();
98 // Called when all channels are connected.
99 void OnChannelsConnected();
101 // The following are not owned by this class.
102 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
103 ClientUserInterface* user_interface_;
104 VideoRenderer* video_renderer_;
106 protocol::ConnectionToHost connection_;
108 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_;
110 std::string local_capabilities_;
112 // The set of all capabilities supported by the host.
113 std::string host_capabilities_;
115 // True if |protocol::Capabilities| message has been received.
116 bool host_capabilities_received_;
118 // Record the statistics of the connection.
119 ChromotingStats stats_;
121 DISALLOW_COPY_AND_ASSIGN(ChromotingClient);
124 } // namespace remoting
126 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_