Let PCF.GetRtpSenderCapabilities return codecs' scalabilityModes.

Also move ScalabilityModeToString to api and add RTC_EXPORT so that
Chromium can use it.

Bug: chromium:986069
Change-Id: I5dbbb6de9b14ca20f3ae0630552dcd44595ad5ef
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267780
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Daniel.L (Byoungchan) Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/main@{#37444}
This commit is contained in:
Byoungchan Lee
2022-07-05 21:06:28 +09:00
committed by WebRTC LUCI CQ
parent e1c707c40f
commit a1a7c638ec
29 changed files with 340 additions and 104 deletions

View File

@ -23,6 +23,8 @@ rtc_library("av1_svc_config") {
"../../svc:scalability_structures",
"../../svc:scalable_video_controller",
]
absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector" ]
}
rtc_library("dav1d_decoder") {

View File

@ -36,6 +36,17 @@ absl::optional<ScalabilityMode> BuildScalabilityMode(int num_temporal_layers,
}
} // namespace
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>
LibaomAv1EncoderSupportedScalabilityModes() {
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes;
for (ScalabilityMode scalability_mode : kAllScalabilityModes) {
if (ScalabilityStructureConfig(scalability_mode) != absl::nullopt) {
scalability_modes.push_back(scalability_mode);
}
}
return scalability_modes;
}
bool LibaomAv1EncoderSupportsScalabilityMode(ScalabilityMode scalability_mode) {
// For libaom AV1, the scalability mode is supported if we can create the
// scalability structure.

View File

@ -10,10 +10,16 @@
#ifndef MODULES_VIDEO_CODING_CODECS_AV1_AV1_SVC_CONFIG_H_
#define MODULES_VIDEO_CODING_CODECS_AV1_AV1_SVC_CONFIG_H_
#include <vector>
#include "absl/container/inlined_vector.h"
#include "api/video_codecs/video_codec.h"
namespace webrtc {
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>
LibaomAv1EncoderSupportedScalabilityModes();
bool LibaomAv1EncoderSupportsScalabilityMode(ScalabilityMode scalability_mode);
// Fills `video_codec.spatialLayers` using other members.

View File

@ -14,6 +14,7 @@
#include <memory>
#include <string>
#include "absl/container/inlined_vector.h"
#include "absl/types/optional.h"
#include "api/video_codecs/sdp_video_format.h"
#include "media/base/media_constants.h"
@ -51,15 +52,23 @@ constexpr ScalabilityMode kSupportedScalabilityModes[] = {
SdpVideoFormat CreateH264Format(H264Profile profile,
H264Level level,
const std::string& packetization_mode) {
const std::string& packetization_mode,
bool add_scalability_modes) {
const absl::optional<std::string> profile_string =
H264ProfileLevelIdToString(H264ProfileLevelId(profile, level));
RTC_CHECK(profile_string);
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes;
if (add_scalability_modes) {
for (const auto scalability_mode : kSupportedScalabilityModes) {
scalability_modes.push_back(scalability_mode);
}
}
return SdpVideoFormat(
cricket::kH264CodecName,
{{cricket::kH264FmtpProfileLevelId, *profile_string},
{cricket::kH264FmtpLevelAsymmetryAllowed, "1"},
{cricket::kH264FmtpPacketizationMode, packetization_mode}});
{cricket::kH264FmtpPacketizationMode, packetization_mode}},
scalability_modes);
}
void DisableRtcUseH264() {
@ -68,7 +77,7 @@ void DisableRtcUseH264() {
#endif
}
std::vector<SdpVideoFormat> SupportedH264Codecs() {
std::vector<SdpVideoFormat> SupportedH264Codecs(bool add_scalability_modes) {
TRACE_EVENT0("webrtc", __func__);
if (!IsH264CodecSupported())
return std::vector<SdpVideoFormat>();
@ -81,17 +90,18 @@ std::vector<SdpVideoFormat> SupportedH264Codecs() {
//
// We support both packetization modes 0 (mandatory) and 1 (optional,
// preferred).
return {
CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1,
"1"),
CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1,
"0"),
CreateH264Format(H264Profile::kProfileConstrainedBaseline,
H264Level::kLevel3_1, "1"),
CreateH264Format(H264Profile::kProfileConstrainedBaseline,
H264Level::kLevel3_1, "0"),
CreateH264Format(H264Profile::kProfileMain, H264Level::kLevel3_1, "1"),
CreateH264Format(H264Profile::kProfileMain, H264Level::kLevel3_1, "0")};
return {CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1,
"1", add_scalability_modes),
CreateH264Format(H264Profile::kProfileBaseline, H264Level::kLevel3_1,
"0", add_scalability_modes),
CreateH264Format(H264Profile::kProfileConstrainedBaseline,
H264Level::kLevel3_1, "1", add_scalability_modes),
CreateH264Format(H264Profile::kProfileConstrainedBaseline,
H264Level::kLevel3_1, "0", add_scalability_modes),
CreateH264Format(H264Profile::kProfileMain, H264Level::kLevel3_1, "1",
add_scalability_modes),
CreateH264Format(H264Profile::kProfileMain, H264Level::kLevel3_1, "0",
add_scalability_modes)};
}
std::vector<SdpVideoFormat> SupportedH264DecoderCodecs() {

View File

@ -30,7 +30,8 @@ struct SdpVideoFormat;
RTC_EXPORT SdpVideoFormat
CreateH264Format(H264Profile profile,
H264Level level,
const std::string& packetization_mode);
const std::string& packetization_mode,
bool add_scalability_modes = false);
// Set to disable the H.264 encoder/decoder implementations that are provided if
// `rtc_use_h264` build flag is true (if false, this function does nothing).
@ -40,7 +41,8 @@ RTC_EXPORT void DisableRtcUseH264();
// Returns a vector with all supported internal H264 encode profiles that we can
// negotiate in SDP, in order of preference.
std::vector<SdpVideoFormat> SupportedH264Codecs();
std::vector<SdpVideoFormat> SupportedH264Codecs(
bool add_scalability_modes = false);
// Returns a vector with all supported internal H264 decode profiles that we can
// negotiate in SDP, in order of preference. This will be available for receive

View File

@ -13,9 +13,7 @@
namespace webrtc {
bool VP8SupportsScalabilityMode(ScalabilityMode scalability_mode) {
constexpr ScalabilityMode kSupportedScalabilityModes[] = {
ScalabilityMode::kL1T1, ScalabilityMode::kL1T2, ScalabilityMode::kL1T3};
for (const auto& entry : kSupportedScalabilityModes) {
for (const auto& entry : kVP8SupportedScalabilityModes) {
if (entry == scalability_mode) {
return true;
}

View File

@ -15,6 +15,8 @@
namespace webrtc {
inline constexpr ScalabilityMode kVP8SupportedScalabilityModes[] = {
ScalabilityMode::kL1T1, ScalabilityMode::kL1T2, ScalabilityMode::kL1T3};
bool VP8SupportsScalabilityMode(ScalabilityMode scalability_mode);
} // namespace webrtc

View File

@ -24,7 +24,8 @@ namespace webrtc {
// Returns a vector with all supported internal VP9 profiles that we can
// negotiate in SDP, in order of preference.
std::vector<SdpVideoFormat> SupportedVP9Codecs();
std::vector<SdpVideoFormat> SupportedVP9Codecs(
bool add_scalability_modes = false);
// Returns a vector with all supported internal VP9 decode profiles in order of
// preference. These will be availble for receive-only connections.

View File

@ -12,6 +12,7 @@
#include <memory>
#include "absl/container/inlined_vector.h"
#include "api/transport/field_trial_based_config.h"
#include "api/video_codecs/scalability_mode.h"
#include "api/video_codecs/sdp_video_format.h"
@ -26,7 +27,7 @@
namespace webrtc {
std::vector<SdpVideoFormat> SupportedVP9Codecs() {
std::vector<SdpVideoFormat> SupportedVP9Codecs(bool add_scalability_modes) {
#ifdef RTC_ENABLE_VP9
// Profile 2 might not be available on some platforms until
// https://bugs.chromium.org/p/webm/issues/detail?id=1544 is solved.
@ -36,13 +37,23 @@ std::vector<SdpVideoFormat> SupportedVP9Codecs() {
(vpx_codec_get_caps(vpx_codec_vp9_dx()) & VPX_CODEC_CAP_HIGHBITDEPTH) !=
0;
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes;
if (add_scalability_modes) {
for (const auto scalability_mode : kAllScalabilityModes) {
if (ScalabilityStructureConfig(scalability_mode).has_value()) {
scalability_modes.push_back(scalability_mode);
}
}
}
std::vector<SdpVideoFormat> supported_formats{SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})};
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}},
scalability_modes)};
if (vpx_supports_high_bit_depth) {
supported_formats.push_back(SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}}));
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}},
scalability_modes));
}
return supported_formats;