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

Unified Diff: webrtc/common_types.cc

Issue 2509273002: Unify VideoCodecType to/from string functionality (Closed)
Patch Set: Rebase and update unknown string in WebRtcVideoEncoderFactory Created 4 years, 1 month 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 | « webrtc/common_types.h ('k') | webrtc/media/base/codec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_types.cc
diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc
index 89f3eab8cb511dbfe77242f4657dbcfd1fe8f0b0..2cbad4711d3cacb2d1dc6080b66103f669340466 100644
--- a/webrtc/common_types.cc
+++ b/webrtc/common_types.cc
@@ -8,12 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/base/checks.h"
#include "webrtc/common_types.h"
#include <limits>
#include <string.h>
+#include "webrtc/base/checks.h"
+#include "webrtc/base/stringutils.h"
+
namespace webrtc {
StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {}
@@ -101,41 +103,45 @@ static const char* kPayloadNameRED = "RED";
static const char* kPayloadNameULPFEC = "ULPFEC";
static const char* kPayloadNameGeneric = "Generic";
-rtc::Optional<std::string> CodecTypeToPayloadName(VideoCodecType type) {
+static bool CodecNamesEq(const char* name1, const char* name2) {
+ return _stricmp(name1, name2) == 0;
+}
+
+rtc::Optional<const char*> CodecTypeToPayloadName(VideoCodecType type) {
switch (type) {
case kVideoCodecVP8:
- return rtc::Optional<std::string>(kPayloadNameVp8);
+ return rtc::Optional<const char*>(kPayloadNameVp8);
case kVideoCodecVP9:
- return rtc::Optional<std::string>(kPayloadNameVp9);
+ return rtc::Optional<const char*>(kPayloadNameVp9);
case kVideoCodecH264:
- return rtc::Optional<std::string>(kPayloadNameH264);
+ return rtc::Optional<const char*>(kPayloadNameH264);
case kVideoCodecI420:
- return rtc::Optional<std::string>(kPayloadNameI420);
+ return rtc::Optional<const char*>(kPayloadNameI420);
case kVideoCodecRED:
- return rtc::Optional<std::string>(kPayloadNameRED);
+ return rtc::Optional<const char*>(kPayloadNameRED);
case kVideoCodecULPFEC:
- return rtc::Optional<std::string>(kPayloadNameULPFEC);
+ return rtc::Optional<const char*>(kPayloadNameULPFEC);
case kVideoCodecGeneric:
- return rtc::Optional<std::string>(kPayloadNameGeneric);
+ return rtc::Optional<const char*>(kPayloadNameGeneric);
default:
- return rtc::Optional<std::string>();
+ return rtc::Optional<const char*>();
}
}
rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name) {
- if (name == kPayloadNameVp8)
+ if (CodecNamesEq(name.c_str(), kPayloadNameVp8))
return rtc::Optional<VideoCodecType>(kVideoCodecVP8);
- if (name == kPayloadNameVp9)
+ if (CodecNamesEq(name.c_str(), kPayloadNameVp9))
return rtc::Optional<VideoCodecType>(kVideoCodecVP9);
- if (name == kPayloadNameH264)
+ if (CodecNamesEq(name.c_str(), kPayloadNameH264))
return rtc::Optional<VideoCodecType>(kVideoCodecH264);
- if (name == kPayloadNameI420)
+ if (CodecNamesEq(name.c_str(), kPayloadNameI420))
return rtc::Optional<VideoCodecType>(kVideoCodecI420);
- if (name == kPayloadNameRED)
+ if (CodecNamesEq(name.c_str(), kPayloadNameRED))
return rtc::Optional<VideoCodecType>(kVideoCodecRED);
- if (name == kPayloadNameULPFEC)
+ if (CodecNamesEq(name.c_str(), kPayloadNameULPFEC))
return rtc::Optional<VideoCodecType>(kVideoCodecULPFEC);
- if (name == kPayloadNameGeneric)
+ if (CodecNamesEq(name.c_str(), kPayloadNameGeneric))
return rtc::Optional<VideoCodecType>(kVideoCodecGeneric);
return rtc::Optional<VideoCodecType>();
}
« no previous file with comments | « webrtc/common_types.h ('k') | webrtc/media/base/codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698