#include "modules/rtp_rtcp/source/rtp_sender.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/rtp_headers.h"
#include "api/rtp_packet_sender.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/corruption_detection_extension.h"
#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor_extension.h"
#include "modules/rtp_rtcp/source/rtp_header_extension_size.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet_history.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_minmax.h"
#include "rtc_base/rate_limiter.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
namespace {
constexpr size_t kMinAudioPaddingLength = …;
constexpr size_t kRtpHeaderLength = …;
constexpr int kMinPayloadPaddingBytes = …;
constexpr double kMaxPaddingSizeFactor = …;
template <typename Extension>
constexpr RtpExtensionSize CreateExtensionSize() { … }
template <typename Extension>
constexpr RtpExtensionSize CreateMaxExtensionSize() { … }
constexpr RtpExtensionSize kFecOrPaddingExtensionSizes[] = …;
constexpr RtpExtensionSize kVideoExtensionSizes[] = …;
constexpr RtpExtensionSize kAudioExtensionSizes[] = …;
bool IsNonVolatile(RTPExtensionType type) { … }
bool HasBweExtension(const RtpHeaderExtensionMap& extensions_map) { … }
}
RTPSender::RTPSender(const RtpRtcpInterface::Configuration& config,
RtpPacketHistory* packet_history,
RtpPacketSender* packet_sender)
: … { … }
RTPSender::~RTPSender() { … }
rtc::ArrayView<const RtpExtensionSize> RTPSender::FecExtensionSizes() { … }
rtc::ArrayView<const RtpExtensionSize> RTPSender::VideoExtensionSizes() { … }
rtc::ArrayView<const RtpExtensionSize> RTPSender::AudioExtensionSizes() { … }
void RTPSender::SetExtmapAllowMixed(bool extmap_allow_mixed) { … }
bool RTPSender::RegisterRtpHeaderExtension(absl::string_view uri, int id) { … }
bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) const { … }
void RTPSender::DeregisterRtpHeaderExtension(absl::string_view uri) { … }
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) { … }
size_t RTPSender::MaxRtpPacketSize() const { … }
void RTPSender::SetRtxStatus(int mode) { … }
int RTPSender::RtxStatus() const { … }
void RTPSender::SetRtxPayloadType(int payload_type,
int associated_payload_type) { … }
int32_t RTPSender::ReSendPacket(uint16_t packet_id) { … }
void RTPSender::OnReceivedAckOnSsrc(int64_t extended_highest_sequence_number) { … }
void RTPSender::OnReceivedAckOnRtxSsrc(
int64_t extended_highest_sequence_number) { … }
void RTPSender::OnReceivedNack(
const std::vector<uint16_t>& nack_sequence_numbers,
int64_t avg_rtt) { … }
bool RTPSender::SupportsPadding() const { … }
bool RTPSender::SupportsRtxPayloadPadding() const { … }
std::vector<std::unique_ptr<RtpPacketToSend>> RTPSender::GeneratePadding(
size_t target_size_bytes,
bool media_has_been_sent,
bool can_send_padding_on_media_ssrc) { … }
void RTPSender::EnqueuePackets(
std::vector<std::unique_ptr<RtpPacketToSend>> packets) { … }
size_t RTPSender::FecOrPaddingPacketMaxRtpHeaderLength() const { … }
size_t RTPSender::ExpectedPerPacketOverhead() const { … }
std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket(
rtc::ArrayView<const uint32_t> csrcs) { … }
size_t RTPSender::RtxPacketOverhead() const { … }
void RTPSender::SetSendingMediaStatus(bool enabled) { … }
bool RTPSender::SendingMedia() const { … }
bool RTPSender::IsAudioConfigured() const { … }
void RTPSender::SetTimestampOffset(uint32_t timestamp) { … }
uint32_t RTPSender::TimestampOffset() const { … }
void RTPSender::SetMid(absl::string_view mid) { … }
static void CopyHeaderAndExtensionsToRtxPacket(const RtpPacketToSend& packet,
RtpPacketToSend* rtx_packet) { … }
std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
const RtpPacketToSend& packet) { … }
void RTPSender::SetRtpState(const RtpState& rtp_state) { … }
RtpState RTPSender::GetRtpState() const { … }
void RTPSender::SetRtxRtpState(const RtpState& rtp_state) { … }
RtpState RTPSender::GetRtxRtpState() const { … }
void RTPSender::UpdateHeaderSizes() { … }
}