| 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 ChannelConfig::ChannelConfig() { | 14 ChannelConfig::ChannelConfig() | 
| 15   Reset(); | 15     : transport(TRANSPORT_NONE), | 
|  | 16       version(0), | 
|  | 17       codec(CODEC_UNDEFINED) { | 
| 16 } | 18 } | 
| 17 | 19 | 
| 18 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) | 20 ChannelConfig::ChannelConfig(TransportType transport, int version, Codec codec) | 
| 19     : transport(transport), | 21     : transport(transport), | 
| 20       version(version), | 22       version(version), | 
| 21       codec(codec) { | 23       codec(codec) { | 
| 22 } | 24 } | 
| 23 | 25 | 
| 24 bool ChannelConfig::operator==(const ChannelConfig& b) const { | 26 bool ChannelConfig::operator==(const ChannelConfig& b) const { | 
|  | 27   // If the transport field is set to NONE then all other fields are irrelevant. | 
|  | 28   if (transport == ChannelConfig::TRANSPORT_NONE) | 
|  | 29     return transport == b.transport; | 
| 25   return transport == b.transport && version == b.version && codec == b.codec; | 30   return transport == b.transport && version == b.version && codec == b.codec; | 
| 26 } | 31 } | 
| 27 | 32 | 
| 28 void ChannelConfig::Reset() { |  | 
| 29   transport = TRANSPORT_STREAM; |  | 
| 30   version = kDefaultStreamVersion; |  | 
| 31   codec = CODEC_UNDEFINED; |  | 
| 32 } |  | 
| 33 |  | 
| 34 SessionConfig::SessionConfig() { | 33 SessionConfig::SessionConfig() { | 
| 35 } | 34 } | 
| 36 | 35 | 
| 37 // static | 36 // static | 
| 38 SessionConfig SessionConfig::GetDefault() { | 37 SessionConfig SessionConfig::GetDefault() { | 
| 39   SessionConfig result; | 38   SessionConfig result; | 
| 40   result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 39   result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 
| 41                                           kDefaultStreamVersion, | 40                                           kDefaultStreamVersion, | 
| 42                                           ChannelConfig::CODEC_UNDEFINED)); | 41                                           ChannelConfig::CODEC_UNDEFINED)); | 
| 43   result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 42   result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 184                     kDefaultStreamVersion, | 183                     kDefaultStreamVersion, | 
| 185                     ChannelConfig::CODEC_UNDEFINED)); | 184                     ChannelConfig::CODEC_UNDEFINED)); | 
| 186 | 185 | 
| 187   // Video channel. | 186   // Video channel. | 
| 188   result->mutable_video_configs()->push_back( | 187   result->mutable_video_configs()->push_back( | 
| 189       ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 188       ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 
| 190                     kDefaultStreamVersion, | 189                     kDefaultStreamVersion, | 
| 191                     ChannelConfig::CODEC_VP8)); | 190                     ChannelConfig::CODEC_VP8)); | 
| 192 | 191 | 
| 193   // Audio channel. | 192   // Audio channel. | 
| 194   result->mutable_audio_configs()->push_back( | 193   result->mutable_audio_configs()->push_back(ChannelConfig()); | 
| 195       ChannelConfig(ChannelConfig::TRANSPORT_NONE, |  | 
| 196                     kDefaultStreamVersion, |  | 
| 197                     ChannelConfig::CODEC_VERBATIM)); |  | 
| 198 #if defined(ENABLE_REMOTING_AUDIO) | 194 #if defined(ENABLE_REMOTING_AUDIO) | 
| 199   EnableAudioChannel(result.get()); | 195   EnableAudioChannel(result.get()); | 
| 200 #endif  // defined(ENABLE_REMOTING_AUDIO) | 196 #endif  // defined(ENABLE_REMOTING_AUDIO) | 
| 201 | 197 | 
| 202   return result.Pass(); | 198   return result.Pass(); | 
| 203 } | 199 } | 
| 204 | 200 | 
| 205 // static | 201 // static | 
| 206 void CandidateSessionConfig::EnableAudioChannel( | 202 void CandidateSessionConfig::EnableAudioChannel( | 
| 207   CandidateSessionConfig* config) { | 203   CandidateSessionConfig* config) { | 
| 208   config->mutable_audio_configs()->clear(); | 204   config->mutable_audio_configs()->clear(); | 
| 209   config->mutable_audio_configs()->push_back( | 205   config->mutable_audio_configs()->push_back( | 
| 210       ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 206       ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 
| 211                     kDefaultStreamVersion, | 207                     kDefaultStreamVersion, | 
| 212                     ChannelConfig::CODEC_VERBATIM)); | 208                     ChannelConfig::CODEC_VERBATIM)); | 
| 213   config->mutable_audio_configs()->push_back( | 209   config->mutable_audio_configs()->push_back( | 
| 214       ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 210       ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 
| 215                     kDefaultStreamVersion, | 211                     kDefaultStreamVersion, | 
| 216                     ChannelConfig::CODEC_VERBATIM)); | 212                     ChannelConfig::CODEC_VERBATIM)); | 
| 217   config->mutable_audio_configs()->push_back( | 213   config->mutable_audio_configs()->push_back(ChannelConfig()); | 
| 218       ChannelConfig(ChannelConfig::TRANSPORT_NONE, |  | 
| 219                     kDefaultStreamVersion, |  | 
| 220                     ChannelConfig::CODEC_VERBATIM)); |  | 
| 221 } | 214 } | 
| 222 | 215 | 
| 223 }  // namespace protocol | 216 }  // namespace protocol | 
| 224 }  // namespace remoting | 217 }  // namespace remoting | 
| OLD | NEW | 
|---|