| 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/jingle_messages.h" | 5 #include "remoting/protocol/jingle_messages.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/protocol/content_description.h" | 10 #include "remoting/protocol/content_description.h" |
| 11 #include "remoting/protocol/name_value_map.h" | 11 #include "remoting/protocol/name_value_map.h" |
| 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 13 | 13 |
| 14 using buzz::QName; | 14 using buzz::QName; |
| 15 using buzz::XmlElement; | 15 using buzz::XmlElement; |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 namespace protocol { | 18 namespace protocol { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kJabberNamespace[] = "jabber:client"; | 22 const char kJabberNamespace[] = "jabber:client"; |
| 23 const char kJingleNamespace[] = "urn:xmpp:jingle:1"; | 23 const char kJingleNamespace[] = "urn:xmpp:jingle:1"; |
| 24 | 24 |
| 25 // Namespace for transport messages when using standard ICE. | 25 // Namespace for transport messages when using standard ICE. |
| 26 const char kIceTransportNamespace[] = "google:remoting:ice"; | 26 const char kIceTransportNamespace[] = "google:remoting:ice"; |
| 27 | 27 |
| 28 const char kWebrtcTransportNamespace[] = "google:remoting:webrtc"; |
| 29 |
| 28 const char kEmptyNamespace[] = ""; | 30 const char kEmptyNamespace[] = ""; |
| 29 const char kXmlNamespace[] = "http://www.w3.org/XML/1998/namespace"; | 31 const char kXmlNamespace[] = "http://www.w3.org/XML/1998/namespace"; |
| 30 | 32 |
| 31 const int kPortMin = 1000; | 33 const int kPortMin = 1000; |
| 32 const int kPortMax = 65535; | 34 const int kPortMax = 65535; |
| 33 | 35 |
| 34 const NameMapElement<JingleMessage::ActionType> kActionTypes[] = { | 36 const NameMapElement<JingleMessage::ActionType> kActionTypes[] = { |
| 35 { JingleMessage::SESSION_INITIATE, "session-initiate" }, | 37 { JingleMessage::SESSION_INITIATE, "session-initiate" }, |
| 36 { JingleMessage::SESSION_ACCEPT, "session-accept" }, | 38 { JingleMessage::SESSION_ACCEPT, "session-accept" }, |
| 37 { JingleMessage::SESSION_TERMINATE, "session-terminate" }, | 39 { JingleMessage::SESSION_TERMINATE, "session-terminate" }, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 327 |
| 326 if (action != SESSION_TERMINATE) { | 328 if (action != SESSION_TERMINATE) { |
| 327 XmlElement* content_tag = | 329 XmlElement* content_tag = |
| 328 new XmlElement(QName(kJingleNamespace, "content")); | 330 new XmlElement(QName(kJingleNamespace, "content")); |
| 329 jingle_tag->AddElement(content_tag); | 331 jingle_tag->AddElement(content_tag); |
| 330 | 332 |
| 331 content_tag->AddAttr(QName(kEmptyNamespace, "name"), | 333 content_tag->AddAttr(QName(kEmptyNamespace, "name"), |
| 332 ContentDescription::kChromotingContentName); | 334 ContentDescription::kChromotingContentName); |
| 333 content_tag->AddAttr(QName(kEmptyNamespace, "creator"), "initiator"); | 335 content_tag->AddAttr(QName(kEmptyNamespace, "creator"), "initiator"); |
| 334 | 336 |
| 335 if (description.get()) | 337 if (description) |
| 336 content_tag->AddElement(description->ToXml()); | 338 content_tag->AddElement(description->ToXml()); |
| 337 | 339 |
| 338 if (transport_info) | 340 if (transport_info) { |
| 339 content_tag->AddElement(new XmlElement(*transport_info)); | 341 content_tag->AddElement(new XmlElement(*transport_info)); |
| 342 } else if (description && description->config()->webrtc_supported()) { |
| 343 content_tag->AddElement( |
| 344 new XmlElement(QName(kWebrtcTransportNamespace, "transport"))); |
| 345 } |
| 340 } | 346 } |
| 341 | 347 |
| 342 return root; | 348 return root; |
| 343 } | 349 } |
| 344 | 350 |
| 345 JingleMessageReply::JingleMessageReply() | 351 JingleMessageReply::JingleMessageReply() |
| 346 : type(REPLY_RESULT), | 352 : type(REPLY_RESULT), |
| 347 error_type(NONE) { | 353 error_type(NONE) { |
| 348 } | 354 } |
| 349 | 355 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 result->AddElement(FormatIceCredentials(credentials)); | 489 result->AddElement(FormatIceCredentials(credentials)); |
| 484 } | 490 } |
| 485 for (const NamedCandidate& candidate : candidates) { | 491 for (const NamedCandidate& candidate : candidates) { |
| 486 result->AddElement(FormatIceCandidate(candidate)); | 492 result->AddElement(FormatIceCandidate(candidate)); |
| 487 } | 493 } |
| 488 return result; | 494 return result; |
| 489 } | 495 } |
| 490 | 496 |
| 491 } // namespace protocol | 497 } // namespace protocol |
| 492 } // namespace remoting | 498 } // namespace remoting |
| OLD | NEW |