Chromium Code Reviews| 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; |
|
Wez
2014/09/13 17:21:41
nit: Add a comment to explain what "default" means
| |
| 13 | |
| 14 // The control channel version that supports the "capabilities" message. | |
| 15 const int kControlStreamVersion = 3; | 13 const int kControlStreamVersion = 3; |
| 16 const int kControlStreamVersionNoCapabilities = kDefaultStreamVersion; | |
| 17 | 14 |
| 18 ChannelConfig ChannelConfig::None() { | 15 ChannelConfig ChannelConfig::None() { |
| 19 return ChannelConfig(); | 16 return ChannelConfig(); |
| 20 } | 17 } |
| 21 | 18 |
| 22 ChannelConfig::ChannelConfig() | 19 ChannelConfig::ChannelConfig() |
| 23 : transport(TRANSPORT_NONE), | 20 : transport(TRANSPORT_NONE), |
| 24 version(0), | 21 version(0), |
| 25 codec(CODEC_UNDEFINED) { | 22 codec(CODEC_UNDEFINED) { |
| 26 } | 23 } |
| 27 | 24 |
| 28 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) | 25 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) |
| 29 : transport(transport), | 26 : transport(transport), |
| 30 version(version), | 27 version(version), |
| 31 codec(codec) { | 28 codec(codec) { |
| 32 } | 29 } |
| 33 | 30 |
| 34 bool ChannelConfig::operator==(const ChannelConfig& b) const { | 31 bool ChannelConfig::operator==(const ChannelConfig& b) const { |
| 35 // If the transport field is set to NONE then all other fields are irrelevant. | 32 // If the transport field is set to NONE then all other fields are irrelevant. |
| 36 if (transport == ChannelConfig::TRANSPORT_NONE) | 33 if (transport == ChannelConfig::TRANSPORT_NONE) |
| 37 return transport == b.transport; | 34 return transport == b.transport; |
| 38 return transport == b.transport && version == b.version && codec == b.codec; | 35 return transport == b.transport && version == b.version && codec == b.codec; |
| 39 } | 36 } |
| 40 | 37 |
| 41 SessionConfig::SessionConfig() { | 38 SessionConfig::SessionConfig() { |
| 42 } | 39 } |
| 43 | 40 |
| 44 bool SessionConfig::SupportsCapabilities() const { | |
| 45 return control_config_.version >= kControlStreamVersion; | |
| 46 } | |
| 47 | |
| 48 // static | 41 // static |
| 49 SessionConfig SessionConfig::ForTest() { | 42 SessionConfig SessionConfig::ForTest() { |
| 50 SessionConfig result; | 43 SessionConfig result; |
| 51 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 44 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 52 kControlStreamVersion, | 45 kControlStreamVersion, |
| 53 ChannelConfig::CODEC_UNDEFINED)); | 46 ChannelConfig::CODEC_UNDEFINED)); |
| 54 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 47 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 55 kDefaultStreamVersion, | 48 kDefaultStreamVersion, |
| 56 ChannelConfig::CODEC_UNDEFINED)); | 49 ChannelConfig::CODEC_UNDEFINED)); |
| 57 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 50 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 166 |
| 174 // static | 167 // static |
| 175 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { | 168 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
| 176 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); | 169 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); |
| 177 | 170 |
| 178 // Control channel. | 171 // Control channel. |
| 179 result->mutable_control_configs()->push_back( | 172 result->mutable_control_configs()->push_back( |
| 180 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 173 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 181 kControlStreamVersion, | 174 kControlStreamVersion, |
| 182 ChannelConfig::CODEC_UNDEFINED)); | 175 ChannelConfig::CODEC_UNDEFINED)); |
| 183 result->mutable_control_configs()->push_back( | |
| 184 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | |
| 185 kControlStreamVersionNoCapabilities, | |
| 186 ChannelConfig::CODEC_UNDEFINED)); | |
| 187 | 176 |
| 188 // Event channel. | 177 // Event channel. |
| 189 result->mutable_event_configs()->push_back( | 178 result->mutable_event_configs()->push_back( |
| 190 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 179 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 191 kDefaultStreamVersion, | 180 kDefaultStreamVersion, |
| 192 ChannelConfig::CODEC_UNDEFINED)); | 181 ChannelConfig::CODEC_UNDEFINED)); |
| 193 | 182 |
| 194 // Video channel. | 183 // Video channel. |
| 195 #if !defined(MEDIA_DISABLE_LIBVPX) | 184 #if !defined(MEDIA_DISABLE_LIBVPX) |
| 196 result->mutable_video_configs()->push_back( | 185 result->mutable_video_configs()->push_back( |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 216 | 205 |
| 217 void CandidateSessionConfig::EnableVideoCodec(ChannelConfig::Codec codec) { | 206 void CandidateSessionConfig::EnableVideoCodec(ChannelConfig::Codec codec) { |
| 218 mutable_video_configs()->push_front( | 207 mutable_video_configs()->push_front( |
| 219 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 208 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 220 kDefaultStreamVersion, | 209 kDefaultStreamVersion, |
| 221 codec)); | 210 codec)); |
| 222 } | 211 } |
| 223 | 212 |
| 224 } // namespace protocol | 213 } // namespace protocol |
| 225 } // namespace remoting | 214 } // namespace remoting |
| OLD | NEW |