File: connection_to_client.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (140 lines) | stat: -rw-r--r-- 5,360 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
#define REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_

#include <stdint.h>

#include <string>

#include "remoting/base/session_options.h"
#include "remoting/base/session_policies.h"
#include "remoting/base/source_location.h"
#include "remoting/protocol/message_pipe.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/transport.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"

namespace remoting {
class DesktopCapturer;
}  // namespace remoting

namespace remoting::protocol {

class AudioSource;
class AudioStream;
class ClientStub;
class ClipboardStub;
class HostStub;
class InputStub;
class PeerConnectionControls;
class Session;
class VideoStream;
class WebrtcEventLogData;

// This interface represents a remote viewer connection to the chromoting host.
// It sets up all protocol channels and connects them to the stubs.
class ConnectionToClient {
 public:
  class EventHandler {
   public:
    // Called when the network connection is authenticating
    virtual void OnConnectionAuthenticating() = 0;

    // Called when the network connection is authenticated. `session_policies`
    // is nullptr if no session policies are specified, in which case local
    // policies should be used.
    virtual void OnConnectionAuthenticated(
        const SessionPolicies* session_policies) = 0;

    // Called to request creation of video streams. May be called before or
    // after OnConnectionChannelsConnected().
    virtual void CreateMediaStreams() = 0;

    // Called when the network connection is authenticated and all
    // channels are connected.
    virtual void OnConnectionChannelsConnected() = 0;

    // Called when the network connection is closed or failed.
    virtual void OnConnectionClosed(ErrorCode error) = 0;

    // Called when the transport protocol (TCP/UDP) changes and all channels are
    // connected.
    virtual void OnTransportProtocolChange(const std::string& protocol) = 0;

    // Called on notification of a route change event, which happens when a
    // channel is connected.
    virtual void OnRouteChange(const std::string& channel_name,
                               const TransportRoute& route) = 0;

    // Called when a new Data Channel has been created by the client.
    virtual void OnIncomingDataChannel(const std::string& channel_name,
                                       std::unique_ptr<MessagePipe> pipe) = 0;

   protected:
    virtual ~EventHandler() = default;
  };

  ConnectionToClient() = default;
  virtual ~ConnectionToClient() = default;

  // Set |event_handler| for connection events. Must be called once when this
  // object is created.
  virtual void SetEventHandler(EventHandler* event_handler) = 0;

  // Returns the Session object for the connection.
  // TODO(sergeyu): Remove this method.
  virtual Session* session() = 0;

  // Disconnect the client connection.
  virtual void Disconnect(ErrorCode error,
                          std::string_view error_details,
                          const SourceLocation& error_location) = 0;

  // Start video stream that sends screen content from |desktop_capturer| to the
  // client. |screen_id| should be webrtc::kFullDesktopScreenId for
  // single-stream mode, or the screen being captured for multi-stream mode.
  virtual std::unique_ptr<VideoStream> StartVideoStream(
      webrtc::ScreenId screen_id,
      std::unique_ptr<DesktopCapturer> desktop_capturer) = 0;

  // Starts an audio stream. Returns nullptr if audio is not supported by the
  // client.
  virtual std::unique_ptr<AudioStream> StartAudioStream(
      std::unique_ptr<AudioSource> audio_source) = 0;

  // The client stubs used by the host to send control messages to the client.
  // The stub must not be accessed before OnConnectionAuthenticated(), or
  // after OnConnectionClosed().
  virtual ClientStub* client_stub() = 0;

  // Set the stubs which will handle messages we receive from the client. These
  // must be called in EventHandler::OnConnectionAuthenticated().
  virtual void set_clipboard_stub(ClipboardStub* clipboard_stub) = 0;
  virtual void set_host_stub(HostStub* host_stub) = 0;
  virtual void set_input_stub(InputStub* input_stub) = 0;

  // Applies the |options| to current session. SessionOptions usually controls
  // experimental behaviors, implementations can ignore this function if no
  // control logic can be applied.
  virtual void ApplySessionOptions(const SessionOptions& options) {}

  // Applies network settings. The connection may be blocked until this method
  // is called.
  virtual void ApplyNetworkSettings(const NetworkSettings& settings) = 0;

  // Returns an interface for changing connection parameters after the
  // connection is established. nullptr will be returned if the connection does
  // not support changing parameters on the fly.
  virtual PeerConnectionControls* peer_connection_controls() = 0;

  // Returns an object holding the RTC event logs if supported by this
  // connection type, or nullptr otherwise.
  virtual WebrtcEventLogData* rtc_event_log() = 0;
};

}  // namespace remoting::protocol

#endif  // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_