clean up misc TimeDelta use

follow-up from https://webrtc-review.googlesource.com/c/src/+/262810

* replace Time::Millis(0) and TimeDelta::Millis(0) with ::Zero()
* drop unnecessary webrtc namespace from some TimeDeltas
* make TimeDelta do the unit conversion for stats

BUG=webrtc:13756

Change-Id: Ic60625ae0fc7959a47a6be9f5051851feaf76373
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265875
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37664}
This commit is contained in:
Philipp Hancke 2022-07-08 18:43:25 +02:00 committed by WebRTC LUCI CQ
parent 175d77ce77
commit a204ad210d
23 changed files with 155 additions and 162 deletions

View file

@ -37,7 +37,7 @@ TEST(RtpPacketInfoTest, Ssrc) {
rhs = RtpPacketInfo();
EXPECT_NE(rhs.ssrc(), value);
rhs = RtpPacketInfo(value, {}, {}, {}, {}, Timestamp::Millis(0));
rhs = RtpPacketInfo(value, {}, {}, {}, {}, Timestamp::Zero());
EXPECT_EQ(rhs.ssrc(), value);
}
@ -64,7 +64,7 @@ TEST(RtpPacketInfoTest, Csrcs) {
rhs = RtpPacketInfo();
EXPECT_NE(rhs.csrcs(), value);
rhs = RtpPacketInfo({}, value, {}, {}, {}, Timestamp::Millis(0));
rhs = RtpPacketInfo({}, value, {}, {}, {}, Timestamp::Zero());
EXPECT_EQ(rhs.csrcs(), value);
}
@ -91,7 +91,7 @@ TEST(RtpPacketInfoTest, RtpTimestamp) {
rhs = RtpPacketInfo();
EXPECT_NE(rhs.rtp_timestamp(), value);
rhs = RtpPacketInfo({}, {}, value, {}, {}, Timestamp::Millis(0));
rhs = RtpPacketInfo({}, {}, value, {}, {}, Timestamp::Zero());
EXPECT_EQ(rhs.rtp_timestamp(), value);
}
@ -118,7 +118,7 @@ TEST(RtpPacketInfoTest, AudioLevel) {
rhs = RtpPacketInfo();
EXPECT_NE(rhs.audio_level(), value);
rhs = RtpPacketInfo({}, {}, {}, value, {}, Timestamp::Millis(0));
rhs = RtpPacketInfo({}, {}, {}, value, {}, Timestamp::Zero());
EXPECT_EQ(rhs.audio_level(), value);
}
@ -145,7 +145,7 @@ TEST(RtpPacketInfoTest, AbsoluteCaptureTime) {
rhs = RtpPacketInfo();
EXPECT_NE(rhs.absolute_capture_time(), value);
rhs = RtpPacketInfo({}, {}, {}, {}, value, Timestamp::Millis(0));
rhs = RtpPacketInfo({}, {}, {}, {}, value, Timestamp::Zero());
EXPECT_EQ(rhs.absolute_capture_time(), value);
}
@ -174,7 +174,7 @@ TEST(RtpPacketInfoTest, LocalCaptureClockOffset) {
// Default local capture clock offset is null.
rhs = RtpPacketInfo({}, {}, {}, {}, AbsoluteCaptureTime{12, 34},
Timestamp::Millis(0));
Timestamp::Zero());
EXPECT_EQ(rhs.local_capture_clock_offset(), absl::nullopt);
}

View file

