Add new RtpPacketPacer interface, with callback.
This CL just adds the new interfaces, follow-ups will add implementation in various parts of the code, and then do cleanup once usage of old interface is gone. Bug: webrtc:10633 Change-Id: Icd916f4220065c0d0e4f3f0bfaaed248f8c70d08 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140891 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28252}
This commit is contained in:
@ -15,6 +15,7 @@ rtc_source_set("rtp_rtcp_format") {
|
||||
"include/rtcp_statistics.h",
|
||||
"include/rtp_cvo.h",
|
||||
"include/rtp_header_extension_map.h",
|
||||
"include/rtp_packet_pacer.h",
|
||||
"include/rtp_rtcp_defines.h",
|
||||
"source/byte_io.h",
|
||||
"source/rtcp_packet.h",
|
||||
|
||||
39
modules/rtp_rtcp/include/rtp_packet_pacer.h
Normal file
39
modules/rtp_rtcp/include/rtp_packet_pacer.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_PACKET_PACER_H_
|
||||
#define MODULES_RTP_RTCP_INCLUDE_RTP_PACKET_PACER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||
namespace webrtc {
|
||||
|
||||
// Interface for a paced sender, as implemented in the pacing module.
|
||||
// This intended to replace the RtpPacketSender interface defined in
|
||||
// rtp_rtcp_defines.h
|
||||
// TODO(bugs.webrtc.org/10633): Add things missing to this interface so that we
|
||||
// can use multiple different pacer implementations, and stop inheriting from
|
||||
// RtpPacketSender.
|
||||
class RtpPacketPacer : RtpPacketSender {
|
||||
public:
|
||||
RtpPacketPacer() = default;
|
||||
~RtpPacketPacer() override;
|
||||
|
||||
// Insert packet into queue, for eventual transmission. Based on the type of
|
||||
// the packet, it will prioritized and scheduled relative to other packets and
|
||||
// the current target send rate.
|
||||
virtual void EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet) = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_RTP_RTCP_INCLUDE_RTP_PACKET_PACER_H_
|
||||
@ -340,21 +340,21 @@ class RtcpRttStats {
|
||||
virtual ~RtcpRttStats() {}
|
||||
};
|
||||
|
||||
// This class will be deprecated and replaced with RtpPacketPacer.
|
||||
class RtpPacketSender {
|
||||
public:
|
||||
RtpPacketSender() {}
|
||||
virtual ~RtpPacketSender() {}
|
||||
|
||||
// These are part of the legacy PacedSender interface and will be removed.
|
||||
enum Priority {
|
||||
kHighPriority = 0, // Pass through; will be sent immediately.
|
||||
kNormalPriority = 2, // Put in back of the line.
|
||||
kLowPriority = 3, // Put in back of the low priority line.
|
||||
};
|
||||
// Low priority packets are mixed with the normal priority packets
|
||||
// while we are paused.
|
||||
|
||||
// Returns true if we send the packet now, else it will add the packet
|
||||
// information to the queue and call TimeToSendPacket when it's time to send.
|
||||
// Adds the packet information to the queue and call TimeToSendPacket when
|
||||
// it's time to send.
|
||||
virtual void InsertPacket(Priority priority,
|
||||
uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
@ -367,7 +367,7 @@ class RtpPacketSender {
|
||||
// the pacer budget calculation. The audio traffic still will be injected
|
||||
// at high priority.
|
||||
// TODO(alexnarest): Make it pure virtual after rtp_sender_unittest will be
|
||||
// updated to support it
|
||||
// updated to support it.
|
||||
virtual void SetAccountForAudioPackets(bool account_for_audio) {}
|
||||
};
|
||||
|
||||
|
||||
@ -126,7 +126,8 @@ std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
|
||||
for (const auto* fec_packet : ulpfec_generator_.generated_fec_packets_) {
|
||||
std::unique_ptr<RtpPacketToSend> fec_packet_to_send(
|
||||
new RtpPacketToSend(&rtp_header_extension_map_));
|
||||
fec_packet_to_send->set_is_fec(true);
|
||||
fec_packet_to_send->set_packet_type(
|
||||
RtpPacketToSend::Type::kForwardErrorCorrection);
|
||||
|
||||
// RTP header.
|
||||
fec_packet_to_send->SetMarker(false);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/video/video_timing.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||
@ -23,6 +24,14 @@ namespace webrtc {
|
||||
// Class to hold rtp packet with metadata for sender side.
|
||||
class RtpPacketToSend : public RtpPacket {
|
||||
public:
|
||||
enum class Type {
|
||||
kAudio, // Audio media packets.
|
||||
kVideo, // Video media packets.
|
||||
kRetransmission, // RTX (usually) packets send as response to NACK.
|
||||
kForwardErrorCorrection, // FEC packets.
|
||||
kPadding // RTX or plain padding sent to maintain BWE.
|
||||
};
|
||||
|
||||
explicit RtpPacketToSend(const ExtensionManager* extensions);
|
||||
RtpPacketToSend(const ExtensionManager* extensions, size_t capacity);
|
||||
RtpPacketToSend(const RtpPacketToSend& packet);
|
||||
@ -38,9 +47,8 @@ class RtpPacketToSend : public RtpPacket {
|
||||
|
||||
void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; }
|
||||
|
||||
bool is_fec() const { return is_fec_; }
|
||||
|
||||
void set_is_fec(bool fec) { is_fec_ = fec; }
|
||||
void set_packet_type(Type type) { packet_type_ = type; }
|
||||
absl::optional<Type> packet_type() const { return packet_type_; }
|
||||
|
||||
// Additional data bound to the RTP packet for use in application code,
|
||||
// outside of WebRTC.
|
||||
@ -78,8 +86,7 @@ class RtpPacketToSend : public RtpPacket {
|
||||
|
||||
private:
|
||||
int64_t capture_time_ms_ = 0;
|
||||
// Used for accounting purposes
|
||||
bool is_fec_ = false;
|
||||
absl::optional<Type> packet_type_;
|
||||
std::vector<uint8_t> application_data_;
|
||||
};
|
||||
|
||||
|
||||
@ -661,8 +661,9 @@ void RTPSender::UpdateRtpStats(const RtpPacketToSend& packet,
|
||||
if (counters->first_packet_time_ms == -1)
|
||||
counters->first_packet_time_ms = now_ms;
|
||||
|
||||
if (packet.is_fec())
|
||||
if (packet.packet_type() == RtpPacketToSend::Type::kForwardErrorCorrection) {
|
||||
counters->fec.AddPacket(packet);
|
||||
}
|
||||
|
||||
if (is_retransmit) {
|
||||
counters->retransmitted.AddPacket(packet);
|
||||
|
||||
@ -307,7 +307,7 @@ void RTPSenderVideo::SendVideoPacketAsRedMaybeWithUlpfec(
|
||||
new RtpPacketToSend(*media_packet));
|
||||
RTC_CHECK(rtp_packet->Parse(fec_packet->data(), fec_packet->length()));
|
||||
rtp_packet->set_capture_time_ms(media_packet->capture_time_ms());
|
||||
rtp_packet->set_is_fec(true);
|
||||
rtp_packet->set_packet_type(RtpPacketToSend::Type::kForwardErrorCorrection);
|
||||
uint16_t fec_sequence_number = rtp_packet->SequenceNumber();
|
||||
if (LogAndSendToNetwork(std::move(rtp_packet), kDontRetransmit,
|
||||
RtpPacketSender::kLowPriority)) {
|
||||
|
||||
Reference in New Issue
Block a user