blob: a5f718509fc54d201ddc6783924d139b29cc6100 [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"
Benjamin Wrightbfb444c2018-10-15 10:20:24 -070020#include "api/crypto/cryptooptions.h"
Niels Möller7d76a312018-10-26 12:57:07 +020021#include "api/media_transport_interface.h"
Niels Möller530ead42018-10-04 14:28:39 +020022#include "modules/rtp_rtcp/include/rtp_rtcp.h"
Niels Möllerdced9f62018-11-19 10:27:07 +010023#include "rtc_base/function_view.h"
Niels Möller530ead42018-10-04 14:28:39 +020024#include "rtc_base/task_queue.h"
Niels Möller530ead42018-10-04 14:28:39 +020025
26namespace webrtc {
27
Benjamin Wright84583f62018-10-04 14:22:34 -070028class FrameEncryptorInterface;
Niels Möller530ead42018-10-04 14:28:39 +020029class ProcessThread;
Niels Möller530ead42018-10-04 14:28:39 +020030class RtcEventLog;
31class RtpRtcp;
32class RtpTransportControllerSendInterface;
33
Niels Möller530ead42018-10-04 14:28:39 +020034struct 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.
41struct 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
52namespace voe {
53
Niels Möllerdced9f62018-11-19 10:27:07 +010054class ChannelSendInterface {
Niels Möller530ead42018-10-04 14:28:39 +020055 public:
Niels Möllerdced9f62018-11-19 10:27:07 +010056 virtual ~ChannelSendInterface() = default;
Niels Möller530ead42018-10-04 14:28:39 +020057
Niels Möllerdced9f62018-11-19 10:27:07 +010058 virtual void RegisterTransport(Transport* transport) = 0;
59 virtual bool 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;
62 virtual void SetNACKStatus(bool enable, int max_packets) = 0;
Niels Möller530ead42018-10-04 14:28:39 +020063
Niels Möllerdced9f62018-11-19 10:27:07 +010064 virtual bool SetEncoder(int payload_type,
65 std::unique_ptr<AudioEncoder> encoder) = 0;
66 virtual void ModifyEncoder(
67 rtc::FunctionView<void(std::unique_ptr<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;
70 virtual void SetMid(const std::string& mid, int extension_id) = 0;
71 virtual void SetRTCP_CNAME(absl::string_view c_name) = 0;
72 virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0;
73 virtual void SetSendAudioLevelIndicationStatus(bool enable, int id) = 0;
74 virtual void EnableSendTransportSequenceNumber(int id) = 0;
75 virtual void RegisterSenderCongestionControlObjects(
Niels Möller530ead42018-10-04 14:28:39 +020076 RtpTransportControllerSendInterface* transport,
Niels Möllerdced9f62018-11-19 10:27:07 +010077 RtcpBandwidthObserver* bandwidth_observer) = 0;
78 virtual void ResetSenderCongestionControlObjects() = 0;
79 virtual std::vector<ReportBlock> GetRemoteRTCPReportBlocks() const = 0;
80 virtual ANAStats GetANAStatistics() const = 0;
81 virtual bool SetSendTelephoneEventPayloadType(int payload_type,
82 int payload_frequency) = 0;
83 virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0;
84 virtual void SetBitrate(int bitrate_bps, int64_t probing_interval_ms) = 0;
85 virtual int GetBitrate() const = 0;
86 virtual void SetInputMute(bool muted) = 0;
Niels Möller530ead42018-10-04 14:28:39 +020087
Niels Möllerdced9f62018-11-19 10:27:07 +010088 virtual void ProcessAndEncodeAudio(
89 std::unique_ptr<AudioFrame> audio_frame) = 0;
90 virtual void SetTransportOverhead(size_t transport_overhead_per_packet) = 0;
91 virtual RtpRtcp* GetRtpRtcp() const = 0;
Niels Möller530ead42018-10-04 14:28:39 +020092
Niels Möllerdced9f62018-11-19 10:27:07 +010093 virtual void OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) = 0;
94 virtual void OnRecoverableUplinkPacketLossRate(
95 float recoverable_packet_loss_rate) = 0;
Piotr (Peter) Slatala179a3922018-11-16 09:57:58 -080096 // In RTP we currently rely on RTCP packets (|ReceivedRTCPPacket|) to inform
97 // about RTT.
98 // In media transport we rely on the TargetTransferRateObserver instead.
99 // In other words, if you are using RTP, you should expect
100 // |ReceivedRTCPPacket| to be called, if you are using media transport,
101 // |OnTargetTransferRate| will be called.
102 //
103 // In future, RTP media will move to the media transport implementation and
104 // these conditions will be removed.
Niels Möllerdced9f62018-11-19 10:27:07 +0100105 // Returns the RTT in milliseconds.
106 virtual int64_t GetRTT() const = 0;
107 virtual void StartSend() = 0;
108 virtual void StopSend() = 0;
Piotr (Peter) Slatala179a3922018-11-16 09:57:58 -0800109
Niels Möllerdced9f62018-11-19 10:27:07 +0100110 // E2EE Custom Audio Frame Encryption (Optional)
111 virtual void SetFrameEncryptor(
112 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
Niels Möller530ead42018-10-04 14:28:39 +0200113};
114
Niels Möllerdced9f62018-11-19 10:27:07 +0100115std::unique_ptr<ChannelSendInterface> CreateChannelSend(
116 rtc::TaskQueue* encoder_queue,
117 ProcessThread* module_process_thread,
118 MediaTransportInterface* media_transport,
119 RtcpRttStats* rtcp_rtt_stats,
120 RtcEventLog* rtc_event_log,
121 FrameEncryptorInterface* frame_encryptor,
122 const webrtc::CryptoOptions& crypto_options,
123 bool extmap_allow_mixed,
124 int rtcp_report_interval_ms);
125
Niels Möller530ead42018-10-04 14:28:39 +0200126} // namespace voe
127} // namespace webrtc
128
129#endif // AUDIO_CHANNEL_SEND_H_