Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/content_description.h" | 5 #include "remoting/protocol/content_description.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "remoting/protocol/authenticator.h" | |
|
Wez
2011/12/03 00:21:05
This goes below remoting/base/constants.h
Sergey Ulanov
2011/12/06 19:37:07
Done.
| |
| 9 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 11 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 11 | 12 |
| 12 using buzz::QName; | 13 using buzz::QName; |
| 13 using buzz::XmlElement; | 14 using buzz::XmlElement; |
| 14 | 15 |
| 15 namespace remoting { | 16 namespace remoting { |
| 16 namespace protocol { | 17 namespace protocol { |
| 17 | 18 |
| 18 const char ContentDescription::kChromotingContentName[] = "chromoting"; | 19 const char ContentDescription::kChromotingContentName[] = "chromoting"; |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const char kDefaultNs[] = ""; | 23 const char kDefaultNs[] = ""; |
| 23 | 24 |
| 24 // Following constants are used to format session description in XML. | 25 // Following constants are used to format session description in XML. |
| 25 const char kDescriptionTag[] = "description"; | 26 const char kDescriptionTag[] = "description"; |
| 26 const char kControlTag[] = "control"; | 27 const char kControlTag[] = "control"; |
| 27 const char kEventTag[] = "event"; | 28 const char kEventTag[] = "event"; |
| 28 const char kVideoTag[] = "video"; | 29 const char kVideoTag[] = "video"; |
| 29 const char kResolutionTag[] = "initial-resolution"; | 30 const char kResolutionTag[] = "initial-resolution"; |
| 30 const char kAuthenticationTag[] = "authentication"; | |
| 31 | 31 |
| 32 const char kTransportAttr[] = "transport"; | 32 const char kTransportAttr[] = "transport"; |
| 33 const char kVersionAttr[] = "version"; | 33 const char kVersionAttr[] = "version"; |
| 34 const char kCodecAttr[] = "codec"; | 34 const char kCodecAttr[] = "codec"; |
| 35 const char kWidthAttr[] = "width"; | 35 const char kWidthAttr[] = "width"; |
| 36 const char kHeightAttr[] = "height"; | 36 const char kHeightAttr[] = "height"; |
| 37 | 37 |
| 38 const char kStreamTransport[] = "stream"; | 38 const char kStreamTransport[] = "stream"; |
| 39 const char kDatagramTransport[] = "datagram"; | 39 const char kDatagramTransport[] = "datagram"; |
| 40 const char kSrtpTransport[] = "srtp"; | 40 const char kSrtpTransport[] = "srtp"; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 QName(kChromotingXmlNamespace, kResolutionTag)); | 191 QName(kChromotingXmlNamespace, kResolutionTag)); |
| 192 resolution_tag->AddAttr(QName(kDefaultNs, kWidthAttr), | 192 resolution_tag->AddAttr(QName(kDefaultNs, kWidthAttr), |
| 193 base::IntToString( | 193 base::IntToString( |
| 194 config()->initial_resolution().width)); | 194 config()->initial_resolution().width)); |
| 195 resolution_tag->AddAttr(QName(kDefaultNs, kHeightAttr), | 195 resolution_tag->AddAttr(QName(kDefaultNs, kHeightAttr), |
| 196 base::IntToString( | 196 base::IntToString( |
| 197 config()->initial_resolution().height)); | 197 config()->initial_resolution().height)); |
| 198 root->AddElement(resolution_tag); | 198 root->AddElement(resolution_tag); |
| 199 | 199 |
| 200 if (authenticator_message_.get()) { | 200 if (authenticator_message_.get()) { |
| 201 DCHECK(authenticator_message_->Name() == | 201 DCHECK(Authenticator::IsAuthenticatorMessage(authenticator_message_.get())); |
| 202 QName(kChromotingXmlNamespace, kAuthenticationTag)); | |
| 203 root->AddElement(new XmlElement(*authenticator_message_)); | 202 root->AddElement(new XmlElement(*authenticator_message_)); |
| 204 } | 203 } |
| 205 | 204 |
| 206 return root; | 205 return root; |
| 207 } | 206 } |
| 208 | 207 |
| 209 // static | 208 // static |
| 210 ContentDescription* ContentDescription::ParseXml( | 209 ContentDescription* ContentDescription::ParseXml( |
| 211 const XmlElement* element) { | 210 const XmlElement* element) { |
| 212 if (element->Name() == QName(kChromotingXmlNamespace, kDescriptionTag)) { | 211 if (element->Name() == QName(kChromotingXmlNamespace, kDescriptionTag)) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 &height)) { | 258 &height)) { |
| 260 return NULL; | 259 return NULL; |
| 261 } | 260 } |
| 262 ScreenResolution resolution(width, height); | 261 ScreenResolution resolution(width, height); |
| 263 if (!resolution.IsValid()) | 262 if (!resolution.IsValid()) |
| 264 return NULL; | 263 return NULL; |
| 265 | 264 |
| 266 *config->mutable_initial_resolution() = resolution; | 265 *config->mutable_initial_resolution() = resolution; |
| 267 | 266 |
| 268 scoped_ptr<XmlElement> authenticator_message; | 267 scoped_ptr<XmlElement> authenticator_message; |
| 269 child = element->FirstNamed(QName(kChromotingXmlNamespace, | 268 child = Authenticator::FindAuthenticatorMessage(element); |
| 270 kAuthenticationTag)); | |
| 271 if (child) | 269 if (child) |
| 272 authenticator_message.reset(new XmlElement(*child)); | 270 authenticator_message.reset(new XmlElement(*child)); |
| 273 | 271 |
| 274 return new ContentDescription( | 272 return new ContentDescription( |
| 275 config.release(), authenticator_message.release()); | 273 config.release(), authenticator_message.release()); |
| 276 } | 274 } |
| 277 LOG(ERROR) << "Invalid description: " << element->Str(); | 275 LOG(ERROR) << "Invalid description: " << element->Str(); |
| 278 return NULL; | 276 return NULL; |
| 279 } | 277 } |
| 280 | 278 |
| 281 } // namespace protocol | 279 } // namespace protocol |
| 282 } // namespace remoting | 280 } // namespace remoting |
| OLD | NEW |