| 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/content_description.h" | 5 #include "remoting/protocol/content_description.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 13 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
| 14 #include "remoting/protocol/name_value_map.h" | 15 #include "remoting/protocol/name_value_map.h" |
| 15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 16 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 16 | 17 |
| 17 using buzz::QName; | 18 using buzz::QName; |
| 18 using buzz::XmlElement; | 19 using buzz::XmlElement; |
| 19 | 20 |
| 20 namespace remoting { | 21 namespace remoting { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 config->version = 0; | 109 config->version = 0; |
| 109 config->codec = ChannelConfig::CODEC_UNDEFINED; | 110 config->codec = ChannelConfig::CODEC_UNDEFINED; |
| 110 } | 111 } |
| 111 | 112 |
| 112 return true; | 113 return true; |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace | 116 } // namespace |
| 116 | 117 |
| 117 ContentDescription::ContentDescription( | 118 ContentDescription::ContentDescription( |
| 118 scoped_ptr<CandidateSessionConfig> config, | 119 std::unique_ptr<CandidateSessionConfig> config, |
| 119 scoped_ptr<buzz::XmlElement> authenticator_message) | 120 std::unique_ptr<buzz::XmlElement> authenticator_message) |
| 120 : candidate_config_(std::move(config)), | 121 : candidate_config_(std::move(config)), |
| 121 authenticator_message_(std::move(authenticator_message)) { | 122 authenticator_message_(std::move(authenticator_message)) {} |
| 122 } | |
| 123 | 123 |
| 124 ContentDescription::~ContentDescription() { } | 124 ContentDescription::~ContentDescription() { } |
| 125 | 125 |
| 126 // ToXml() creates content description for chromoting session. The | 126 // ToXml() creates content description for chromoting session. The |
| 127 // description looks as follows: | 127 // description looks as follows: |
| 128 // <description xmlns="google:remoting"> | 128 // <description xmlns="google:remoting"> |
| 129 // <standard-ice/> | 129 // <standard-ice/> |
| 130 // <control transport="stream" version="1" /> | 130 // <control transport="stream" version="1" /> |
| 131 // <event transport="datagram" version="1" /> | 131 // <event transport="datagram" version="1" /> |
| 132 // <video transport="stream" codec="vp8" version="1" /> | 132 // <video transport="stream" codec="vp8" version="1" /> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 child = child->NextNamed(tag); | 193 child = child->NextNamed(tag); |
| 194 } | 194 } |
| 195 if (optional && configs->empty()) { | 195 if (optional && configs->empty()) { |
| 196 // If there's no mention of the tag, implicitly assume disabled channel. | 196 // If there's no mention of the tag, implicitly assume disabled channel. |
| 197 configs->push_back(ChannelConfig::None()); | 197 configs->push_back(ChannelConfig::None()); |
| 198 } | 198 } |
| 199 return true; | 199 return true; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // static | 202 // static |
| 203 scoped_ptr<ContentDescription> ContentDescription::ParseXml( | 203 std::unique_ptr<ContentDescription> ContentDescription::ParseXml( |
| 204 const XmlElement* element, | 204 const XmlElement* element, |
| 205 bool webrtc_transport) { | 205 bool webrtc_transport) { |
| 206 if (element->Name() != QName(kChromotingXmlNamespace, kDescriptionTag)) { | 206 if (element->Name() != QName(kChromotingXmlNamespace, kDescriptionTag)) { |
| 207 LOG(ERROR) << "Invalid description: " << element->Str(); | 207 LOG(ERROR) << "Invalid description: " << element->Str(); |
| 208 return nullptr; | 208 return nullptr; |
| 209 } | 209 } |
| 210 scoped_ptr<CandidateSessionConfig> config( | 210 std::unique_ptr<CandidateSessionConfig> config( |
| 211 CandidateSessionConfig::CreateEmpty()); | 211 CandidateSessionConfig::CreateEmpty()); |
| 212 | 212 |
| 213 config->set_webrtc_supported(webrtc_transport); | 213 config->set_webrtc_supported(webrtc_transport); |
| 214 | 214 |
| 215 if (element->FirstNamed(QName(kChromotingXmlNamespace, kStandardIceTag)) != | 215 if (element->FirstNamed(QName(kChromotingXmlNamespace, kStandardIceTag)) != |
| 216 nullptr) { | 216 nullptr) { |
| 217 config->set_ice_supported(true); | 217 config->set_ice_supported(true); |
| 218 if (!ParseChannelConfigs(element, kControlTag, false, false, | 218 if (!ParseChannelConfigs(element, kControlTag, false, false, |
| 219 config->mutable_control_configs()) || | 219 config->mutable_control_configs()) || |
| 220 !ParseChannelConfigs(element, kEventTag, false, false, | 220 !ParseChannelConfigs(element, kEventTag, false, false, |
| 221 config->mutable_event_configs()) || | 221 config->mutable_event_configs()) || |
| 222 !ParseChannelConfigs(element, kVideoTag, true, false, | 222 !ParseChannelConfigs(element, kVideoTag, true, false, |
| 223 config->mutable_video_configs()) || | 223 config->mutable_video_configs()) || |
| 224 !ParseChannelConfigs(element, kAudioTag, true, true, | 224 !ParseChannelConfigs(element, kAudioTag, true, true, |
| 225 config->mutable_audio_configs())) { | 225 config->mutable_audio_configs())) { |
| 226 return nullptr; | 226 return nullptr; |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Check if VP9 experiment is enabled. | 230 // Check if VP9 experiment is enabled. |
| 231 if (element->FirstNamed(QName(kChromotingXmlNamespace, kVp9ExperimentTag))) { | 231 if (element->FirstNamed(QName(kChromotingXmlNamespace, kVp9ExperimentTag))) { |
| 232 config->set_vp9_experiment_enabled(true); | 232 config->set_vp9_experiment_enabled(true); |
| 233 } | 233 } |
| 234 | 234 |
| 235 scoped_ptr<XmlElement> authenticator_message; | 235 std::unique_ptr<XmlElement> authenticator_message; |
| 236 const XmlElement* child = Authenticator::FindAuthenticatorMessage(element); | 236 const XmlElement* child = Authenticator::FindAuthenticatorMessage(element); |
| 237 if (child) | 237 if (child) |
| 238 authenticator_message.reset(new XmlElement(*child)); | 238 authenticator_message.reset(new XmlElement(*child)); |
| 239 | 239 |
| 240 return make_scoped_ptr(new ContentDescription( | 240 return base::WrapUnique(new ContentDescription( |
| 241 std::move(config), std::move(authenticator_message))); | 241 std::move(config), std::move(authenticator_message))); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace protocol | 244 } // namespace protocol |
| 245 } // namespace remoting | 245 } // namespace remoting |
| OLD | NEW |