From 7ddea57e94273eb8b417f807e43089ab74d1becf Mon Sep 17 00:00:00 2001 From: Johannes Kron Date: Wed, 11 Sep 2019 12:00:22 +0200 Subject: [PATCH] Add field-trial parameter to enable tests simulating a slow decoder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds a field trial parameter WebRTC-SlowDownDecoder that is used to simulate a slow decoder. The parameter specifies how many extra ms it takes to decode each video frame. This must only be used in manual testing. Bug: None Change-Id: Iad4079100d67b95c224277aaeaf572e38068717f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151911 Commit-Queue: Johannes Kron Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#29153} --- modules/video_coding/BUILD.gn | 2 ++ modules/video_coding/generic_decoder.cc | 15 ++++++++++++++- modules/video_coding/generic_decoder.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index f3d9c48fe9..a385695ac4 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -141,6 +141,7 @@ rtc_static_library("video_coding") { "../../api:fec_controller_api", "../../api:rtp_headers", "../../api/units:data_rate", + "../../api/units:time_delta", "../../api/video:builtin_video_bitrate_allocator_factory", "../../api/video:encoded_frame", "../../api/video:video_bitrate_allocator", @@ -155,6 +156,7 @@ rtc_static_library("video_coding") { "../../rtc_base:rtc_numerics", "../../rtc_base:rtc_task_queue", "../../rtc_base/experiments:alr_experiment", + "../../rtc_base/experiments:field_trial_parser", "../../rtc_base/experiments:jitter_upper_bound_experiment", "../../rtc_base/experiments:rtt_mult_experiment", "../../rtc_base/synchronization:sequence_checker", diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index d8e04342b0..2cd3204b04 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -18,17 +18,25 @@ #include "modules/video_coding/include/video_error_codes.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" +#include "system_wrappers/include/field_trial.h" namespace webrtc { VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock) - : _clock(clock), _timing(timing), _timestampMap(kDecoderFrameMemoryLength) { + : _clock(clock), + _timing(timing), + _timestampMap(kDecoderFrameMemoryLength), + _extra_decode_time("t", absl::nullopt) { ntp_offset_ = _clock->CurrentNtpInMilliseconds() - _clock->TimeInMilliseconds(); + + ParseFieldTrial({&_extra_decode_time}, + field_trial::FindFullName("WebRTC-SlowDownDecoder")); } VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {} @@ -64,6 +72,11 @@ int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, absl::optional decode_time_ms, absl::optional qp) { + // Wait some extra time to simulate a slow decoder. + if (_extra_decode_time) { + rtc::Thread::SleepMs(_extra_decode_time->ms()); + } + RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point"; TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded", "timestamp", decodedImage.timestamp()); diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h index 43ca23c036..d51ff48fb8 100644 --- a/modules/video_coding/generic_decoder.h +++ b/modules/video_coding/generic_decoder.h @@ -13,12 +13,14 @@ #include +#include "api/units/time_delta.h" #include "modules/include/module_common_types.h" #include "modules/video_coding/encoded_frame.h" #include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/timestamp_map.h" #include "modules/video_coding/timing.h" #include "rtc_base/critical_section.h" +#include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/thread_checker.h" namespace webrtc { @@ -71,6 +73,8 @@ class VCMDecodedFrameCallback : public DecodedImageCallback { rtc::CriticalSection lock_; VCMTimestampMap _timestampMap RTC_GUARDED_BY(lock_); int64_t ntp_offset_; + // Set by the field trial WebRTC-SlowDownDecoder to simulate a slow decoder. + FieldTrialOptional _extra_decode_time; }; class VCMGenericDecoder {