Only update TimestampExtrapolator on the last frame of the temporal unit.

Bug: webrtc:14526
Change-Id: I3fd7cb286050fc4cbe0008534f05141aa19b7606
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278142
Reviewed-by: Johannes Kron <kron@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38310}
This commit is contained in:
philipel 2022-10-06 15:49:17 +02:00 committed by WebRTC LUCI CQ
parent 767898c048
commit 7446b60823
3 changed files with 50 additions and 3 deletions

View File

@ -69,7 +69,8 @@ class VCMTiming {
// Used to report that a frame is passed to decoding. Updates the timestamp
// filter which is used to map between timestamps and receiver system time.
void IncomingTimestamp(uint32_t rtp_timestamp, Timestamp last_packet_time);
virtual void IncomingTimestamp(uint32_t rtp_timestamp,
Timestamp last_packet_time);
// Returns the receiver system time when the frame with timestamp
// `frame_timestamp` should be rendered, assuming that the system time

View File

@ -143,9 +143,12 @@ absl::optional<int64_t> VideoStreamBufferController::InsertFrame(
int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits();
if (buffer_->InsertFrame(std::move(frame))) {
RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!";
if (!metadata.delayed_by_retransmission && metadata.receive_time)
if (!metadata.delayed_by_retransmission && metadata.receive_time &&
(field_trials_.IsDisabled("WebRTC-IncomingTimestampOnMarkerBitOnly") ||
metadata.is_last_spatial_layer)) {
timing_->IncomingTimestamp(metadata.rtp_timestamp,
*metadata.receive_time);
}
if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) {
stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size,
metadata.contentType);

View File

@ -80,6 +80,21 @@ std::unique_ptr<test::FakeEncodedFrame> WithReceiveTimeFromRtpTimestamp(
return frame;
}
class VCMTimingTest : public VCMTiming {
public:
using VCMTiming::VCMTiming;
void IncomingTimestamp(uint32_t rtp_timestamp,
Timestamp last_packet_time) override {
IncomingTimestampMocked(rtp_timestamp, last_packet_time);
VCMTiming::IncomingTimestamp(rtp_timestamp, last_packet_time);
}
MOCK_METHOD(void,
IncomingTimestampMocked,
(uint32_t rtp_timestamp, Timestamp last_packet_time),
());
};
class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback {
public:
MOCK_METHOD(void,
@ -210,8 +225,8 @@ class VideoStreamBufferControllerFixture
Clock* const clock_;
test::FakeMetronome fake_metronome_;
DecodeSynchronizer decode_sync_;
VCMTiming timing_;
::testing::NiceMock<VCMTimingTest> timing_;
::testing::NiceMock<VCMReceiveStatisticsCallbackMock> stats_callback_;
std::unique_ptr<VideoStreamBufferController> buffer_;
@ -834,4 +849,32 @@ INSTANTIATE_TEST_SUITE_P(
"WebRTC-ZeroPlayoutDelay/"
"min_pacing:16ms,max_decode_queue_size:5/")));
class IncomingTimestampVideoStreamBufferControllerTest
: public ::testing::Test,
public VideoStreamBufferControllerFixture {};
TEST_P(IncomingTimestampVideoStreamBufferControllerTest,
IncomingTimestampOnMarkerBitOnly) {
StartNextDecodeForceKeyframe();
EXPECT_CALL(timing_, IncomingTimestampMocked)
.Times(field_trials_.IsDisabled("WebRTC-IncomingTimestampOnMarkerBitOnly")
? 3
: 1);
buffer_->InsertFrame(WithReceiveTimeFromRtpTimestamp(
test::FakeFrameBuilder().Id(0).SpatialLayer(0).Time(0).Build()));
buffer_->InsertFrame(WithReceiveTimeFromRtpTimestamp(
test::FakeFrameBuilder().Id(1).SpatialLayer(1).Time(0).Build()));
buffer_->InsertFrame(WithReceiveTimeFromRtpTimestamp(
test::FakeFrameBuilder().Id(2).SpatialLayer(2).Time(0).AsLast().Build()));
}
INSTANTIATE_TEST_SUITE_P(
VideoStreamBufferController,
IncomingTimestampVideoStreamBufferControllerTest,
::testing::Combine(
::testing::Bool(),
::testing::Values(
"WebRTC-IncomingTimestampOnMarkerBitOnly/Enabled/",
"WebRTC-IncomingTimestampOnMarkerBitOnly/Disabled/")));
} // namespace webrtc