#include "call/rtp_video_sender.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "api/array_view.h"
#include "api/task_queue/task_queue_factory.h"
#include "api/transport/field_trial_based_config.h"
#include "api/units/time_delta.h"
#include "api/video_codecs/video_codec.h"
#include "call/rtp_transport_controller_send_interface.h"
#include "modules/pacing/packet_router.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "modules/rtp_rtcp/source/rtp_sender.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
namespace webrtc {
namespace webrtc_internal_rtp_video_sender {
RtpStreamSender::RtpStreamSender(
std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp,
std::unique_ptr<RTPSenderVideo> sender_video,
std::unique_ptr<VideoFecGenerator> fec_generator)
: … { … }
RtpStreamSender::~RtpStreamSender() = default;
}
namespace {
static const int kMinSendSidePacketHistorySize = …;
static const size_t kPathMTU = …;
RtpStreamSender;
bool PayloadTypeSupportsSkippingFecPackets(absl::string_view payload_name,
const FieldTrialsView& trials) { … }
bool ShouldDisableRedAndUlpfec(bool flexfec_enabled,
const RtpConfig& rtp_config,
const FieldTrialsView& trials) { … }
std::unique_ptr<VideoFecGenerator> MaybeCreateFecGenerator(
const Environment& env,
const RtpConfig& rtp,
const std::map<uint32_t, RtpState>& suspended_ssrcs,
int simulcast_index) { … }
std::vector<RtpStreamSender> CreateRtpStreamSenders(
const Environment& env,
const RtpConfig& rtp_config,
const RtpSenderObservers& observers,
int rtcp_report_interval_ms,
Transport* send_transport,
RtpTransportControllerSendInterface* transport,
const std::map<uint32_t, RtpState>& suspended_ssrcs,
RateLimiter* retransmission_rate_limiter,
FrameEncryptorInterface* frame_encryptor,
const CryptoOptions& crypto_options,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) { … }
absl::optional<VideoCodecType> GetVideoCodecType(const RtpConfig& config) { … }
bool TransportSeqNumExtensionConfigured(const RtpConfig& config) { … }
bool IsFirstFrameOfACodedVideoSequence(
const EncodedImage& encoded_image,
const CodecSpecificInfo* codec_specific_info) { … }
}
RtpVideoSender::RtpVideoSender(
const Environment& env,
const std::map<uint32_t, RtpState>& suspended_ssrcs,
const std::map<uint32_t, RtpPayloadState>& states,
const RtpConfig& rtp_config,
int rtcp_report_interval_ms,
Transport* send_transport,
const RtpSenderObservers& observers,
RtpTransportControllerSendInterface* transport,
RateLimiter* retransmission_limiter,
std::unique_ptr<FecController> fec_controller,
FrameEncryptorInterface* frame_encryptor,
const CryptoOptions& crypto_options,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer)
: … { … }
RtpVideoSender::~RtpVideoSender() { … }
void RtpVideoSender::SetSending(bool enabled) { … }
void RtpVideoSender::SetActiveModulesLocked(bool sending) { … }
bool RtpVideoSender::IsActive() { … }
bool RtpVideoSender::IsActiveLocked() { … }
EncodedImageCallback::Result RtpVideoSender::OnEncodedImage(
const EncodedImage& encoded_image,
const CodecSpecificInfo* codec_specific_info) { … }
void RtpVideoSender::OnBitrateAllocationUpdated(
const VideoBitrateAllocation& bitrate) { … }
void RtpVideoSender::OnVideoLayersAllocationUpdated(
const VideoLayersAllocation& allocation) { … }
bool RtpVideoSender::NackEnabled() const { … }
DataRate RtpVideoSender::GetPostEncodeOverhead() const { … }
void RtpVideoSender::DeliverRtcp(const uint8_t* packet, size_t length) { … }
void RtpVideoSender::ConfigureSsrcs(
const std::map<uint32_t, RtpState>& suspended_ssrcs) { … }
void RtpVideoSender::OnNetworkAvailability(bool network_available) { … }
std::map<uint32_t, RtpState> RtpVideoSender::GetRtpStates() const { … }
std::map<uint32_t, RtpPayloadState> RtpVideoSender::GetRtpPayloadStates()
const { … }
void RtpVideoSender::OnTransportOverheadChanged(
size_t transport_overhead_bytes_per_packet) { … }
void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
int framerate) { … }
uint32_t RtpVideoSender::GetPayloadBitrateBps() const { … }
uint32_t RtpVideoSender::GetProtectionBitrateBps() const { … }
std::vector<RtpSequenceNumberMap::Info> RtpVideoSender::GetSentRtpPacketInfos(
uint32_t ssrc,
rtc::ArrayView<const uint16_t> sequence_numbers) const { … }
int RtpVideoSender::ProtectionRequest(const FecProtectionParams* delta_params,
const FecProtectionParams* key_params,
uint32_t* sent_video_rate_bps,
uint32_t* sent_nack_rate_bps,
uint32_t* sent_fec_rate_bps) { … }
void RtpVideoSender::SetRetransmissionMode(int retransmission_mode) { … }
void RtpVideoSender::SetFecAllowed(bool fec_allowed) { … }
void RtpVideoSender::OnPacketFeedbackVector(
std::vector<StreamPacketInfo> packet_feedback_vector) { … }
void RtpVideoSender::SetEncodingData(size_t width,
size_t height,
size_t num_temporal_layers) { … }
DataRate RtpVideoSender::CalculateOverheadRate(DataRate data_rate,
DataSize packet_size,
DataSize overhead_per_packet,
Frequency framerate) const { … }
}