blob: 579b2dfd8ee8e2a12ae96e60b848632f208149d3 [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
12#define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010013
Danil Chapovalovc44f6cc2019-03-06 11:31:09 +010014#include <memory>
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010015#include <set>
Peter Boström9c017252016-02-26 16:26:20 +010016#include <string>
danilchapb8b6fbb2015-12-10 05:05:27 -080017#include <utility>
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010018#include <vector>
19
Fredrik Solenberg18f0c3c2018-12-06 11:49:35 +010020#include "absl/strings/string_view.h"
Danil Chapovalovd264df52018-06-14 12:59:38 +020021#include "absl/types/optional.h"
Marina Cioceae77912b2020-02-27 16:16:55 +010022#include "api/frame_transformer_interface.h"
23#include "api/scoped_refptr.h"
Per Kjellandere11b7d22019-02-21 07:55:59 +010024#include "api/transport/webrtc_key_value_config.h"
Erik Språngeeaa8f92018-05-17 12:35:56 +020025#include "api/video/video_bitrate_allocation.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "modules/include/module.h"
Niels Möller53382cb2018-11-27 14:05:08 +010027#include "modules/rtp_rtcp/include/receive_statistics.h"
Henrik Boström87e3f9d2019-05-27 10:44:24 +020028#include "modules/rtp_rtcp/include/report_block_data.h"
Erik Språngaa59eca2019-07-24 14:52:55 +020029#include "modules/rtp_rtcp/include/rtp_packet_sender.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020030#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Erik Språng58ee1872019-06-18 16:20:11 +020031#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
Erik Språng3663f942020-02-07 10:05:15 +010032#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h"
Erik Språngf87536c2020-03-05 10:14:04 +010033#include "modules/rtp_rtcp/source/video_fec_generator.h"
Steve Anton10542f22019-01-11 09:11:00 -080034#include "rtc_base/constructor_magic.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020035#include "rtc_base/deprecation.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010036
37namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070038
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010039// Forward declarations.
Benjamin Wright192eeec2018-10-17 17:27:25 -070040class FrameEncryptorInterface;
michaelt4da30442016-11-17 01:38:43 -080041class OverheadObserver;
sprangcd349d92016-07-13 09:11:28 -070042class RateLimiter;
danilchapf5f793c2017-07-27 04:44:18 -070043class ReceiveStatisticsProvider;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010044class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070045class RtcEventLog;
Erik Språng4580ca22019-07-04 10:38:43 +020046class RTPSender;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010047class Transport;
spranga790d832016-12-02 07:29:44 -080048class VideoBitrateAllocationObserver;
terelius429c3452016-01-21 05:42:04 -080049
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010050namespace rtcp {
51class TransportFeedback;
52}
53
Danil Chapovaloveb0edd82017-12-14 16:02:31 +010054class RtpRtcp : public Module, public RtcpFeedbackSenderInterface {
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010055 public:
56 struct Configuration {
57 Configuration();
Erik Språng4580ca22019-07-04 10:38:43 +020058 Configuration(Configuration&& rhs);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010059
Sergey Ulanovec4f0682016-07-28 15:19:10 -070060 // 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
danilchapf5f793c2017-07-27 04:44:18 -070068 ReceiveStatisticsProvider* receive_statistics = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070069
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 Alon0a8562e2019-04-09 11:55:13 +020074 // Called when the receiver requests an intra frame.
Sergey Ulanovec4f0682016-07-28 15:19:10 -070075 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
76
Elad Alon0a8562e2019-04-09 11:55:13 +020077 // Called when the receiver sends a loss notification.
78 RtcpLossNotificationObserver* rtcp_loss_notification_observer = nullptr;
79
Sergey Ulanovec4f0682016-07-28 15:19:10 -070080 // Called when we receive a changed estimate from the receiver of out
81 // stream.
82 RtcpBandwidthObserver* bandwidth_callback = nullptr;
83
Sebastian Janssone1795f42019-07-24 11:38:03 +020084 NetworkStateEstimateObserver* network_state_estimate_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070085 TransportFeedbackObserver* transport_feedback_callback = nullptr;
spranga790d832016-12-02 07:29:44 -080086 VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070087 RtcpRttStats* rtt_stats = nullptr;
88 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +010089 // 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 Ulanovec4f0682016-07-28 15:19:10 -070099
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ångaa59eca2019-07-24 14:52:55 +0200105 RtpPacketSender* paced_sender = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700106
Erik Språngf87536c2020-03-05 10:14:04 +0100107 // Generates FEC packets.
108 // TODO(sprang): Wire up to RtpSenderEgress.
109 VideoFecGenerator* fec_generator = nullptr;
brandtre950cad2016-11-15 05:25:41 -0800110
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700111 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700112 SendSideDelayObserver* send_side_delay_observer = nullptr;
113 RtcEventLog* event_log = nullptr;
114 SendPacketObserver* send_packet_observer = nullptr;
115 RateLimiter* retransmission_rate_limiter = nullptr;
michaelt4da30442016-11-17 01:38:43 -0800116 OverheadObserver* overhead_observer = nullptr;
Erik Språng7ea9b802019-10-16 19:03:38 +0200117 StreamDataCountersCallback* rtp_stats_callback = nullptr;
Niels Möller5fe95102019-03-04 16:49:25 +0100118
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800119 int rtcp_report_interval_ms = 0;
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700120
Erik Språng7b52f102018-02-07 14:37:37 +0100121 // Update network2 instead of pacer_exit field of video timing extension.
122 bool populate_network2_timestamp = false;
123
Marina Cioceae77912b2020-02-27 16:16:55 +0100124 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer;
125
Benjamin Wright192eeec2018-10-17 17:27:25 -0700126 // 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 Kron9190b822018-10-29 11:22:05 +0100131 // Corresponds to extmap-allow-mixed in SDP negotiation.
132 bool extmap_allow_mixed = false;
133
Rasmus Brandtce588ae2020-03-10 14:12:48 +0100134 // 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 Kjellandere11b7d22019-02-21 07:55:59 +0100141 // If set, field trials are read from |field_trials|, otherwise
142 // defaults to webrtc::FieldTrialBasedConfig.
Per Kjellander19d01042019-02-24 20:04:14 +0100143 const WebRtcKeyValueConfig* field_trials = nullptr;
Per Kjellandere11b7d22019-02-21 07:55:59 +0100144
Erik Språng54d5d2c2019-08-20 17:22:36 +0200145 // SSRCs for media and retransmission, respectively.
Erik Språng4580ca22019-07-04 10:38:43 +0200146 // FlexFec SSRC is fetched from |flexfec_sender|.
Erik Språngdbbf4132019-10-18 10:34:25 +0200147 uint32_t local_media_ssrc = 0;
Erik Språng4580ca22019-07-04 10:38:43 +0200148 absl::optional<uint32_t> rtx_send_ssrc;
149
Erik Språng3663f942020-02-07 10:05:15 +0100150 bool need_rtp_packet_infos = false;
151
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700152 private:
terelius429c3452016-01-21 05:42:04 -0800153 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100154 };
155
Danil Chapovalovc44f6cc2019-03-06 11:31:09 +0100156 // Creates an RTP/RTCP module object using provided |configuration|.
157 static std::unique_ptr<RtpRtcp> Create(const Configuration& configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100158
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700159 // **************************************************************************
160 // Receiver functions
161 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100162
nisse479d3d72017-09-13 07:53:37 -0700163 virtual void IncomingRtcpPacket(const uint8_t* incoming_packet,
164 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100165
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700166 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100167
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700168 // **************************************************************************
169 // Sender
170 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100171
nisse284542b2017-01-10 08:58:32 -0800172 // Sets the maximum size of an RTP packet, including RTP headers.
173 virtual void SetMaxRtpPacketSize(size_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100174
nisse284542b2017-01-10 08:58:32 -0800175 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100178
Niels Möller5fe95102019-03-04 16:49:25 +0100179 virtual void RegisterSendPayloadFrequency(int payload_type,
180 int payload_frequency) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100181
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700182 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100186
Johannes Kron9190b822018-10-29 11:22:05 +0100187 virtual void SetExtmapAllowMixed(bool extmap_allow_mixed) = 0;
188
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700189 // (De)registers RTP header extension type and id.
190 // Returns -1 on failure else 0.
Sebastian Janssonf39c8152019-10-14 17:32:21 +0200191 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 Kjellanderff761fb2015-11-04 08:31:52 +0100196
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700197 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Sebastian Janssonf39c8152019-10-14 17:32:21 +0200198 virtual void DeregisterSendRtpHeaderExtension(absl::string_view uri) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100199
Mirko Bonadei999a72a2019-07-12 17:33:46 +0000200 // 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;
stefan53b6cc32017-02-03 08:13:57 -0800207
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700208 // Returns start timestamp.
209 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100210
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700211 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100214
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700215 // Returns SequenceNumber.
216 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100217
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700218 // Sets SequenceNumber, default is a random number.
219 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100220
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700221 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 Kjellanderff761fb2015-11-04 08:31:52 +0100225
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700226 // Returns SSRC.
Per Kjellanderb11c4112019-10-16 10:41:32 +0200227 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100228
Amit Hilbuch77938e62018-12-21 09:23:38 -0800229 // 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 Anton296a0ce2018-03-22 15:17:27 -0700235 // 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 Ulanovec4f0682016-07-28 15:19:10 -0700240 // Sets CSRC.
241 // |csrcs| - vector of CSRCs
242 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100243
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700244 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100247
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700248 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100251
Erik Språngc06aef22019-10-17 13:02:27 +0200252 // Returns the SSRC used for RTX if set, otherwise a nullopt.
253 virtual absl::optional<uint32_t> RtxSsrc() const = 0;
254
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700255 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100259
brandtr9dfff292016-11-14 05:14:50 -0800260 // Returns the FlexFEC SSRC, if there is one.
Danil Chapovalovd264df52018-06-14 12:59:38 +0200261 virtual absl::optional<uint32_t> FlexfecSsrc() const = 0;
brandtr9dfff292016-11-14 05:14:50 -0800262
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700263 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100266
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700267 // Returns current sending status.
268 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100269
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700270 // Starts/Stops media packets. On by default.
271 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100272
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700273 // Returns current media sending status.
274 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100275
Erik Språng1e51a382019-12-11 16:47:09 +0100276 // Returns whether audio is configured (i.e. Configuration::audio = true).
277 virtual bool IsAudioConfigured() const = 0;
278
Sebastian Jansson1bca65b2018-10-10 09:58:08 +0200279 // 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ång482b3ef2019-01-08 16:19:11 +0100283 // Fetches the current send bitrates in bits/s.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700284 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 Kjellanderff761fb2015-11-04 08:31:52 +0100288
Niels Möller5fe95102019-03-04 16:49:25 +0100289 virtual RTPSender* RtpSender() = 0;
290 virtual const RTPSender* RtpSender() const = 0;
Erik Språng482b3ef2019-01-08 16:19:11 +0100291
Niels Möller5fe95102019-03-04 16:49:25 +0100292 // 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ång9c771c22019-06-17 16:31:53 +0200299 // 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ånga9229042019-10-24 12:39:32 +0200305 virtual void OnPacketsAcknowledged(
306 rtc::ArrayView<const uint16_t> sequence_numbers) = 0;
307
Erik Språngf6468d22019-07-05 16:53:43 +0200308 virtual std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding(
309 size_t target_size_bytes) = 0;
Erik Språng478cb462019-06-26 15:49:27 +0200310
Erik Språng3663f942020-02-07 10:05:15 +0100311 virtual std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos(
312 rtc::ArrayView<const uint16_t> sequence_numbers) const = 0;
313
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700314 // **************************************************************************
315 // RTCP
316 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100317
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700318 // Returns RTCP status.
319 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100320
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700321 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100324
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700325 // Sets RTCP CName (i.e unique identifier).
326 // Returns -1 on failure else 0.
327 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100328
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700329 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100333
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700334 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100344
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700345 // Returns -1 on failure else 0.
346 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100347
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700348 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100355
Niels Möller5fe95102019-03-04 16:49:25 +0100356 // Returns the estimated RTT, with fallback to a default value.
357 virtual int64_t ExpectedRetransmissionTimeMs() const = 0;
358
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700359 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100363
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700364 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100368
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700369 // Returns send statistics for the RTP and RTX stream.
370 virtual void GetSendStreamDataCounters(
371 StreamDataCounters* rtp_counters,
372 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100373
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700374 // Returns received RTCP report block.
375 // Returns -1 on failure else 0.
Henrik Boström6e436d12019-05-27 12:19:33 +0200376 // TODO(https://crbug.com/webrtc/10678): Remove this in favor of
377 // GetLatestReportBlockData().
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700378 virtual int32_t RemoteRTCPStat(
379 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Boström6e436d12019-05-27 12:19:33 +0200380 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100385
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700386 // (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 Ulanovec4f0682016-07-28 15:19:10 -0700392 // (XR) Sets Receiver Reference Time Report (RTTR) status.
393 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100394
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700395 // Returns current Receiver Reference Time Report (RTTR) status.
396 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100397
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700398 // (REMB) Receiver Estimated Max Bitrate.
Danil Chapovalov51e21aa2017-10-10 17:46:26 +0200399 // Schedules sending REMB on next and following sender/receiver reports.
Danil Chapovaloveb0edd82017-12-14 16:02:31 +0100400 void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) override = 0;
Danil Chapovalov51e21aa2017-10-10 17:46:26 +0200401 // Stops sending REMB on next and following sender/receiver reports.
Danil Chapovaloveb0edd82017-12-14 16:02:31 +0100402 void UnsetRemb() override = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100403
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700404 // (TMMBR) Temporary Max Media Bit Rate
405 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100406
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700407 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100408
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700409 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100410
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700411 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100417
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700418 // 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 Kjellanderff761fb2015-11-04 08:31:52 +0100422
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700423 // Store the sent packets, needed to answer to a Negative acknowledgment
424 // requests.
425 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800426
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700427 // Returns true if the module is configured to store packets.
428 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100429
Erik Språng566124a2018-04-23 12:32:22 +0200430 virtual void SetVideoBitrateAllocation(
431 const VideoBitrateAllocation& bitrate) = 0;
sprang5e38c962016-12-01 05:18:09 -0800432
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700433 // **************************************************************************
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700434 // Video
435 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100436
Niels Möllerdd0094a2019-06-04 14:46:27 +0200437 // 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 Alon7d6a4c02019-02-25 13:00:51 +0100443 // 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 Alone86af2c2019-06-03 14:37:50 +0200447 bool decodability_flag,
448 bool buffering_allowed) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100449};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700450
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100451} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700452
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200453#endif // MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_