@ -208,7 +208,7 @@ class RtpVideoSenderTestFixture {
// SendTask().
void RunOnTransportQueue(absl::AnyInvocable<void() &&> task) {
transport_controller_.GetWorkerQueue()->PostTask(std::move(task));
AdvanceTime(TimeDelta::Millis(0));
AdvanceTime(TimeDelta::Zero());
}
private:

View file

@ -40,7 +40,7 @@ TEST(SimulatedNetworkTest, CodelDoesNothingAtCapacity) {
packet_size / link_capacity + TimeDelta::Millis(1);
// Send at capacity and see we get no loss.
Timestamp start_time = Timestamp::Millis(0);
Timestamp start_time = Timestamp::Zero();
Timestamp current_time = start_time;
Timestamp next_packet_time = start_time;
uint64_t next_id = 0;
@ -94,7 +94,7 @@ TEST(SimulatedNetworkTest, CodelLimitsDelayAndDropsPacketsOnOverload) {
const DataSize packet_size = overload_rate * link_capacity * packet_inverval;
// Send above capacity and see delays are still controlled at the cost of
// packet loss.
Timestamp start_time = Timestamp::Millis(0);
Timestamp start_time = Timestamp::Zero();
Timestamp current_time = start_time;
Timestamp next_packet_time = start_time;
Timestamp last_check = start_time;

View file

@ -105,11 +105,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
uint32_t frames_dropped = 0;
uint32_t frames_decoded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
webrtc::TimeDelta total_decode_time = webrtc::TimeDelta::Millis(0);
TimeDelta total_decode_time = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
webrtc::TimeDelta total_processing_delay = webrtc::TimeDelta::Millis(0);
TimeDelta total_processing_delay = TimeDelta::Zero();
// TODO(bugs.webrtc.org/13986): standardize
webrtc::TimeDelta total_assembly_time = webrtc::TimeDelta::Millis(0);
TimeDelta total_assembly_time = TimeDelta::Zero();
uint32_t frames_assembled_from_multiple_packets = 0;
// Total inter frame delay in seconds.
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalinterframedelay

View file

@ -630,10 +630,10 @@ struct VideoReceiverInfo : public MediaReceiverInfo {
uint32_t frames_rendered = 0;
absl::optional<uint64_t> qp_sum;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
webrtc::TimeDelta total_decode_time = webrtc::TimeDelta::Millis(0);
webrtc::TimeDelta total_decode_time = webrtc::TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
webrtc::TimeDelta total_processing_delay = webrtc::TimeDelta::Millis(0);
webrtc::TimeDelta total_assembly_time = webrtc::TimeDelta::Millis(0);
webrtc::TimeDelta total_processing_delay = webrtc::TimeDelta::Zero();
webrtc::TimeDelta total_assembly_time = webrtc::TimeDelta::Zero();
uint32_t frames_assembled_from_multiple_packets = 0;
double total_inter_frame_delay = 0;
double total_squared_inter_frame_delay = 0;

View file

@ -236,7 +236,7 @@ class NetworkControllerTestFixture {
int min_data_rate_kbps = 0,
int max_data_rate_kbps = 5 * kInitialBitrateKbps) {
NetworkControllerConfig config;
config.constraints.at_time = Timestamp::Millis(0);
config.constraints.at_time = Timestamp::Zero();
config.constraints.min_data_rate =
DataRate::KilobitsPerSec(min_data_rate_kbps);
config.constraints.max_data_rate =

View file

@ -90,8 +90,8 @@ absl::optional<DataRate> RobustThroughputEstimator::bitrate() const {
if (window_.empty() || window_.size() < settings_.required_packets)
return absl::nullopt;
TimeDelta largest_recv_gap(TimeDelta::Millis(0));
TimeDelta second_largest_recv_gap(TimeDelta::Millis(0));
TimeDelta largest_recv_gap(TimeDelta::Zero());
TimeDelta second_largest_recv_gap(TimeDelta::Zero());
for (size_t i = 1; i < window_.size(); i++) {
// Find receive time gaps.
TimeDelta gap = window_[i].receive_time - window_[i - 1].receive_time;

View file

@ -23,7 +23,7 @@ TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
BitrateProber prober(config);
EXPECT_FALSE(prober.is_probing());
Timestamp now = Timestamp::Millis(0);
Timestamp now = Timestamp::Zero();
const Timestamp start_time = now;
EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity());
@ -160,7 +160,7 @@ TEST(BitrateProberTest, VerifyProbeSizeOnHighBitrate) {
const DataRate kHighBitrate = DataRate::KilobitsPerSec(10000); // 10 Mbps
prober.CreateProbeCluster({.at_time = Timestamp::Millis(0),
prober.CreateProbeCluster({.at_time = Timestamp::Zero(),
.target_data_rate = kHighBitrate,
.target_duration = TimeDelta::Millis(15),
.target_probe_count = 5,
@ -178,8 +178,8 @@ TEST(BitrateProberTest, MinumumNumberOfProbingPackets) {
const DataRate kBitrate = DataRate::KilobitsPerSec(100);
const DataSize kPacketSize = DataSize::Bytes(1000);
Timestamp now = Timestamp::Millis(0);
prober.CreateProbeCluster({.at_time = Timestamp::Millis(0),
Timestamp now = Timestamp::Zero();
prober.CreateProbeCluster({.at_time = Timestamp::Zero(),
.target_data_rate = kBitrate,
.target_duration = TimeDelta::Millis(15),
.target_probe_count = 5,
@ -201,8 +201,8 @@ TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
const DataSize kPacketSize = DataSize::Bytes(1000);
const DataSize kExpectedDataSent = kBitrate * TimeDelta::Millis(15);
Timestamp now = Timestamp::Millis(0);
prober.CreateProbeCluster({.at_time = Timestamp::Millis(0),
Timestamp now = Timestamp::Zero();
prober.CreateProbeCluster({.at_time = Timestamp::Zero(),
.target_data_rate = kBitrate,
.target_duration = TimeDelta::Millis(15),
.target_probe_count = 5,
@ -225,8 +225,8 @@ TEST(BitrateProberTest, HighBitrateProbing) {
const DataSize kPacketSize = DataSize::Bytes(1000);
const DataSize kExpectedDataSent = kBitrate * TimeDelta::Millis(15);
Timestamp now = Timestamp::Millis(0);
prober.CreateProbeCluster({.at_time = Timestamp::Millis(0),
Timestamp now = Timestamp::Zero();
prober.CreateProbeCluster({.at_time = Timestamp::Zero(),
.target_data_rate = kBitrate,
.target_duration = TimeDelta::Millis(15),
.target_probe_count = 5,
@ -251,7 +251,7 @@ TEST(BitrateProberTest, ProbeClusterTimeout) {
const DataSize kExpectedDataSent = kSmallPacketSize * 2 * 5;
const TimeDelta kTimeout = TimeDelta::Millis(5000);
Timestamp now = Timestamp::Millis(0);
Timestamp now = Timestamp::Zero();
prober.CreateProbeCluster({.at_time = now,
.target_data_rate = kBitrate,
.target_duration = TimeDelta::Millis(15),

View file

@ -562,7 +562,7 @@ TEST_F(RemoteEstimatorProxyOnRequestTest,
}
TEST_F(RemoteEstimatorProxyTest, ReportsIncomingPacketToNetworkStateEstimator) {
Timestamp first_send_timestamp = Timestamp::Millis(0);
Timestamp first_send_timestamp = Timestamp::Zero();
const DataSize kPacketOverhead = DataSize::Bytes(38);
proxy_.SetTransportOverhead(kPacketOverhead);
@ -605,7 +605,7 @@ TEST_F(RemoteEstimatorProxyTest, IncomingPacketHandlesWrapInAbsSendTime) {
AbsoluteSendTime::To24Bits(Timestamp::Millis(1 << 24));
const TimeDelta kExpectedAbsSendTimeDelta = TimeDelta::Millis(30);
Timestamp first_send_timestamp = Timestamp::Millis(0);
Timestamp first_send_timestamp = Timestamp::Zero();
EXPECT_CALL(network_state_estimator_, OnReceivedPacket(_))
.WillOnce(Invoke([&first_send_timestamp](const PacketResult& packet) {
EXPECT_EQ(packet.receive_time, kBaseTime);

View file

@ -497,8 +497,8 @@ TEST_P(RtpRtcpImpl2Test, RttForReceiverOnly) {
TEST_P(RtpRtcpImpl2Test, NoSrBeforeMedia) {
// Ignore fake transport delays in this test.
sender_.transport_.SimulateNetworkDelay(TimeDelta::Millis(0));
receiver_.transport_.SimulateNetworkDelay(TimeDelta::Millis(0));
sender_.transport_.SimulateNetworkDelay(TimeDelta::Zero());
receiver_.transport_.SimulateNetworkDelay(TimeDelta::Zero());
// Move ahead to the instant a rtcp is expected.
// Verify no SR is sent before media has been sent, RR should still be sent
@ -607,7 +607,7 @@ TEST_P(RtpRtcpImpl2Test, SendsExtendedNackList) {
}
TEST_P(RtpRtcpImpl2Test, ReSendsNackListAfterRttMs) {
sender_.transport_.SimulateNetworkDelay(TimeDelta::Millis(0));
sender_.transport_.SimulateNetworkDelay(TimeDelta::Zero());
// Send module sends a NACK.
const uint16_t kNackLength = 2;
uint16_t nack_list[kNackLength] = {123, 125};
@ -632,7 +632,7 @@ TEST_P(RtpRtcpImpl2Test, ReSendsNackListAfterRttMs) {
}
TEST_P(RtpRtcpImpl2Test, UniqueNackRequests) {
receiver_.transport_.SimulateNetworkDelay(TimeDelta::Millis(0));
receiver_.transport_.SimulateNetworkDelay(TimeDelta::Zero());
EXPECT_EQ(0U, receiver_.RtcpSent().nack_packets);
EXPECT_EQ(0U, receiver_.RtcpSent().nack_requests);
EXPECT_EQ(0U, receiver_.RtcpSent().unique_nack_requests);

View file

@ -194,7 +194,7 @@ class TestFrameBuffer2 : public ::testing::Test {
});
});
if (max_wait_time == 0) {
time_controller_.AdvanceTime(TimeDelta::Millis(0));
time_controller_.AdvanceTime(TimeDelta::Zero());
}
}
@ -304,7 +304,7 @@ TEST_F(TestFrameBuffer2, DISABLED_OneUnorderedSuperFrame) {
ExtractFrame(50);
InsertFrame(pid, 1, ts, true, kFrameSize);
InsertFrame(pid, 0, ts, false, kFrameSize);
time_controller_.AdvanceTime(TimeDelta::Millis(0));
time_controller_.AdvanceTime(TimeDelta::Zero());
CheckFrame(0, pid, 0);
CheckFrame(1, pid, 1);

View file

@ -150,10 +150,10 @@ TEST(ReceiverTimingTest, UseLowLatencyRenderer) {
timing.set_max_playout_delay(TimeDelta::Millis(20));
EXPECT_FALSE(timing.RenderParameters().use_low_latency_rendering);
// True if min==0, max > 0.
timing.set_min_playout_delay(TimeDelta::Millis(0));
timing.set_min_playout_delay(TimeDelta::Zero());
EXPECT_TRUE(timing.RenderParameters().use_low_latency_rendering);
// True if min==max==0.
timing.set_max_playout_delay(TimeDelta::Millis(0));
timing.set_max_playout_delay(TimeDelta::Zero());
EXPECT_TRUE(timing.RenderParameters().use_low_latency_rendering);
// True also for max playout delay==500 ms.
timing.set_max_playout_delay(TimeDelta::Millis(500));

View file

@ -74,7 +74,7 @@ void StunRequestManager::FlushForTest(int msg_type) {
// of canceling any outstanding tasks and prepare a new flag for
// operations related to this call to `Send`.
request->ResetTasksForTest();
request->Send(webrtc::TimeDelta::Millis(0));
request->Send(webrtc::TimeDelta::Zero());
}
}
}

View file

@ -564,14 +564,11 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo(
if (video_receiver_info.qp_sum)
inbound_video->qp_sum = *video_receiver_info.qp_sum;
inbound_video->total_decode_time =
static_cast<double>(video_receiver_info.total_decode_time.ms()) /
rtc::kNumMillisecsPerSec;
video_receiver_info.total_decode_time.seconds<double>();
inbound_video->total_processing_delay =
static_cast<double>(video_receiver_info.total_processing_delay.ms()) /
rtc::kNumMillisecsPerSec;
video_receiver_info.total_processing_delay.seconds<double>();
inbound_video->total_assembly_time =
static_cast<double>(video_receiver_info.total_assembly_time.ms()) /
rtc::kNumMillisecsPerSec;
video_receiver_info.total_assembly_time.seconds<double>();
inbound_video->frames_assembled_from_multiple_packets =
video_receiver_info.frames_assembled_from_multiple_packets;
inbound_video->total_inter_frame_delay =

View file

@ -121,7 +121,7 @@ class TestFrame : public RecordableEncodedFrame {
EncodedResolution resolution() const override {
return EncodedResolution{0, 0};
}
Timestamp render_time() const override { return Timestamp::Millis(0); }
Timestamp render_time() const override { return Timestamp::Zero(); }
};
TEST(VideoRtpTrackSourceTest, BroadcastsFrames) {

View file

@ -195,7 +195,7 @@ TEST(RepeatingTaskTest, CompensatesForLongRunTime) {
}
TEST(RepeatingTaskTest, CompensatesForShortRunTime) {
SimulatedClock clock(Timestamp::Millis(0));
SimulatedClock clock(Timestamp::Zero());
FakeTaskQueue task_queue(&clock);
std::atomic_int counter(0);
RepeatingTaskHandle::Start(
@ -336,7 +336,7 @@ TEST(RepeatingTaskTest, Example) {
TEST(RepeatingTaskTest, ClockIntegration) {
absl::AnyInvocable<void() &&> delayed_task;
TimeDelta expected_delay = TimeDelta::Zero();
SimulatedClock clock(Timestamp::Millis(0));
SimulatedClock clock(Timestamp::Zero());
NiceMock<MockTaskQueue> task_queue;
ON_CALL(task_queue, PostDelayedTask)

View file

@ -48,7 +48,7 @@ class PixelLimitResourceTest : public ::testing::Test {
void RunTaskOnTaskQueue(absl::AnyInvocable<void() &&> task) {
task_queue_->PostTask(std::move(task));
time_controller_.AdvanceTime(TimeDelta::Millis(0));
time_controller_.AdvanceTime(TimeDelta::Zero());
}
protected:
@ -83,7 +83,7 @@ TEST_F(PixelLimitResourceTest,
rtc::scoped_refptr<PixelLimitResource> pixel_limit_resource =
PixelLimitResource::Create(task_queue_.get(), &input_state_provider_);
pixel_limit_resource->SetResourceListener(&resource_listener);
time_controller_.AdvanceTime(TimeDelta::Millis(0));
time_controller_.AdvanceTime(TimeDelta::Zero());
pixel_limit_resource->SetMaxPixels(kMaxPixels);
SetCurrentPixels(kMaxPixels + 1);
@ -118,7 +118,7 @@ TEST_F(PixelLimitResourceTest,
rtc::scoped_refptr<PixelLimitResource> pixel_limit_resource =
PixelLimitResource::Create(task_queue_.get(), &input_state_provider_);
pixel_limit_resource->SetResourceListener(&resource_listener);
time_controller_.AdvanceTime(TimeDelta::Millis(0));
time_controller_.AdvanceTime(TimeDelta::Zero());
pixel_limit_resource->SetMaxPixels(kMaxPixels);
SetCurrentPixels(kMinPixels - 1);

View file

@ -35,7 +35,7 @@ EncoderRtcpFeedback::EncoderRtcpFeedback(
ssrcs_(ssrcs),
get_packet_infos_(std::move(get_packet_infos)),
video_stream_encoder_(encoder),
time_last_packet_delivery_queue_(Timestamp::Millis(0)),
time_last_packet_delivery_queue_(Timestamp::Zero()),
min_keyframe_send_interval_(
TimeDelta::Millis(KeyframeIntervalSettings::ParseFromFieldTrials()
.MinKeyframeSendIntervalMs()

View file

@ -126,7 +126,7 @@ TEST(FrameCadenceAdapterTest, CountsOutstandingFramesToProcess) {
TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsByDefault) {
test::ScopedKeyValueConfig no_field_trials;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock());
adapter->Initialize(nullptr);
@ -148,7 +148,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsByDefault) {
TEST(FrameCadenceAdapterTest,
FrameRateFollowsRateStatisticsWhenFeatureDisabled) {
ZeroHertzFieldTrialDisabler feature_disabler;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(feature_disabler, time_controller.GetClock());
adapter->Initialize(nullptr);
@ -169,7 +169,7 @@ TEST(FrameCadenceAdapterTest,
TEST(FrameCadenceAdapterTest, FrameRateFollowsMaxFpsWhenZeroHertzActivated) {
ZeroHertzFieldTrialEnabler enabler;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(nullptr);
adapter->SetZeroHertzModeEnabled(
@ -185,7 +185,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsMaxFpsWhenZeroHertzActivated) {
TEST(FrameCadenceAdapterTest,
FrameRateFollowsRateStatisticsAfterZeroHertzDeactivated) {
ZeroHertzFieldTrialEnabler enabler;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(nullptr);
adapter->SetZeroHertzModeEnabled(
@ -214,7 +214,7 @@ TEST(FrameCadenceAdapterTest,
TEST(FrameCadenceAdapterTest, ForwardsFramesDelayed) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -336,7 +336,7 @@ TEST(FrameCadenceAdapterTest, StopsRepeatingFramesDelayed) {
// At 3.5s, we receive this frame.
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -364,7 +364,7 @@ TEST(FrameCadenceAdapterTest, StopsRepeatingFramesDelayed) {
TEST(FrameCadenceAdapterTest, RequestsRefreshFrameOnKeyFrameRequestWhenNew) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -382,7 +382,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshFrameOnKeyFrameRequestWhenNew) {
TEST(FrameCadenceAdapterTest, IgnoresKeyFrameRequestShortlyAfterFrame) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -397,7 +397,7 @@ TEST(FrameCadenceAdapterTest, IgnoresKeyFrameRequestShortlyAfterFrame) {
TEST(FrameCadenceAdapterTest, RequestsRefreshFramesUntilArrival) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -423,7 +423,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshFramesUntilArrival) {
TEST(FrameCadenceAdapterTest, RequestsRefreshAfterFrameDrop) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -464,7 +464,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshAfterFrameDrop) {
TEST(FrameCadenceAdapterTest, OmitsRefreshAfterFrameDropWithTimelyFrameEntry) {
ZeroHertzFieldTrialEnabler enabler;
MockCallback callback;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto adapter = CreateAdapter(enabler, time_controller.GetClock());
adapter->Initialize(&callback);
adapter->SetZeroHertzModeEnabled(
@ -524,7 +524,7 @@ class FrameCadenceAdapterSimulcastLayersParamTest
protected:
ZeroHertzFieldTrialEnabler enabler_;
MockCallback callback_;
GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)};
GlobalSimulatedTimeController time_controller_{Timestamp::Zero()};
const std::unique_ptr<FrameCadenceAdapterInterface> adapter_{
CreateAdapter(enabler_, time_controller_.GetClock())};
};
@ -651,7 +651,7 @@ class ZeroHertzLayerQualityConvergenceTest : public ::testing::Test {
protected:
ZeroHertzFieldTrialEnabler field_trial_enabler_;
MockCallback callback_;
GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)};
GlobalSimulatedTimeController time_controller_{Timestamp::Zero()};
std::unique_ptr<FrameCadenceAdapterInterface> adapter_{
CreateAdapter(field_trial_enabler_, time_controller_.GetClock())};
};

View file

@ -769,10 +769,10 @@ void ReceiveStatisticsProxy::OnDecodedFrame(const VideoFrame& frame,
absl::optional<uint8_t> qp,
TimeDelta decode_time,
VideoContentType content_type) {
webrtc::TimeDelta processing_delay = webrtc::TimeDelta::Millis(0);
TimeDelta processing_delay = TimeDelta::Zero();
webrtc::Timestamp current_time = clock_->CurrentTime();
// TODO(bugs.webrtc.org/13984): some tests do not fill packet_infos().
webrtc::TimeDelta assembly_time = webrtc::TimeDelta::Millis(0);
TimeDelta assembly_time = TimeDelta::Zero();
if (frame.packet_infos().size() > 0) {
const auto [first_packet, last_packet] = std::minmax_element(
frame.packet_infos().cbegin(), frame.packet_infos().cend(),
@ -803,8 +803,8 @@ void ReceiveStatisticsProxy::OnDecodedFrame(
const VideoFrameMetaData& frame_meta,
absl::optional<uint8_t> qp,
TimeDelta decode_time,
webrtc::TimeDelta processing_delay,
webrtc::TimeDelta assembly_time,
TimeDelta processing_delay,
TimeDelta assembly_time,
VideoContentType content_type) {
RTC_DCHECK_RUN_ON(&main_thread_);

View file

@ -57,7 +57,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
void OnDecodedFrame(const VideoFrame& frame,
absl::optional<uint8_t> qp,
webrtc::TimeDelta decode_time,
TimeDelta decode_time,
VideoContentType content_type);
// Called asyncronously on the worker thread as a result of a call to the
@ -65,9 +65,9 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
// the actual decoding happens.
void OnDecodedFrame(const VideoFrameMetaData& frame_meta,
absl::optional<uint8_t> qp,
webrtc::TimeDelta decode_time,
webrtc::TimeDelta processing_delay,
webrtc::TimeDelta assembly_time,
TimeDelta decode_time,
TimeDelta processing_delay,
TimeDelta assembly_time,
VideoContentType content_type);
void OnSyncOffsetUpdated(int64_t video_playout_ntp_ms,

View file

@ -111,8 +111,7 @@ TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameIncreasesFramesDecoded) {
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (uint32_t i = 1; i <= 3; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(i, FlushAndGetStats().frames_decoded);
}
@ -123,8 +122,7 @@ TEST_F(ReceiveStatisticsProxy2Test, DecodedFpsIsReported) {
const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps;
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i < kRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
fake_clock_.AdvanceTimeMilliseconds(1000 / kFps);
}
@ -140,8 +138,7 @@ TEST_F(ReceiveStatisticsProxy2Test, DecodedFpsIsNotReportedForTooFewSamples) {
const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps;
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i < kRequiredSamples - 1; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
fake_clock_.AdvanceTimeMilliseconds(1000 / kFps);
}
@ -154,7 +151,7 @@ TEST_F(ReceiveStatisticsProxy2Test,
OnDecodedFrameWithQpDoesNotResetFramesDecodedOrTotalDecodeTime) {
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
TimeDelta expected_total_decode_time = TimeDelta::Millis(0);
TimeDelta expected_total_decode_time = TimeDelta::Zero();
unsigned int expected_frames_decoded = 0;
for (uint32_t i = 1; i <= 3; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
@ -183,7 +180,7 @@ TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameIncreasesProcessingDelay) {
const TimeDelta kProcessingDelay = TimeDelta::Millis(10);
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
TimeDelta expected_total_processing_delay = TimeDelta::Millis(0);
TimeDelta expected_total_processing_delay = TimeDelta::Zero();
unsigned int expected_frames_decoded = 0;
// We set receive time fixed and increase the clock by 10ms
// in the loop which will increase the processing delay by
@ -220,7 +217,7 @@ TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameIncreasesAssemblyTime) {
const TimeDelta kAssemblyTime = TimeDelta::Millis(7);
EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
TimeDelta expected_total_assembly_time = TimeDelta::Millis(0);
TimeDelta expected_total_assembly_time = TimeDelta::Zero();
unsigned int expected_frames_decoded = 0;
unsigned int expected_frames_assembled_from_multiple_packets = 0;
@ -285,10 +282,10 @@ TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameIncreasesAssemblyTime) {
TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameIncreasesQpSum) {
EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum);
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(3u, FlushAndGetStats().qp_sum);
statistics_proxy_->OnDecodedFrame(frame, 127u, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, 127u, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(130u, FlushAndGetStats().qp_sum);
}
@ -310,11 +307,11 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsContentType) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString(
statistics_proxy_->GetStats().content_type));
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(),
VideoContentType::SCREENSHARE);
EXPECT_EQ(kScreenshareString,
videocontenttypehelpers::ToString(FlushAndGetStats().content_type));
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(kRealtimeString,
videocontenttypehelpers::ToString(FlushAndGetStats().content_type));
@ -332,7 +329,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsMaxTotalInterFrameDelay) {
EXPECT_EQ(expected_total_squared_inter_frame_delay,
statistics_proxy_->GetStats().total_squared_inter_frame_delay);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_DOUBLE_EQ(expected_total_inter_frame_delay,
FlushAndGetStats().total_inter_frame_delay);
@ -340,7 +337,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsMaxTotalInterFrameDelay) {
FlushAndGetStats().total_squared_inter_frame_delay);
fake_clock_.AdvanceTime(kInterFrameDelay1);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
expected_total_inter_frame_delay += kInterFrameDelay1.seconds<double>();
expected_total_squared_inter_frame_delay +=
@ -352,7 +349,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsMaxTotalInterFrameDelay) {
statistics_proxy_->GetStats().total_squared_inter_frame_delay);
fake_clock_.AdvanceTime(kInterFrameDelay2);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
expected_total_inter_frame_delay += kInterFrameDelay2.seconds<double>();
expected_total_squared_inter_frame_delay +=
@ -364,7 +361,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsMaxTotalInterFrameDelay) {
statistics_proxy_->GetStats().total_squared_inter_frame_delay);
fake_clock_.AdvanceTime(kInterFrameDelay3);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
expected_total_inter_frame_delay += kInterFrameDelay3.seconds<double>();
expected_total_squared_inter_frame_delay +=
@ -382,22 +379,22 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsMaxInterframeDelay) {
const int64_t kInterframeDelayMs2 = 200;
const int64_t kInterframeDelayMs3 = 100;
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(-1, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(kInterframeDelayMs1, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(kInterframeDelayMs2, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// kInterframeDelayMs3 is smaller than kInterframeDelayMs2.
EXPECT_EQ(kInterframeDelayMs2, FlushAndGetStats().interframe_delay_max_ms);
@ -409,23 +406,23 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportInterframeDelayInWindow) {
const int64_t kInterframeDelayMs2 = 750;
const int64_t kInterframeDelayMs3 = 700;
EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(-1, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(kInterframeDelayMs1, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Still first delay is the maximum
EXPECT_EQ(kInterframeDelayMs1, FlushAndGetStats().interframe_delay_max_ms);
fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Now the first sample is out of the window, so the second is the maximum.
EXPECT_EQ(kInterframeDelayMs2, FlushAndGetStats().interframe_delay_max_ms);
@ -535,7 +532,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReportsSumSquaredFrameDurations) {
TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameWithoutQpQpSumWontExist) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(absl::nullopt, FlushAndGetStats().qp_sum);
}
@ -543,10 +540,10 @@ TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameWithoutQpQpSumWontExist) {
TEST_F(ReceiveStatisticsProxy2Test, OnDecodedFrameWithoutQpResetsQpSum) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
EXPECT_EQ(absl::nullopt, statistics_proxy_->GetStats().qp_sum);
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, 3u, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(3u, FlushAndGetStats().qp_sum);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
EXPECT_EQ(absl::nullopt, FlushAndGetStats().qp_sum);
}
@ -1017,8 +1014,7 @@ TEST_F(ReceiveStatisticsProxy2Test, DoesNotReportStaleFramerates) {
// Since OnRenderedFrame is never called the fps in each sample will be 0,
// i.e. bad
frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds());
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
statistics_proxy_->OnRenderedFrame(MetaData(frame));
fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps);
@ -1087,7 +1083,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ReceivedFrameHistogramsAreUpdated) {
TEST_F(ReceiveStatisticsProxy2Test, ZeroDelayReportedIfFrameNotDelayed) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Frame not delayed, delayed frames to render: 0%.
@ -1108,7 +1104,7 @@ TEST_F(ReceiveStatisticsProxy2Test, ZeroDelayReportedIfFrameNotDelayed) {
TEST_F(ReceiveStatisticsProxy2Test,
DelayedFrameHistogramsAreNotUpdatedIfMinRuntimeHasNotPassed) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Frame not delayed, delayed frames to render: 0%.
@ -1129,7 +1125,7 @@ TEST_F(ReceiveStatisticsProxy2Test,
TEST_F(ReceiveStatisticsProxy2Test,
DelayedFramesHistogramsAreNotUpdatedIfNoRenderedFrames) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Min run time has passed. No rendered frames.
@ -1144,7 +1140,7 @@ TEST_F(ReceiveStatisticsProxy2Test,
TEST_F(ReceiveStatisticsProxy2Test, DelayReportedIfFrameIsDelayed) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Frame delayed 1 ms, delayed frames to render: 100%.
@ -1167,7 +1163,7 @@ TEST_F(ReceiveStatisticsProxy2Test, DelayReportedIfFrameIsDelayed) {
TEST_F(ReceiveStatisticsProxy2Test, AverageDelayOfDelayedFramesIsReported) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
VideoContentType::UNSPECIFIED);
// Two frames delayed (6 ms, 10 ms), delayed frames to render: 50%.
@ -1319,13 +1315,13 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, InterFrameDelaysAreReported) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i < kMinRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
// One extra with double the interval.
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
FlushAndUpdateHistograms(absl::nullopt, StreamDataCounters(), nullptr);
@ -1356,18 +1352,18 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent,
for (int i = 0; i <= kMinRequiredSamples - kLastFivePercentsSamples; ++i) {
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
}
// Last 5% of intervals are double in size.
for (int i = 0; i < kLastFivePercentsSamples; ++i) {
fake_clock_.AdvanceTimeMilliseconds(2 * kInterFrameDelayMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
}
// Final sample is outlier and 10 times as big.
fake_clock_.AdvanceTimeMilliseconds(10 * kInterFrameDelayMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
FlushAndUpdateHistograms(absl::nullopt, StreamDataCounters(), nullptr);
@ -1390,8 +1386,8 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent,
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i < kMinRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1414,8 +1410,8 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent,
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i <= kMinRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1427,10 +1423,10 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent,
// Insert two more frames. The interval during the pause should be
// disregarded in the stats.
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
FlushAndUpdateHistograms(absl::nullopt, StreamDataCounters(), nullptr);
@ -1466,18 +1462,18 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, FreezesAreReported) {
for (int i = 0; i < kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
// Add extra freeze.
fake_clock_.AdvanceTimeMilliseconds(kFreezeDelayMs);
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
FlushAndUpdateHistograms(absl::nullopt, StreamDataCounters(), nullptr);
@ -1515,8 +1511,8 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, HarmonicFrameRateIsReported) {
for (int i = 0; i < kMinRequiredSamples; ++i) {
fake_clock_.AdvanceTimeMilliseconds(kFrameDurationMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(MetaData(frame));
}
@ -1524,7 +1520,7 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, HarmonicFrameRateIsReported) {
// Add freeze.
loop_.Flush();
fake_clock_.AdvanceTimeMilliseconds(kFreezeDurationMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(MetaData(frame));
@ -1532,7 +1528,7 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, HarmonicFrameRateIsReported) {
loop_.Flush();
fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs);
statistics_proxy_->OnStreamInactive();
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(MetaData(frame));
@ -1563,9 +1559,9 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, PausesAreIgnored) {
for (int i = 0; i <= kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1575,9 +1571,9 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, PausesAreIgnored) {
// Second playback interval with triple the length.
for (int i = 0; i <= kMinRequiredSamples * 3; ++i) {
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1607,15 +1603,15 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, ManyPausesAtTheBeginning) {
webrtc::VideoFrame frame = CreateFrame(kWidth, kHeight);
for (int i = 0; i <= kMinRequiredSamples; ++i) {
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
statistics_proxy_->OnStreamInactive();
fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type_);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1640,18 +1636,18 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, TimeInHdReported) {
// HD frames.
for (int i = 0; i < kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame_hd);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
// SD frames.
for (int i = 0; i < 2 * kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame_sd);
statistics_proxy_->OnDecodedFrame(
meta, absl::nullopt, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, absl::nullopt, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
@ -1680,23 +1676,23 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, TimeInBlockyVideoReported) {
// High quality frames.
for (int i = 0; i < kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, kLowQp, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, kLowQp, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
// Blocky frames.
for (int i = 0; i < 2 * kMinRequiredSamples; ++i) {
VideoFrameMetaData meta = MetaData(frame);
statistics_proxy_->OnDecodedFrame(
meta, kHighQp, TimeDelta::Millis(0), webrtc::TimeDelta::Millis(0),
webrtc::TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(meta, kHighQp, TimeDelta::Zero(),
TimeDelta::Zero(), TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(meta);
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
}
// Extra last frame.
statistics_proxy_->OnDecodedFrame(frame, kHighQp, TimeDelta::Millis(0),
statistics_proxy_->OnDecodedFrame(frame, kHighQp, TimeDelta::Zero(),
content_type_);
statistics_proxy_->OnRenderedFrame(MetaData(frame));
@ -1722,8 +1718,8 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, DownscalesReported) {
webrtc::VideoFrame frame_ld = CreateFrame(320, 180);
// Call once to pass content type.
statistics_proxy_->OnDecodedFrame(frame_hd, absl::nullopt,
TimeDelta::Millis(0), content_type_);
statistics_proxy_->OnDecodedFrame(frame_hd, absl::nullopt, TimeDelta::Zero(),
content_type_);
loop_.Flush();
statistics_proxy_->OnRenderedFrame(MetaData(frame_hd));
@ -1781,15 +1777,15 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent,
videocontenttypehelpers::SetSimulcastId(&content_type, 1);
for (int i = 0; i <= kMinRequiredSamples; ++i) {
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type);
}
videocontenttypehelpers::SetSimulcastId(&content_type, 2);
for (int i = 0; i <= kMinRequiredSamples; ++i) {
fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt,
TimeDelta::Millis(0), content_type);
statistics_proxy_->OnDecodedFrame(frame, absl::nullopt, TimeDelta::Zero(),
content_type);
}
FlushAndUpdateHistograms(absl::nullopt, StreamDataCounters(), nullptr);

View file

@ -746,7 +746,7 @@ class SimpleVideoStreamEncoderFactory {
};
test::ScopedKeyValueConfig field_trials_;
GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)};
GlobalSimulatedTimeController time_controller_{Timestamp::Zero()};
std::unique_ptr<TaskQueueFactory> task_queue_factory_{
time_controller_.CreateTaskQueueFactory()};
std::unique_ptr<MockableSendStatisticsProxy> stats_proxy_ =
@ -9116,7 +9116,7 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) {
// Lots of boiler plate.
test::ScopedKeyValueConfig field_trials;
GlobalSimulatedTimeController time_controller(Timestamp::Millis(0));
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
auto stats_proxy = std::make_unique<MockableSendStatisticsProxy>(
time_controller.GetClock(), VideoSendStream::Config(nullptr),
webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials);