#include "audio/channel_send.h"
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "api/array_view.h"
#include "api/call/transport.h"
#include "api/crypto/frame_encryptor_interface.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "api/sequence_checker.h"
#include "api/task_queue/task_queue_factory.h"
#include "audio/channel_send_frame_transformer_delegate.h"
#include "audio/utility/audio_frame_operations.h"
#include "call/rtp_transport_controller_send_interface.h"
#include "logging/rtc_event_log/events/rtc_event_audio_playout.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "modules/audio_coding/include/audio_coding_module.h"
#include "modules/audio_processing/rms_level.h"
#include "modules/pacing/packet_router.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/rate_limiter.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
namespace webrtc {
namespace voe {
namespace {
constexpr int64_t kMaxRetransmissionWindowMs = …;
constexpr int64_t kMinRetransmissionWindowMs = …;
class RtpPacketSenderProxy;
class TransportSequenceNumberProxy;
class AudioBitrateAccountant { … };
class ChannelSend : public ChannelSendInterface,
public AudioPacketizationCallback,
public RtcpPacketTypeCounterObserver,
public ReportBlockDataObserver { … };
const int kTelephoneEventAttenuationdB = …;
class RtpPacketSenderProxy : public RtpPacketSender { … };
int32_t ChannelSend::SendData(AudioFrameType frameType,
uint8_t payloadType,
uint32_t rtp_timestamp,
const uint8_t* payloadData,
size_t payloadSize,
int64_t absolute_capture_timestamp_ms) { … }
int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType,
uint8_t payloadType,
uint32_t rtp_timestamp_without_offset,
rtc::ArrayView<const uint8_t> payload,
int64_t absolute_capture_timestamp_ms,
rtc::ArrayView<const uint32_t> csrcs,
absl::optional<uint8_t> audio_level_dbov) { … }
ChannelSend::ChannelSend(
const Environment& env,
Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats,
FrameEncryptorInterface* frame_encryptor,
const webrtc::CryptoOptions& crypto_options,
bool extmap_allow_mixed,
int rtcp_report_interval_ms,
uint32_t ssrc,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
RtpTransportControllerSendInterface* transport_controller)
: … { … }
ChannelSend::~ChannelSend() { … }
void ChannelSend::StartSend() { … }
void ChannelSend::StopSend() { … }
void ChannelSend::SetEncoder(int payload_type,
const SdpAudioFormat& encoder_format,
std::unique_ptr<AudioEncoder> encoder) { … }
void ChannelSend::ModifyEncoder(
rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) { … }
void ChannelSend::CallEncoder(rtc::FunctionView<void(AudioEncoder*)> modifier) { … }
void ChannelSend::OnBitrateAllocation(BitrateAllocationUpdate update) { … }
int ChannelSend::GetTargetBitrate() const { … }
void ChannelSend::OnReportBlockDataUpdated(ReportBlockData report_block) { … }
void ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) { … }
void ChannelSend::SetInputMute(bool enable) { … }
bool ChannelSend::InputMute() const { … }
bool ChannelSend::SendTelephoneEventOutband(int event, int duration_ms) { … }
void ChannelSend::RegisterCngPayloadType(int payload_type,
int payload_frequency) { … }
void ChannelSend::SetSendTelephoneEventPayloadType(int payload_type,
int payload_frequency) { … }
void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) { … }
void ChannelSend::RegisterSenderCongestionControlObjects(
RtpTransportControllerSendInterface* transport) { … }
void ChannelSend::ResetSenderCongestionControlObjects() { … }
void ChannelSend::SetRTCP_CNAME(absl::string_view c_name) { … }
std::vector<ReportBlockData> ChannelSend::GetRemoteRTCPReportBlocks() const { … }
CallSendStatistics ChannelSend::GetRTCPStatistics() const { … }
void ChannelSend::RtcpPacketTypesCounterUpdated(
uint32_t ssrc,
const RtcpPacketTypeCounter& packet_counter) { … }
void ChannelSend::ProcessAndEncodeAudio(
std::unique_ptr<AudioFrame> audio_frame) { … }
ANAStats ChannelSend::GetANAStatistics() const { … }
RtpRtcpInterface* ChannelSend::GetRtpRtcp() const { … }
int64_t ChannelSend::GetRTT() const { … }
void ChannelSend::SetFrameEncryptor(
rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) { … }
void ChannelSend::SetEncoderToPacketizerFrameTransformer(
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) { … }
void ChannelSend::OnReceivedRtt(int64_t rtt_ms) { … }
void ChannelSend::InitFrameTransformerDelegate(
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) { … }
}
std::unique_ptr<ChannelSendInterface> CreateChannelSend(
const Environment& env,
Transport* rtp_transport,
RtcpRttStats* rtcp_rtt_stats,
FrameEncryptorInterface* frame_encryptor,
const webrtc::CryptoOptions& crypto_options,
bool extmap_allow_mixed,
int rtcp_report_interval_ms,
uint32_t ssrc,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
RtpTransportControllerSendInterface* transport_controller) { … }
}
}