[email protected] | 91e4b7f6 | 2012-01-25 23:23:02 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | cd8d237 | 2010-11-04 01:18:04 | [diff] [blame] | 5 | #ifndef REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ |
6 | #define REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ | ||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 7 | |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 8 | #include <stdint.h> |
9 | |||||
[email protected] | 91e4b7f6 | 2012-01-25 23:23:02 | [diff] [blame] | 10 | #include <string> |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 11 | |
Zijie He | ba57151 | 2017-11-20 20:22:23 | [diff] [blame] | 12 | #include "remoting/base/session_options.h" |
Joseph Arhar | 5f69f39 | 2017-07-01 00:33:20 | [diff] [blame] | 13 | #include "remoting/protocol/message_pipe.h" |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 14 | #include "remoting/protocol/transport.h" |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 15 | |
sergeyu | a609b7a | 2015-11-30 06:25:39 | [diff] [blame] | 16 | namespace webrtc { |
17 | class DesktopCapturer; | ||||
18 | } // namespace webrtc | ||||
19 | |||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 20 | namespace remoting { |
sergeyu | a609b7a | 2015-11-30 06:25:39 | [diff] [blame] | 21 | |
[email protected] | d87c404 | 2010-11-04 00:46:01 | [diff] [blame] | 22 | namespace protocol { |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 23 | |
sergeyu | cd16e206 | 2016-09-12 19:28:35 | [diff] [blame] | 24 | class AudioSource; |
Joseph Arhar | 5f69f39 | 2017-07-01 00:33:20 | [diff] [blame] | 25 | class AudioStream; |
[email protected] | 35b9c56 | 2010-11-09 02:22:43 | [diff] [blame] | 26 | class ClientStub; |
[email protected] | e265ad7 | 2012-03-16 17:28:03 | [diff] [blame] | 27 | class ClipboardStub; |
sergeyu | 2385cffe | 2014-09-19 19:23:41 | [diff] [blame] | 28 | class HostStub; |
sergeyu | 2385cffe | 2014-09-19 19:23:41 | [diff] [blame] | 29 | class InputStub; |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 30 | class Session; |
sergeyu | a609b7a | 2015-11-30 06:25:39 | [diff] [blame] | 31 | class VideoStream; |
[email protected] | 35b9c56 | 2010-11-09 02:22:43 | [diff] [blame] | 32 | |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 33 | // This interface represents a remote viewer connection to the chromoting host. |
34 | // It sets up all protocol channels and connects them to the stubs. | ||||
35 | class ConnectionToClient { | ||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 36 | public: |
37 | class EventHandler { | ||||
38 | public: | ||||
[email protected] | 064128c | 2014-04-07 22:33:28 | [diff] [blame] | 39 | // Called when the network connection is authenticating |
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 40 | virtual void OnConnectionAuthenticating() = 0; |
[email protected] | 064128c | 2014-04-07 22:33:28 | [diff] [blame] | 41 | |
[email protected] | cba6f81 | 2012-03-27 01:01:50 | [diff] [blame] | 42 | // Called when the network connection is authenticated. |
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 43 | virtual void OnConnectionAuthenticated() = 0; |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 44 | |
sergeyu | 9102cff | 2016-04-07 19:14:01 | [diff] [blame] | 45 | // Called to request creation of video streams. May be called before or |
46 | // after OnConnectionChannelsConnected(). | ||||
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 47 | virtual void CreateMediaStreams() = 0; |
sergeyu | 9102cff | 2016-04-07 19:14:01 | [diff] [blame] | 48 | |
[email protected] | cba6f81 | 2012-03-27 01:01:50 | [diff] [blame] | 49 | // Called when the network connection is authenticated and all |
50 | // channels are connected. | ||||
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 51 | virtual void OnConnectionChannelsConnected() = 0; |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 52 | |
[email protected] | cba6f81 | 2012-03-27 01:01:50 | [diff] [blame] | 53 | // Called when the network connection is closed or failed. |
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 54 | virtual void OnConnectionClosed(ErrorCode error) = 0; |
[email protected] | c0f7082 | 2011-05-06 21:19:29 | [diff] [blame] | 55 | |
[email protected] | 91e4b7f6 | 2012-01-25 23:23:02 | [diff] [blame] | 56 | // Called on notification of a route change event, which happens when a |
57 | // channel is connected. | ||||
sergeyu | 4e1f4cd | 2016-09-27 00:42:52 | [diff] [blame] | 58 | virtual void OnRouteChange(const std::string& channel_name, |
[email protected] | be451c8 | 2012-03-20 22:24:47 | [diff] [blame] | 59 | const TransportRoute& route) = 0; |
[email protected] | ab58cf36 | 2013-01-28 03:57:51 | [diff] [blame] | 60 | |
Joseph Arhar | 5f69f39 | 2017-07-01 00:33:20 | [diff] [blame] | 61 | // Called when a new Data Channel has been created by the client. |
62 | virtual void OnIncomingDataChannel(const std::string& channel_name, | ||||
63 | std::unique_ptr<MessagePipe> pipe) = 0; | ||||
64 | |||||
[email protected] | ab58cf36 | 2013-01-28 03:57:51 | [diff] [blame] | 65 | protected: |
Zijie He | cd945d73 | 2017-10-02 18:14:34 | [diff] [blame] | 66 | virtual ~EventHandler() = default; |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 67 | }; |
68 | |||||
Zijie He | cd945d73 | 2017-10-02 18:14:34 | [diff] [blame] | 69 | ConnectionToClient() = default; |
70 | virtual ~ConnectionToClient() = default; | ||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 71 | |
[email protected] | 91e4b7f6 | 2012-01-25 23:23:02 | [diff] [blame] | 72 | // Set |event_handler| for connection events. Must be called once when this |
73 | // object is created. | ||||
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 74 | virtual void SetEventHandler(EventHandler* event_handler) = 0; |
[email protected] | e295ff06 | 2010-07-15 22:56:04 | [diff] [blame] | 75 | |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 76 | // Returns the Session object for the connection. |
77 | // TODO(sergeyu): Remove this method. | ||||
78 | virtual Session* session() = 0; | ||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 79 | |
[email protected] | a46bcef | 2011-11-11 01:27:23 | [diff] [blame] | 80 | // Disconnect the client connection. |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 81 | virtual void Disconnect(ErrorCode error) = 0; |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 82 | |
sergeyu | a609b7a | 2015-11-30 06:25:39 | [diff] [blame] | 83 | // Start video stream that sends screen content from |desktop_capturer| to the |
84 | // client. | ||||
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 85 | virtual std::unique_ptr<VideoStream> StartVideoStream( |
86 | std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) = 0; | ||||
sergeyu | a609b7a | 2015-11-30 06:25:39 | [diff] [blame] | 87 | |
sergeyu | cd16e206 | 2016-09-12 19:28:35 | [diff] [blame] | 88 | // Starts an audio stream. Returns nullptr if audio is not supported by the |
89 | // client. | ||||
90 | virtual std::unique_ptr<AudioStream> StartAudioStream( | ||||
91 | std::unique_ptr<AudioSource> audio_source) = 0; | ||||
92 | |||||
93 | // The client stubs used by the host to send control messages to the client. | ||||
94 | // The stub must not be accessed before OnConnectionAuthenticated(), or | ||||
[email protected] | 24a2a9d2 | 2012-12-07 09:06:47 | [diff] [blame] | 95 | // after OnConnectionClosed(). |
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 96 | virtual ClientStub* client_stub() = 0; |
[email protected] | 35b9c56 | 2010-11-09 02:22:43 | [diff] [blame] | 97 | |
sergeyu | 1f8cd50 | 2015-02-13 21:45:53 | [diff] [blame] | 98 | // Set the stubs which will handle messages we receive from the client. These |
99 | // must be called in EventHandler::OnConnectionAuthenticated(). | ||||
sergeyu | b031cd2 | 2015-11-19 22:17:13 | [diff] [blame] | 100 | virtual void set_clipboard_stub(ClipboardStub* clipboard_stub) = 0; |
101 | virtual void set_host_stub(HostStub* host_stub) = 0; | ||||
102 | virtual void set_input_stub(InputStub* input_stub) = 0; | ||||
Zijie He | cd945d73 | 2017-10-02 18:14:34 | [diff] [blame] | 103 | |
Zijie He | ba57151 | 2017-11-20 20:22:23 | [diff] [blame] | 104 | // Applies the |options| to current session. SessionOptions usually controls |
105 | // experimental behaviors, implementations can ignore this function if no | ||||
106 | // control logic can be applied. | ||||
107 | virtual void ApplySessionOptions(const SessionOptions& options) {} | ||||
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 108 | }; |
109 | |||||
[email protected] | d87c404 | 2010-11-04 00:46:01 | [diff] [blame] | 110 | } // namespace protocol |
[email protected] | cb3b1f931 | 2010-06-07 19:58:23 | [diff] [blame] | 111 | } // namespace remoting |
112 | |||||
[email protected] | cd8d237 | 2010-11-04 01:18:04 | [diff] [blame] | 113 | #endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ |