Use Timestamp to represent packet receive timestamps

Before this CL, timestamps of received packets were rounded
to the nearest millisecond and stored as int64_t. Due to the
rounding it sometimes happened that timestamps later in the
pipeline that are not rounded seem to occur even before the
video frame was received.

Change-Id: I92d8f3540b23baae2d4a1dc6a7cb3f58bcdaad18
Bug: webrtc:12722
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216398
Reviewed-by: Chen Xing <chxg@google.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33916}
This commit is contained in:
Johannes Kron
2021-04-30 13:10:56 +02:00
committed by WebRTC LUCI CQ
parent c27c047e3e
commit f7de74c58c
23 changed files with 133 additions and 93 deletions

View File

@ -565,19 +565,19 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
return kInvalidPointer;
}
int64_t receive_time_ms = clock_->TimeInMilliseconds();
Timestamp receive_time = clock_->CurrentTime();
stats_->ReceivedPacket();
PacketList packet_list;
// Insert packet in a packet list.
packet_list.push_back([&rtp_header, &payload, &receive_time_ms] {
packet_list.push_back([&rtp_header, &payload, &receive_time] {
// Convert to Packet.
Packet packet;
packet.payload_type = rtp_header.payloadType;
packet.sequence_number = rtp_header.sequenceNumber;
packet.timestamp = rtp_header.timestamp;
packet.payload.SetData(payload.data(), payload.size());
packet.packet_info = RtpPacketInfo(rtp_header, receive_time_ms);
packet.packet_info = RtpPacketInfo(rtp_header, receive_time);
// Waiting time will be set upon inserting the packet in the buffer.
RTC_DCHECK(!packet.waiting_time);
return packet;

View File

@ -497,7 +497,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
// Insert one packet.
clock_.AdvanceTimeMilliseconds(123456);
int64_t expected_receive_time_ms = clock_.TimeInMilliseconds();
Timestamp expected_receive_time = clock_.CurrentTime();
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
// Pull audio once.
@ -518,7 +518,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
EXPECT_THAT(packet_info.csrcs(), ElementsAre(43, 65, 17));
EXPECT_EQ(packet_info.rtp_timestamp(), rtp_header.timestamp);
EXPECT_FALSE(packet_info.audio_level().has_value());
EXPECT_EQ(packet_info.receive_time_ms(), expected_receive_time_ms);
EXPECT_EQ(packet_info.receive_time(), expected_receive_time);
}
// Start with a simple check that the fake decoder is behaving as expected.
@ -590,7 +590,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
// Insert one packet.
clock_.AdvanceTimeMilliseconds(123456);
int64_t expected_receive_time_ms = clock_.TimeInMilliseconds();
Timestamp expected_receive_time = clock_.CurrentTime();
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
// Pull audio once.
@ -610,7 +610,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
EXPECT_THAT(packet_info.csrcs(), IsEmpty());
EXPECT_EQ(packet_info.rtp_timestamp(), rtp_header.timestamp);
EXPECT_EQ(packet_info.audio_level(), rtp_header.extension.audioLevel);
EXPECT_EQ(packet_info.receive_time_ms(), expected_receive_time_ms);
EXPECT_EQ(packet_info.receive_time(), expected_receive_time);
}
// Insert two more packets. The first one is out of order, and is already too
@ -626,7 +626,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
rtp_header.extension.audioLevel = 2;
payload[0] = 2;
clock_.AdvanceTimeMilliseconds(2000);
expected_receive_time_ms = clock_.TimeInMilliseconds();
expected_receive_time = clock_.CurrentTime();
EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload));
// Expect only the second packet to be decoded (the one with "2" as the first
@ -656,7 +656,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
EXPECT_THAT(packet_info.csrcs(), IsEmpty());
EXPECT_EQ(packet_info.rtp_timestamp(), rtp_header.timestamp);
EXPECT_EQ(packet_info.audio_level(), rtp_header.extension.audioLevel);
EXPECT_EQ(packet_info.receive_time_ms(), expected_receive_time_ms);
EXPECT_EQ(packet_info.receive_time(), expected_receive_time);
}
EXPECT_CALL(mock_decoder, Die());

View File

@ -139,7 +139,7 @@ bool RedPayloadSplitter::SplitRed(PacketList* packet_list) {
/*rtp_timestamp=*/new_packet.timestamp,
/*audio_level=*/absl::nullopt,
/*absolute_capture_time=*/absl::nullopt,
/*receive_time_ms=*/red_packet.packet_info.receive_time_ms());
/*receive_time=*/red_packet.packet_info.receive_time());
new_packets.push_front(std::move(new_packet));
payload_ptr += payload_length;
}