Revert "Represent RtpPacketToSend::capture_time with Timestamp"

This reverts commit 385eb9714daa80306d2f92d36678c42892dab555.

Reason for revert: Causes problems downstream:

#
# Fatal error in: rtc_base/units/unit_base.h, line 122
# last system error: 0
# Check failed: value >= 0 (-234 vs. 0)

Original change's description:
> Represent RtpPacketToSend::capture_time with Timestamp
>
> Bug: webrtc:13757
> Change-Id: I0ede22cd34e3a59afe1477d8edd495dce64e3242
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252586
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#36083}

Bug: webrtc:13757
Change-Id: I8442abd438be8726cf671d0f372d50ecfac6847e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252720
Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36087}
This commit is contained in:
Tomas Gunnarsson 2022-02-26 10:32:51 +00:00 committed by WebRTC LUCI CQ
parent 1db3c7435e
commit 56db8d0952
19 changed files with 86 additions and 137 deletions

View File

@ -31,7 +31,6 @@ rtc_library("video_rtp_headers") {
"../../rtc_base:rtc_base_approved",
"../../rtc_base/system:rtc_export",
"../units:data_rate",
"../units:time_delta",
]
absl_deps = [
"//third_party/abseil-cpp/absl/container:inlined_vector",

View File

@ -11,7 +11,6 @@
#include "api/video/video_timing.h"
#include "api/array_view.h"
#include "api/units/time_delta.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/strings/string_builder.h"
@ -26,14 +25,6 @@ uint16_t VideoSendTiming::GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) {
return rtc::saturated_cast<uint16_t>(time_ms - base_ms);
}
uint16_t VideoSendTiming::GetDeltaCappedMs(TimeDelta delta) {
if (delta < TimeDelta::Zero()) {
RTC_DLOG(LS_ERROR) << "Delta " << delta.ms()
<< "ms expected to be positive";
}
return rtc::saturated_cast<uint16_t>(delta.ms());
}
TimingFrameInfo::TimingFrameInfo()
: rtp_timestamp(0),
capture_time_ms(-1),

View File

@ -16,8 +16,6 @@
#include <limits>
#include <string>
#include "api/units/time_delta.h"
namespace webrtc {
// Video timing timestamps in ms counted from capture_time_ms of a frame.
@ -36,7 +34,6 @@ struct VideoSendTiming {
// https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores
// 16-bit deltas of timestamps from packet capture time.
static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms);
static uint16_t GetDeltaCappedMs(TimeDelta delta);
uint16_t encode_start_delta_ms;
uint16_t encode_finish_delta_ms;

View File

@ -124,7 +124,7 @@ void PacedSender::EnqueuePackets(
packet->SequenceNumber(), "rtp_timestamp",
packet->Timestamp());
RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero());
RTC_DCHECK_GE(packet->capture_time_ms(), 0);
pacing_controller_.EnqueuePacket(std::move(packet));
}
}

View File

@ -60,7 +60,7 @@ std::unique_ptr<RtpPacketToSend> BuildPacket(RtpPacketMediaType type,
packet->set_packet_type(type);
packet->SetSsrc(ssrc);
packet->SetSequenceNumber(sequence_number);
packet->set_capture_time(Timestamp::Millis(capture_time_ms));
packet->set_capture_time_ms(capture_time_ms);
packet->SetPayloadSize(size);
return packet;
}
@ -73,7 +73,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender {
void SendPacket(std::unique_ptr<RtpPacketToSend> packet,
const PacedPacketInfo& cluster_info) override {
SendPacket(packet->Ssrc(), packet->SequenceNumber(),
packet->capture_time().ms(),
packet->capture_time_ms(),
packet->packet_type() == RtpPacketMediaType::kRetransmission,
packet->packet_type() == RtpPacketMediaType::kPadding);
}

View File

@ -141,7 +141,7 @@ void TaskQueuePacedSender::EnqueuePackets(
RTC_DCHECK_RUN_ON(&task_queue_);
for (auto& packet : packets_) {
packet_size_.Apply(1, packet->size());
RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero());
RTC_DCHECK_GE(packet->capture_time_ms(), 0);
pacing_controller_.EnqueuePacket(std::move(packet));
}
MaybeProcessPackets(Timestamp::MinusInfinity());

View File

@ -156,7 +156,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
// In case of VideoTimingExtension, since it's present not in every packet,
// data after rtp header may be corrupted if these packets are protected by
// the FEC.
int64_t diff_ms = now_ms - packet->capture_time().ms();
int64_t diff_ms = now_ms - packet->capture_time_ms();
if (packet->HasExtension<TransmissionOffset>()) {
packet->SetExtension<TransmissionOffset>(kTimestampTicksPerMs * diff_ms);
}
@ -167,9 +167,9 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
if (packet->HasExtension<VideoTimingExtension>()) {
if (populate_network2_timestamp_) {
packet->set_network2_time(Timestamp::Millis(now_ms));
packet->set_network2_time_ms(now_ms);
} else {
packet->set_pacer_exit_time(Timestamp::Millis(now_ms));
packet->set_pacer_exit_time_ms(now_ms);
}
}
@ -190,8 +190,8 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
if (packet->packet_type() != RtpPacketMediaType::kPadding &&
packet->packet_type() != RtpPacketMediaType::kRetransmission) {
UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc);
UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(),
UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc);
UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(),
packet_ssrc);
}

