Index: webrtc/api/mediatypes.cc |
diff --git a/webrtc/api/mediatypes.cc b/webrtc/api/mediatypes.cc |
index 97b0189b7a9349396219aa69a6df3adf5a124520..fbcb53d85b272a6db147df56c4d0a8c70ed96976 100644 |
--- a/webrtc/api/mediatypes.cc |
+++ b/webrtc/api/mediatypes.cc |
@@ -9,27 +9,39 @@ |
*/ |
#include "webrtc/api/mediatypes.h" |
+ |
+#include "webrtc/api/mediastreaminterface.h" |
#include "webrtc/base/checks.h" |
+namespace { |
+static const char* kMediaTypeData = "data"; |
+} // namespace |
+ |
namespace cricket { |
std::string MediaTypeToString(MediaType type) { |
- std::string type_str; |
switch (type) { |
case MEDIA_TYPE_AUDIO: |
- type_str = "audio"; |
- break; |
+ return webrtc::MediaStreamTrackInterface::kAudioKind; |
case MEDIA_TYPE_VIDEO: |
- type_str = "video"; |
- break; |
+ return webrtc::MediaStreamTrackInterface::kVideoKind; |
case MEDIA_TYPE_DATA: |
- type_str = "data"; |
- break; |
- default: |
- RTC_NOTREACHED(); |
- break; |
+ return kMediaTypeData; |
+ } |
+ // Not reachable; avoids compile warning. |
+ FATAL(); |
+} |
+ |
+MediaType MediaTypeFromString(const std::string& type_str) { |
+ if (type_str == webrtc::MediaStreamTrackInterface::kAudioKind) { |
+ return MEDIA_TYPE_AUDIO; |
+ } else if (type_str == webrtc::MediaStreamTrackInterface::kVideoKind) { |
+ return MEDIA_TYPE_VIDEO; |
+ } else if (type_str == kMediaTypeData) { |
+ return MEDIA_TYPE_DATA; |
+ } else { |
+ FATAL(); |
} |
- return type_str; |
} |
} // namespace cricket |