| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef AUDIO_CHANNEL_SEND_H_ |
| 12 | #define AUDIO_CHANNEL_SEND_H_ |
| 13 |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 |
| 18 | #include "api/audio/audio_frame.h" |
| 19 | #include "api/audio_codecs/audio_encoder.h" |
| 20 | #include "api/crypto/crypto_options.h" |
| 21 | #include "api/field_trials_view.h" |
| 22 | #include "api/frame_transformer_interface.h" |
| 23 | #include "api/function_view.h" |
| 24 | #include "api/task_queue/task_queue_factory.h" |
| 25 | #include "modules/rtp_rtcp/include/report_block_data.h" |
| 26 | #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" |
| 27 | #include "modules/rtp_rtcp/source/rtp_sender_audio.h" |
| 28 |
| 29 | namespace webrtc { |
| 30 |
| 31 | class FrameEncryptorInterface; |
| 32 | class RtcEventLog; |
| 33 | class RtpTransportControllerSendInterface; |
| 34 |
| 35 | struct CallSendStatistics { |
| 36 | int64_t rttMs; |
| 37 | int64_t payload_bytes_sent; |
| 38 | int64_t header_and_padding_bytes_sent; |
| 39 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent |
| 40 | uint64_t retransmitted_bytes_sent; |
| 41 | int packetsSent; |
| 42 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay |
| 43 | TimeDelta total_packet_send_delay = TimeDelta::Zero(); |
| 44 | // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent |
| 45 | uint64_t retransmitted_packets_sent; |
| 46 | // A snapshot of Report Blocks with additional data of interest to statistics. |
| 47 | // Within this list, the sender-source SSRC pair is unique and per-pair the |
| 48 | // ReportBlockData represents the latest Report Block that was received for |
| 49 | // that pair. |
| 50 | std::vector<ReportBlockData> report_block_datas; |
| 51 | uint32_t nacks_received; |
| 52 | }; |
| 53 |
| 54 | namespace voe { |
| 55 |
| 56 | class ChannelSendInterface { |
| 57 | public: |
| 58 | virtual ~ChannelSendInterface() = default; |
| 59 |
| 60 | virtual void ReceivedRTCPPacket(const uint8_t* packet, size_t length) = 0; |
| 61 |
| 62 | virtual CallSendStatistics GetRTCPStatistics() const = 0; |
| 63 |
| 64 | virtual void SetEncoder(int payload_type, |
| 65 | const SdpAudioFormat& encoder_format, |
| 66 | std::unique_ptr<AudioEncoder> encoder) = 0; |
| 67 | virtual void ModifyEncoder( |
| 68 | rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0; |
| 69 | virtual void CallEncoder(rtc::FunctionView<void(AudioEncoder*)> modifier) = 0; |
| 70 |
| 71 | // Use 0 to indicate that the extension should not be registered. |
| 72 | virtual void SetRTCP_CNAME(absl::string_view c_name) = 0; |
| 73 | virtual void SetSendAudioLevelIndicationStatus(bool enable, int id) = 0; |
| 74 | virtual void RegisterSenderCongestionControlObjects( |
| 75 | RtpTransportControllerSendInterface* transport) = 0; |
| 76 | virtual void ResetSenderCongestionControlObjects() = 0; |
| 77 | virtual std::vector<ReportBlockData> GetRemoteRTCPReportBlocks() const = 0; |
| 78 | virtual ANAStats GetANAStatistics() const = 0; |
| 79 | virtual void RegisterCngPayloadType(int payload_type, |
| 80 | int payload_frequency) = 0; |
| 81 | virtual void SetSendTelephoneEventPayloadType(int payload_type, |
| 82 | int payload_frequency) = 0; |
| 83 | virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0; |
| 84 | virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0; |
| 85 | virtual int GetTargetBitrate() const = 0; |
| 86 | virtual void SetInputMute(bool muted) = 0; |
| 87 |
| 88 | virtual void ProcessAndEncodeAudio( |
| 89 | std::unique_ptr<AudioFrame> audio_frame) = 0; |
| 90 | virtual RtpRtcpInterface* GetRtpRtcp() const = 0; |
| 91 |
| 92 | // In RTP we currently rely on RTCP packets (`ReceivedRTCPPacket`) to inform |
| 93 | // about RTT. |
| 94 | // In media transport we rely on the TargetTransferRateObserver instead. |
| 95 | // In other words, if you are using RTP, you should expect |
| 96 | // `ReceivedRTCPPacket` to be called, if you are using media transport, |
| 97 | // `OnTargetTransferRate` will be called. |
| 98 | // |
| 99 | // In future, RTP media will move to the media transport implementation and |
| 100 | // these conditions will be removed. |
| 101 | // Returns the RTT in milliseconds. |
| 102 | virtual int64_t GetRTT() const = 0; |
| 103 | virtual void StartSend() = 0; |
| 104 | virtual void StopSend() = 0; |
| 105 |
| 106 | // E2EE Custom Audio Frame Encryption (Optional) |
| 107 | virtual void SetFrameEncryptor( |
| 108 | rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0; |
| 109 |
| 110 | // Sets a frame transformer between encoder and packetizer, to transform |
| 111 | // encoded frames before sending them out the network. |
| 112 | virtual void SetEncoderToPacketizerFrameTransformer( |
| 113 | rtc::scoped_refptr<webrtc::FrameTransformerInterface> |
| 114 | frame_transformer) = 0; |
| 115 | }; |
| 116 |
| 117 | std::unique_ptr<ChannelSendInterface> CreateChannelSend( |
| 118 | Clock* clock, |
| 119 | TaskQueueFactory* task_queue_factory, |
| 120 | Transport* rtp_transport, |
| 121 | RtcpRttStats* rtcp_rtt_stats, |
| 122 | RtcEventLog* rtc_event_log, |
| 123 | FrameEncryptorInterface* frame_encryptor, |
| 124 | const webrtc::CryptoOptions& crypto_options, |
| 125 | bool extmap_allow_mixed, |
| 126 | int rtcp_report_interval_ms, |
| 127 | uint32_t ssrc, |
| 128 | rtc::scoped_refptr<FrameTransformerInterface> frame_transformer, |
| 129 | RtpTransportControllerSendInterface* transport_controller, |
| 130 | const FieldTrialsView& field_trials); |
| 131 |
| 132 | } // namespace voe |
| 133 | } // namespace webrtc |
| 134 |
| 135 | #endif // AUDIO_CHANNEL_SEND_H_ |
| 136 |