Add field-trial parameter to enable tests simulating a slow decoder
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 <kron@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29153}
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index f3d9c48..a385695 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -141,6 +141,7 @@
"../../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_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 d8e0434..2cd3204 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 @@
void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
absl::optional<int32_t> decode_time_ms,
absl::optional<uint8_t> 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 43ca23c..d51ff48 100644
--- a/modules/video_coding/generic_decoder.h
+++ b/modules/video_coding/generic_decoder.h
@@ -13,12 +13,14 @@
#include <memory>
+#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 @@
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<TimeDelta> _extra_decode_time;
};
class VCMGenericDecoder {