View File

@ -142,7 +142,7 @@ std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
clock_->TimeInMilliseconds()));
// Set "capture time" so that the TransmissionOffset header extension
// can be set by the RTPSender.
fec_packet_to_send->set_capture_time(clock_->CurrentTime());
fec_packet_to_send->set_capture_time_ms(clock_->TimeInMilliseconds());
fec_packet_to_send->SetSsrc(ssrc_);
// Reserve extensions, if registered. These will be set by the RTPSender.
fec_packet_to_send->ReserveExtension<AbsoluteSendTime>();

View File

@ -99,7 +99,7 @@ void PacketSequencer::UpdateLastPacketState(const RtpPacketToSend& packet) {
// Save timestamps to generate timestamp field and extensions for the padding.
last_rtp_timestamp_ = packet.Timestamp();
last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
last_capture_time_ms_ = packet.capture_time().ms();
last_capture_time_ms_ = packet.capture_time_ms();
}
void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) {
@ -107,7 +107,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) {
RTC_DCHECK(CanSendPaddingOnMediaSsrc());
packet.SetTimestamp(last_rtp_timestamp_);
packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_));
packet.set_capture_time_ms(last_capture_time_ms_);
packet.SetPayloadType(last_payload_type_);
return;
}
@ -119,7 +119,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) {
}
packet.SetTimestamp(last_rtp_timestamp_);
packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_));
packet.set_capture_time_ms(last_capture_time_ms_);
// Only change the timestamp of padding packets sent over RTX.
// Padding only packets over RTP has to be sent as part of a media
@ -129,10 +129,9 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) {
packet.SetTimestamp(packet.Timestamp() +
(now_ms - last_timestamp_time_ms_) *
kTimestampTicksPerMs);
if (packet.capture_time() > Timestamp::Zero()) {
packet.set_capture_time(
packet.capture_time() +
TimeDelta::Millis(now_ms - last_timestamp_time_ms_));
if (packet.capture_time_ms() > 0) {
packet.set_capture_time_ms(packet.capture_time_ms() +
(now_ms - last_timestamp_time_ms_));
}
}
}

View File

@ -41,10 +41,10 @@ class PacketSequencerTest : public ::testing::Test {
packet.set_packet_type(type);
packet.SetSsrc(ssrc);
packet.SetSequenceNumber(kDefaultSequenceNumber);
packet.set_capture_time(clock_.CurrentTime());
packet.set_capture_time_ms(clock_.TimeInMilliseconds());
packet.SetTimestamp(
kStartRtpTimestamp +
static_cast<uint32_t>(packet.capture_time().ms() - kStartTime.ms()));
static_cast<uint32_t>(packet.capture_time_ms() - kStartTime.ms()));
return packet;
}
@ -152,7 +152,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastMediaPacket) {
EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1);
EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType);
EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp());
EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time());
EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms());
}
TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) {
@ -181,7 +181,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) {
EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1);
EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1);
EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp());
EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time());
EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms());
}
TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) {
@ -201,7 +201,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) {
padding_packet.SetPayloadSize(100);
padding_packet.SetPayloadType(kMediaPayloadType + 1);
padding_packet.SetTimestamp(kStartRtpTimestamp + 1);
padding_packet.set_capture_time(kStartTime + TimeDelta::Millis(1));
padding_packet.set_capture_time_ms(kStartTime.ms() + 1);
sequencer_.set_rtx_sequence_number(kRtxStartSequenceNumber);
sequencer_.Sequence(padding_packet);
@ -209,7 +209,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) {
EXPECT_EQ(padding_packet.SequenceNumber(), kRtxStartSequenceNumber);
EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1);
EXPECT_EQ(padding_packet.Timestamp(), kStartRtpTimestamp + 1);
EXPECT_EQ(padding_packet.capture_time(), kStartTime + TimeDelta::Millis(1));
EXPECT_EQ(padding_packet.capture_time_ms(), kStartTime.ms() + 1);
}
TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) {
@ -242,8 +242,8 @@ TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) {
EXPECT_EQ(
padding_packet.Timestamp(),
media_packet.Timestamp() + (kTimeDelta.ms() * kTimestampTicksPerMs));
EXPECT_EQ(padding_packet.capture_time(),
media_packet.capture_time() + kTimeDelta);
EXPECT_EQ(padding_packet.capture_time_ms(),
media_packet.capture_time_ms() + kTimeDelta.ms());
}
} // namespace

