blob: b6a6a37bf54214e6ce340b138f6303dc4c2b075d [file] [log] [blame]
Niels Möller530ead42018-10-04 12:28:391/*
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öller530ead42018-10-04 12:28:3914#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 Anton10542f22019-01-11 17:11:0020#include "api/crypto/crypto_options.h"
Jonas Orelande62c2f22022-03-29 09:04:4821#include "api/field_trials_view.h"
Marina Ciocead2aa8f92020-03-31 09:29:5622#include "api/frame_transformer_interface.h"
Artem Titov741daaf2019-03-21 13:37:3623#include "api/function_view.h"
Sebastian Jansson44dd9f22019-03-08 13:50:3024#include "api/task_queue/task_queue_factory.h"
Henrik Boström6e436d12019-05-27 10:19:3325#include "modules/rtp_rtcp/include/report_block_data.h"
Tomas Gunnarssonf25761d2020-06-03 20:55:3326#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
Niels Mölleree5ccbc2019-03-06 15:47:2927#include "modules/rtp_rtcp/source/rtp_sender_audio.h"
Niels Möller530ead42018-10-04 12:28:3928
29namespace webrtc {
30
Benjamin Wright84583f62018-10-04 21:22:3431class FrameEncryptorInterface;
Niels Möller530ead42018-10-04 12:28:3932class RtcEventLog;
Niels Möller530ead42018-10-04 12:28:3933class RtpTransportControllerSendInterface;
34
Niels Möller530ead42018-10-04 12:28:3935struct CallSendStatistics {
36 int64_t rttMs;
Niels Möllerac0a4cb2019-10-09 13:01:3337 int64_t payload_bytes_sent;
38 int64_t header_and_padding_bytes_sent;
Henrik Boströmcf96e0f2019-04-17 11:51:5339 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent
40 uint64_t retransmitted_bytes_sent;
Niels Möller530ead42018-10-04 12:28:3941 int packetsSent;
Henrik Boströmaebba7b2022-10-26 14:53:0342 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay
43 TimeDelta total_packet_send_delay = TimeDelta::Zero();
Henrik Boströmcf96e0f2019-04-17 11:51:5344 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent
45 uint64_t retransmitted_packets_sent;
Henrik Boström6e436d12019-05-27 10:19:3346 // 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;
Philipp Hancke6a7bf102023-04-21 17:32:4251 uint32_t nacks_received;
Niels Möller530ead42018-10-04 12:28:3952};
53
Niels Möller530ead42018-10-04 12:28:3954namespace voe {
55
Niels Möllerdced9f62018-11-19 09:27:0756class ChannelSendInterface {
Niels Möller530ead42018-10-04 12:28:3957 public:
Niels Möllerdced9f62018-11-19 09:27:0758 virtual ~ChannelSendInterface() = default;
Niels Möller530ead42018-10-04 12:28:3959
Niels Möller8fb1a6a2019-03-05 13:29:4260 virtual void ReceivedRTCPPacket(const uint8_t* packet, size_t length) = 0;
Niels Möller530ead42018-10-04 12:28:3961
Niels Möllerdced9f62018-11-19 09:27:0762 virtual CallSendStatistics GetRTCPStatistics() const = 0;
Niels Möller530ead42018-10-04 12:28:3963
Niels Möller8fb1a6a2019-03-05 13:29:4264 virtual void SetEncoder(int payload_type,
Philipp Hancked2098932023-11-01 18:18:3265 const SdpAudioFormat& encoder_format,
Niels Möllerdced9f62018-11-19 09:27:0766 std::unique_ptr<AudioEncoder> encoder) = 0;
67 virtual void ModifyEncoder(
68 rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0;
Sebastian Jansson14a7cf92019-02-13 14:11:4269 virtual void CallEncoder(rtc::FunctionView<void(AudioEncoder*)> modifier) = 0;
Niels Möller530ead42018-10-04 12:28:3970
Amit Hilbuch77938e62018-12-21 17:23:3871 // Use 0 to indicate that the extension should not be registered.
Niels Möllerdced9f62018-11-19 09:27:0772 virtual void SetRTCP_CNAME(absl::string_view c_name) = 0;
Niels Möllerdced9f62018-11-19 09:27:0773 virtual void SetSendAudioLevelIndicationStatus(bool enable, int id) = 0;
Niels Möllerdced9f62018-11-19 09:27:0774 virtual void RegisterSenderCongestionControlObjects(
Danil Chapovalova2cf8ee2023-05-16 11:26:3375 RtpTransportControllerSendInterface* transport) = 0;
Niels Möllerdced9f62018-11-19 09:27:0776 virtual void ResetSenderCongestionControlObjects() = 0;
Danil Chapovalova9b9d4e2023-05-03 11:20:1177 virtual std::vector<ReportBlockData> GetRemoteRTCPReportBlocks() const = 0;
Niels Möllerdced9f62018-11-19 09:27:0778 virtual ANAStats GetANAStatistics() const = 0;
Niels Mölleree5ccbc2019-03-06 15:47:2979 virtual void RegisterCngPayloadType(int payload_type,
80 int payload_frequency) = 0;
Niels Möller8fb1a6a2019-03-05 13:29:4281 virtual void SetSendTelephoneEventPayloadType(int payload_type,
Niels Möllerdced9f62018-11-19 09:27:0782 int payload_frequency) = 0;
83 virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0;
Sebastian Jansson254d8692018-11-21 18:19:0084 virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0;
Jakob Ivarssonbf087452021-11-11 12:43:4985 virtual int GetTargetBitrate() const = 0;
Niels Möllerdced9f62018-11-19 09:27:0786 virtual void SetInputMute(bool muted) = 0;
Niels Möller530ead42018-10-04 12:28:3987
Niels Möllerdced9f62018-11-19 09:27:0788 virtual void ProcessAndEncodeAudio(
89 std::unique_ptr<AudioFrame> audio_frame) = 0;
Tomas Gunnarssonf25761d2020-06-03 20:55:3390 virtual RtpRtcpInterface* GetRtpRtcp() const = 0;
Niels Möller530ead42018-10-04 12:28:3991
Artem Titovb0ea6372021-07-26 09:47:0792 // In RTP we currently rely on RTCP packets (`ReceivedRTCPPacket`) to inform
Piotr (Peter) Slatala179a3922018-11-16 17:57:5893 // about RTT.
94 // In media transport we rely on the TargetTransferRateObserver instead.
95 // In other words, if you are using RTP, you should expect
Artem Titovb0ea6372021-07-26 09:47:0796 // `ReceivedRTCPPacket` to be called, if you are using media transport,
97 // `OnTargetTransferRate` will be called.
Piotr (Peter) Slatala179a3922018-11-16 17:57:5898 //
99 // In future, RTP media will move to the media transport implementation and
100 // these conditions will be removed.
Niels Möllerdced9f62018-11-19 09:27:07101 // Returns the RTT in milliseconds.
102 virtual int64_t GetRTT() const = 0;
103 virtual void StartSend() = 0;
104 virtual void StopSend() = 0;
Piotr (Peter) Slatala179a3922018-11-16 17:57:58105
Niels Möllerdced9f62018-11-19 09:27:07106 // E2EE Custom Audio Frame Encryption (Optional)
107 virtual void SetFrameEncryptor(
108 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
Marina Ciocead2aa8f92020-03-31 09:29:56109
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;
Niels Möller530ead42018-10-04 12:28:39115};
116
Niels Möllerdced9f62018-11-19 09:27:07117std::unique_ptr<ChannelSendInterface> CreateChannelSend(
Sebastian Jansson977b3352019-03-04 16:43:34118 Clock* clock,
Sebastian Jansson44dd9f22019-03-08 13:50:30119 TaskQueueFactory* task_queue_factory,
Niels Möllere9771992018-11-26 09:55:07120 Transport* rtp_transport,
Niels Möllerdced9f62018-11-19 09:27:07121 RtcpRttStats* rtcp_rtt_stats,
122 RtcEventLog* rtc_event_log,
123 FrameEncryptorInterface* frame_encryptor,
124 const webrtc::CryptoOptions& crypto_options,
125 bool extmap_allow_mixed,
Erik Språng4c2c4122019-07-11 13:20:15126 int rtcp_report_interval_ms,
Marina Ciocead2aa8f92020-03-31 09:29:56127 uint32_t ssrc,
Erik Språng2b4d2f32020-06-29 14:37:44128 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
Danil Chapovalova2cf8ee2023-05-16 11:26:33129 RtpTransportControllerSendInterface* transport_controller,
Jonas Orelande62c2f22022-03-29 09:04:48130 const FieldTrialsView& field_trials);
Niels Möllerdced9f62018-11-19 09:27:07131
Niels Möller530ead42018-10-04 12:28:39132} // namespace voe
133} // namespace webrtc
134
135#endif // AUDIO_CHANNEL_SEND_H_