Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |
| 12 | #define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 13 | |
Danil Chapovalov | c44f6cc | 2019-03-06 11:31:09 +0100 | [diff] [blame] | 14 | #include <memory> |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 15 | #include <set> |
Peter Boström | 9c01725 | 2016-02-26 16:26:20 +0100 | [diff] [blame] | 16 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 17 | #include <utility> |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Fredrik Solenberg | 18f0c3c | 2018-12-06 11:49:35 +0100 | [diff] [blame] | 20 | #include "absl/strings/string_view.h" |
Danil Chapovalov | d264df5 | 2018-06-14 12:59:38 +0200 | [diff] [blame] | 21 | #include "absl/types/optional.h" |
Marina Ciocea | e77912b | 2020-02-27 16:16:55 +0100 | [diff] [blame] | 22 | #include "api/frame_transformer_interface.h" |
| 23 | #include "api/scoped_refptr.h" |
Per Kjellander | e11b7d2 | 2019-02-21 07:55:59 +0100 | [diff] [blame] | 24 | #include "api/transport/webrtc_key_value_config.h" |
Erik Språng | eeaa8f9 | 2018-05-17 12:35:56 +0200 | [diff] [blame] | 25 | #include "api/video/video_bitrate_allocation.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #include "modules/include/module.h" |
Niels Möller | 53382cb | 2018-11-27 14:05:08 +0100 | [diff] [blame] | 27 | #include "modules/rtp_rtcp/include/receive_statistics.h" |
Henrik Boström | 87e3f9d | 2019-05-27 10:44:24 +0200 | [diff] [blame] | 28 | #include "modules/rtp_rtcp/include/report_block_data.h" |
Erik Språng | aa59eca | 2019-07-24 14:52:55 +0200 | [diff] [blame] | 29 | #include "modules/rtp_rtcp/include/rtp_packet_sender.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 30 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Erik Språng | 58ee187 | 2019-06-18 16:20:11 +0200 | [diff] [blame] | 31 | #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" |
Erik Språng | 3663f94 | 2020-02-07 10:05:15 +0100 | [diff] [blame] | 32 | #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" |
Erik Språng | f87536c | 2020-03-05 10:14:04 +0100 | [diff] [blame] | 33 | #include "modules/rtp_rtcp/source/video_fec_generator.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 34 | #include "rtc_base/constructor_magic.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 35 | #include "rtc_base/deprecation.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 36 | |
| 37 | namespace webrtc { |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 38 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 39 | // Forward declarations. |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame] | 40 | class FrameEncryptorInterface; |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 41 | class OverheadObserver; |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 42 | class RateLimiter; |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 43 | class ReceiveStatisticsProvider; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 44 | class RemoteBitrateEstimator; |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 45 | class RtcEventLog; |
Erik Språng | 4580ca2 | 2019-07-04 10:38:43 +0200 | [diff] [blame] | 46 | class RTPSender; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 47 | class Transport; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 48 | class VideoBitrateAllocationObserver; |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 49 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 50 | namespace rtcp { |
| 51 | class TransportFeedback; |
| 52 | } |
| 53 | |
Danil Chapovalov | eb0edd8 | 2017-12-14 16:02:31 +0100 | [diff] [blame] | 54 | class RtpRtcp : public Module, public RtcpFeedbackSenderInterface { |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 55 | public: |
| 56 | struct Configuration { |
| 57 | Configuration(); |
Erik Språng | 4580ca2 | 2019-07-04 10:38:43 +0200 | [diff] [blame] | 58 | Configuration(Configuration&& rhs); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 59 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 60 | // True for a audio version of the RTP/RTCP module object false will create |
| 61 | // a video version. |
| 62 | bool audio = false; |
| 63 | bool receiver_only = false; |
| 64 | |
| 65 | // The clock to use to read time. If nullptr then system clock will be used. |
| 66 | Clock* clock = nullptr; |
| 67 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 68 | ReceiveStatisticsProvider* receive_statistics = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 69 | |
| 70 | // Transport object that will be called when packets are ready to be sent |
| 71 | // out on the network. |
| 72 | Transport* outgoing_transport = nullptr; |
| 73 | |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 74 | // Called when the receiver requests an intra frame. |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 75 | RtcpIntraFrameObserver* intra_frame_callback = nullptr; |
| 76 | |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 77 | // Called when the receiver sends a loss notification. |
| 78 | RtcpLossNotificationObserver* rtcp_loss_notification_observer = nullptr; |
| 79 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 80 | // Called when we receive a changed estimate from the receiver of out |
| 81 | // stream. |
| 82 | RtcpBandwidthObserver* bandwidth_callback = nullptr; |
| 83 | |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 84 | NetworkStateEstimateObserver* network_state_estimate_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 85 | TransportFeedbackObserver* transport_feedback_callback = nullptr; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 86 | VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 87 | RtcpRttStats* rtt_stats = nullptr; |
| 88 | RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr; |
Danil Chapovalov | bd74d5c | 2020-03-12 09:22:44 +0100 | [diff] [blame^] | 89 | // Called on receipt of RTCP report block from remote side. |
| 90 | // TODO(bugs.webrtc.org/10678): Remove RtcpStatisticsCallback in |
| 91 | // favor of ReportBlockDataObserver. |
| 92 | // TODO(bugs.webrtc.org/10679): Consider whether we want to use |
| 93 | // only getters or only callbacks. If we decide on getters, the |
| 94 | // ReportBlockDataObserver should also be removed in favor of |
| 95 | // GetLatestReportBlockData(). |
| 96 | RtcpStatisticsCallback* rtcp_statistics_callback = nullptr; |
| 97 | RtcpCnameCallback* rtcp_cname_callback = nullptr; |
| 98 | ReportBlockDataObserver* report_block_data_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 99 | |
| 100 | // Estimates the bandwidth available for a set of streams from the same |
| 101 | // client. |
| 102 | RemoteBitrateEstimator* remote_bitrate_estimator = nullptr; |
| 103 | |
| 104 | // Spread any bursts of packets into smaller bursts to minimize packet loss. |
Erik Språng | aa59eca | 2019-07-24 14:52:55 +0200 | [diff] [blame] | 105 | RtpPacketSender* paced_sender = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 106 | |
Erik Språng | f87536c | 2020-03-05 10:14:04 +0100 | [diff] [blame] | 107 | // Generates FEC packets. |
| 108 | // TODO(sprang): Wire up to RtpSenderEgress. |
| 109 | VideoFecGenerator* fec_generator = nullptr; |
brandtr | e950cad | 2016-11-15 05:25:41 -0800 | [diff] [blame] | 110 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 111 | BitrateStatisticsObserver* send_bitrate_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 112 | SendSideDelayObserver* send_side_delay_observer = nullptr; |
| 113 | RtcEventLog* event_log = nullptr; |
| 114 | SendPacketObserver* send_packet_observer = nullptr; |
| 115 | RateLimiter* retransmission_rate_limiter = nullptr; |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 116 | OverheadObserver* overhead_observer = nullptr; |
Erik Språng | 7ea9b80 | 2019-10-16 19:03:38 +0200 | [diff] [blame] | 117 | StreamDataCountersCallback* rtp_stats_callback = nullptr; |
Niels Möller | 5fe9510 | 2019-03-04 16:49:25 +0100 | [diff] [blame] | 118 | |
Jiawei Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 119 | int rtcp_report_interval_ms = 0; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 120 | |
Erik Språng | 7b52f10 | 2018-02-07 14:37:37 +0100 | [diff] [blame] | 121 | // Update network2 instead of pacer_exit field of video timing extension. |
| 122 | bool populate_network2_timestamp = false; |
| 123 | |
Marina Ciocea | e77912b | 2020-02-27 16:16:55 +0100 | [diff] [blame] | 124 | rtc::scoped_refptr<FrameTransformerInterface> frame_transformer; |
| 125 | |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame] | 126 | // E2EE Custom Video Frame Encryption |
| 127 | FrameEncryptorInterface* frame_encryptor = nullptr; |
| 128 | // Require all outgoing frames to be encrypted with a FrameEncryptor. |
| 129 | bool require_frame_encryption = false; |
| 130 | |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 131 | // Corresponds to extmap-allow-mixed in SDP negotiation. |
| 132 | bool extmap_allow_mixed = false; |
| 133 | |
Rasmus Brandt | ce588ae | 2020-03-10 14:12:48 +0100 | [diff] [blame] | 134 | // If true, the RTP sender will always annotate outgoing packets with |
| 135 | // MID and RID header extensions, if provided and negotiated. |
| 136 | // If false, the RTP sender will stop sending MID and RID header extensions, |
| 137 | // when it knows that the receiver is ready to demux based on SSRC. This is |
| 138 | // done by RTCP RR acking. |
| 139 | bool always_send_mid_and_rid = false; |
| 140 | |
Per Kjellander | e11b7d2 | 2019-02-21 07:55:59 +0100 | [diff] [blame] | 141 | // If set, field trials are read from |field_trials|, otherwise |
| 142 | // defaults to webrtc::FieldTrialBasedConfig. |
Per Kjellander | 19d0104 | 2019-02-24 20:04:14 +0100 | [diff] [blame] | 143 | const WebRtcKeyValueConfig* field_trials = nullptr; |
Per Kjellander | e11b7d2 | 2019-02-21 07:55:59 +0100 | [diff] [blame] | 144 | |
Erik Språng | 54d5d2c | 2019-08-20 17:22:36 +0200 | [diff] [blame] | 145 | // SSRCs for media and retransmission, respectively. |
Erik Språng | 4580ca2 | 2019-07-04 10:38:43 +0200 | [diff] [blame] | 146 | // FlexFec SSRC is fetched from |flexfec_sender|. |
Erik Språng | dbbf413 | 2019-10-18 10:34:25 +0200 | [diff] [blame] | 147 | uint32_t local_media_ssrc = 0; |
Erik Språng | 4580ca2 | 2019-07-04 10:38:43 +0200 | [diff] [blame] | 148 | absl::optional<uint32_t> rtx_send_ssrc; |
| 149 | |
Erik Språng | 3663f94 | 2020-02-07 10:05:15 +0100 | [diff] [blame] | 150 | bool need_rtp_packet_infos = false; |
| 151 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 152 | private: |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 153 | RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 154 | }; |
| 155 | |
Danil Chapovalov | c44f6cc | 2019-03-06 11:31:09 +0100 | [diff] [blame] | 156 | // Creates an RTP/RTCP module object using provided |configuration|. |
| 157 | static std::unique_ptr<RtpRtcp> Create(const Configuration& configuration); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 158 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 159 | // ************************************************************************** |
| 160 | // Receiver functions |
| 161 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 162 | |
nisse | 479d3d7 | 2017-09-13 07:53:37 -0700 | [diff] [blame] | 163 | virtual void IncomingRtcpPacket(const uint8_t* incoming_packet, |
| 164 | size_t incoming_packet_length) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 165 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 166 | virtual void SetRemoteSSRC(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 167 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 168 | // ************************************************************************** |
| 169 | // Sender |
| 170 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 171 | |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 172 | // Sets the maximum size of an RTP packet, including RTP headers. |
| 173 | virtual void SetMaxRtpPacketSize(size_t size) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 174 | |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 175 | // Returns max RTP packet size. Takes into account RTP headers and |
| 176 | // FEC/ULP/RED overhead (when FEC is enabled). |
| 177 | virtual size_t MaxRtpPacketSize() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 178 | |
Niels Möller | 5fe9510 | 2019-03-04 16:49:25 +0100 | [diff] [blame] | 179 | virtual void RegisterSendPayloadFrequency(int payload_type, |
| 180 | int payload_frequency) = 0; |
Peter Boström | 8b79b07 | 2016-02-26 16:31:37 +0100 | [diff] [blame] | 181 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 182 | // Unregisters a send payload. |
| 183 | // |payload_type| - payload type of codec |
| 184 | // Returns -1 on failure else 0. |
| 185 | virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 186 | |
Johannes Kron | 9190b82 | 2018-10-29 11:22:05 +0100 | [diff] [blame] | 187 | virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0; |
| 188 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 189 | // (De)registers RTP header extension type and id. |
| 190 | // Returns -1 on failure else 0. |
Sebastian Jansson | f39c815 | 2019-10-14 17:32:21 +0200 | [diff] [blame] | 191 | RTC_DEPRECATED virtual int32_t RegisterSendRtpHeaderExtension( |
| 192 | RTPExtensionType type, |
| 193 | uint8_t id) = 0; |
| 194 | // Register extension by uri, triggers CHECK on falure. |
| 195 | virtual void RegisterRtpHeaderExtension(absl::string_view uri, int id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 196 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 197 | virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0; |
Sebastian Jansson | f39c815 | 2019-10-14 17:32:21 +0200 | [diff] [blame] | 198 | virtual void DeregisterSendRtpHeaderExtension(absl::string_view uri) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 199 | |
Mirko Bonadei | 999a72a | 2019-07-12 17:33:46 +0000 | [diff] [blame] | 200 | // Returns true if RTP module is send media, and any of the extensions |
| 201 | // required for bandwidth estimation is registered. |
| 202 | virtual bool SupportsPadding() const = 0; |
| 203 | // Same as SupportsPadding(), but additionally requires that |
| 204 | // SetRtxSendStatus() has been called with the kRtxRedundantPayloads option |
| 205 | // enabled. |
| 206 | virtual bool SupportsRtxPayloadPadding() const = 0; |
stefan | 53b6cc3 | 2017-02-03 08:13:57 -0800 | [diff] [blame] | 207 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 208 | // Returns start timestamp. |
| 209 | virtual uint32_t StartTimestamp() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 210 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 211 | // Sets start timestamp. Start timestamp is set to a random value if this |
| 212 | // function is never called. |
| 213 | virtual void SetStartTimestamp(uint32_t timestamp) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 214 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 215 | // Returns SequenceNumber. |
| 216 | virtual uint16_t SequenceNumber() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 217 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 218 | // Sets SequenceNumber, default is a random number. |
| 219 | virtual void SetSequenceNumber(uint16_t seq) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 220 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 221 | virtual void SetRtpState(const RtpState& rtp_state) = 0; |
| 222 | virtual void SetRtxState(const RtpState& rtp_state) = 0; |
| 223 | virtual RtpState GetRtpState() const = 0; |
| 224 | virtual RtpState GetRtxState() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 225 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 226 | // Returns SSRC. |
Per Kjellander | b11c411 | 2019-10-16 10:41:32 +0200 | [diff] [blame] | 227 | virtual uint32_t SSRC() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 228 | |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 229 | // Sets the value for sending in the RID (and Repaired) RTP header extension. |
| 230 | // RIDs are used to identify an RTP stream if SSRCs are not negotiated. |
| 231 | // If the RID and Repaired RID extensions are not registered, the RID will |
| 232 | // not be sent. |
| 233 | virtual void SetRid(const std::string& rid) = 0; |
| 234 | |
Steve Anton | 296a0ce | 2018-03-22 15:17:27 -0700 | [diff] [blame] | 235 | // Sets the value for sending in the MID RTP header extension. |
| 236 | // The MID RTP header extension should be registered for this to do anything. |
| 237 | // Once set, this value can not be changed or removed. |
| 238 | virtual void SetMid(const std::string& mid) = 0; |
| 239 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 240 | // Sets CSRC. |
| 241 | // |csrcs| - vector of CSRCs |
| 242 | virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 243 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 244 | // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination |
| 245 | // of values of the enumerator RtxMode. |
| 246 | virtual void SetRtxSendStatus(int modes) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 247 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 248 | // Returns status of sending RTX (RFC 4588). The returned value can be |
| 249 | // a combination of values of the enumerator RtxMode. |
| 250 | virtual int RtxSendStatus() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 251 | |
Erik Språng | c06aef2 | 2019-10-17 13:02:27 +0200 | [diff] [blame] | 252 | // Returns the SSRC used for RTX if set, otherwise a nullopt. |
| 253 | virtual absl::optional<uint32_t> RtxSsrc() const = 0; |
| 254 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 255 | // Sets the payload type to use when sending RTX packets. Note that this |
| 256 | // doesn't enable RTX, only the payload type is set. |
| 257 | virtual void SetRtxSendPayloadType(int payload_type, |
| 258 | int associated_payload_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 259 | |
brandtr | 9dfff29 | 2016-11-14 05:14:50 -0800 | [diff] [blame] | 260 | // Returns the FlexFEC SSRC, if there is one. |
Danil Chapovalov | d264df5 | 2018-06-14 12:59:38 +0200 | [diff] [blame] | 261 | virtual absl::optional<uint32_t> FlexfecSsrc() const = 0; |
brandtr | 9dfff29 | 2016-11-14 05:14:50 -0800 | [diff] [blame] | 262 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 263 | // Sets sending status. Sends kRtcpByeCode when going from true to false. |
| 264 | // Returns -1 on failure else 0. |
| 265 | virtual int32_t SetSendingStatus(bool sending) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 266 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 267 | // Returns current sending status. |
| 268 | virtual bool Sending() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 269 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 270 | // Starts/Stops media packets. On by default. |
| 271 | virtual void SetSendingMediaStatus(bool sending) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 272 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 273 | // Returns current media sending status. |
| 274 | virtual bool SendingMedia() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 275 | |
Erik Språng | 1e51a38 | 2019-12-11 16:47:09 +0100 | [diff] [blame] | 276 | // Returns whether audio is configured (i.e. Configuration::audio = true). |
| 277 | virtual bool IsAudioConfigured() const = 0; |
| 278 | |
Sebastian Jansson | 1bca65b | 2018-10-10 09:58:08 +0200 | [diff] [blame] | 279 | // Indicate that the packets sent by this module should be counted towards the |
| 280 | // bitrate estimate since the stream participates in the bitrate allocation. |
| 281 | virtual void SetAsPartOfAllocation(bool part_of_allocation) = 0; |
| 282 | |
Erik Språng | 482b3ef | 2019-01-08 16:19:11 +0100 | [diff] [blame] | 283 | // Fetches the current send bitrates in bits/s. |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 284 | virtual void BitrateSent(uint32_t* total_rate, |
| 285 | uint32_t* video_rate, |
| 286 | uint32_t* fec_rate, |
| 287 | uint32_t* nack_rate) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 288 | |
Niels Möller | 5fe9510 | 2019-03-04 16:49:25 +0100 | [diff] [blame] | 289 | virtual RTPSender* RtpSender() = 0; |
| 290 | virtual const RTPSender* RtpSender() const = 0; |
Erik Språng | 482b3ef | 2019-01-08 16:19:11 +0100 | [diff] [blame] | 291 | |
Niels Möller | 5fe9510 | 2019-03-04 16:49:25 +0100 | [diff] [blame] | 292 | // Record that a frame is about to be sent. Returns true on success, and false |
| 293 | // if the module isn't ready to send. |
| 294 | virtual bool OnSendingRtpFrame(uint32_t timestamp, |
| 295 | int64_t capture_time_ms, |
| 296 | int payload_type, |
| 297 | bool force_sender_report) = 0; |
| 298 | |
Erik Språng | 9c771c2 | 2019-06-17 16:31:53 +0200 | [diff] [blame] | 299 | // Try to send the provided packet. Returns true iff packet matches any of |
| 300 | // the SSRCs for this module (media/rtx/fec etc) and was forwarded to the |
| 301 | // transport. |
| 302 | virtual bool TrySendPacket(RtpPacketToSend* packet, |
| 303 | const PacedPacketInfo& pacing_info) = 0; |
| 304 | |
Erik Språng | a922904 | 2019-10-24 12:39:32 +0200 | [diff] [blame] | 305 | virtual void OnPacketsAcknowledged( |
| 306 | rtc::ArrayView<const uint16_t> sequence_numbers) = 0; |
| 307 | |
Erik Språng | f6468d2 | 2019-07-05 16:53:43 +0200 | [diff] [blame] | 308 | virtual std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding( |
| 309 | size_t target_size_bytes) = 0; |
Erik Språng | 478cb46 | 2019-06-26 15:49:27 +0200 | [diff] [blame] | 310 | |
Erik Språng | 3663f94 | 2020-02-07 10:05:15 +0100 | [diff] [blame] | 311 | virtual std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos( |
| 312 | rtc::ArrayView<const uint16_t> sequence_numbers) const = 0; |
| 313 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 314 | // ************************************************************************** |
| 315 | // RTCP |
| 316 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 317 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 318 | // Returns RTCP status. |
| 319 | virtual RtcpMode RTCP() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 320 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 321 | // Sets RTCP status i.e on(compound or non-compound)/off. |
| 322 | // |method| - RTCP method to use. |
| 323 | virtual void SetRTCPStatus(RtcpMode method) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 324 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 325 | // Sets RTCP CName (i.e unique identifier). |
| 326 | // Returns -1 on failure else 0. |
| 327 | virtual int32_t SetCNAME(const char* cname) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 328 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 329 | // Returns remote CName. |
| 330 | // Returns -1 on failure else 0. |
| 331 | virtual int32_t RemoteCNAME(uint32_t remote_ssrc, |
| 332 | char cname[RTCP_CNAME_SIZE]) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 333 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 334 | // Returns remote NTP. |
| 335 | // Returns -1 on failure else 0. |
| 336 | virtual int32_t RemoteNTP(uint32_t* received_ntp_secs, |
| 337 | uint32_t* received_ntp_frac, |
| 338 | uint32_t* rtcp_arrival_time_secs, |
| 339 | uint32_t* rtcp_arrival_time_frac, |
| 340 | uint32_t* rtcp_timestamp) const = 0; |
| 341 | |
| 342 | // Returns -1 on failure else 0. |
| 343 | virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 344 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 345 | // Returns -1 on failure else 0. |
| 346 | virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 347 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 348 | // Returns current RTT (round-trip time) estimate. |
| 349 | // Returns -1 on failure else 0. |
| 350 | virtual int32_t RTT(uint32_t remote_ssrc, |
| 351 | int64_t* rtt, |
| 352 | int64_t* avg_rtt, |
| 353 | int64_t* min_rtt, |
| 354 | int64_t* max_rtt) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 355 | |
Niels Möller | 5fe9510 | 2019-03-04 16:49:25 +0100 | [diff] [blame] | 356 | // Returns the estimated RTT, with fallback to a default value. |
| 357 | virtual int64_t ExpectedRetransmissionTimeMs() const = 0; |
| 358 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 359 | // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the |
| 360 | // process function. |
| 361 | // Returns -1 on failure else 0. |
| 362 | virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 363 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 364 | // Returns statistics of the amount of data sent. |
| 365 | // Returns -1 on failure else 0. |
| 366 | virtual int32_t DataCountersRTP(size_t* bytes_sent, |
| 367 | uint32_t* packets_sent) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 368 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 369 | // Returns send statistics for the RTP and RTX stream. |
| 370 | virtual void GetSendStreamDataCounters( |
| 371 | StreamDataCounters* rtp_counters, |
| 372 | StreamDataCounters* rtx_counters) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 373 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 374 | // Returns received RTCP report block. |
| 375 | // Returns -1 on failure else 0. |
Henrik Boström | 6e436d1 | 2019-05-27 12:19:33 +0200 | [diff] [blame] | 376 | // TODO(https://crbug.com/webrtc/10678): Remove this in favor of |
| 377 | // GetLatestReportBlockData(). |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 378 | virtual int32_t RemoteRTCPStat( |
| 379 | std::vector<RTCPReportBlock>* receive_blocks) const = 0; |
Henrik Boström | 6e436d1 | 2019-05-27 12:19:33 +0200 | [diff] [blame] | 380 | // A snapshot of Report Blocks with additional data of interest to statistics. |
| 381 | // Within this list, the sender-source SSRC pair is unique and per-pair the |
| 382 | // ReportBlockData represents the latest Report Block that was received for |
| 383 | // that pair. |
| 384 | virtual std::vector<ReportBlockData> GetLatestReportBlockData() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 385 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 386 | // (APP) Sets application specific data. |
| 387 | // Returns -1 on failure else 0. |
| 388 | virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type, |
| 389 | uint32_t name, |
| 390 | const uint8_t* data, |
| 391 | uint16_t length) = 0; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 392 | // (XR) Sets Receiver Reference Time Report (RTTR) status. |
| 393 | virtual void SetRtcpXrRrtrStatus(bool enable) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 394 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 395 | // Returns current Receiver Reference Time Report (RTTR) status. |
| 396 | virtual bool RtcpXrRrtrStatus() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 397 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 398 | // (REMB) Receiver Estimated Max Bitrate. |
Danil Chapovalov | 51e21aa | 2017-10-10 17:46:26 +0200 | [diff] [blame] | 399 | // Schedules sending REMB on next and following sender/receiver reports. |
Danil Chapovalov | eb0edd8 | 2017-12-14 16:02:31 +0100 | [diff] [blame] | 400 | void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) override = 0; |
Danil Chapovalov | 51e21aa | 2017-10-10 17:46:26 +0200 | [diff] [blame] | 401 | // Stops sending REMB on next and following sender/receiver reports. |
Danil Chapovalov | eb0edd8 | 2017-12-14 16:02:31 +0100 | [diff] [blame] | 402 | void UnsetRemb() override = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 403 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 404 | // (TMMBR) Temporary Max Media Bit Rate |
| 405 | virtual bool TMMBR() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 406 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 407 | virtual void SetTMMBRStatus(bool enable) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 408 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 409 | // (NACK) |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 410 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 411 | // Sends a Negative acknowledgement packet. |
| 412 | // Returns -1 on failure else 0. |
| 413 | // TODO(philipel): Deprecate this and start using SendNack instead, mostly |
| 414 | // because we want a function that actually send NACK for the specified |
| 415 | // packets. |
| 416 | virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 417 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 418 | // Sends NACK for the packets specified. |
| 419 | // Note: This assumes the caller keeps track of timing and doesn't rely on |
| 420 | // the RTP module to do this. |
| 421 | virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 422 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 423 | // Store the sent packets, needed to answer to a Negative acknowledgment |
| 424 | // requests. |
| 425 | virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0; |
philipel | 83f831a | 2016-03-12 03:30:23 -0800 | [diff] [blame] | 426 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 427 | // Returns true if the module is configured to store packets. |
| 428 | virtual bool StorePackets() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 429 | |
Erik Språng | 566124a | 2018-04-23 12:32:22 +0200 | [diff] [blame] | 430 | virtual void SetVideoBitrateAllocation( |
| 431 | const VideoBitrateAllocation& bitrate) = 0; |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 432 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 433 | // ************************************************************************** |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 434 | // Video |
| 435 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 436 | |
Niels Möller | dd0094a | 2019-06-04 14:46:27 +0200 | [diff] [blame] | 437 | // Requests new key frame. |
| 438 | // using PLI, https://tools.ietf.org/html/rfc4585#section-6.3.1.1 |
| 439 | void SendPictureLossIndication() { SendRTCP(kRtcpPli); } |
| 440 | // using FIR, https://tools.ietf.org/html/rfc5104#section-4.3.1.2 |
| 441 | void SendFullIntraRequest() { SendRTCP(kRtcpFir); } |
| 442 | |
Elad Alon | 7d6a4c0 | 2019-02-25 13:00:51 +0100 | [diff] [blame] | 443 | // Sends a LossNotification RTCP message. |
| 444 | // Returns -1 on failure else 0. |
| 445 | virtual int32_t SendLossNotification(uint16_t last_decoded_seq_num, |
| 446 | uint16_t last_received_seq_num, |
Elad Alon | e86af2c | 2019-06-03 14:37:50 +0200 | [diff] [blame] | 447 | bool decodability_flag, |
| 448 | bool buffering_allowed) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 449 | }; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 450 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 451 | } // namespace webrtc |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 452 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 453 | #endif // MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |