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 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 namespace protocol { | 10 namespace protocol { |
11 | 11 |
12 const int kDefaultStreamVersion = 2; | 12 const int kDefaultStreamVersion = 2; |
13 | 13 |
| 14 // The control channel version that supports the "capabilities" message. |
| 15 const int kControlStreamVersion = 3; |
| 16 const int kControlStreamVersionNoCapabilities = kDefaultStreamVersion; |
| 17 |
14 ChannelConfig ChannelConfig::None() { | 18 ChannelConfig ChannelConfig::None() { |
15 return ChannelConfig(); | 19 return ChannelConfig(); |
16 } | 20 } |
17 | 21 |
18 ChannelConfig::ChannelConfig() | 22 ChannelConfig::ChannelConfig() |
19 : transport(TRANSPORT_NONE), | 23 : transport(TRANSPORT_NONE), |
20 version(0), | 24 version(0), |
21 codec(CODEC_UNDEFINED) { | 25 codec(CODEC_UNDEFINED) { |
22 } | 26 } |
23 | 27 |
24 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) | 28 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) |
25 : transport(transport), | 29 : transport(transport), |
26 version(version), | 30 version(version), |
27 codec(codec) { | 31 codec(codec) { |
28 } | 32 } |
29 | 33 |
30 bool ChannelConfig::operator==(const ChannelConfig& b) const { | 34 bool ChannelConfig::operator==(const ChannelConfig& b) const { |
31 // If the transport field is set to NONE then all other fields are irrelevant. | 35 // If the transport field is set to NONE then all other fields are irrelevant. |
32 if (transport == ChannelConfig::TRANSPORT_NONE) | 36 if (transport == ChannelConfig::TRANSPORT_NONE) |
33 return transport == b.transport; | 37 return transport == b.transport; |
34 return transport == b.transport && version == b.version && codec == b.codec; | 38 return transport == b.transport && version == b.version && codec == b.codec; |
35 } | 39 } |
36 | 40 |
37 SessionConfig::SessionConfig() { | 41 SessionConfig::SessionConfig() { |
| 42 } |
38 | 43 |
| 44 bool SessionConfig::SupportsCapabilities() const { |
| 45 return control_config_.version >= kControlStreamVersion; |
39 } | 46 } |
40 | 47 |
41 // static | 48 // static |
42 SessionConfig SessionConfig::ForTest() { | 49 SessionConfig SessionConfig::ForTest() { |
43 SessionConfig result; | 50 SessionConfig result; |
44 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 51 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
45 kDefaultStreamVersion, | 52 kControlStreamVersionNoCapabilities, |
46 ChannelConfig::CODEC_UNDEFINED)); | 53 ChannelConfig::CODEC_UNDEFINED)); |
47 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 54 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
48 kDefaultStreamVersion, | 55 kDefaultStreamVersion, |
49 ChannelConfig::CODEC_UNDEFINED)); | 56 ChannelConfig::CODEC_UNDEFINED)); |
50 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 57 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
51 kDefaultStreamVersion, | 58 kDefaultStreamVersion, |
52 ChannelConfig::CODEC_VP8)); | 59 ChannelConfig::CODEC_VP8)); |
53 result.set_audio_config(ChannelConfig(ChannelConfig::TRANSPORT_NONE, | 60 result.set_audio_config(ChannelConfig(ChannelConfig::TRANSPORT_NONE, |
54 kDefaultStreamVersion, | 61 kDefaultStreamVersion, |
55 ChannelConfig::CODEC_VERBATIM)); | 62 ChannelConfig::CODEC_VERBATIM)); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 return result.Pass(); | 171 return result.Pass(); |
165 } | 172 } |
166 | 173 |
167 // static | 174 // static |
168 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { | 175 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
169 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); | 176 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); |
170 | 177 |
171 // Control channel. | 178 // Control channel. |
172 result->mutable_control_configs()->push_back( | 179 result->mutable_control_configs()->push_back( |
173 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 180 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
174 kDefaultStreamVersion, | 181 kControlStreamVersion, |
| 182 ChannelConfig::CODEC_UNDEFINED)); |
| 183 result->mutable_control_configs()->push_back( |
| 184 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 185 kControlStreamVersionNoCapabilities, |
175 ChannelConfig::CODEC_UNDEFINED)); | 186 ChannelConfig::CODEC_UNDEFINED)); |
176 result->mutable_control_configs()->push_back( | 187 result->mutable_control_configs()->push_back( |
177 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 188 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
178 kDefaultStreamVersion, | 189 kControlStreamVersionNoCapabilities, |
179 ChannelConfig::CODEC_UNDEFINED)); | 190 ChannelConfig::CODEC_UNDEFINED)); |
180 | 191 |
181 // Event channel. | 192 // Event channel. |
182 result->mutable_event_configs()->push_back( | 193 result->mutable_event_configs()->push_back( |
183 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 194 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
184 kDefaultStreamVersion, | 195 kDefaultStreamVersion, |
185 ChannelConfig::CODEC_UNDEFINED)); | 196 ChannelConfig::CODEC_UNDEFINED)); |
186 result->mutable_event_configs()->push_back( | 197 result->mutable_event_configs()->push_back( |
187 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 198 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
188 kDefaultStreamVersion, | 199 kDefaultStreamVersion, |
(...skipping 29 matching lines...) Expand all Loading... |
218 | 229 |
219 // static | 230 // static |
220 void CandidateSessionConfig::DisableAudioChannel( | 231 void CandidateSessionConfig::DisableAudioChannel( |
221 CandidateSessionConfig* config) { | 232 CandidateSessionConfig* config) { |
222 config->mutable_audio_configs()->clear(); | 233 config->mutable_audio_configs()->clear(); |
223 config->mutable_audio_configs()->push_back(ChannelConfig()); | 234 config->mutable_audio_configs()->push_back(ChannelConfig()); |
224 } | 235 } |
225 | 236 |
226 } // namespace protocol | 237 } // namespace protocol |
227 } // namespace remoting | 238 } // namespace remoting |
OLD | NEW |