Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020 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 MODULES_RTP_RTCP_SOURCE_RTP_RTCP_INTERFACE_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTP_RTCP_INTERFACE_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
Ali Tofigh | d14e889 | 2022-05-13 09:42:16 | [diff] [blame] | 18 | #include "absl/strings/string_view.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 20 | #include "api/field_trials_view.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 21 | #include "api/frame_transformer_interface.h" |
| 22 | #include "api/scoped_refptr.h" |
Danil Chapovalov | 630c40d | 2023-07-17 14:42:45 | [diff] [blame] | 23 | #include "api/units/time_delta.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 24 | #include "api/video/video_bitrate_allocation.h" |
| 25 | #include "modules/rtp_rtcp/include/receive_statistics.h" |
| 26 | #include "modules/rtp_rtcp/include/report_block_data.h" |
| 27 | #include "modules/rtp_rtcp/include/rtp_packet_sender.h" |
| 28 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 29 | #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" |
| 30 | #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" |
| 31 | #include "modules/rtp_rtcp/source/video_fec_generator.h" |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 32 | #include "system_wrappers/include/ntp_time.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 33 | |
| 34 | namespace webrtc { |
| 35 | |
| 36 | // Forward declarations. |
| 37 | class FrameEncryptorInterface; |
| 38 | class RateLimiter; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 39 | class RtcEventLog; |
| 40 | class RTPSender; |
| 41 | class Transport; |
| 42 | class VideoBitrateAllocationObserver; |
| 43 | |
| 44 | class RtpRtcpInterface : public RtcpFeedbackSenderInterface { |
| 45 | public: |
| 46 | struct Configuration { |
| 47 | Configuration() = default; |
| 48 | Configuration(Configuration&& rhs) = default; |
| 49 | |
Byoungchan Lee | 604fd2f | 2022-01-21 00:49:39 | [diff] [blame] | 50 | Configuration(const Configuration&) = delete; |
| 51 | Configuration& operator=(const Configuration&) = delete; |
| 52 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 53 | // True for a audio version of the RTP/RTCP module object false will create |
| 54 | // a video version. |
| 55 | bool audio = false; |
| 56 | bool receiver_only = false; |
| 57 | |
| 58 | // The clock to use to read time. If nullptr then system clock will be used. |
| 59 | Clock* clock = nullptr; |
| 60 | |
| 61 | ReceiveStatisticsProvider* receive_statistics = nullptr; |
| 62 | |
| 63 | // Transport object that will be called when packets are ready to be sent |
| 64 | // out on the network. |
| 65 | Transport* outgoing_transport = nullptr; |
| 66 | |
| 67 | // Called when the receiver requests an intra frame. |
| 68 | RtcpIntraFrameObserver* intra_frame_callback = nullptr; |
| 69 | |
| 70 | // Called when the receiver sends a loss notification. |
| 71 | RtcpLossNotificationObserver* rtcp_loss_notification_observer = nullptr; |
| 72 | |
Danil Chapovalov | 5251863 | 2023-05-09 15:11:49 | [diff] [blame] | 73 | // Called when receive an RTCP message related to the link in general, e.g. |
| 74 | // bandwidth estimation related message. |
| 75 | NetworkLinkRtcpObserver* network_link_rtcp_observer = nullptr; |
| 76 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 77 | NetworkStateEstimateObserver* network_state_estimate_observer = nullptr; |
| 78 | TransportFeedbackObserver* transport_feedback_callback = nullptr; |
| 79 | VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr; |
| 80 | RtcpRttStats* rtt_stats = nullptr; |
| 81 | RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr; |
| 82 | // Called on receipt of RTCP report block from remote side. |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 83 | // TODO(bugs.webrtc.org/10679): Consider whether we want to use |
| 84 | // only getters or only callbacks. If we decide on getters, the |
| 85 | // ReportBlockDataObserver should also be removed in favor of |
| 86 | // GetLatestReportBlockData(). |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 87 | RtcpCnameCallback* rtcp_cname_callback = nullptr; |
| 88 | ReportBlockDataObserver* report_block_data_observer = nullptr; |
| 89 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 90 | // Spread any bursts of packets into smaller bursts to minimize packet loss. |
| 91 | RtpPacketSender* paced_sender = nullptr; |
| 92 | |
| 93 | // Generates FEC packets. |
| 94 | // TODO(sprang): Wire up to RtpSenderEgress. |
| 95 | VideoFecGenerator* fec_generator = nullptr; |
| 96 | |
| 97 | BitrateStatisticsObserver* send_bitrate_observer = nullptr; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 98 | RtcEventLog* event_log = nullptr; |
| 99 | SendPacketObserver* send_packet_observer = nullptr; |
| 100 | RateLimiter* retransmission_rate_limiter = nullptr; |
| 101 | StreamDataCountersCallback* rtp_stats_callback = nullptr; |
| 102 | |
| 103 | int rtcp_report_interval_ms = 0; |
| 104 | |
| 105 | // Update network2 instead of pacer_exit field of video timing extension. |
| 106 | bool populate_network2_timestamp = false; |
| 107 | |
| 108 | rtc::scoped_refptr<FrameTransformerInterface> frame_transformer; |
| 109 | |
| 110 | // E2EE Custom Video Frame Encryption |
| 111 | FrameEncryptorInterface* frame_encryptor = nullptr; |
| 112 | // Require all outgoing frames to be encrypted with a FrameEncryptor. |
| 113 | bool require_frame_encryption = false; |
| 114 | |
| 115 | // Corresponds to extmap-allow-mixed in SDP negotiation. |
| 116 | bool extmap_allow_mixed = false; |
| 117 | |
| 118 | // If true, the RTP sender will always annotate outgoing packets with |
| 119 | // MID and RID header extensions, if provided and negotiated. |
| 120 | // If false, the RTP sender will stop sending MID and RID header extensions, |
| 121 | // when it knows that the receiver is ready to demux based on SSRC. This is |
| 122 | // done by RTCP RR acking. |
| 123 | bool always_send_mid_and_rid = false; |
| 124 | |
Danil Chapovalov | 7bb9322 | 2023-03-24 16:10:31 | [diff] [blame] | 125 | // If set, field trials are read from `field_trials`. |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 126 | const FieldTrialsView* field_trials = nullptr; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 127 | |
| 128 | // SSRCs for media and retransmission, respectively. |
Artem Titov | 913cfa7 | 2021-07-28 21:57:33 | [diff] [blame] | 129 | // FlexFec SSRC is fetched from `flexfec_sender`. |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 130 | uint32_t local_media_ssrc = 0; |
| 131 | absl::optional<uint32_t> rtx_send_ssrc; |
| 132 | |
| 133 | bool need_rtp_packet_infos = false; |
| 134 | |
Niels Möller | be810cba | 2020-12-02 13:25:03 | [diff] [blame] | 135 | // Estimate RTT as non-sender as described in |
| 136 | // https://tools.ietf.org/html/rfc3611#section-4.4 and #section-4.5 |
| 137 | bool non_sender_rtt_measurement = false; |
Niels Möller | af785d9 | 2022-05-31 08:45:41 | [diff] [blame] | 138 | |
| 139 | // If non-empty, sets the value for sending in the RID (and Repaired) RTP |
| 140 | // header extension. RIDs are used to identify an RTP stream if SSRCs are |
| 141 | // not negotiated. If the RID and Repaired RID extensions are not |
| 142 | // registered, the RID will not be sent. |
| 143 | std::string rid; |
Markus Handell | c8c4a28 | 2023-05-08 14:46:21 | [diff] [blame] | 144 | |
| 145 | // Enables send packet batching from the egress RTP sender. |
| 146 | bool enable_send_packet_batching = false; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 147 | }; |
| 148 | |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 149 | // Stats for RTCP sender reports (SR) for a specific SSRC. |
| 150 | // Refer to https://tools.ietf.org/html/rfc3550#section-6.4.1. |
| 151 | struct SenderReportStats { |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 152 | // Arrival NTP timestamp for the last received RTCP SR. |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 153 | NtpTime last_arrival_timestamp; |
| 154 | // Received (a.k.a., remote) NTP timestamp for the last received RTCP SR. |
| 155 | NtpTime last_remote_timestamp; |
Danil Chapovalov | 9f39721 | 2023-02-27 18:49:31 | [diff] [blame] | 156 | // Received (a.k.a., remote) RTP timestamp from the last received RTCP SR. |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 157 | uint32_t last_remote_rtp_timestamp = 0; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 158 | // Total number of RTP data packets transmitted by the sender since starting |
| 159 | // transmission up until the time this SR packet was generated. The count |
| 160 | // should be reset if the sender changes its SSRC identifier. |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 161 | uint32_t packets_sent = 0; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 162 | // Total number of payload octets (i.e., not including header or padding) |
| 163 | // transmitted in RTP data packets by the sender since starting transmission |
| 164 | // up until the time this SR packet was generated. The count should be reset |
| 165 | // if the sender changes its SSRC identifier. |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 166 | uint64_t bytes_sent = 0; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 167 | // Total number of RTCP SR blocks received. |
| 168 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-reportssent. |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 169 | uint64_t reports_count = 0; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 170 | }; |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 171 | // Stats about the non-sender SSRC, based on RTCP extended reports (XR). |
| 172 | // Refer to https://datatracker.ietf.org/doc/html/rfc3611#section-2. |
| 173 | struct NonSenderRttStats { |
| 174 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime |
| 175 | absl::optional<TimeDelta> round_trip_time; |
| 176 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime |
| 177 | TimeDelta total_round_trip_time = TimeDelta::Zero(); |
| 178 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements |
| 179 | int round_trip_time_measurements = 0; |
| 180 | }; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 181 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 182 | // ************************************************************************** |
| 183 | // Receiver functions |
| 184 | // ************************************************************************** |
| 185 | |
Harald Alvestrand | 1f206b8 | 2023-02-01 11:12:46 | [diff] [blame] | 186 | virtual void IncomingRtcpPacket( |
| 187 | rtc::ArrayView<const uint8_t> incoming_packet) = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 188 | |
| 189 | virtual void SetRemoteSSRC(uint32_t ssrc) = 0; |
| 190 | |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 191 | // Called when the local ssrc changes (post initialization) for receive |
| 192 | // streams to match with send. Called on the packet receive thread/tq. |
| 193 | virtual void SetLocalSsrc(uint32_t ssrc) = 0; |
| 194 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 195 | // ************************************************************************** |
| 196 | // Sender |
| 197 | // ************************************************************************** |
| 198 | |
| 199 | // Sets the maximum size of an RTP packet, including RTP headers. |
| 200 | virtual void SetMaxRtpPacketSize(size_t size) = 0; |
| 201 | |
| 202 | // Returns max RTP packet size. Takes into account RTP headers and |
| 203 | // FEC/ULP/RED overhead (when FEC is enabled). |
| 204 | virtual size_t MaxRtpPacketSize() const = 0; |
| 205 | |
| 206 | virtual void RegisterSendPayloadFrequency(int payload_type, |
| 207 | int payload_frequency) = 0; |
| 208 | |
| 209 | // Unregisters a send payload. |
Artem Titov | 913cfa7 | 2021-07-28 21:57:33 | [diff] [blame] | 210 | // `payload_type` - payload type of codec |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 211 | // Returns -1 on failure else 0. |
| 212 | virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0; |
| 213 | |
| 214 | virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0; |
| 215 | |
| 216 | // Register extension by uri, triggers CHECK on falure. |
| 217 | virtual void RegisterRtpHeaderExtension(absl::string_view uri, int id) = 0; |
| 218 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 219 | virtual void DeregisterSendRtpHeaderExtension(absl::string_view uri) = 0; |
| 220 | |
| 221 | // Returns true if RTP module is send media, and any of the extensions |
| 222 | // required for bandwidth estimation is registered. |
| 223 | virtual bool SupportsPadding() const = 0; |
| 224 | // Same as SupportsPadding(), but additionally requires that |
| 225 | // SetRtxSendStatus() has been called with the kRtxRedundantPayloads option |
| 226 | // enabled. |
| 227 | virtual bool SupportsRtxPayloadPadding() const = 0; |
| 228 | |
| 229 | // Returns start timestamp. |
| 230 | virtual uint32_t StartTimestamp() const = 0; |
| 231 | |
| 232 | // Sets start timestamp. Start timestamp is set to a random value if this |
| 233 | // function is never called. |
| 234 | virtual void SetStartTimestamp(uint32_t timestamp) = 0; |
| 235 | |
| 236 | // Returns SequenceNumber. |
| 237 | virtual uint16_t SequenceNumber() const = 0; |
| 238 | |
| 239 | // Sets SequenceNumber, default is a random number. |
| 240 | virtual void SetSequenceNumber(uint16_t seq) = 0; |
| 241 | |
| 242 | virtual void SetRtpState(const RtpState& rtp_state) = 0; |
| 243 | virtual void SetRtxState(const RtpState& rtp_state) = 0; |
| 244 | virtual RtpState GetRtpState() const = 0; |
| 245 | virtual RtpState GetRtxState() const = 0; |
| 246 | |
Ivo Creusen | 8c40d51 | 2021-07-13 12:53:22 | [diff] [blame] | 247 | // This can be used to enable/disable receive-side RTT. |
| 248 | virtual void SetNonSenderRttMeasurement(bool enabled) = 0; |
| 249 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 250 | // Returns SSRC. |
| 251 | virtual uint32_t SSRC() const = 0; |
| 252 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 253 | // Sets the value for sending in the MID RTP header extension. |
| 254 | // The MID RTP header extension should be registered for this to do anything. |
| 255 | // Once set, this value can not be changed or removed. |
Ali Tofigh | d14e889 | 2022-05-13 09:42:16 | [diff] [blame] | 256 | virtual void SetMid(absl::string_view mid) = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 257 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 258 | // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination |
| 259 | // of values of the enumerator RtxMode. |
| 260 | virtual void SetRtxSendStatus(int modes) = 0; |
| 261 | |
| 262 | // Returns status of sending RTX (RFC 4588). The returned value can be |
| 263 | // a combination of values of the enumerator RtxMode. |
| 264 | virtual int RtxSendStatus() const = 0; |
| 265 | |
| 266 | // Returns the SSRC used for RTX if set, otherwise a nullopt. |
| 267 | virtual absl::optional<uint32_t> RtxSsrc() const = 0; |
| 268 | |
| 269 | // Sets the payload type to use when sending RTX packets. Note that this |
| 270 | // doesn't enable RTX, only the payload type is set. |
| 271 | virtual void SetRtxSendPayloadType(int payload_type, |
| 272 | int associated_payload_type) = 0; |
| 273 | |
| 274 | // Returns the FlexFEC SSRC, if there is one. |
| 275 | virtual absl::optional<uint32_t> FlexfecSsrc() const = 0; |
| 276 | |
Philipp Hancke | 8602f60 | 2022-08-30 17:53:47 | [diff] [blame] | 277 | // Sets sending status. |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 278 | // Returns -1 on failure else 0. |
| 279 | virtual int32_t SetSendingStatus(bool sending) = 0; |
| 280 | |
| 281 | // Returns current sending status. |
| 282 | virtual bool Sending() const = 0; |
| 283 | |
| 284 | // Starts/Stops media packets. On by default. |
| 285 | virtual void SetSendingMediaStatus(bool sending) = 0; |
| 286 | |
| 287 | // Returns current media sending status. |
| 288 | virtual bool SendingMedia() const = 0; |
| 289 | |
| 290 | // Returns whether audio is configured (i.e. Configuration::audio = true). |
| 291 | virtual bool IsAudioConfigured() const = 0; |
| 292 | |
| 293 | // Indicate that the packets sent by this module should be counted towards the |
| 294 | // bitrate estimate since the stream participates in the bitrate allocation. |
| 295 | virtual void SetAsPartOfAllocation(bool part_of_allocation) = 0; |
| 296 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 297 | // Returns bitrate sent (post-pacing) per packet type. |
| 298 | virtual RtpSendRates GetSendRates() const = 0; |
| 299 | |
| 300 | virtual RTPSender* RtpSender() = 0; |
| 301 | virtual const RTPSender* RtpSender() const = 0; |
| 302 | |
| 303 | // Record that a frame is about to be sent. Returns true on success, and false |
| 304 | // if the module isn't ready to send. |
| 305 | virtual bool OnSendingRtpFrame(uint32_t timestamp, |
| 306 | int64_t capture_time_ms, |
| 307 | int payload_type, |
| 308 | bool force_sender_report) = 0; |
| 309 | |
| 310 | // Try to send the provided packet. Returns true iff packet matches any of |
| 311 | // the SSRCs for this module (media/rtx/fec etc) and was forwarded to the |
| 312 | // transport. |
Markus Handell | cb838e2 | 2023-05-05 12:41:30 | [diff] [blame] | 313 | virtual bool TrySendPacket(std::unique_ptr<RtpPacketToSend> packet, |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 314 | const PacedPacketInfo& pacing_info) = 0; |
| 315 | |
Markus Handell | c8c4a28 | 2023-05-08 14:46:21 | [diff] [blame] | 316 | // Notifies that a batch of packet sends is completed. The implementation can |
| 317 | // use this to optimize packet sending. |
| 318 | virtual void OnBatchComplete() = 0; |
| 319 | |
Erik Språng | 1d50cb6 | 2020-07-02 15:41:32 | [diff] [blame] | 320 | // Update the FEC protection parameters to use for delta- and key-frames. |
| 321 | // Only used when deferred FEC is active. |
| 322 | virtual void SetFecProtectionParams( |
| 323 | const FecProtectionParams& delta_params, |
| 324 | const FecProtectionParams& key_params) = 0; |
| 325 | |
| 326 | // If deferred FEC generation is enabled, this method should be called after |
| 327 | // calling TrySendPacket(). Any generated FEC packets will be removed and |
| 328 | // returned from the FEC generator. |
| 329 | virtual std::vector<std::unique_ptr<RtpPacketToSend>> FetchFecPackets() = 0; |
| 330 | |
Erik Språng | 5045949 | 2022-09-08 14:53:06 | [diff] [blame] | 331 | virtual void OnAbortedRetransmissions( |
| 332 | rtc::ArrayView<const uint16_t> sequence_numbers) = 0; |
| 333 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 334 | virtual void OnPacketsAcknowledged( |
| 335 | rtc::ArrayView<const uint16_t> sequence_numbers) = 0; |
| 336 | |
| 337 | virtual std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding( |
| 338 | size_t target_size_bytes) = 0; |
| 339 | |
| 340 | virtual std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos( |
| 341 | rtc::ArrayView<const uint16_t> sequence_numbers) const = 0; |
| 342 | |
| 343 | // Returns an expected per packet overhead representing the main RTP header, |
| 344 | // any CSRCs, and the registered header extensions that are expected on all |
| 345 | // packets (i.e. disregarding things like abs capture time which is only |
| 346 | // populated on a subset of packets, but counting MID/RID type extensions |
| 347 | // when we expect to send them). |
| 348 | virtual size_t ExpectedPerPacketOverhead() const = 0; |
| 349 | |
Erik Språng | b6bbdeb | 2021-08-13 14:12:41 | [diff] [blame] | 350 | // Access to packet state (e.g. sequence numbering) must only be access by |
| 351 | // one thread at a time. It may be only one thread, or a construction thread |
| 352 | // that calls SetRtpState() - handing over to a pacer thread that calls |
| 353 | // TrySendPacket() - and at teardown ownership is handed to a destruciton |
| 354 | // thread that calls GetRtpState(). |
| 355 | // This method is used to signal that "ownership" of the rtp state is being |
| 356 | // transferred to another thread. |
| 357 | virtual void OnPacketSendingThreadSwitched() = 0; |
| 358 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 359 | // ************************************************************************** |
| 360 | // RTCP |
| 361 | // ************************************************************************** |
| 362 | |
| 363 | // Returns RTCP status. |
| 364 | virtual RtcpMode RTCP() const = 0; |
| 365 | |
| 366 | // Sets RTCP status i.e on(compound or non-compound)/off. |
Artem Titov | 913cfa7 | 2021-07-28 21:57:33 | [diff] [blame] | 367 | // `method` - RTCP method to use. |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 368 | virtual void SetRTCPStatus(RtcpMode method) = 0; |
| 369 | |
| 370 | // Sets RTCP CName (i.e unique identifier). |
| 371 | // Returns -1 on failure else 0. |
Ali Tofigh | d14e889 | 2022-05-13 09:42:16 | [diff] [blame] | 372 | virtual int32_t SetCNAME(absl::string_view cname) = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 373 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 374 | // Returns current RTT (round-trip time) estimate. |
Danil Chapovalov | 8095d02 | 2023-05-09 07:59:46 | [diff] [blame] | 375 | virtual absl::optional<TimeDelta> LastRtt() const = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 376 | |
| 377 | // Returns the estimated RTT, with fallback to a default value. |
Danil Chapovalov | 630c40d | 2023-07-17 14:42:45 | [diff] [blame] | 378 | virtual TimeDelta ExpectedRetransmissionTime() const = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 379 | |
| 380 | // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the |
| 381 | // process function. |
| 382 | // Returns -1 on failure else 0. |
| 383 | virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0; |
| 384 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 385 | // Returns send statistics for the RTP and RTX stream. |
| 386 | virtual void GetSendStreamDataCounters( |
| 387 | StreamDataCounters* rtp_counters, |
| 388 | StreamDataCounters* rtx_counters) const = 0; |
| 389 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 390 | // A snapshot of Report Blocks with additional data of interest to statistics. |
| 391 | // Within this list, the sender-source SSRC pair is unique and per-pair the |
| 392 | // ReportBlockData represents the latest Report Block that was received for |
| 393 | // that pair. |
| 394 | virtual std::vector<ReportBlockData> GetLatestReportBlockData() const = 0; |
Alessio Bazzica | bc1c93d | 2021-03-12 16:45:26 | [diff] [blame] | 395 | // Returns stats based on the received RTCP SRs. |
| 396 | virtual absl::optional<SenderReportStats> GetSenderReportStats() const = 0; |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 397 | // Returns non-sender RTT stats, based on DLRR. |
| 398 | virtual absl::optional<NonSenderRttStats> GetNonSenderRttStats() const = 0; |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 399 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 400 | // (REMB) Receiver Estimated Max Bitrate. |
| 401 | // Schedules sending REMB on next and following sender/receiver reports. |
| 402 | void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) override = 0; |
| 403 | // Stops sending REMB on next and following sender/receiver reports. |
| 404 | void UnsetRemb() override = 0; |
| 405 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 406 | // (NACK) |
| 407 | |
| 408 | // Sends a Negative acknowledgement packet. |
| 409 | // Returns -1 on failure else 0. |
| 410 | // TODO(philipel): Deprecate this and start using SendNack instead, mostly |
| 411 | // because we want a function that actually send NACK for the specified |
| 412 | // packets. |
| 413 | virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0; |
| 414 | |
| 415 | // Sends NACK for the packets specified. |
| 416 | // Note: This assumes the caller keeps track of timing and doesn't rely on |
| 417 | // the RTP module to do this. |
| 418 | virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; |
| 419 | |
| 420 | // Store the sent packets, needed to answer to a Negative acknowledgment |
| 421 | // requests. |
| 422 | virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0; |
| 423 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 424 | virtual void SetVideoBitrateAllocation( |
| 425 | const VideoBitrateAllocation& bitrate) = 0; |
| 426 | |
| 427 | // ************************************************************************** |
| 428 | // Video |
| 429 | // ************************************************************************** |
| 430 | |
| 431 | // Requests new key frame. |
| 432 | // using PLI, https://tools.ietf.org/html/rfc4585#section-6.3.1.1 |
| 433 | void SendPictureLossIndication() { SendRTCP(kRtcpPli); } |
| 434 | // using FIR, https://tools.ietf.org/html/rfc5104#section-4.3.1.2 |
| 435 | void SendFullIntraRequest() { SendRTCP(kRtcpFir); } |
| 436 | |
| 437 | // Sends a LossNotification RTCP message. |
| 438 | // Returns -1 on failure else 0. |
| 439 | virtual int32_t SendLossNotification(uint16_t last_decoded_seq_num, |
| 440 | uint16_t last_received_seq_num, |
| 441 | bool decodability_flag, |
| 442 | bool buffering_allowed) = 0; |
| 443 | }; |
| 444 | |
| 445 | } // namespace webrtc |
| 446 | |
| 447 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_RTCP_INTERFACE_H_ |