Chromium Code Reviews| Index: webrtc/common_video/h264/profile_level_id.cc |
| diff --git a/webrtc/common_video/h264/profile_level_id.cc b/webrtc/common_video/h264/profile_level_id.cc |
| index 9f9aef9f61d147f72111b6ee3d6f5c79395e00d6..4b5be2d239efffc59767b10dd102c51c590e8b56 100644 |
| --- a/webrtc/common_video/h264/profile_level_id.cc |
| +++ b/webrtc/common_video/h264/profile_level_id.cc |
| @@ -10,6 +10,7 @@ |
| #include "webrtc/common_video/h264/profile_level_id.h" |
| +#include <cstdio> |
| #include <cstdlib> |
| #include <cstring> |
| @@ -128,5 +129,48 @@ rtc::Optional<ProfileLevelId> ParseProfileLevelId(const char* str) { |
| return rtc::Optional<ProfileLevelId>(); |
| } |
| +std::string ProfileLevelIdToString(const ProfileLevelId& profile_level_id) { |
| + // Handle special case level == 1b. |
| + if (profile_level_id.level == kLevel1_b) { |
| + switch (profile_level_id.profile) { |
| + case kProfileConstrainedBaseline: |
| + return "42f00b"; |
| + case kProfileBaseline: |
| + return "42100b"; |
| + case kProfileMain: |
| + return "4D100b"; |
| + // Level 1b is not allowed for other profiles. |
| + default: |
| + return std::string(); |
|
kthelgason
2016/11/03 09:39:05
Maybe we should return an rtc::Optional<std::strin
magjed_webrtc
2016/11/03 12:31:16
You are probably right. It's clearer than returnin
|
| + } |
| + } |
| + |
| + const char* profile_idc_iop_string; |
| + switch (profile_level_id.profile) { |
| + case kProfileConstrainedBaseline: |
| + profile_idc_iop_string = "42e0"; |
| + break; |
| + case kProfileBaseline: |
| + profile_idc_iop_string = "4200"; |
| + break; |
| + case kProfileMain: |
| + profile_idc_iop_string = "4D00"; |
| + break; |
| + case kProfileConstrainedHigh: |
| + profile_idc_iop_string = "640c"; |
| + break; |
| + case kProfileHigh: |
| + profile_idc_iop_string = "6400"; |
| + break; |
| + // Unrecognized profile. |
| + default: |
| + return std::string(); |
|
kthelgason
2016/11/03 09:39:05
perhaps replace this with a RTC_NOTREACHED() if we
magjed_webrtc
2016/11/03 12:31:16
If we handle some case, then we should not CHECK/N
|
| + } |
| + |
| + char str[7]; |
| + snprintf(str, 7u, "%s%02x", profile_idc_iop_string, profile_level_id.level); |
| + return str; |
| +} |
| + |
| } // namespace H264 |
| } // namespace webrtc |