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 #include "remoting/protocol/session_config.h" | 5 #include "remoting/protocol/session_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 result->event_config_ = candidate_config->event_configs().front(); | 142 result->event_config_ = candidate_config->event_configs().front(); |
143 result->video_config_ = candidate_config->video_configs().front(); | 143 result->video_config_ = candidate_config->video_configs().front(); |
144 result->audio_config_ = candidate_config->audio_configs().front(); | 144 result->audio_config_ = candidate_config->audio_configs().front(); |
145 | 145 |
146 return result; | 146 return result; |
147 } | 147 } |
148 | 148 |
149 // static | 149 // static |
150 scoped_ptr<SessionConfig> SessionConfig::ForTest() { | 150 scoped_ptr<SessionConfig> SessionConfig::ForTest() { |
151 scoped_ptr<SessionConfig> result(new SessionConfig(Protocol::ICE)); | 151 scoped_ptr<SessionConfig> result(new SessionConfig(Protocol::ICE)); |
152 result->control_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | 152 result->control_config_ = ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
153 kControlStreamVersion, | 153 kControlStreamVersion, |
154 ChannelConfig::CODEC_UNDEFINED); | 154 ChannelConfig::CODEC_UNDEFINED); |
155 result->event_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | 155 result->event_config_ = ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
156 kDefaultStreamVersion, | 156 kDefaultStreamVersion, |
157 ChannelConfig::CODEC_UNDEFINED); | 157 ChannelConfig::CODEC_UNDEFINED); |
158 result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | 158 result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
159 kDefaultStreamVersion, | 159 kDefaultStreamVersion, |
160 ChannelConfig::CODEC_VP8); | 160 ChannelConfig::CODEC_VP8); |
161 result->audio_config_ = ChannelConfig(ChannelConfig::TRANSPORT_NONE, | 161 result->audio_config_ = ChannelConfig(ChannelConfig::TRANSPORT_NONE, |
162 kDefaultStreamVersion, | 162 kDefaultStreamVersion, |
163 ChannelConfig::CODEC_UNDEFINED); | 163 ChannelConfig::CODEC_UNDEFINED); |
164 return result.Pass(); | 164 return result.Pass(); |
165 } | 165 } |
166 | 166 |
167 scoped_ptr<SessionConfig> SessionConfig::ForTestWithVerbatimVideo() { | 167 scoped_ptr<SessionConfig> SessionConfig::ForTestWithVerbatimVideo() { |
168 scoped_ptr<SessionConfig> result = ForTest(); | 168 scoped_ptr<SessionConfig> result = ForTest(); |
169 result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | 169 result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
170 kDefaultStreamVersion, | 170 kDefaultStreamVersion, |
171 ChannelConfig::CODEC_VERBATIM); | 171 ChannelConfig::CODEC_VERBATIM); |
172 return result.Pass(); | 172 return result.Pass(); |
173 } | 173 } |
174 | 174 |
175 scoped_ptr<SessionConfig> SessionConfig::ForTestWithWebrtc() { | 175 scoped_ptr<SessionConfig> SessionConfig::ForTestWithWebrtc() { |
176 return make_scoped_ptr(new SessionConfig(Protocol::WEBRTC)); | 176 return make_scoped_ptr(new SessionConfig(Protocol::WEBRTC)); |
177 } | 177 } |
178 | 178 |
179 const ChannelConfig& SessionConfig::control_config() const { | 179 const ChannelConfig& SessionConfig::control_config() const { |
180 DCHECK(protocol_ == Protocol::ICE); | 180 DCHECK(protocol_ == Protocol::ICE); |
181 return control_config_; | 181 return control_config_; |
182 } | 182 } |
183 const ChannelConfig& SessionConfig::event_config() const { | 183 const ChannelConfig& SessionConfig::event_config() const { |
184 DCHECK(protocol_ == Protocol::ICE); | 184 DCHECK(protocol_ == Protocol::ICE); |
185 return event_config_; | 185 return event_config_; |
186 } | 186 } |
187 const ChannelConfig& SessionConfig::video_config() const { | 187 const ChannelConfig& SessionConfig::video_config() const { |
188 DCHECK(protocol_ == Protocol::ICE); | 188 DCHECK(protocol_ == Protocol::ICE); |
189 return video_config_; | 189 return video_config_; |
190 } | 190 } |
191 const ChannelConfig& SessionConfig::audio_config() const { | 191 const ChannelConfig& SessionConfig::audio_config() const { |
192 DCHECK(protocol_ == Protocol::ICE); | 192 DCHECK(protocol_ == Protocol::ICE); |
193 return audio_config_; | 193 return audio_config_; |
194 } | 194 } |
195 | 195 |
196 bool SessionConfig::is_using_quic() const { | |
197 DCHECK(protocol_ == Protocol::ICE); | |
198 return control_config_.transport == ChannelConfig::TRANSPORT_QUIC_STREAM || | |
199 event_config_.transport == ChannelConfig::TRANSPORT_QUIC_STREAM || | |
200 video_config_.transport == ChannelConfig::TRANSPORT_QUIC_STREAM || | |
201 audio_config_.transport == ChannelConfig::TRANSPORT_QUIC_STREAM; | |
202 } | |
203 | |
204 SessionConfig::SessionConfig(Protocol protocol) : protocol_(protocol) {} | 196 SessionConfig::SessionConfig(Protocol protocol) : protocol_(protocol) {} |
205 | 197 |
206 CandidateSessionConfig::CandidateSessionConfig() {} | 198 CandidateSessionConfig::CandidateSessionConfig() {} |
207 CandidateSessionConfig::CandidateSessionConfig( | 199 CandidateSessionConfig::CandidateSessionConfig( |
208 const CandidateSessionConfig& config) = default; | 200 const CandidateSessionConfig& config) = default; |
209 CandidateSessionConfig::~CandidateSessionConfig() {} | 201 CandidateSessionConfig::~CandidateSessionConfig() {} |
210 | 202 |
211 bool CandidateSessionConfig::IsSupported(const SessionConfig& config) const { | 203 bool CandidateSessionConfig::IsSupported(const SessionConfig& config) const { |
212 switch (config.protocol()) { | 204 switch (config.protocol()) { |
213 case SessionConfig::Protocol::ICE: | 205 case SessionConfig::Protocol::ICE: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { | 255 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
264 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); | 256 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); |
265 | 257 |
266 result->set_ice_supported(true); | 258 result->set_ice_supported(true); |
267 | 259 |
268 // Control channel. | 260 // Control channel. |
269 result->mutable_control_configs()->push_back( | 261 result->mutable_control_configs()->push_back( |
270 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 262 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
271 kControlStreamVersion, | 263 kControlStreamVersion, |
272 ChannelConfig::CODEC_UNDEFINED)); | 264 ChannelConfig::CODEC_UNDEFINED)); |
273 result->mutable_control_configs()->push_back( | |
274 ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | |
275 kControlStreamVersion, | |
276 ChannelConfig::CODEC_UNDEFINED)); | |
277 | 265 |
278 // Event channel. | 266 // Event channel. |
279 result->mutable_event_configs()->push_back( | 267 result->mutable_event_configs()->push_back( |
280 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 268 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
281 kDefaultStreamVersion, | 269 kDefaultStreamVersion, |
282 ChannelConfig::CODEC_UNDEFINED)); | 270 ChannelConfig::CODEC_UNDEFINED)); |
283 result->mutable_event_configs()->push_back( | |
284 ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | |
285 kDefaultStreamVersion, | |
286 ChannelConfig::CODEC_UNDEFINED)); | |
287 | 271 |
288 // Video channel. | 272 // Video channel. |
289 result->mutable_video_configs()->push_back( | 273 result->mutable_video_configs()->push_back( |
290 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 274 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
291 kDefaultStreamVersion, | 275 kDefaultStreamVersion, |
292 ChannelConfig::CODEC_VP9)); | 276 ChannelConfig::CODEC_VP9)); |
293 result->mutable_video_configs()->push_back( | 277 result->mutable_video_configs()->push_back( |
294 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 278 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
295 kDefaultStreamVersion, | 279 kDefaultStreamVersion, |
296 ChannelConfig::CODEC_VP8)); | 280 ChannelConfig::CODEC_VP8)); |
297 result->mutable_video_configs()->push_back( | |
298 ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | |
299 kDefaultStreamVersion, | |
300 ChannelConfig::CODEC_VP9)); | |
301 result->mutable_video_configs()->push_back( | |
302 ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | |
303 kDefaultStreamVersion, | |
304 ChannelConfig::CODEC_VP8)); | |
305 | 281 |
306 // Audio channel. | 282 // Audio channel. |
307 result->mutable_audio_configs()->push_back( | 283 result->mutable_audio_configs()->push_back( |
308 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 284 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
309 kDefaultStreamVersion, | 285 kDefaultStreamVersion, |
310 ChannelConfig::CODEC_OPUS)); | 286 ChannelConfig::CODEC_OPUS)); |
311 result->mutable_audio_configs()->push_back( | |
312 ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, | |
313 kDefaultStreamVersion, | |
314 ChannelConfig::CODEC_OPUS)); | |
315 result->mutable_audio_configs()->push_back(ChannelConfig::None()); | 287 result->mutable_audio_configs()->push_back(ChannelConfig::None()); |
316 | 288 |
317 return result.Pass(); | 289 return result.Pass(); |
318 } | 290 } |
319 | 291 |
320 void CandidateSessionConfig::DisableAudioChannel() { | 292 void CandidateSessionConfig::DisableAudioChannel() { |
321 mutable_audio_configs()->clear(); | 293 mutable_audio_configs()->clear(); |
322 mutable_audio_configs()->push_back(ChannelConfig()); | 294 mutable_audio_configs()->push_back(ChannelConfig()); |
323 } | 295 } |
324 | 296 |
325 void CandidateSessionConfig::PreferTransport( | 297 void CandidateSessionConfig::PreferTransport( |
326 ChannelConfig::TransportType transport) { | 298 ChannelConfig::TransportType transport) { |
327 UpdateConfigListToPreferTransport(&control_configs_, transport); | 299 UpdateConfigListToPreferTransport(&control_configs_, transport); |
328 UpdateConfigListToPreferTransport(&event_configs_, transport); | 300 UpdateConfigListToPreferTransport(&event_configs_, transport); |
329 UpdateConfigListToPreferTransport(&video_configs_, transport); | 301 UpdateConfigListToPreferTransport(&video_configs_, transport); |
330 UpdateConfigListToPreferTransport(&audio_configs_, transport); | 302 UpdateConfigListToPreferTransport(&audio_configs_, transport); |
331 } | 303 } |
332 | 304 |
333 } // namespace protocol | 305 } // namespace protocol |
334 } // namespace remoting | 306 } // namespace remoting |
OLD | NEW |