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_PROTOCOL_SESSION_CONFIG_H_ | 5 #ifndef REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
6 #define REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 6 #define REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/memory/scoped_ptr.h" | |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 namespace protocol { | 14 namespace protocol { |
15 | 15 |
16 extern const int kDefaultStreamVersion; | 16 extern const int kDefaultStreamVersion; |
17 | 17 |
18 // Struct for configuration parameters of a single channel. | 18 // Struct for configuration parameters of a single channel. |
19 // Some channels (like video) may have multiple underlying sockets that need | 19 // Some channels (like video) may have multiple underlying sockets that need |
20 // to be configured simultaneously. | 20 // to be configured simultaneously. |
21 struct ChannelConfig { | 21 struct ChannelConfig { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ICE, | 68 ICE, |
69 | 69 |
70 // New WebRTC-based protocol. | 70 // New WebRTC-based protocol. |
71 WEBRTC, | 71 WEBRTC, |
72 }; | 72 }; |
73 | 73 |
74 // Selects session configuration that is supported by both participants. | 74 // Selects session configuration that is supported by both participants. |
75 // nullptr is returned if such configuration doesn't exist. When selecting | 75 // nullptr is returned if such configuration doesn't exist. When selecting |
76 // channel configuration priority is given to the configs listed first | 76 // channel configuration priority is given to the configs listed first |
77 // in |client_config|. | 77 // in |client_config|. |
78 static scoped_ptr<SessionConfig> SelectCommon( | 78 static std::unique_ptr<SessionConfig> SelectCommon( |
79 const CandidateSessionConfig* client_config, | 79 const CandidateSessionConfig* client_config, |
80 const CandidateSessionConfig* host_config); | 80 const CandidateSessionConfig* host_config); |
81 | 81 |
82 // Extracts final protocol configuration. Must be used for the description | 82 // Extracts final protocol configuration. Must be used for the description |
83 // received in the session-accept stanza. If the selection is ambiguous | 83 // received in the session-accept stanza. If the selection is ambiguous |
84 // (e.g. there is more than one configuration for one of the channel) | 84 // (e.g. there is more than one configuration for one of the channel) |
85 // or undefined (e.g. no configurations for a channel) then nullptr is | 85 // or undefined (e.g. no configurations for a channel) then nullptr is |
86 // returned. | 86 // returned. |
87 static scoped_ptr<SessionConfig> GetFinalConfig( | 87 static std::unique_ptr<SessionConfig> GetFinalConfig( |
88 const CandidateSessionConfig* candidate_config); | 88 const CandidateSessionConfig* candidate_config); |
89 | 89 |
90 // Returns a suitable session configuration for use in tests. | 90 // Returns a suitable session configuration for use in tests. |
91 static scoped_ptr<SessionConfig> ForTest(); | 91 static std::unique_ptr<SessionConfig> ForTest(); |
92 static scoped_ptr<SessionConfig> ForTestWithVerbatimVideo(); | 92 static std::unique_ptr<SessionConfig> ForTestWithVerbatimVideo(); |
93 static scoped_ptr<SessionConfig> ForTestWithWebrtc(); | 93 static std::unique_ptr<SessionConfig> ForTestWithWebrtc(); |
94 | 94 |
95 Protocol protocol() const { return protocol_; } | 95 Protocol protocol() const { return protocol_; } |
96 | 96 |
97 // All fields below should be ignored when protocol() is set to WEBRTC. | 97 // All fields below should be ignored when protocol() is set to WEBRTC. |
98 const ChannelConfig& control_config() const; | 98 const ChannelConfig& control_config() const; |
99 const ChannelConfig& event_config() const; | 99 const ChannelConfig& event_config() const; |
100 const ChannelConfig& video_config() const; | 100 const ChannelConfig& video_config() const; |
101 const ChannelConfig& audio_config() const; | 101 const ChannelConfig& audio_config() const; |
102 | 102 |
103 bool is_audio_enabled() const { | 103 bool is_audio_enabled() const { |
104 return audio_config_.transport != ChannelConfig::TRANSPORT_NONE; | 104 return audio_config_.transport != ChannelConfig::TRANSPORT_NONE; |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
108 SessionConfig(Protocol protocol); | 108 SessionConfig(Protocol protocol); |
109 | 109 |
110 const Protocol protocol_; | 110 const Protocol protocol_; |
111 | 111 |
112 ChannelConfig control_config_; | 112 ChannelConfig control_config_; |
113 ChannelConfig event_config_; | 113 ChannelConfig event_config_; |
114 ChannelConfig video_config_; | 114 ChannelConfig video_config_; |
115 ChannelConfig audio_config_; | 115 ChannelConfig audio_config_; |
116 }; | 116 }; |
117 | 117 |
118 // Defines session description that is sent from client to the host in the | 118 // Defines session description that is sent from client to the host in the |
119 // session-initiate message. It is different from the regular Config | 119 // session-initiate message. It is different from the regular Config |
120 // because it allows one to specify multiple configurations for each channel. | 120 // because it allows one to specify multiple configurations for each channel. |
121 class CandidateSessionConfig { | 121 class CandidateSessionConfig { |
122 public: | 122 public: |
123 static scoped_ptr<CandidateSessionConfig> CreateEmpty(); | 123 static std::unique_ptr<CandidateSessionConfig> CreateEmpty(); |
124 static scoped_ptr<CandidateSessionConfig> CreateFrom( | 124 static std::unique_ptr<CandidateSessionConfig> CreateFrom( |
125 const SessionConfig& config); | 125 const SessionConfig& config); |
126 static scoped_ptr<CandidateSessionConfig> CreateDefault(); | 126 static std::unique_ptr<CandidateSessionConfig> CreateDefault(); |
127 | 127 |
128 ~CandidateSessionConfig(); | 128 ~CandidateSessionConfig(); |
129 | 129 |
130 bool webrtc_supported() const { return webrtc_supported_; } | 130 bool webrtc_supported() const { return webrtc_supported_; } |
131 void set_webrtc_supported(bool webrtc_supported) { | 131 void set_webrtc_supported(bool webrtc_supported) { |
132 webrtc_supported_ = webrtc_supported; | 132 webrtc_supported_ = webrtc_supported; |
133 } | 133 } |
134 | 134 |
135 bool ice_supported() const { return ice_supported_; } | 135 bool ice_supported() const { return ice_supported_; } |
136 void set_ice_supported(bool ice_supported) { ice_supported_ = ice_supported; } | 136 void set_ice_supported(bool ice_supported) { ice_supported_ = ice_supported; } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // | 175 // |
176 // TODO(sergeyu): Remove this kludge as soon as VP9 is enabled by default. | 176 // TODO(sergeyu): Remove this kludge as soon as VP9 is enabled by default. |
177 bool vp9_experiment_enabled() const { return vp9_experiment_enabled_; } | 177 bool vp9_experiment_enabled() const { return vp9_experiment_enabled_; } |
178 void set_vp9_experiment_enabled(bool value) { | 178 void set_vp9_experiment_enabled(bool value) { |
179 vp9_experiment_enabled_ = value; | 179 vp9_experiment_enabled_ = value; |
180 } | 180 } |
181 | 181 |
182 // Returns true if |config| is supported. | 182 // Returns true if |config| is supported. |
183 bool IsSupported(const SessionConfig& config) const; | 183 bool IsSupported(const SessionConfig& config) const; |
184 | 184 |
185 scoped_ptr<CandidateSessionConfig> Clone() const; | 185 std::unique_ptr<CandidateSessionConfig> Clone() const; |
186 | 186 |
187 // Helpers for enabling/disabling specific features. | 187 // Helpers for enabling/disabling specific features. |
188 void DisableAudioChannel(); | 188 void DisableAudioChannel(); |
189 void PreferTransport(ChannelConfig::TransportType transport); | 189 void PreferTransport(ChannelConfig::TransportType transport); |
190 | 190 |
191 private: | 191 private: |
192 CandidateSessionConfig(); | 192 CandidateSessionConfig(); |
193 explicit CandidateSessionConfig(const CandidateSessionConfig& config); | 193 explicit CandidateSessionConfig(const CandidateSessionConfig& config); |
194 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); | 194 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); |
195 | 195 |
196 bool webrtc_supported_ = false; | 196 bool webrtc_supported_ = false; |
197 bool ice_supported_ = false; | 197 bool ice_supported_ = false; |
198 | 198 |
199 std::list<ChannelConfig> control_configs_; | 199 std::list<ChannelConfig> control_configs_; |
200 std::list<ChannelConfig> event_configs_; | 200 std::list<ChannelConfig> event_configs_; |
201 std::list<ChannelConfig> video_configs_; | 201 std::list<ChannelConfig> video_configs_; |
202 std::list<ChannelConfig> audio_configs_; | 202 std::list<ChannelConfig> audio_configs_; |
203 | 203 |
204 bool vp9_experiment_enabled_ = false; | 204 bool vp9_experiment_enabled_ = false; |
205 }; | 205 }; |
206 | 206 |
207 } // namespace protocol | 207 } // namespace protocol |
208 } // namespace remoting | 208 } // namespace remoting |
209 | 209 |
210 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 210 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
OLD | NEW |