Skip to content

Commit

Permalink
Offer VideoLayersAllocation if field trial enabled
Browse files Browse the repository at this point in the history
Enable using the field trial WebRTC-VideoLayersAllocationAdvertised/Enabled/

Bug: webrtc:1200
Change-Id: I7c1d94c6051aace8d22c16e0f2e2256dd7ade7fd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/189960
Commit-Queue: Per Kjellander <[email protected]>
Reviewed-by: Erik Språng <[email protected]>
Reviewed-by: Danil Chapovalov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#32465}
  • Loading branch information
perkj authored and Commit Bot committed Oct 21, 2020
1 parent 024d015 commit 70c8945
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
7 changes: 5 additions & 2 deletions api/rtp_parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ constexpr char RtpExtension::kVideoContentTypeUri[];
constexpr char RtpExtension::kVideoTimingUri[];
constexpr char RtpExtension::kGenericFrameDescriptorUri00[];
constexpr char RtpExtension::kDependencyDescriptorUri[];
constexpr char RtpExtension::kVideoLayersAllocationUri[];
constexpr char RtpExtension::kTransportSequenceNumberUri[];
constexpr char RtpExtension::kTransportSequenceNumberV2Uri[];
constexpr char RtpExtension::kPlayoutDelayUri[];
Expand Down Expand Up @@ -161,7 +162,8 @@ bool RtpExtension::IsSupportedForVideo(absl::string_view uri) {
uri == webrtc::RtpExtension::kDependencyDescriptorUri ||
uri == webrtc::RtpExtension::kColorSpaceUri ||
uri == webrtc::RtpExtension::kRidUri ||
uri == webrtc::RtpExtension::kRepairedRidUri;
uri == webrtc::RtpExtension::kRepairedRidUri ||
uri == webrtc::RtpExtension::kVideoLayersAllocationUri;
}

bool RtpExtension::IsEncryptionSupported(absl::string_view uri) {
Expand All @@ -183,7 +185,8 @@ bool RtpExtension::IsEncryptionSupported(absl::string_view uri) {
uri == webrtc::RtpExtension::kVideoContentTypeUri ||
uri == webrtc::RtpExtension::kMidUri ||
uri == webrtc::RtpExtension::kRidUri ||
uri == webrtc::RtpExtension::kRepairedRidUri;
uri == webrtc::RtpExtension::kRepairedRidUri ||
uri == webrtc::RtpExtension::kVideoLayersAllocationUri;
}

const RtpExtension* RtpExtension::FindHeaderExtensionByUri(
Expand Down
4 changes: 4 additions & 0 deletions api/rtp_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ struct RTC_EXPORT RtpExtension {
"https://aomediacodec.github.io/av1-rtp-spec/"
"#dependency-descriptor-rtp-header-extension";

// Experimental extension for signalling target bitrate per layer.
static constexpr char kVideoLayersAllocationUri[] =
"http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00";

// Header extension for transport sequence number, see url for details:
// http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
static constexpr char kTransportSequenceNumberUri[] =
Expand Down
31 changes: 22 additions & 9 deletions media/engine/webrtc_video_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const {
IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised")
? webrtc::RtpTransceiverDirection::kSendRecv
: webrtc::RtpTransceiverDirection::kStopped);

result.emplace_back(
webrtc::RtpExtension::kVideoLayersAllocationUri, id++,
IsEnabled(trials_, "WebRTC-VideoLayersAllocationAdvertised")
? webrtc::RtpTransceiverDirection::kSendRecv
: webrtc::RtpTransceiverDirection::kStopped);

return result;
}

Expand Down Expand Up @@ -1302,15 +1309,21 @@ bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp) {
video_config_.periodic_alr_bandwidth_probing;
config.encoder_settings.experiment_cpu_load_estimator =
video_config_.experiment_cpu_load_estimator;
// TODO(bugs.webrtc.org/12000): Enable allocation callback type
// VideoLayersAllocation if RtpVideoLayersAllocationExtension has been
// negotiated in `send_rtp_extensions_`.
config.encoder_settings.allocation_cb_type =
IsEnabled(call_->trials(), "WebRTC-Target-Bitrate-Rtcp")
? webrtc::VideoStreamEncoderSettings::BitrateAllocationCallbackType::
kVideoBitrateAllocation
: webrtc::VideoStreamEncoderSettings::BitrateAllocationCallbackType::
kVideoBitrateAllocationWhenScreenSharing;
using TargetBitrateType =
webrtc::VideoStreamEncoderSettings::BitrateAllocationCallbackType;
if (send_rtp_extensions_ &&
webrtc::RtpExtension::FindHeaderExtensionByUri(
*send_rtp_extensions_,
webrtc::RtpExtension::kVideoLayersAllocationUri)) {
config.encoder_settings.allocation_cb_type =
TargetBitrateType::kVideoLayersAllocation;
} else if (IsEnabled(call_->trials(), "WebRTC-Target-Bitrate-Rtcp")) {
config.encoder_settings.allocation_cb_type =
TargetBitrateType::kVideoBitrateAllocation;
} else {
config.encoder_settings.allocation_cb_type =
TargetBitrateType::kVideoBitrateAllocationWhenScreenSharing;
}
config.encoder_settings.encoder_factory = encoder_factory_;
config.encoder_settings.bitrate_allocator_factory =
bitrate_allocator_factory_;
Expand Down
17 changes: 17 additions & 0 deletions media/engine/webrtc_video_engine_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,23 @@ TEST_F(WebRtcVideoEngineTestWithDependencyDescriptor,
ExpectRtpCapabilitySupport(RtpExtension::kDependencyDescriptorUri, true);
}

TEST_F(WebRtcVideoEngineTest, AdvertiseVideoLayersAllocation) {
ExpectRtpCapabilitySupport(RtpExtension::kVideoLayersAllocationUri, false);
}

class WebRtcVideoEngineTestWithVideoLayersAllocation
: public WebRtcVideoEngineTest {
public:
WebRtcVideoEngineTestWithVideoLayersAllocation()
: WebRtcVideoEngineTest(
"WebRTC-VideoLayersAllocationAdvertised/Enabled/") {}
};

TEST_F(WebRtcVideoEngineTestWithVideoLayersAllocation,
AdvertiseVideoLayersAllocation) {
ExpectRtpCapabilitySupport(RtpExtension::kVideoLayersAllocationUri, true);
}

TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeCapturer) {
// Allocate the source first to prevent early destruction before channel's
// dtor is called.
Expand Down

0 comments on commit 70c8945

Please sign in to comment.