| 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 // ChromotingClient is the controller for the Client implementation. | 5 // ChromotingClient is the controller for the Client implementation. |
| 6 | 6 |
| 7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| 8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "remoting/protocol/client_stub.h" | 14 #include "remoting/protocol/client_stub.h" |
| 15 #include "remoting/protocol/clipboard_stub.h" | 15 #include "remoting/protocol/clipboard_stub.h" |
| 16 #include "remoting/protocol/connection_to_host.h" | 16 #include "remoting/protocol/connection_to_host.h" |
| 17 #include "remoting/protocol/connection_to_host_impl.h" | 17 #include "remoting/protocol/connection_to_host_impl.h" |
| 18 #include "remoting/protocol/input_stub.h" | 18 #include "remoting/protocol/input_stub.h" |
| 19 #include "remoting/protocol/performance_tracker.h" | 19 #include "remoting/protocol/performance_tracker.h" |
| 20 #include "remoting/protocol/video_stub.h" | 20 #include "remoting/protocol/video_stub.h" |
| 21 #include "remoting/signaling/signal_strategy.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 24 } // namespace base | 25 } // namespace base |
| 25 | 26 |
| 26 namespace remoting { | 27 namespace remoting { |
| 27 | 28 |
| 28 namespace protocol { | 29 namespace protocol { |
| 29 class CandidateSessionConfig; | 30 class CandidateSessionConfig; |
| 30 class TransportContext; | 31 class TransportContext; |
| 31 } // namespace protocol | 32 } // namespace protocol |
| 32 | 33 |
| 33 class AudioDecodeScheduler; | 34 class AudioDecodeScheduler; |
| 34 class AudioPlayer; | 35 class AudioPlayer; |
| 35 class ClientContext; | 36 class ClientContext; |
| 36 class ClientUserInterface; | 37 class ClientUserInterface; |
| 37 class FrameConsumerProxy; | 38 class FrameConsumerProxy; |
| 38 class FrameProducer; | 39 class FrameProducer; |
| 39 class VideoRenderer; | 40 class VideoRenderer; |
| 40 class SignalStrategy; | |
| 41 | 41 |
| 42 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, | 42 class ChromotingClient : public SignalStrategy::Listener, |
| 43 public protocol::ConnectionToHost::HostEventCallback, |
| 43 public protocol::ClientStub { | 44 public protocol::ClientStub { |
| 44 public: | 45 public: |
| 45 // |client_context|, |user_interface| and |video_renderer| must outlive the | 46 // |client_context|, |user_interface| and |video_renderer| must outlive the |
| 46 // client. |audio_player| may be null, in which case audio will not be | 47 // client. |audio_player| may be null, in which case audio will not be |
| 47 // requested. | 48 // requested. |
| 48 ChromotingClient(ClientContext* client_context, | 49 ChromotingClient(ClientContext* client_context, |
| 49 ClientUserInterface* user_interface, | 50 ClientUserInterface* user_interface, |
| 50 VideoRenderer* video_renderer, | 51 VideoRenderer* video_renderer, |
| 51 scoped_ptr<AudioPlayer> audio_player); | 52 scoped_ptr<AudioPlayer> audio_player); |
| 52 | 53 |
| 53 ~ChromotingClient() override; | 54 ~ChromotingClient() override; |
| 54 | 55 |
| 55 void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config); | 56 void set_protocol_config( |
| 57 scoped_ptr<protocol::CandidateSessionConfig> config) { |
| 58 protocol_config_ = config.Pass(); |
| 59 } |
| 56 | 60 |
| 57 // Used to set fake/mock objects for tests which use the ChromotingClient. | 61 // Used to set fake/mock objects for tests which use the ChromotingClient. |
| 58 void SetConnectionToHostForTests( | 62 void SetConnectionToHostForTests( |
| 59 scoped_ptr<protocol::ConnectionToHost> connection_to_host); | 63 scoped_ptr<protocol::ConnectionToHost> connection_to_host); |
| 60 | 64 |
| 61 // Start the client. Must be called on the main thread. |signal_strategy| | 65 // Start the client. Must be called on the main thread. |signal_strategy| |
| 62 // must outlive the client. | 66 // must outlive the client. |
| 63 void Start(SignalStrategy* signal_strategy, | 67 void Start(SignalStrategy* signal_strategy, |
| 64 scoped_ptr<protocol::Authenticator> authenticator, | 68 scoped_ptr<protocol::Authenticator> authenticator, |
| 65 scoped_refptr<protocol::TransportContext> transport_context, | 69 scoped_refptr<protocol::TransportContext> transport_context, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 89 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; | 93 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
| 90 | 94 |
| 91 // ConnectionToHost::HostEventCallback implementation. | 95 // ConnectionToHost::HostEventCallback implementation. |
| 92 void OnConnectionState(protocol::ConnectionToHost::State state, | 96 void OnConnectionState(protocol::ConnectionToHost::State state, |
| 93 protocol::ErrorCode error) override; | 97 protocol::ErrorCode error) override; |
| 94 void OnConnectionReady(bool ready) override; | 98 void OnConnectionReady(bool ready) override; |
| 95 void OnRouteChanged(const std::string& channel_name, | 99 void OnRouteChanged(const std::string& channel_name, |
| 96 const protocol::TransportRoute& route) override; | 100 const protocol::TransportRoute& route) override; |
| 97 | 101 |
| 98 private: | 102 private: |
| 103 // SignalStrategy::StatusObserver interface. |
| 104 void OnSignalStrategyStateChange(SignalStrategy::State state) override; |
| 105 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; |
| 106 |
| 107 // Starts connection once |signal_strategy_| is connected. |
| 108 void StartConnection(); |
| 109 |
| 99 // Called when the connection is authenticated. | 110 // Called when the connection is authenticated. |
| 100 void OnAuthenticated(); | 111 void OnAuthenticated(); |
| 101 | 112 |
| 102 // Called when all channels are connected. | 113 // Called when all channels are connected. |
| 103 void OnChannelsConnected(); | 114 void OnChannelsConnected(); |
| 104 | 115 |
| 116 base::ThreadChecker thread_checker_; |
| 117 |
| 118 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; |
| 119 |
| 105 // The following are not owned by this class. | 120 // The following are not owned by this class. |
| 106 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 121 ClientUserInterface* user_interface_ = nullptr; |
| 107 ClientUserInterface* user_interface_; | 122 VideoRenderer* video_renderer_ = nullptr; |
| 108 VideoRenderer* video_renderer_; | 123 SignalStrategy* signal_strategy_ = nullptr; |
| 109 | 124 |
| 125 std::string host_jid_; |
| 126 scoped_ptr<protocol::Authenticator> authenticator_; |
| 127 |
| 128 scoped_ptr<protocol::SessionManager> session_manager_; |
| 110 scoped_ptr<protocol::ConnectionToHost> connection_; | 129 scoped_ptr<protocol::ConnectionToHost> connection_; |
| 111 | 130 |
| 112 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; | 131 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; |
| 113 | 132 |
| 114 std::string local_capabilities_; | 133 std::string local_capabilities_; |
| 115 | 134 |
| 116 // The set of all capabilities supported by the host. | 135 // The set of all capabilities supported by the host. |
| 117 std::string host_capabilities_; | 136 std::string host_capabilities_; |
| 118 | 137 |
| 119 // True if |protocol::Capabilities| message has been received. | 138 // True if |protocol::Capabilities| message has been received. |
| 120 bool host_capabilities_received_; | 139 bool host_capabilities_received_ = false; |
| 121 | 140 |
| 122 // Record the statistics of the connection. | 141 // Record the statistics of the connection. |
| 123 protocol::PerformanceTracker perf_tracker_; | 142 protocol::PerformanceTracker perf_tracker_; |
| 124 | 143 |
| 125 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 144 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
| 126 }; | 145 }; |
| 127 | 146 |
| 128 } // namespace remoting | 147 } // namespace remoting |
| 129 | 148 |
| 130 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 149 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| OLD | NEW |