Add field trial to force outgoing video playout delay

Video playout delay is used to give a hint to the receiver
how the video should be played out.

Add the field trial WebRTC-ForceSendPlayoutDelay to set the video playout
delay of outgoing RTP packets to enable experimentation with this feature.

Bug: webrtc:11896
Change-Id: Ie6123b5967763bde6a830f4c5e5a963e73fb0acb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185042
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32169}
This commit is contained in:
Johannes Kron
2020-09-22 16:23:30 +02:00
committed by Commit Bot
parent 736ff83e69
commit 4da8e4c0c1
2 changed files with 22 additions and 3 deletions

View File

@ -36,6 +36,7 @@
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/rtp_rtcp/source/time_util.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
@ -115,6 +116,19 @@ bool IsNoopDelay(const VideoPlayoutDelay& delay) {
return delay.min_ms == -1 && delay.max_ms == -1;
}
absl::optional<VideoPlayoutDelay> LoadVideoPlayoutDelayOverride(
const WebRtcKeyValueConfig* key_value_config) {
RTC_DCHECK(key_value_config);
FieldTrialOptional<int> playout_delay_min_ms("min_ms", absl::nullopt);
FieldTrialOptional<int> playout_delay_max_ms("max_ms", absl::nullopt);
ParseFieldTrial({&playout_delay_max_ms, &playout_delay_min_ms},
key_value_config->Lookup("WebRTC-ForceSendPlayoutDelay"));
return playout_delay_max_ms && playout_delay_min_ms
? absl::make_optional<VideoPlayoutDelay>(*playout_delay_min_ms,
*playout_delay_max_ms)
: absl::nullopt;
}
} // namespace
RTPSenderVideo::RTPSenderVideo(const Config& config)
@ -128,6 +142,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
transmit_color_space_next_frame_(false),
current_playout_delay_{-1, -1},
playout_delay_pending_(false),
forced_playout_delay_(LoadVideoPlayoutDelayOverride(config.field_trials)),
red_payload_type_(config.red_payload_type),
fec_generator_(config.fec_generator),
fec_type_(config.fec_type),
@ -790,12 +805,13 @@ bool RTPSenderVideo::UpdateConditionalRetransmit(
void RTPSenderVideo::MaybeUpdateCurrentPlayoutDelay(
const RTPVideoHeader& header) {
if (IsNoopDelay(header.playout_delay)) {
VideoPlayoutDelay requested_delay =
forced_playout_delay_.value_or(header.playout_delay);
if (IsNoopDelay(requested_delay)) {
return;
}
VideoPlayoutDelay requested_delay = header.playout_delay;
if (requested_delay.min_ms > PlayoutDelayLimits::kMaxMs ||
requested_delay.max_ms > PlayoutDelayLimits::kMaxMs) {
RTC_DLOG(LS_ERROR)

View File

@ -189,6 +189,9 @@ class RTPSenderVideo {
// Flag indicating if we need to propagate |current_playout_delay_| in order
// to guarantee it gets delivered.
bool playout_delay_pending_;
// Set by the field trial WebRTC-ForceSendPlayoutDelay to override the playout
// delay of outgoing video frames.
const absl::optional<VideoPlayoutDelay> forced_playout_delay_;
// Should never be held when calling out of this class.
Mutex mutex_;