#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include <string.h>
#include <algorithm>
#include <cstdint>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/sequence_checker.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/rtp_rtcp/source/ntp_time_util.h"
#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
#include "modules/rtp_rtcp/source/rtp_packet_history.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/ntp_time.h"
#ifdef _WIN32
#pragma warning(disable : 4355)
#endif
namespace webrtc {
namespace {
constexpr TimeDelta kDefaultExpectedRetransmissionTime = …;
constexpr TimeDelta kRttUpdateInterval = …;
RTCPSender::Configuration AddRtcpSendEvaluationCallback(
RTCPSender::Configuration config,
std::function<void(TimeDelta)> send_evaluation_callback) { … }
}
ModuleRtpRtcpImpl2::RtpSenderContext::RtpSenderContext(
TaskQueueBase& worker_queue,
const RtpRtcpInterface::Configuration& config)
: … { … }
ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Configuration& configuration)
: … { … }
ModuleRtpRtcpImpl2::~ModuleRtpRtcpImpl2() { … }
std::unique_ptr<ModuleRtpRtcpImpl2> ModuleRtpRtcpImpl2::Create(
const Configuration& configuration) { … }
void ModuleRtpRtcpImpl2::SetRtxSendStatus(int mode) { … }
int ModuleRtpRtcpImpl2::RtxSendStatus() const { … }
void ModuleRtpRtcpImpl2::SetRtxSendPayloadType(int payload_type,
int associated_payload_type) { … }
absl::optional<uint32_t> ModuleRtpRtcpImpl2::RtxSsrc() const { … }
absl::optional<uint32_t> ModuleRtpRtcpImpl2::FlexfecSsrc() const { … }
void ModuleRtpRtcpImpl2::IncomingRtcpPacket(
rtc::ArrayView<const uint8_t> rtcp_packet) { … }
void ModuleRtpRtcpImpl2::RegisterSendPayloadFrequency(int payload_type,
int payload_frequency) { … }
int32_t ModuleRtpRtcpImpl2::DeRegisterSendPayload(const int8_t payload_type) { … }
uint32_t ModuleRtpRtcpImpl2::StartTimestamp() const { … }
void ModuleRtpRtcpImpl2::SetStartTimestamp(const uint32_t timestamp) { … }
uint16_t ModuleRtpRtcpImpl2::SequenceNumber() const { … }
void ModuleRtpRtcpImpl2::SetSequenceNumber(const uint16_t seq_num) { … }
void ModuleRtpRtcpImpl2::SetRtpState(const RtpState& rtp_state) { … }
void ModuleRtpRtcpImpl2::SetRtxState(const RtpState& rtp_state) { … }
RtpState ModuleRtpRtcpImpl2::GetRtpState() const { … }
RtpState ModuleRtpRtcpImpl2::GetRtxState() const { … }
void ModuleRtpRtcpImpl2::SetNonSenderRttMeasurement(bool enabled) { … }
uint32_t ModuleRtpRtcpImpl2::local_media_ssrc() const { … }
void ModuleRtpRtcpImpl2::SetMid(absl::string_view mid) { … }
RTCPSender::FeedbackState ModuleRtpRtcpImpl2::GetFeedbackState() { … }
int32_t ModuleRtpRtcpImpl2::SetSendingStatus(const bool sending) { … }
bool ModuleRtpRtcpImpl2::Sending() const { … }
void ModuleRtpRtcpImpl2::SetSendingMediaStatus(const bool sending) { … }
bool ModuleRtpRtcpImpl2::SendingMedia() const { … }
bool ModuleRtpRtcpImpl2::IsAudioConfigured() const { … }
void ModuleRtpRtcpImpl2::SetAsPartOfAllocation(bool part_of_allocation) { … }
bool ModuleRtpRtcpImpl2::OnSendingRtpFrame(uint32_t timestamp,
int64_t capture_time_ms,
int payload_type,
bool force_sender_report) { … }
bool ModuleRtpRtcpImpl2::CanSendPacket(const RtpPacketToSend& packet) const { … }
void ModuleRtpRtcpImpl2::AssignSequenceNumber(RtpPacketToSend& packet) { … }
void ModuleRtpRtcpImpl2::SendPacket(std::unique_ptr<RtpPacketToSend> packet,
const PacedPacketInfo& pacing_info) { … }
bool ModuleRtpRtcpImpl2::TrySendPacket(std::unique_ptr<RtpPacketToSend> packet,
const PacedPacketInfo& pacing_info) { … }
void ModuleRtpRtcpImpl2::OnBatchComplete() { … }
void ModuleRtpRtcpImpl2::SetFecProtectionParams(
const FecProtectionParams& delta_params,
const FecProtectionParams& key_params) { … }
std::vector<std::unique_ptr<RtpPacketToSend>>
ModuleRtpRtcpImpl2::FetchFecPackets() { … }
void ModuleRtpRtcpImpl2::OnAbortedRetransmissions(
rtc::ArrayView<const uint16_t> sequence_numbers) { … }
void ModuleRtpRtcpImpl2::OnPacketsAcknowledged(
rtc::ArrayView<const uint16_t> sequence_numbers) { … }
bool ModuleRtpRtcpImpl2::SupportsPadding() const { … }
bool ModuleRtpRtcpImpl2::SupportsRtxPayloadPadding() const { … }
std::vector<std::unique_ptr<RtpPacketToSend>>
ModuleRtpRtcpImpl2::GeneratePadding(size_t target_size_bytes) { … }
std::vector<RtpSequenceNumberMap::Info>
ModuleRtpRtcpImpl2::GetSentRtpPacketInfos(
rtc::ArrayView<const uint16_t> sequence_numbers) const { … }
size_t ModuleRtpRtcpImpl2::ExpectedPerPacketOverhead() const { … }
void ModuleRtpRtcpImpl2::OnPacketSendingThreadSwitched() { … }
size_t ModuleRtpRtcpImpl2::MaxRtpPacketSize() const { … }
void ModuleRtpRtcpImpl2::SetMaxRtpPacketSize(size_t rtp_packet_size) { … }
RtcpMode ModuleRtpRtcpImpl2::RTCP() const { … }
void ModuleRtpRtcpImpl2::SetRTCPStatus(const RtcpMode method) { … }
int32_t ModuleRtpRtcpImpl2::SetCNAME(absl::string_view c_name) { … }
absl::optional<TimeDelta> ModuleRtpRtcpImpl2::LastRtt() const { … }
TimeDelta ModuleRtpRtcpImpl2::ExpectedRetransmissionTime() const { … }
int32_t ModuleRtpRtcpImpl2::SendRTCP(RTCPPacketType packet_type) { … }
void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const { … }
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
const { … }
absl::optional<RtpRtcpInterface::SenderReportStats>
ModuleRtpRtcpImpl2::GetSenderReportStats() const { … }
absl::optional<RtpRtcpInterface::NonSenderRttStats>
ModuleRtpRtcpImpl2::GetNonSenderRttStats() const { … }
void ModuleRtpRtcpImpl2::SetRemb(int64_t bitrate_bps,
std::vector<uint32_t> ssrcs) { … }
void ModuleRtpRtcpImpl2::UnsetRemb() { … }
void ModuleRtpRtcpImpl2::SetExtmapAllowMixed(bool extmap_allow_mixed) { … }
void ModuleRtpRtcpImpl2::RegisterRtpHeaderExtension(absl::string_view uri,
int id) { … }
void ModuleRtpRtcpImpl2::DeregisterSendRtpHeaderExtension(
absl::string_view uri) { … }
void ModuleRtpRtcpImpl2::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { … }
int32_t ModuleRtpRtcpImpl2::SendNACK(const uint16_t* nack_list,
const uint16_t size) { … }
void ModuleRtpRtcpImpl2::SendNack(
const std::vector<uint16_t>& sequence_numbers) { … }
bool ModuleRtpRtcpImpl2::TimeToSendFullNackList(int64_t now) const { … }
void ModuleRtpRtcpImpl2::SetStorePacketsStatus(const bool enable,
const uint16_t number_to_store) { … }
bool ModuleRtpRtcpImpl2::StorePackets() const { … }
void ModuleRtpRtcpImpl2::SendCombinedRtcpPacket(
std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets) { … }
int32_t ModuleRtpRtcpImpl2::SendLossNotification(uint16_t last_decoded_seq_num,
uint16_t last_received_seq_num,
bool decodability_flag,
bool buffering_allowed) { … }
void ModuleRtpRtcpImpl2::SetRemoteSSRC(const uint32_t ssrc) { … }
void ModuleRtpRtcpImpl2::SetLocalSsrc(uint32_t local_ssrc) { … }
RtpSendRates ModuleRtpRtcpImpl2::GetSendRates() const { … }
void ModuleRtpRtcpImpl2::OnRequestSendReport() { … }
void ModuleRtpRtcpImpl2::OnReceivedNack(
const std::vector<uint16_t>& nack_sequence_numbers) { … }
void ModuleRtpRtcpImpl2::OnReceivedRtcpReportBlocks(
rtc::ArrayView<const ReportBlockData> report_blocks) { … }
void ModuleRtpRtcpImpl2::set_rtt_ms(int64_t rtt_ms) { … }
int64_t ModuleRtpRtcpImpl2::rtt_ms() const { … }
void ModuleRtpRtcpImpl2::SetVideoBitrateAllocation(
const VideoBitrateAllocation& bitrate) { … }
RTPSender* ModuleRtpRtcpImpl2::RtpSender() { … }
const RTPSender* ModuleRtpRtcpImpl2::RtpSender() const { … }
void ModuleRtpRtcpImpl2::PeriodicUpdate() { … }
void ModuleRtpRtcpImpl2::MaybeSendRtcp() { … }
void ModuleRtpRtcpImpl2::MaybeSendRtcpAtOrAfterTimestamp(
Timestamp execution_time) { … }
void ModuleRtpRtcpImpl2::ScheduleRtcpSendEvaluation(TimeDelta duration) { … }
void ModuleRtpRtcpImpl2::ScheduleMaybeSendRtcpAtOrAfterTimestamp(
Timestamp execution_time,
TimeDelta duration) { … }
}