Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 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 | |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 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" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "api/crypto/crypto_options.h" |
Niels Möller | 7d76a31 | 2018-10-26 12:57:07 +0200 | [diff] [blame] | 21 | #include "api/media_transport_interface.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 22 | #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 23 | #include "rtc_base/function_view.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 24 | #include "rtc_base/task_queue.h" |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
| 27 | |
Benjamin Wright | 84583f6 | 2018-10-04 14:22:34 -0700 | [diff] [blame] | 28 | class FrameEncryptorInterface; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 29 | class ProcessThread; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 30 | class RtcEventLog; |
| 31 | class RtpRtcp; |
| 32 | class RtpTransportControllerSendInterface; |
| 33 | |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 34 | struct CallSendStatistics { |
| 35 | int64_t rttMs; |
| 36 | size_t bytesSent; |
| 37 | int packetsSent; |
| 38 | }; |
| 39 | |
| 40 | // See section 6.4.2 in http://www.ietf.org/rfc/rfc3550.txt for details. |
| 41 | struct ReportBlock { |
| 42 | uint32_t sender_SSRC; // SSRC of sender |
| 43 | uint32_t source_SSRC; |
| 44 | uint8_t fraction_lost; |
| 45 | int32_t cumulative_num_packets_lost; |
| 46 | uint32_t extended_highest_sequence_number; |
| 47 | uint32_t interarrival_jitter; |
| 48 | uint32_t last_SR_timestamp; |
| 49 | uint32_t delay_since_last_SR; |
| 50 | }; |
| 51 | |
| 52 | namespace voe { |
| 53 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 54 | class ChannelSendInterface { |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 55 | public: |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 56 | virtual ~ChannelSendInterface() = default; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 57 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 58 | virtual bool ReceivedRTCPPacket(const uint8_t* packet, size_t length) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 59 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 60 | virtual CallSendStatistics GetRTCPStatistics() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 61 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 62 | virtual bool SetEncoder(int payload_type, |
| 63 | std::unique_ptr<AudioEncoder> encoder) = 0; |
| 64 | virtual void ModifyEncoder( |
| 65 | rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 66 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 67 | virtual void SetLocalSSRC(uint32_t ssrc) = 0; |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 68 | // Use 0 to indicate that the extension should not be registered. |
| 69 | virtual void SetRid(const std::string& rid, |
| 70 | int extension_id, |
| 71 | int repaired_extension_id) = 0; |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 72 | virtual void SetMid(const std::string& mid, int extension_id) = 0; |
| 73 | virtual void SetRTCP_CNAME(absl::string_view c_name) = 0; |
| 74 | virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0; |
| 75 | virtual void SetSendAudioLevelIndicationStatus(bool enable, int id) = 0; |
| 76 | virtual void EnableSendTransportSequenceNumber(int id) = 0; |
| 77 | virtual void RegisterSenderCongestionControlObjects( |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 78 | RtpTransportControllerSendInterface* transport, |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 79 | RtcpBandwidthObserver* bandwidth_observer) = 0; |
| 80 | virtual void ResetSenderCongestionControlObjects() = 0; |
| 81 | virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const = 0; |
| 82 | virtual ANAStats GetANAStatistics() const = 0; |
| 83 | virtual bool SetSendTelephoneEventPayloadType(int payload_type, |
| 84 | int payload_frequency) = 0; |
| 85 | virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0; |
Sebastian Jansson | 254d869 | 2018-11-21 19:19:00 +0100 | [diff] [blame] | 86 | virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0; |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 87 | virtual int GetBitrate() const = 0; |
| 88 | virtual void SetInputMute(bool muted) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 89 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 90 | virtual void ProcessAndEncodeAudio( |
| 91 | std::unique_ptr<AudioFrame> audio_frame) = 0; |
| 92 | virtual void SetTransportOverhead(size_t transport_overhead_per_packet) = 0; |
| 93 | virtual RtpRtcp* GetRtpRtcp() const = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 94 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 95 | virtual void OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) = 0; |
| 96 | virtual void OnRecoverableUplinkPacketLossRate( |
| 97 | float recoverable_packet_loss_rate) = 0; |
Piotr (Peter) Slatala | 179a392 | 2018-11-16 09:57:58 -0800 | [diff] [blame] | 98 | // In RTP we currently rely on RTCP packets (|ReceivedRTCPPacket|) to inform |
| 99 | // about RTT. |
| 100 | // In media transport we rely on the TargetTransferRateObserver instead. |
| 101 | // In other words, if you are using RTP, you should expect |
| 102 | // |ReceivedRTCPPacket| to be called, if you are using media transport, |
| 103 | // |OnTargetTransferRate| will be called. |
| 104 | // |
| 105 | // In future, RTP media will move to the media transport implementation and |
| 106 | // these conditions will be removed. |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 107 | // Returns the RTT in milliseconds. |
| 108 | virtual int64_t GetRTT() const = 0; |
| 109 | virtual void StartSend() = 0; |
| 110 | virtual void StopSend() = 0; |
Piotr (Peter) Slatala | 179a392 | 2018-11-16 09:57:58 -0800 | [diff] [blame] | 111 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 112 | // E2EE Custom Audio Frame Encryption (Optional) |
| 113 | virtual void SetFrameEncryptor( |
| 114 | rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0; |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 115 | }; |
| 116 | |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 117 | std::unique_ptr<ChannelSendInterface> CreateChannelSend( |
| 118 | rtc::TaskQueue* encoder_queue, |
| 119 | ProcessThread* module_process_thread, |
| 120 | MediaTransportInterface* media_transport, |
Niels Möller | e977199 | 2018-11-26 10:55:07 +0100 | [diff] [blame] | 121 | Transport* rtp_transport, |
Niels Möller | dced9f6 | 2018-11-19 10:27:07 +0100 | [diff] [blame] | 122 | RtcpRttStats* rtcp_rtt_stats, |
| 123 | RtcEventLog* rtc_event_log, |
| 124 | FrameEncryptorInterface* frame_encryptor, |
| 125 | const webrtc::CryptoOptions& crypto_options, |
| 126 | bool extmap_allow_mixed, |
| 127 | int rtcp_report_interval_ms); |
| 128 | |
Niels Möller | 530ead4 | 2018-10-04 14:28:39 +0200 | [diff] [blame] | 129 | } // namespace voe |
| 130 | } // namespace webrtc |
| 131 | |
| 132 | #endif // AUDIO_CHANNEL_SEND_H_ |