#include "media/base/sdp_video_format_utils.h"
#include <cstring>
#include <map>
#include <string>
#include <utility>
#include "api/video_codecs/h264_profile_level_id.h"
#ifdef RTC_ENABLE_H265
#include "api/video_codecs/h265_profile_tier_level.h"
#endif
#include "absl/algorithm/container.h"
#include "media/base/media_constants.h"
#include "rtc_base/checks.h"
#include "rtc_base/string_to_number.h"
namespace webrtc {
namespace {
const char kProfileLevelId[] = …;
const char kH264LevelAsymmetryAllowed[] = …;
const char kVPxFmtpMaxFrameRate[] = …;
const char kVPxFmtpMaxFrameSize[] = …;
const int kVPxFmtpFrameSizeSubBlockPixels = …;
#ifdef RTC_ENABLE_H265
constexpr char kH265ProfileId[] = "profile-id";
constexpr char kH265TierFlag[] = "tier-flag";
constexpr char kH265LevelId[] = "level-id";
#endif
bool IsH264LevelAsymmetryAllowed(const CodecParameterMap& params) { … }
bool H264LevelIsLess(H264Level a, H264Level b) { … }
H264Level H264LevelMin(H264Level a, H264Level b) { … }
absl::optional<int> ParsePositiveNumberFromParams(
const CodecParameterMap& params,
const char* parameter_name) { … }
#ifdef RTC_ENABLE_H265
H265Level H265LevelMin(H265Level a, H265Level b) {
return a <= b ? a : b;
}
bool IsDefaultH265PTL(const CodecParameterMap& params) {
return !params.count(kH265ProfileId) && !params.count(kH265TierFlag) &&
!params.count(kH265LevelId);
}
#endif
}
#ifdef RTC_ENABLE_H265
void H265GenerateProfileTierLevelForAnswer(
const CodecParameterMap& local_supported_params,
const CodecParameterMap& remote_offered_params,
CodecParameterMap* answer_params) {
if (IsDefaultH265PTL(local_supported_params) &&
IsDefaultH265PTL(remote_offered_params)) {
return;
}
const absl::optional<H265ProfileTierLevel> local_profile_tier_level =
ParseSdpForH265ProfileTierLevel(local_supported_params);
const absl::optional<H265ProfileTierLevel> remote_profile_tier_level =
ParseSdpForH265ProfileTierLevel(remote_offered_params);
RTC_DCHECK(local_profile_tier_level);
RTC_DCHECK(remote_profile_tier_level);
RTC_DCHECK_EQ(local_profile_tier_level->profile,
remote_profile_tier_level->profile);
RTC_DCHECK_EQ(local_profile_tier_level->tier,
remote_profile_tier_level->tier);
const H265Level answer_level = H265LevelMin(local_profile_tier_level->level,
remote_profile_tier_level->level);
(*answer_params)[kH265LevelId] = H265LevelToString(answer_level);
}
#endif
void H264GenerateProfileLevelIdForAnswer(
const CodecParameterMap& local_supported_params,
const CodecParameterMap& remote_offered_params,
CodecParameterMap* answer_params) { … }
absl::optional<int> ParseSdpForVPxMaxFrameRate(
const CodecParameterMap& params) { … }
absl::optional<int> ParseSdpForVPxMaxFrameSize(
const CodecParameterMap& params) { … }
bool SupportsPerLayerPictureLossIndication(const CodecParameterMap& params) { … }
}