View File

@ -492,7 +492,7 @@ RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState(
RtpPacketHistory::PacketState state;
state.rtp_sequence_number = stored_packet.packet_->SequenceNumber();
state.send_time_ms = stored_packet.send_time_ms_;
state.capture_time_ms = stored_packet.packet_->capture_time().ms();
state.capture_time_ms = stored_packet.packet_->capture_time_ms();
state.ssrc = stored_packet.packet_->Ssrc();
state.packet_size = stored_packet.packet_->size();
state.times_retransmitted = stored_packet.times_retransmitted();

View File

@ -45,7 +45,7 @@ class RtpPacketHistoryTest : public ::testing::TestWithParam<bool> {
// Payload, ssrc, timestamp and extensions are irrelevant for this tests.
std::unique_ptr<RtpPacketToSend> packet(new RtpPacketToSend(nullptr));
packet->SetSequenceNumber(seq_num);
packet->set_capture_time(fake_clock_.CurrentTime());
packet->set_capture_time_ms(fake_clock_.TimeInMilliseconds());
packet->set_allow_retransmission(true);
return packet;
}
@ -122,9 +122,9 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) {
TEST_P(RtpPacketHistoryTest, GetRtpPacket) {
hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10);
Timestamp capture_time = Timestamp::Millis(1);
int64_t capture_time_ms = 1;
std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kStartSeqNum);
packet->set_capture_time(capture_time);
packet->set_capture_time_ms(capture_time_ms);
rtc::CopyOnWriteBuffer buffer = packet->Buffer();
hist_.PutRtpPacket(std::move(packet), absl::nullopt);
@ -132,7 +132,7 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) {
hist_.GetPacketAndSetSendTime(kStartSeqNum);
EXPECT_TRUE(packet_out);
EXPECT_EQ(buffer, packet_out->Buffer());
EXPECT_EQ(capture_time, packet_out->capture_time());
EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms());
}
TEST_P(RtpPacketHistoryTest, PacketStateIsCorrect) {
@ -212,7 +212,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) {
hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10);
hist_.SetRtt(kMinRetransmitIntervalMs);
Timestamp capture_time = fake_clock_.CurrentTime();
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kStartSeqNum);
size_t len = packet->size();
hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds());
@ -222,7 +222,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) {
packet = hist_.GetPacketAndSetSendTime(kStartSeqNum);
EXPECT_TRUE(packet);
EXPECT_EQ(len, packet->size());
EXPECT_EQ(packet->capture_time(), capture_time);
EXPECT_EQ(capture_time_ms, packet->capture_time_ms());
// Second retransmission - advance time to just before retransmission OK.
fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1);

View File

