blob: 8d1a6ab634387ce9334f56018cf9d219d7c195c7 [file] [log] [blame]
[email protected]91e4b7f62012-01-25 23:23:021// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]cb3b1f9312010-06-07 19:58:232// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]cd8d2372010-11-04 01:18:045#ifndef REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
6#define REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
[email protected]cb3b1f9312010-06-07 19:58:237
avi5a080f012015-12-22 23:15:438#include <stdint.h>
9
[email protected]91e4b7f62012-01-25 23:23:0210#include <string>
[email protected]cb3b1f9312010-06-07 19:58:2311
Zijie Heba571512017-11-20 20:22:2312#include "remoting/base/session_options.h"
Joseph Arhar5f69f392017-07-01 00:33:2013#include "remoting/protocol/message_pipe.h"
sergeyub031cd22015-11-19 22:17:1314#include "remoting/protocol/transport.h"
[email protected]cb3b1f9312010-06-07 19:58:2315
sergeyua609b7a2015-11-30 06:25:3916namespace webrtc {
17class DesktopCapturer;
18} // namespace webrtc
19
[email protected]cb3b1f9312010-06-07 19:58:2320namespace remoting {
sergeyua609b7a2015-11-30 06:25:3921
[email protected]d87c4042010-11-04 00:46:0122namespace protocol {
[email protected]cb3b1f9312010-06-07 19:58:2323
sergeyucd16e2062016-09-12 19:28:3524class AudioSource;
Joseph Arhar5f69f392017-07-01 00:33:2025class AudioStream;
[email protected]35b9c562010-11-09 02:22:4326class ClientStub;
[email protected]e265ad72012-03-16 17:28:0327class ClipboardStub;
sergeyu2385cffe2014-09-19 19:23:4128class HostStub;
sergeyu2385cffe2014-09-19 19:23:4129class InputStub;
sergeyub031cd22015-11-19 22:17:1330class Session;
sergeyua609b7a2015-11-30 06:25:3931class VideoStream;
[email protected]35b9c562010-11-09 02:22:4332
sergeyub031cd22015-11-19 22:17:1333// This interface represents a remote viewer connection to the chromoting host.
34// It sets up all protocol channels and connects them to the stubs.
35class ConnectionToClient {
[email protected]cb3b1f9312010-06-07 19:58:2336 public:
37 class EventHandler {
38 public:
[email protected]064128c2014-04-07 22:33:2839 // Called when the network connection is authenticating
sergeyu4e1f4cd2016-09-27 00:42:5240 virtual void OnConnectionAuthenticating() = 0;
[email protected]064128c2014-04-07 22:33:2841
[email protected]cba6f812012-03-27 01:01:5042 // Called when the network connection is authenticated.
sergeyu4e1f4cd2016-09-27 00:42:5243 virtual void OnConnectionAuthenticated() = 0;
[email protected]cb3b1f9312010-06-07 19:58:2344
sergeyu9102cff2016-04-07 19:14:0145 // Called to request creation of video streams. May be called before or
46 // after OnConnectionChannelsConnected().
sergeyu4e1f4cd2016-09-27 00:42:5247 virtual void CreateMediaStreams() = 0;
sergeyu9102cff2016-04-07 19:14:0148
[email protected]cba6f812012-03-27 01:01:5049 // Called when the network connection is authenticated and all
50 // channels are connected.
sergeyu4e1f4cd2016-09-27 00:42:5251 virtual void OnConnectionChannelsConnected() = 0;
[email protected]cb3b1f9312010-06-07 19:58:2352
[email protected]cba6f812012-03-27 01:01:5053 // Called when the network connection is closed or failed.
sergeyu4e1f4cd2016-09-27 00:42:5254 virtual void OnConnectionClosed(ErrorCode error) = 0;
[email protected]c0f70822011-05-06 21:19:2955
[email protected]91e4b7f62012-01-25 23:23:0256 // Called on notification of a route change event, which happens when a
57 // channel is connected.
sergeyu4e1f4cd2016-09-27 00:42:5258 virtual void OnRouteChange(const std::string& channel_name,
[email protected]be451c82012-03-20 22:24:4759 const TransportRoute& route) = 0;
[email protected]ab58cf362013-01-28 03:57:5160
Joseph Arhar5f69f392017-07-01 00:33:2061 // 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]ab58cf362013-01-28 03:57:5165 protected:
Zijie Hecd945d732017-10-02 18:14:3466 virtual ~EventHandler() = default;
[email protected]cb3b1f9312010-06-07 19:58:2367 };
68
Zijie Hecd945d732017-10-02 18:14:3469 ConnectionToClient() = default;
70 virtual ~ConnectionToClient() = default;
[email protected]cb3b1f9312010-06-07 19:58:2371
[email protected]91e4b7f62012-01-25 23:23:0272 // Set |event_handler| for connection events. Must be called once when this
73 // object is created.
sergeyub031cd22015-11-19 22:17:1374 virtual void SetEventHandler(EventHandler* event_handler) = 0;
[email protected]e295ff062010-07-15 22:56:0475
sergeyub031cd22015-11-19 22:17:1376 // Returns the Session object for the connection.
77 // TODO(sergeyu): Remove this method.
78 virtual Session* session() = 0;
[email protected]cb3b1f9312010-06-07 19:58:2379
[email protected]a46bcef2011-11-11 01:27:2380 // Disconnect the client connection.
sergeyub031cd22015-11-19 22:17:1381 virtual void Disconnect(ErrorCode error) = 0;
[email protected]cb3b1f9312010-06-07 19:58:2382
sergeyua609b7a2015-11-30 06:25:3983 // Start video stream that sends screen content from |desktop_capturer| to the
84 // client.
dcheng0765c492016-04-06 22:41:5385 virtual std::unique_ptr<VideoStream> StartVideoStream(
86 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer) = 0;
sergeyua609b7a2015-11-30 06:25:3987
sergeyucd16e2062016-09-12 19:28:3588 // 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]24a2a9d22012-12-07 09:06:4795 // after OnConnectionClosed().
sergeyub031cd22015-11-19 22:17:1396 virtual ClientStub* client_stub() = 0;
[email protected]35b9c562010-11-09 02:22:4397
sergeyu1f8cd502015-02-13 21:45:5398 // Set the stubs which will handle messages we receive from the client. These
99 // must be called in EventHandler::OnConnectionAuthenticated().
sergeyub031cd22015-11-19 22:17:13100 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 Hecd945d732017-10-02 18:14:34103
Zijie Heba571512017-11-20 20:22:23104 // 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]cb3b1f9312010-06-07 19:58:23108};
109
[email protected]d87c4042010-11-04 00:46:01110} // namespace protocol
[email protected]cb3b1f9312010-06-07 19:58:23111} // namespace remoting
112
[email protected]cd8d2372010-11-04 01:18:04113#endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_