blob: 761e4b25664677e0021eee46e1110e9436467084 [file] [log] [blame]
Niels Möller530ead42018-10-04 14:28:39 +02001/*
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 14:28:39 +020014#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 09:11:00 -080020#include "api/crypto/crypto_options.h"
Artem Titov741daaf2019-03-21 14:37:36 +010021#include "api/function_view.h"
Niels Möller7d76a312018-10-26 12:57:07 +020022#include "api/media_transport_interface.h"
Sebastian Jansson44dd9f22019-03-08 14:50:30 +010023#include "api/task_queue/task_queue_factory.h"
Niels Möller530ead42018-10-04 14:28:39 +020024#include "modules/rtp_rtcp/include/rtp_rtcp.h"
Niels Mölleree5ccbc2019-03-06 16:47:29 +010025#include "modules/rtp_rtcp/source/rtp_sender_audio.h"
Niels Möller530ead42018-10-04 14:28:39 +020026
27namespace webrtc {
28
Benjamin Wright84583f62018-10-04 14:22:34 -070029class FrameEncryptorInterface;
Niels Möller530ead42018-10-04 14:28:39 +020030class ProcessThread;
Niels Möller530ead42018-10-04 14:28:39 +020031class RtcEventLog;
32class RtpRtcp;
33class RtpTransportControllerSendInterface;
34
Niels Möller530ead42018-10-04 14:28:39 +020035struct CallSendStatistics {
36 int64_t rttMs;
37 size_t bytesSent;
38 int packetsSent;
39};
40
41// See section 6.4.2 in http://www.ietf.org/rfc/rfc3550.txt for details.
42struct ReportBlock {
43 uint32_t sender_SSRC; // SSRC of sender
44 uint32_t source_SSRC;
45 uint8_t fraction_lost;
46 int32_t cumulative_num_packets_lost;
47 uint32_t extended_highest_sequence_number;
48 uint32_t interarrival_jitter;
49 uint32_t last_SR_timestamp;
50 uint32_t delay_since_last_SR;
51};
52
53namespace voe {
54
Niels Möllerdced9f62018-11-19 10:27:07 +010055class ChannelSendInterface {
Niels Möller530ead42018-10-04 14:28:39 +020056 public:
Niels Möllerdced9f62018-11-19 10:27:07 +010057 virtual ~ChannelSendInterface() = default;
Niels Möller530ead42018-10-04 14:28:39 +020058
Niels Möller8fb1a6a2019-03-05 14:29:42 +010059 virtual void ReceivedRTCPPacket(const uint8_t* packet, size_t length) = 0;
Niels Möller530ead42018-10-04 14:28:39 +020060
Niels Möllerdced9f62018-11-19 10:27:07 +010061 virtual CallSendStatistics GetRTCPStatistics() const = 0;
Niels Möller530ead42018-10-04 14:28:39 +020062
Niels Möller8fb1a6a2019-03-05 14:29:42 +010063 virtual void SetEncoder(int payload_type,
Niels Möllerdced9f62018-11-19 10:27:07 +010064 std::unique_ptr<AudioEncoder> encoder) = 0;
65 virtual void ModifyEncoder(
66 rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) = 0;
Sebastian Jansson14a7cf92019-02-13 15:11:42 +010067 virtual void CallEncoder(rtc::FunctionView<void(AudioEncoder*)> modifier) = 0;
Niels Möller530ead42018-10-04 14:28:39 +020068
Niels Möllerdced9f62018-11-19 10:27:07 +010069 virtual void SetLocalSSRC(uint32_t ssrc) = 0;
Amit Hilbuch77938e62018-12-21 09:23:38 -080070 // Use 0 to indicate that the extension should not be registered.
71 virtual void SetRid(const std::string& rid,
72 int extension_id,
73 int repaired_extension_id) = 0;
Niels Möllerdced9f62018-11-19 10:27:07 +010074 virtual void SetMid(const std::string& mid, int extension_id) = 0;
75 virtual void SetRTCP_CNAME(absl::string_view c_name) = 0;
76 virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0;
77 virtual void SetSendAudioLevelIndicationStatus(bool enable, int id) = 0;
78 virtual void EnableSendTransportSequenceNumber(int id) = 0;
79 virtual void RegisterSenderCongestionControlObjects(
Niels Möller530ead42018-10-04 14:28:39 +020080 RtpTransportControllerSendInterface* transport,
Niels Möllerdced9f62018-11-19 10:27:07 +010081 RtcpBandwidthObserver* bandwidth_observer) = 0;
82 virtual void ResetSenderCongestionControlObjects() = 0;
83 virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const = 0;
84 virtual ANAStats GetANAStatistics() const = 0;
Niels Mölleree5ccbc2019-03-06 16:47:29 +010085 virtual void RegisterCngPayloadType(int payload_type,
86 int payload_frequency) = 0;
Niels Möller8fb1a6a2019-03-05 14:29:42 +010087 virtual void SetSendTelephoneEventPayloadType(int payload_type,
Niels Möllerdced9f62018-11-19 10:27:07 +010088 int payload_frequency) = 0;
89 virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0;
Sebastian Jansson254d8692018-11-21 19:19:00 +010090 virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0;
Niels Möllerdced9f62018-11-19 10:27:07 +010091 virtual int GetBitrate() const = 0;
92 virtual void SetInputMute(bool muted) = 0;
Niels Möller530ead42018-10-04 14:28:39 +020093
Niels Möllerdced9f62018-11-19 10:27:07 +010094 virtual void ProcessAndEncodeAudio(
95 std::unique_ptr<AudioFrame> audio_frame) = 0;
Niels Möllerdced9f62018-11-19 10:27:07 +010096 virtual RtpRtcp* GetRtpRtcp() const = 0;
Niels Möller530ead42018-10-04 14:28:39 +020097
Niels Möllerdced9f62018-11-19 10:27:07 +010098 virtual void OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) = 0;
99 virtual void OnRecoverableUplinkPacketLossRate(
100 float recoverable_packet_loss_rate) = 0;
Piotr (Peter) Slatala179a3922018-11-16 09:57:58 -0800101 // In RTP we currently rely on RTCP packets (|ReceivedRTCPPacket|) to inform
102 // about RTT.
103 // In media transport we rely on the TargetTransferRateObserver instead.
104 // In other words, if you are using RTP, you should expect
105 // |ReceivedRTCPPacket| to be called, if you are using media transport,
106 // |OnTargetTransferRate| will be called.
107 //
108 // In future, RTP media will move to the media transport implementation and
109 // these conditions will be removed.
Niels Möllerdced9f62018-11-19 10:27:07 +0100110 // Returns the RTT in milliseconds.
111 virtual int64_t GetRTT() const = 0;
112 virtual void StartSend() = 0;
113 virtual void StopSend() = 0;
Piotr (Peter) Slatala179a3922018-11-16 09:57:58 -0800114
Niels Möllerdced9f62018-11-19 10:27:07 +0100115 // E2EE Custom Audio Frame Encryption (Optional)
116 virtual void SetFrameEncryptor(
117 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
Niels Möller530ead42018-10-04 14:28:39 +0200118};
119
Niels Möllerdced9f62018-11-19 10:27:07 +0100120std::unique_ptr<ChannelSendInterface> CreateChannelSend(
Sebastian Jansson977b3352019-03-04 17:43:34 +0100121 Clock* clock,
Sebastian Jansson44dd9f22019-03-08 14:50:30 +0100122 TaskQueueFactory* task_queue_factory,
Niels Möllerdced9f62018-11-19 10:27:07 +0100123 ProcessThread* module_process_thread,
124 MediaTransportInterface* media_transport,
Anton Sukhanov626015d2019-02-04 15:16:06 -0800125 OverheadObserver* overhead_observer,
Niels Möllere9771992018-11-26 10:55:07 +0100126 Transport* rtp_transport,
Niels Möllerdced9f62018-11-19 10:27:07 +0100127 RtcpRttStats* rtcp_rtt_stats,
128 RtcEventLog* rtc_event_log,
129 FrameEncryptorInterface* frame_encryptor,
130 const webrtc::CryptoOptions& crypto_options,
131 bool extmap_allow_mixed,
132 int rtcp_report_interval_ms);
133
Niels Möller530ead42018-10-04 14:28:39 +0200134} // namespace voe
135} // namespace webrtc
136
137#endif // AUDIO_CHANNEL_SEND_H_