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

Unified Diff: remoting/protocol/content_description.cc

Issue 10829324: Add mux-stream transport support in session description (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/protocol/jingle_messages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/content_description.cc
diff --git a/remoting/protocol/content_description.cc b/remoting/protocol/content_description.cc
index 70ba05b570ae48b4747ec83b0f998368fff7562a..9f7d5d54f0f30c2285bc4dbf25125838461f67ee 100644
--- a/remoting/protocol/content_description.cc
+++ b/remoting/protocol/content_description.cc
@@ -8,6 +8,7 @@
#include "base/string_number_conversions.h"
#include "remoting/base/constants.h"
#include "remoting/protocol/authenticator.h"
+#include "remoting/protocol/name_value_map.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
using buzz::QName;
@@ -36,45 +37,19 @@ const char kCodecAttr[] = "codec";
const char kDeprecatedWidthAttr[] = "width";
const char kDeprecatedHeightAttr[] = "height";
-const char kStreamTransport[] = "stream";
-const char kDatagramTransport[] = "datagram";
-const char kNoneTransport[] = "none";
-
-const char kVerbatimCodec[] = "verbatim";
-const char kVp8Codec[] = "vp8";
-const char kZipCodec[] = "zip";
-const char kVorbisCodec[] = "vorbis";
-
-const char* GetTransportName(ChannelConfig::TransportType type) {
- switch (type) {
- case ChannelConfig::TRANSPORT_STREAM:
- return kStreamTransport;
- case ChannelConfig::TRANSPORT_DATAGRAM:
- return kDatagramTransport;
- case ChannelConfig::TRANSPORT_NONE:
- return kNoneTransport;
- }
- NOTREACHED();
- return NULL;
-}
-
-const char* GetCodecName(ChannelConfig::Codec type) {
- switch (type) {
- case ChannelConfig::CODEC_VERBATIM:
- return kVerbatimCodec;
- case ChannelConfig::CODEC_VP8:
- return kVp8Codec;
- case ChannelConfig::CODEC_ZIP:
- return kZipCodec;
- case ChannelConfig::CODEC_VORBIS:
- return kVorbisCodec;
- default:
- break;
- }
- NOTREACHED();
- return NULL;
-}
+const NameMapElement<ChannelConfig::TransportType> kTransports[] = {
+ { ChannelConfig::TRANSPORT_STREAM, "stream" },
+ { ChannelConfig::TRANSPORT_MUX_STREAM, "mux-stream" },
+ { ChannelConfig::TRANSPORT_DATAGRAM, "datagram" },
+ { ChannelConfig::TRANSPORT_NONE, "none" },
+};
+const NameMapElement<ChannelConfig::Codec> kCodecs[] = {
+ { ChannelConfig::CODEC_VERBATIM, "verbatim" },
+ { ChannelConfig::CODEC_VP8, "vp8" },
+ { ChannelConfig::CODEC_ZIP, "zip" },
+ { ChannelConfig::CODEC_VORBIS, "vorbis" },
+};
// Format a channel configuration tag for chromotocol session description,
// e.g. for video channel:
@@ -85,61 +60,33 @@ XmlElement* FormatChannelConfig(const ChannelConfig& config,
QName(kChromotingXmlNamespace, tag_name));
result->AddAttr(QName(kDefaultNs, kTransportAttr),
- GetTransportName(config.transport));
+ ValueToName(kTransports, config.transport));
result->AddAttr(QName(kDefaultNs, kVersionAttr),
base::IntToString(config.version));
if (config.codec != ChannelConfig::CODEC_UNDEFINED) {
result->AddAttr(QName(kDefaultNs, kCodecAttr),
- GetCodecName(config.codec));
+ ValueToName(kCodecs, config.codec));
}
return result;
}
-bool ParseTransportName(const std::string& value,
- ChannelConfig::TransportType* transport) {
- if (value == kStreamTransport) {
- *transport = ChannelConfig::TRANSPORT_STREAM;
- } else if (value == kDatagramTransport) {
- *transport = ChannelConfig::TRANSPORT_DATAGRAM;
- } else if (value == kNoneTransport) {
- *transport = ChannelConfig::TRANSPORT_NONE;
- } else {
- return false;
- }
- return true;
-}
-
-bool ParseCodecName(const std::string& value, ChannelConfig::Codec* codec) {
- if (value == kVerbatimCodec) {
- *codec = ChannelConfig::CODEC_VERBATIM;
- } else if (value == kVp8Codec) {
- *codec = ChannelConfig::CODEC_VP8;
- } else if (value == kZipCodec) {
- *codec = ChannelConfig::CODEC_ZIP;
- } else if (value == kVorbisCodec) {
- *codec = ChannelConfig::CODEC_VORBIS;
- } else {
- return false;
- }
- return true;
-}
-
// Returns false if the element is invalid.
bool ParseChannelConfig(const XmlElement* element, bool codec_required,
ChannelConfig* config) {
- if (!ParseTransportName(element->Attr(QName(kDefaultNs, kTransportAttr)),
- &config->transport) ||
+ if (!NameToValue(
+ kTransports, element->Attr(QName(kDefaultNs, kTransportAttr)),
+ &config->transport) ||
!base::StringToInt(element->Attr(QName(kDefaultNs, kVersionAttr)),
&config->version)) {
return false;
}
if (codec_required) {
- if (!ParseCodecName(element->Attr(QName(kDefaultNs, kCodecAttr)),
- &config->codec)) {
+ if (!NameToValue(kCodecs, element->Attr(QName(kDefaultNs, kCodecAttr)),
+ &config->codec)) {
return false;
}
} else {
« no previous file with comments | « no previous file | remoting/protocol/jingle_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698