@ -15,12 +15,10 @@
#include <utility>
#include "absl/base/attributes.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/ref_counted_base.h"
#include "api/scoped_refptr.h"
#include "api/units/timestamp.h"
#include "api/video/video_timing.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
@ -46,15 +44,9 @@ class RtpPacketToSend : public RtpPacket {
~RtpPacketToSend();
// Time in local time base as close as it can to frame capture time.
webrtc::Timestamp capture_time() const { return capture_time_; }
void set_capture_time(webrtc::Timestamp time) { capture_time_ = time; }
int64_t capture_time_ms() const { return capture_time_ms_; }
ABSL_DEPRECATED("Use capture_time() instead")
int64_t capture_time_ms() const { return capture_time_.ms_or(-1); }
ABSL_DEPRECATED("Use set_capture_time() instead")
void set_capture_time_ms(int64_t time) {
capture_time_ = webrtc::Timestamp::Millis(time);
}
void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; }
void set_packet_type(RtpPacketMediaType type) { packet_type_ = type; }
absl::optional<RtpPacketMediaType> packet_type() const {
@ -85,55 +77,27 @@ class RtpPacketToSend : public RtpPacket {
additional_data_ = std::move(data);
}
void set_packetization_finish_time(webrtc::Timestamp time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(time - capture_time_),
VideoTimingExtension::kPacketizationFinishDeltaOffset);
}
void set_pacer_exit_time(webrtc::Timestamp time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(time - capture_time_),
VideoTimingExtension::kPacerExitDeltaOffset);
}
void set_network_time(webrtc::Timestamp time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(time - capture_time_),
VideoTimingExtension::kNetworkTimestampDeltaOffset);
}
void set_network2_time(webrtc::Timestamp time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(time - capture_time_),
VideoTimingExtension::kNetwork2TimestampDeltaOffset);
}
ABSL_DEPRECATED("Use set_packetization_finish_time() instead")
void set_packetization_finish_time_ms(int64_t time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time),
VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time),
VideoTimingExtension::kPacketizationFinishDeltaOffset);
}
ABSL_DEPRECATED("Use set_pacer_exit_time() instead")
void set_pacer_exit_time_ms(int64_t time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time),
VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time),
VideoTimingExtension::kPacerExitDeltaOffset);
}
ABSL_DEPRECATED("Use set_network_time() instead")
void set_network_time_ms(int64_t time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time),
VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time),
VideoTimingExtension::kNetworkTimestampDeltaOffset);
}
ABSL_DEPRECATED("Use set_network2_time() instead")
void set_network2_time_ms(int64_t time) {
SetExtension<VideoTimingExtension>(
VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time),
VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time),
VideoTimingExtension::kNetwork2TimestampDeltaOffset);
}
@ -157,7 +121,7 @@ class RtpPacketToSend : public RtpPacket {
bool is_red() const { return is_red_; }
private:
webrtc::Timestamp capture_time_ = webrtc::Timestamp::Zero();
int64_t capture_time_ms_ = 0;
absl::optional<RtpPacketMediaType> packet_type_;
bool allow_retransmission_ = false;
absl::optional<uint16_t> retransmitted_sequence_number_;

View File

@ -484,11 +484,13 @@ std::vector<std::unique_ptr<RtpPacketToSend>> RTPSender::GeneratePadding(
bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet) {
RTC_DCHECK(packet);
int64_t now_ms = clock_->TimeInMilliseconds();
auto packet_type = packet->packet_type();
RTC_CHECK(packet_type) << "Packet type must be set before sending.";
if (packet->capture_time() <= Timestamp::Zero()) {
packet->set_capture_time(clock_->CurrentTime());
if (packet->capture_time_ms() <= 0) {
packet->set_capture_time_ms(now_ms);
}
std::vector<std::unique_ptr<RtpPacketToSend>> packets;
@ -501,13 +503,13 @@ bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet) {
void RTPSender::EnqueuePackets(
std::vector<std::unique_ptr<RtpPacketToSend>> packets) {
RTC_DCHECK(!packets.empty());
Timestamp now = clock_->CurrentTime();
int64_t now_ms = clock_->TimeInMilliseconds();
for (auto& packet : packets) {
RTC_DCHECK(packet);
RTC_CHECK(packet->packet_type().has_value())
<< "Packet type must be set before sending.";
if (packet->capture_time() <= Timestamp::Zero()) {
packet->set_capture_time(now);
if (packet->capture_time_ms() <= 0) {
packet->set_capture_time_ms(now_ms);
}
}
@ -724,7 +726,7 @@ std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
rtx_packet->set_additional_data(packet.additional_data());
// Copy capture time so e.g. TransmissionOffset is correctly set.
rtx_packet->set_capture_time(packet.capture_time());
rtx_packet->set_capture_time_ms(packet.capture_time_ms());
return rtx_packet;
}

View File

@ -272,7 +272,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type,
packet->SetMarker(MarkerBit(frame_type, payload_type));
packet->SetPayloadType(payload_type);
packet->SetTimestamp(rtp_timestamp);
packet->set_capture_time(clock_->CurrentTime());
packet->set_capture_time_ms(clock_->TimeInMilliseconds());
// Update audio level extension, if included.
packet->SetExtension<AudioLevel>(
frame_type == AudioFrameType::kAudioFrameSpeech, audio_level_dbov);
@ -370,7 +370,7 @@ bool RTPSenderAudio::SendTelephoneEventPacket(bool ended,
packet->SetMarker(marker_bit);
packet->SetSsrc(rtp_sender_->SSRC());
packet->SetTimestamp(dtmf_timestamp);
packet->set_capture_time(clock_->CurrentTime());
packet->set_capture_time_ms(clock_->TimeInMilliseconds());
// Create DTMF data.
uint8_t* dtmfbuffer = packet->AllocatePayload(kDtmfSize);

View File

@ -225,7 +225,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
// In case of VideoTimingExtension, since it's present not in every packet,
// data after rtp header may be corrupted if these packets are protected by
// the FEC.
int64_t diff_ms = now_ms - packet->capture_time().ms();
int64_t diff_ms = now_ms - packet->capture_time_ms();
if (packet->HasExtension<TransmissionOffset>()) {
packet->SetExtension<TransmissionOffset>(kTimestampTicksPerMs * diff_ms);
}
@ -236,9 +236,9 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
if (packet->HasExtension<VideoTimingExtension>()) {
if (populate_network2_timestamp_) {
packet->set_network2_time(Timestamp::Millis(now_ms));
packet->set_network2_time_ms(now_ms);
} else {
packet->set_pacer_exit_time(Timestamp::Millis(now_ms));
packet->set_pacer_exit_time_ms(now_ms);
}
}
@ -265,8 +265,8 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
if (packet->packet_type() != RtpPacketMediaType::kPadding &&
packet->packet_type() != RtpPacketMediaType::kRetransmission) {
UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc);
UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(),
UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc);
UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(),
packet_ssrc);
}

View File

@ -184,7 +184,7 @@ class RtpSenderEgressTest : public ::testing::TestWithParam<TestConfig> {
packet->set_packet_type(RtpPacketMediaType::kVideo);
packet->SetMarker(marker_bit);
packet->SetTimestamp(capture_time_ms * 90);
packet->set_capture_time(Timestamp::Millis(capture_time_ms));
packet->set_capture_time_ms(capture_time_ms);
packet->SetSequenceNumber(sequence_number_++);
return packet;
}
@ -756,7 +756,7 @@ TEST_P(RtpSenderEgressTest, SendPacketUpdatesExtensions) {
std::unique_ptr<RtpSenderEgress> sender = CreateRtpSenderEgress();
std::unique_ptr<RtpPacketToSend> packet = BuildRtpPacket();
packet->set_packetization_finish_time(clock_->CurrentTime());
packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds());
const int32_t kDiffMs = 10;
time_controller_.AdvanceTime(TimeDelta::Millis(kDiffMs));

View File

@ -198,7 +198,7 @@ class RtpSenderTest : public ::testing::Test {
packet->set_packet_type(RtpPacketMediaType::kVideo);
packet->SetMarker(marker_bit);
packet->SetTimestamp(timestamp);
packet->set_capture_time(Timestamp::Millis(capture_time_ms));
packet->set_capture_time_ms(capture_time_ms);
return packet;
}
@ -354,12 +354,13 @@ TEST_F(RtpSenderTest, PaddingAlwaysAllowedOnAudio) {
TEST_F(RtpSenderTest, SendToNetworkForwardsPacketsToPacer) {
auto packet = BuildRtpPacket(kPayload, kMarkerBit, kTimestamp, 0);
Timestamp now = clock_->CurrentTime();
int64_t now_ms = clock_->TimeInMilliseconds();
EXPECT_CALL(mock_paced_sender_,
EnqueuePackets(ElementsAre(AllOf(
Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)),
Pointee(Property(&RtpPacketToSend::capture_time, now))))));
EXPECT_CALL(
mock_paced_sender_,
EnqueuePackets(ElementsAre(AllOf(
Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)),
Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms))))));
EXPECT_TRUE(
rtp_sender_->SendToNetwork(std::make_unique<RtpPacketToSend>(*packet)));
}
@ -377,8 +378,7 @@ TEST_F(RtpSenderTest, ReSendPacketForwardsPacketsToPacer) {
EnqueuePackets(ElementsAre(AllOf(
Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)),
Pointee(Property(&RtpPacketToSend::SequenceNumber, kSeqNum)),
Pointee(Property(&RtpPacketToSend::capture_time,
Timestamp::Millis(now_ms))),
Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)),
Pointee(Property(&RtpPacketToSend::packet_type,
RtpPacketMediaType::kRetransmission))))));
EXPECT_TRUE(rtp_sender_->ReSendPacket(kSeqNum));
@ -527,11 +527,10 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) {
// Start by sending one media packet.
EXPECT_CALL(
mock_paced_sender_,
EnqueuePackets(ElementsAre(
AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time,
Timestamp::Millis(start_time)))))));
EnqueuePackets(ElementsAre(AllOf(
Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time))))));
std::unique_ptr<RtpPacketToSend> media_packet =
SendPacket(start_time, /*payload_size=*/600);
sequencer_->Sequence(*media_packet);
@ -547,8 +546,8 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) {
Property(&RtpPacketToSend::padding_size, kMaxPaddingLength),
Property(&RtpPacketToSend::Timestamp,
start_timestamp + (kTimestampTicksPerMs * kTimeDiff.ms())),
Property(&RtpPacketToSend::capture_time,
Timestamp::Millis(start_time) + kTimeDiff)))));
Property(&RtpPacketToSend::capture_time_ms,
start_time + kTimeDiff.ms())))));
}
TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) {
@ -564,11 +563,10 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) {
// Start by sending one media packet and putting in the packet history.
EXPECT_CALL(
mock_paced_sender_,
EnqueuePackets(ElementsAre(
AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time,
Timestamp::Millis(start_time)))))));
EnqueuePackets(ElementsAre(AllOf(
Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time))))));
std::unique_ptr<RtpPacketToSend> media_packet =
SendPacket(start_time, kPayloadSize);
packet_history_->PutRtpPacket(std::move(media_packet), start_time);
@ -578,14 +576,14 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) {
time_controller_.AdvanceTime(kTimeDiff);
// Timestamps on payload padding should be set to original.
EXPECT_THAT(GeneratePadding(/*target_size_bytes=*/100),
Each(AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::payload_size,
kPayloadSize + kRtxHeaderSize)),
Pointee(Property(&RtpPacketToSend::Timestamp,
start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time,
Timestamp::Millis(start_time))))));
EXPECT_THAT(
GeneratePadding(/*target_size_bytes=*/100),
Each(AllOf(
Pointee(Property(&RtpPacketToSend::padding_size, 0u)),
Pointee(Property(&RtpPacketToSend::payload_size,
kPayloadSize + kRtxHeaderSize)),
Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)),
Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))));
}
// Test that the MID header extension is included on sent packets when
@ -1275,10 +1273,9 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) {
// preserved.
time_controller_.AdvanceTime(TimeDelta::Millis(10));
EXPECT_CALL(
mock_paced_sender_,
EnqueuePackets(ElementsAre(Pointee(Property(
&RtpPacketToSend::capture_time, Timestamp::Millis(start_time_ms))))));
EXPECT_CALL(mock_paced_sender_,
EnqueuePackets(ElementsAre(Pointee(Property(
&RtpPacketToSend::capture_time_ms, start_time_ms)))));
EXPECT_GT(rtp_sender_->ReSendPacket(kSeqNum), 0);
}

View File

@ -534,7 +534,7 @@ bool RTPSenderVideo::SendVideo(
RTC_DCHECK_LE(packet_capacity, single_packet->capacity());
single_packet->SetPayloadType(payload_type);
single_packet->SetTimestamp(rtp_timestamp);
single_packet->set_capture_time(Timestamp::Millis(capture_time_ms));
single_packet->set_capture_time_ms(capture_time_ms);
// Construct the absolute capture time extension if not provided.
if (!video_header.absolute_capture_time.has_value()) {
@ -695,7 +695,7 @@ bool RTPSenderVideo::SendVideo(
// Put packetization finish timestamp into extension.
if (packet->HasExtension<VideoTimingExtension>()) {
packet->set_packetization_finish_time(clock_->CurrentTime());
packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds());
}
packet->set_fec_protect_packet(use_fec);