| 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 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ |
| 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "net/base/backoff_entry.h" | 14 #include "net/base/backoff_entry.h" |
| 15 #include "remoting/codec/video_encoder.h" | |
| 16 #include "remoting/host/client_session.h" | 15 #include "remoting/host/client_session.h" |
| 17 #include "remoting/host/desktop_environment.h" | |
| 18 #include "remoting/host/host_key_pair.h" | 16 #include "remoting/host/host_key_pair.h" |
| 19 #include "remoting/host/host_status_observer.h" | 17 #include "remoting/host/host_status_observer.h" |
| 20 #include "remoting/host/mouse_move_observer.h" | 18 #include "remoting/host/mouse_move_observer.h" |
| 21 #include "remoting/host/ui_strings.h" | 19 #include "remoting/host/ui_strings.h" |
| 22 #include "remoting/protocol/authenticator.h" | 20 #include "remoting/protocol/authenticator.h" |
| 23 #include "remoting/protocol/session_manager.h" | 21 #include "remoting/protocol/session_manager.h" |
| 24 #include "remoting/protocol/connection_to_client.h" | 22 #include "remoting/protocol/connection_to_client.h" |
| 25 | 23 |
| 26 namespace remoting { | 24 namespace remoting { |
| 27 | 25 |
| 28 namespace protocol { | 26 namespace protocol { |
| 29 class InputStub; | 27 class InputStub; |
| 30 class SessionConfig; | 28 class SessionConfig; |
| 31 class CandidateSessionConfig; | 29 class CandidateSessionConfig; |
| 32 } // namespace protocol | 30 } // namespace protocol |
| 33 | 31 |
| 34 class AudioEncoder; | |
| 35 class AudioScheduler; | |
| 36 class ChromotingHostContext; | 32 class ChromotingHostContext; |
| 37 class DesktopEnvironment; | 33 class DesktopEnvironmentFactory; |
| 38 class Encoder; | |
| 39 class ScreenRecorder; | |
| 40 class VideoFrameCapturer; | |
| 41 | 34 |
| 42 // A class to implement the functionality of a host process. | 35 // A class to implement the functionality of a host process. |
| 43 // | 36 // |
| 44 // Here's the work flow of this class: | 37 // Here's the work flow of this class: |
| 45 // 1. We should load the saved GAIA ID token or if this is the first | 38 // 1. We should load the saved GAIA ID token or if this is the first |
| 46 // time the host process runs we should prompt user for the | 39 // time the host process runs we should prompt user for the |
| 47 // credential. We will use this token or credentials to authenicate | 40 // credential. We will use this token or credentials to authenicate |
| 48 // and register the host. | 41 // and register the host. |
| 49 // | 42 // |
| 50 // 2. We listen for incoming connection using libjingle. We will create | 43 // 2. We listen for incoming connection using libjingle. We will create |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 // all pending tasks to complete. After all of that completed we | 55 // all pending tasks to complete. After all of that completed we |
| 63 // return to the idle state. We then go to step (2) if there a new | 56 // return to the idle state. We then go to step (2) if there a new |
| 64 // incoming connection. | 57 // incoming connection. |
| 65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 58 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
| 66 public ClientSession::EventHandler, | 59 public ClientSession::EventHandler, |
| 67 public protocol::SessionManager::Listener, | 60 public protocol::SessionManager::Listener, |
| 68 public MouseMoveObserver { | 61 public MouseMoveObserver { |
| 69 public: | 62 public: |
| 70 // The caller must ensure that |context|, |signal_strategy| and | 63 // The caller must ensure that |context|, |signal_strategy| and |
| 71 // |environment| out-live the host. | 64 // |environment| out-live the host. |
| 72 ChromotingHost(ChromotingHostContext* context, | 65 ChromotingHost( |
| 73 SignalStrategy* signal_strategy, | 66 ChromotingHostContext* context, |
| 74 DesktopEnvironment* environment, | 67 SignalStrategy* signal_strategy, |
| 75 scoped_ptr<protocol::SessionManager> session_manager); | 68 DesktopEnvironmentFactory* desktop_environment_factory, |
| 69 scoped_ptr<protocol::SessionManager> session_manager); |
| 76 | 70 |
| 77 // Asynchronously start the host process. | 71 // Asynchronously start the host process. |
| 78 // | 72 // |
| 79 // After this is invoked, the host process will connect to the talk | 73 // After this is invoked, the host process will connect to the talk |
| 80 // network and start listening for incoming connections. | 74 // network and start listening for incoming connections. |
| 81 // | 75 // |
| 82 // This method can only be called once during the lifetime of this object. | 76 // This method can only be called once during the lifetime of this object. |
| 83 void Start(const std::string& xmpp_login); | 77 void Start(const std::string& xmpp_login); |
| 84 | 78 |
| 85 // Asynchronously shutdown the host process. |shutdown_task| is | 79 // Asynchronously shutdown the host process. |shutdown_task| is |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 150 |
| 157 typedef std::vector<ClientSession*> ClientList; | 151 typedef std::vector<ClientSession*> ClientList; |
| 158 | 152 |
| 159 enum State { | 153 enum State { |
| 160 kInitial, | 154 kInitial, |
| 161 kStarted, | 155 kStarted, |
| 162 kStopping, | 156 kStopping, |
| 163 kStopped, | 157 kStopped, |
| 164 }; | 158 }; |
| 165 | 159 |
| 166 // Creates encoder for the specified configuration. | |
| 167 static VideoEncoder* CreateVideoEncoder( | |
| 168 const protocol::SessionConfig& config); | |
| 169 | |
| 170 // Creates an audio encoder for the specified configuration. | |
| 171 static scoped_ptr<AudioEncoder> CreateAudioEncoder( | |
| 172 const protocol::SessionConfig& config); | |
| 173 | |
| 174 virtual ~ChromotingHost(); | 160 virtual ~ChromotingHost(); |
| 175 | 161 |
| 176 void StopScreenRecorder(); | 162 // Called from Shutdown() to finish shutdown. |
| 177 void StopAudioScheduler(); | |
| 178 void OnRecorderStopped(); | |
| 179 | |
| 180 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. | |
| 181 void ShutdownFinish(); | 163 void ShutdownFinish(); |
| 182 | 164 |
| 183 // Unless specified otherwise all members of this class must be | 165 // Unless specified otherwise all members of this class must be |
| 184 // used on the network thread only. | 166 // used on the network thread only. |
| 185 | 167 |
| 186 // Parameters specified when the host was created. | 168 // Parameters specified when the host was created. |
| 187 ChromotingHostContext* context_; | 169 ChromotingHostContext* context_; |
| 188 DesktopEnvironment* desktop_environment_; | 170 DesktopEnvironmentFactory* desktop_environment_factory_; |
| 189 scoped_ptr<protocol::SessionManager> session_manager_; | 171 scoped_ptr<protocol::SessionManager> session_manager_; |
| 190 | 172 |
| 191 // Connection objects. | 173 // Connection objects. |
| 192 SignalStrategy* signal_strategy_; | 174 SignalStrategy* signal_strategy_; |
| 193 | 175 |
| 194 // Must be used on the network thread only. | 176 // Must be used on the network thread only. |
| 195 ObserverList<HostStatusObserver> status_observers_; | 177 ObserverList<HostStatusObserver> status_observers_; |
| 196 | 178 |
| 197 // The connections to remote clients. | 179 // The connections to remote clients. |
| 198 ClientList clients_; | 180 ClientList clients_; |
| 199 | 181 |
| 200 // Schedulers for audio and video capture. | |
| 201 // TODO(sergeyu): Do we need to have one set of schedulers per client? | |
| 202 scoped_refptr<ScreenRecorder> recorder_; | |
| 203 scoped_refptr<AudioScheduler> audio_scheduler_; | |
| 204 | |
| 205 // Number of screen recorders and audio schedulers that are currently being | |
| 206 // stopped. Used to delay shutdown if one or more recorders/schedulers are | |
| 207 // asynchronously shutting down. | |
| 208 int stopping_recorders_; | |
| 209 | |
| 210 // Tracks the internal state of the host. | 182 // Tracks the internal state of the host. |
| 211 State state_; | 183 State state_; |
| 212 | 184 |
| 213 // Configuration of the protocol. | 185 // Configuration of the protocol. |
| 214 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; | 186 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; |
| 215 | 187 |
| 216 // Login backoff state. | 188 // Login backoff state. |
| 217 net::BackoffEntry login_backoff_; | 189 net::BackoffEntry login_backoff_; |
| 218 | 190 |
| 219 // Flags used for RejectAuthenticatingClient(). | 191 // Flags used for RejectAuthenticatingClient(). |
| (...skipping 10 matching lines...) Expand all Loading... |
| 230 | 202 |
| 231 // The maximum duration of any session. | 203 // The maximum duration of any session. |
| 232 base::TimeDelta max_session_duration_; | 204 base::TimeDelta max_session_duration_; |
| 233 | 205 |
| 234 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 206 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
| 235 }; | 207 }; |
| 236 | 208 |
| 237 } // namespace remoting | 209 } // namespace remoting |
| 238 | 210 |
| 239 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 211 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
| OLD | NEW |