#include "modules/rtp_rtcp/source/rtcp_sender.h"
#include <string.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtp_headers.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h"
#include "modules/rtp_rtcp/source/ntp_time_util.h"
#include "modules/rtp_rtcp/source/rtcp_packet/app.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
#include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
#include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h"
#include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
#include "modules/rtp_rtcp/source/rtcp_packet/pli.h"
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
#include "modules/rtp_rtcp/source/rtcp_packet/remb.h"
#include "modules/rtp_rtcp/source/rtcp_packet/sdes.h"
#include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
#include "modules/rtp_rtcp/source/rtcp_packet/tmmbn.h"
#include "modules/rtp_rtcp/source/rtcp_packet/tmmbr.h"
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "modules/rtp_rtcp/source/tmmbr_help.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
const uint32_t kRtcpAnyExtendedReports = …;
constexpr int32_t kDefaultVideoReportInterval = …;
constexpr int32_t kDefaultAudioReportInterval = …;
}
class RTCPSender::PacketSender { … };
RTCPSender::FeedbackState::FeedbackState()
: … { … }
RTCPSender::FeedbackState::FeedbackState(const FeedbackState&) = default;
RTCPSender::FeedbackState::FeedbackState(FeedbackState&&) = default;
RTCPSender::FeedbackState::~FeedbackState() = default;
class RTCPSender::RtcpContext { … };
RTCPSender::Configuration RTCPSender::Configuration::FromRtpRtcpConfiguration(
const RtpRtcpInterface::Configuration& configuration) { … }
RTCPSender::RTCPSender(Configuration config)
: … { … }
RTCPSender::~RTCPSender() { … }
RtcpMode RTCPSender::Status() const { … }
void RTCPSender::SetRTCPStatus(RtcpMode new_method) { … }
bool RTCPSender::Sending() const { … }
void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
bool sending) { … }
void RTCPSender::SetNonSenderRttMeasurement(bool enabled) { … }
int32_t RTCPSender::SendLossNotification(const FeedbackState& feedback_state,
uint16_t last_decoded_seq_num,
uint16_t last_received_seq_num,
bool decodability_flag,
bool buffering_allowed) { … }
void RTCPSender::SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) { … }
void RTCPSender::UnsetRemb() { … }
bool RTCPSender::TMMBR() const { … }
void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) { … }
void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) { … }
void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
absl::optional<Timestamp> capture_time,
absl::optional<int8_t> payload_type) { … }
void RTCPSender::SetRtpClockRate(int8_t payload_type, int rtp_clock_rate_hz) { … }
uint32_t RTCPSender::SSRC() const { … }
void RTCPSender::SetSsrc(uint32_t ssrc) { … }
void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { … }
int32_t RTCPSender::SetCNAME(absl::string_view c_name) { … }
bool RTCPSender::TimeToSendRTCPReport(bool send_keyframe_before_rtp) const { … }
void RTCPSender::BuildSR(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildSDES(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildRR(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildPLI(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildFIR(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildREMB(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) { … }
void RTCPSender::BuildTMMBR(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildTMMBN(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildAPP(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildLossNotification(const RtcpContext& ctx,
PacketSender& sender) { … }
void RTCPSender::BuildNACK(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildBYE(const RtcpContext& ctx, PacketSender& sender) { … }
void RTCPSender::BuildExtendedReports(const RtcpContext& ctx,
PacketSender& sender) { … }
int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
RTCPPacketType packet_type,
int32_t nack_size,
const uint16_t* nack_list) { … }
absl::optional<int32_t> RTCPSender::ComputeCompoundRTCPPacket(
const FeedbackState& feedback_state,
RTCPPacketType packet_type,
int32_t nack_size,
const uint16_t* nack_list,
PacketSender& sender) { … }
TimeDelta RTCPSender::ComputeTimeUntilNextReport(DataRate send_bitrate) { … }
void RTCPSender::PrepareReport(const FeedbackState& feedback_state) { … }
std::vector<rtcp::ReportBlock> RTCPSender::CreateReportBlocks(
const FeedbackState& feedback_state) { … }
void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { … }
void RTCPSender::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { … }
void RTCPSender::SetFlag(uint32_t type, bool is_volatile) { … }
bool RTCPSender::IsFlagPresent(uint32_t type) const { … }
bool RTCPSender::ConsumeFlag(uint32_t type, bool forced) { … }
bool RTCPSender::AllVolatileFlagsConsumed() const { … }
void RTCPSender::SetVideoBitrateAllocation(
const VideoBitrateAllocation& bitrate) { … }
absl::optional<VideoBitrateAllocation> RTCPSender::CheckAndUpdateLayerStructure(
const VideoBitrateAllocation& bitrate) const { … }
void RTCPSender::SendCombinedRtcpPacket(
std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets) { … }
void RTCPSender::SetNextRtcpSendEvaluationDuration(TimeDelta duration) { … }
}