Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: remoting/protocol/content_description.cc

Issue 10532211: Added piping for sending audio packets from host to client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/protocol/authenticator.h" 10 #include "remoting/protocol/authenticator.h"
11 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 11 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
12 12
13 using buzz::QName; 13 using buzz::QName;
14 using buzz::XmlElement; 14 using buzz::XmlElement;
15 15
16 namespace remoting { 16 namespace remoting {
17 namespace protocol { 17 namespace protocol {
18 18
19 const char ContentDescription::kChromotingContentName[] = "chromoting"; 19 const char ContentDescription::kChromotingContentName[] = "chromoting";
20 20
21 namespace { 21 namespace {
22 22
23 const char kDefaultNs[] = ""; 23 const char kDefaultNs[] = "";
24 24
25 // Following constants are used to format session description in XML. 25 // Following constants are used to format session description in XML.
26 const char kDescriptionTag[] = "description"; 26 const char kDescriptionTag[] = "description";
27 const char kControlTag[] = "control"; 27 const char kControlTag[] = "control";
28 const char kEventTag[] = "event"; 28 const char kEventTag[] = "event";
29 const char kVideoTag[] = "video"; 29 const char kVideoTag[] = "video";
30 const char kAudioTag[] = "audio";
30 const char kDeprecatedResolutionTag[] = "initial-resolution"; 31 const char kDeprecatedResolutionTag[] = "initial-resolution";
31 32
32 const char kTransportAttr[] = "transport"; 33 const char kTransportAttr[] = "transport";
33 const char kVersionAttr[] = "version"; 34 const char kVersionAttr[] = "version";
34 const char kCodecAttr[] = "codec"; 35 const char kCodecAttr[] = "codec";
35 const char kDeprecatedWidthAttr[] = "width"; 36 const char kDeprecatedWidthAttr[] = "width";
36 const char kDeprecatedHeightAttr[] = "height"; 37 const char kDeprecatedHeightAttr[] = "height";
37 38
38 const char kStreamTransport[] = "stream"; 39 const char kStreamTransport[] = "stream";
39 const char kDatagramTransport[] = "datagram"; 40 const char kDatagramTransport[] = "datagram";
41 const char kNoneTransport[] = "none";
40 42
41 const char kVerbatimCodec[] = "verbatim"; 43 const char kVerbatimCodec[] = "verbatim";
42 const char kVp8Codec[] = "vp8"; 44 const char kVp8Codec[] = "vp8";
43 const char kZipCodec[] = "zip"; 45 const char kZipCodec[] = "zip";
44 46
45 const char* GetTransportName(ChannelConfig::TransportType type) { 47 const char* GetTransportName(ChannelConfig::TransportType type) {
46 switch (type) { 48 switch (type) {
47 case ChannelConfig::TRANSPORT_STREAM: 49 case ChannelConfig::TRANSPORT_STREAM:
48 return kStreamTransport; 50 return kStreamTransport;
49 case ChannelConfig::TRANSPORT_DATAGRAM: 51 case ChannelConfig::TRANSPORT_DATAGRAM:
50 return kDatagramTransport; 52 return kDatagramTransport;
53 case ChannelConfig::TRANSPORT_NONE:
54 return kNoneTransport;
51 } 55 }
52 NOTREACHED(); 56 NOTREACHED();
53 return NULL; 57 return NULL;
54 } 58 }
55 59
56 const char* GetCodecName(ChannelConfig::Codec type) { 60 const char* GetCodecName(ChannelConfig::Codec type) {
57 switch (type) { 61 switch (type) {
58 case ChannelConfig::CODEC_VERBATIM: 62 case ChannelConfig::CODEC_VERBATIM:
59 return kVerbatimCodec; 63 return kVerbatimCodec;
60 case ChannelConfig::CODEC_VP8: 64 case ChannelConfig::CODEC_VP8:
(...skipping 29 matching lines...) Expand all
90 94
91 return result; 95 return result;
92 } 96 }
93 97
94 bool ParseTransportName(const std::string& value, 98 bool ParseTransportName(const std::string& value,
95 ChannelConfig::TransportType* transport) { 99 ChannelConfig::TransportType* transport) {
96 if (value == kStreamTransport) { 100 if (value == kStreamTransport) {
97 *transport = ChannelConfig::TRANSPORT_STREAM; 101 *transport = ChannelConfig::TRANSPORT_STREAM;
98 } else if (value == kDatagramTransport) { 102 } else if (value == kDatagramTransport) {
99 *transport = ChannelConfig::TRANSPORT_DATAGRAM; 103 *transport = ChannelConfig::TRANSPORT_DATAGRAM;
104 } else if (value == kNoneTransport) {
105 *transport = ChannelConfig::TRANSPORT_NONE;
100 } else { 106 } else {
101 return false; 107 return false;
102 } 108 }
103 return true; 109 return true;
104 } 110 }
105 111
106 bool ParseCodecName(const std::string& value, ChannelConfig::Codec* codec) { 112 bool ParseCodecName(const std::string& value, ChannelConfig::Codec* codec) {
107 if (value == kVerbatimCodec) { 113 if (value == kVerbatimCodec) {
108 *codec = ChannelConfig::CODEC_VERBATIM; 114 *codec = ChannelConfig::CODEC_VERBATIM;
109 } else if (value == kVp8Codec) { 115 } else if (value == kVp8Codec) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scoped_ptr<XmlElement> message(new XmlElement(*authenticator_message_)); 162 scoped_ptr<XmlElement> message(new XmlElement(*authenticator_message_));
157 return new ContentDescription(candidate_config_->Clone(), message.Pass()); 163 return new ContentDescription(candidate_config_->Clone(), message.Pass());
158 } 164 }
159 165
160 // ToXml() creates content description for chromoting session. The 166 // ToXml() creates content description for chromoting session. The
161 // description looks as follows: 167 // description looks as follows:
162 // <description xmlns="google:remoting"> 168 // <description xmlns="google:remoting">
163 // <control transport="stream" version="1" /> 169 // <control transport="stream" version="1" />
164 // <event transport="datagram" version="1" /> 170 // <event transport="datagram" version="1" />
165 // <video transport="stream" codec="vp8" version="1" /> 171 // <video transport="stream" codec="vp8" version="1" />
172 // <audio transport="stream" version="1" />
166 // <authentication> 173 // <authentication>
167 // Message created by Authenticator implementation. 174 // Message created by Authenticator implementation.
168 // </authentication> 175 // </authentication>
169 // </description> 176 // </description>
170 // 177 //
171 XmlElement* ContentDescription::ToXml() const { 178 XmlElement* ContentDescription::ToXml() const {
172 XmlElement* root = new XmlElement( 179 XmlElement* root = new XmlElement(
173 QName(kChromotingXmlNamespace, kDescriptionTag), true); 180 QName(kChromotingXmlNamespace, kDescriptionTag), true);
174 181
175 std::vector<ChannelConfig>::const_iterator it; 182 std::vector<ChannelConfig>::const_iterator it;
176 183
177 for (it = config()->control_configs().begin(); 184 for (it = config()->control_configs().begin();
178 it != config()->control_configs().end(); ++it) { 185 it != config()->control_configs().end(); ++it) {
179 root->AddElement(FormatChannelConfig(*it, kControlTag)); 186 root->AddElement(FormatChannelConfig(*it, kControlTag));
180 } 187 }
181 188
182 for (it = config()->event_configs().begin(); 189 for (it = config()->event_configs().begin();
183 it != config()->event_configs().end(); ++it) { 190 it != config()->event_configs().end(); ++it) {
184 root->AddElement(FormatChannelConfig(*it, kEventTag)); 191 root->AddElement(FormatChannelConfig(*it, kEventTag));
185 } 192 }
186 193
187 for (it = config()->video_configs().begin(); 194 for (it = config()->video_configs().begin();
188 it != config()->video_configs().end(); ++it) { 195 it != config()->video_configs().end(); ++it) {
189 root->AddElement(FormatChannelConfig(*it, kVideoTag)); 196 root->AddElement(FormatChannelConfig(*it, kVideoTag));
190 } 197 }
191 198
199 for (it = config()->audio_configs().begin();
200 it != config()->audio_configs().end(); ++it) {
201 root->AddElement(FormatChannelConfig(*it, kAudioTag));
202 }
203
192 // Older endpoints require an initial-resolution tag, but otherwise ignore it. 204 // Older endpoints require an initial-resolution tag, but otherwise ignore it.
193 XmlElement* resolution_tag = new XmlElement( 205 XmlElement* resolution_tag = new XmlElement(
194 QName(kChromotingXmlNamespace, kDeprecatedResolutionTag)); 206 QName(kChromotingXmlNamespace, kDeprecatedResolutionTag));
195 resolution_tag->AddAttr(QName(kDefaultNs, kDeprecatedWidthAttr), "640"); 207 resolution_tag->AddAttr(QName(kDefaultNs, kDeprecatedWidthAttr), "640");
196 resolution_tag->AddAttr(QName(kDefaultNs, kDeprecatedHeightAttr), "480"); 208 resolution_tag->AddAttr(QName(kDefaultNs, kDeprecatedHeightAttr), "480");
197 root->AddElement(resolution_tag); 209 root->AddElement(resolution_tag);
198 210
199 if (authenticator_message_.get()) { 211 if (authenticator_message_.get()) {
200 DCHECK(Authenticator::IsAuthenticatorMessage(authenticator_message_.get())); 212 DCHECK(Authenticator::IsAuthenticatorMessage(authenticator_message_.get()));
201 root->AddElement(new XmlElement(*authenticator_message_)); 213 root->AddElement(new XmlElement(*authenticator_message_));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 QName video_tag(kChromotingXmlNamespace, kVideoTag); 250 QName video_tag(kChromotingXmlNamespace, kVideoTag);
239 child = element->FirstNamed(video_tag); 251 child = element->FirstNamed(video_tag);
240 while (child) { 252 while (child) {
241 ChannelConfig channel_config; 253 ChannelConfig channel_config;
242 if (!ParseChannelConfig(child, true, &channel_config)) 254 if (!ParseChannelConfig(child, true, &channel_config))
243 return NULL; 255 return NULL;
244 config->mutable_video_configs()->push_back(channel_config); 256 config->mutable_video_configs()->push_back(channel_config);
245 child = child->NextNamed(video_tag); 257 child = child->NextNamed(video_tag);
246 } 258 }
247 259
260 // <audio> tags.
261 QName audio_tag(kChromotingXmlNamespace, kAudioTag);
262 child = element->FirstNamed(audio_tag);
263 if (!child) {
264 // If there's no mention of audio, implicitly assume
265 // TRANSPORT_NONE for the audio_channel.
266 ChannelConfig no_audio(ChannelConfig::TRANSPORT_NONE,
267 kDefaultStreamVersion,
268 ChannelConfig::CODEC_UNDEFINED);
269 config->mutable_audio_configs()->push_back(no_audio);
270 }
271 while (child) {
272 ChannelConfig channel_config;
273 if (!ParseChannelConfig(child, false, &channel_config))
274 return NULL;
275 config->mutable_audio_configs()->push_back(channel_config);
276 child = child->NextNamed(audio_tag);
277 }
278
248 scoped_ptr<XmlElement> authenticator_message; 279 scoped_ptr<XmlElement> authenticator_message;
249 child = Authenticator::FindAuthenticatorMessage(element); 280 child = Authenticator::FindAuthenticatorMessage(element);
250 if (child) 281 if (child)
251 authenticator_message.reset(new XmlElement(*child)); 282 authenticator_message.reset(new XmlElement(*child));
252 283
253 return new ContentDescription(config.Pass(), authenticator_message.Pass()); 284 return new ContentDescription(config.Pass(), authenticator_message.Pass());
254 } 285 }
255 LOG(ERROR) << "Invalid description: " << element->Str(); 286 LOG(ERROR) << "Invalid description: " << element->Str();
256 return NULL; 287 return NULL;
257 } 288 }
258 289
259 } // namespace protocol 290 } // namespace protocol
260 } // namespace remoting 291 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698