Add support for deferred sequence numbering.

With this turned on, packets will be sequence number after the pacing
stage rather that during packetization.
This avoids a race where packets may be sent out of order, and paves
the way for the ability to cull packets from the pacer queue without
causing sequence number gaps.

For now, the feature is off by default. Follow-ups will enable it for
video and audio separately.

Bug: webrtc:11340, webrtc:12470
Change-Id: I6d411d8c85b9047e3e9b05ff4c2c3ed97c579aa1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208584
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34661}
This commit is contained in:
Erik Språng
2021-08-06 13:10:11 +02:00
committed by WebRTC LUCI CQ
parent 82c2248511
commit bb90497eaa
11 changed files with 164 additions and 41 deletions

View File

@ -266,6 +266,9 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
void AssignSequenceNumber(RtpPacketToSend* packet) override;
// Storage of packets, for retransmissions and padding, if applicable.
RtpPacketHistory packet_history;
// If false, sequencing is owned by `packet_generator` and can happen on
// several threads. If true, sequencing always happens on the pacer thread.
const bool deferred_sequencing_;
// Handles sequence number assignment and padding timestamp generation.
PacketSequencer sequencer_;
// Handles final time timestamping/stats/etc and handover to Transport.
@ -308,6 +311,7 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
TaskQueueBase* const worker_queue_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker pacer_thread_checker_;
std::unique_ptr<RtpSenderContext> rtp_sender_;
RTCPSender rtcp_sender_;