blob: 830d895774d2559ece632a707c7b73ee91949b4f [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
11#ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
12#define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
13
14#include <set>
Peter Boström9c017252016-02-26 16:26:20 +010015#include <string>
danilchapb8b6fbb2015-12-10 05:05:27 -080016#include <utility>
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017#include <vector>
18
kwiberg4485ffb2016-04-26 08:14:39 -070019#include "webrtc/base/constructormagic.h"
brandtr1743a192016-11-07 03:36:05 -080020#include "webrtc/base/deprecation.h"
brandtr9dfff292016-11-14 05:14:50 -080021#include "webrtc/base/optional.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010022#include "webrtc/modules/include/module.h"
brandtre950cad2016-11-15 05:25:41 -080023#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010024#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
philipel83f831a2016-03-12 03:30:23 -080025#include "webrtc/modules/video_coding/include/video_coding_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010026
27namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070028
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010029// Forward declarations.
sprangcd349d92016-07-13 09:11:28 -070030class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010031class ReceiveStatistics;
32class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070033class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010034class RtpReceiver;
35class Transport;
terelius429c3452016-01-21 05:42:04 -080036
Peter Boström9c017252016-02-26 16:26:20 +010037RTPExtensionType StringToRtpExtensionType(const std::string& extension);
38
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010039namespace rtcp {
40class TransportFeedback;
41}
42
43class RtpRtcp : public Module {
44 public:
45 struct Configuration {
46 Configuration();
47
Sergey Ulanovec4f0682016-07-28 15:19:10 -070048 // True for a audio version of the RTP/RTCP module object false will create
49 // a video version.
50 bool audio = false;
51 bool receiver_only = false;
52
53 // The clock to use to read time. If nullptr then system clock will be used.
54 Clock* clock = nullptr;
55
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010056 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070057
58 // Transport object that will be called when packets are ready to be sent
59 // out on the network.
60 Transport* outgoing_transport = nullptr;
61
62 // Called when the receiver request a intra frame.
63 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
64
65 // Called when we receive a changed estimate from the receiver of out
66 // stream.
67 RtcpBandwidthObserver* bandwidth_callback = nullptr;
68
69 TransportFeedbackObserver* transport_feedback_callback = nullptr;
70 RtcpRttStats* rtt_stats = nullptr;
71 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
72
73 // Estimates the bandwidth available for a set of streams from the same
74 // client.
75 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
76
77 // Spread any bursts of packets into smaller bursts to minimize packet loss.
78 RtpPacketSender* paced_sender = nullptr;
79
brandtre950cad2016-11-15 05:25:41 -080080 // Generate FlexFEC packets.
81 // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender.
82 FlexfecSender* flexfec_sender = nullptr;
83
Sergey Ulanovec4f0682016-07-28 15:19:10 -070084 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
85 nullptr;
86 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
87 FrameCountObserver* send_frame_count_observer = nullptr;
88 SendSideDelayObserver* send_side_delay_observer = nullptr;
89 RtcEventLog* event_log = nullptr;
90 SendPacketObserver* send_packet_observer = nullptr;
91 RateLimiter* retransmission_rate_limiter = nullptr;
92
93 private:
terelius429c3452016-01-21 05:42:04 -080094 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010095 };
96
Sergey Ulanovec4f0682016-07-28 15:19:10 -070097 // Create a RTP/RTCP module object using the system clock.
98 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010099 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
100
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700101 // **************************************************************************
102 // Receiver functions
103 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100104
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700105 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
106 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100107
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700108 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100109
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700110 // **************************************************************************
111 // Sender
112 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100113
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700114 // Sets MTU.
115 // |size| - Max transfer unit in bytes, default is 1500.
116 // Returns -1 on failure else 0.
117 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100118
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700119 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
120 // |tcp| - true for TCP false UDP.
121 // |ipv6| - true for IP version 6 false for version 4.
122 // |authentication_overhead| - number of bytes to leave for an authentication
123 // header.
124 // Returns -1 on failure else 0
michaelt79e05882016-11-08 02:50:09 -0800125 // TODO(michaelt): deprecate the function.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700126 virtual int32_t SetTransportOverhead(bool tcp,
127 bool ipv6,
128 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100129
michaelt79e05882016-11-08 02:50:09 -0800130 // Sets transtport overhead per packet.
131 virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0;
132
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700133 // Returns max payload length, which is a combination of the configuration
134 // MaxTransferUnit and TransportOverhead.
135 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
136 // enabled).
137 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100138
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700139 // Returns max data payload length, which is a combination of the
140 // configuration MaxTransferUnit, headers and TransportOverhead.
141 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
142 // enabled).
143 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100144
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700145 // Sets codec name and payload type. Returns -1 on failure else 0.
146 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100147
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700148 // Sets codec name and payload type. Return -1 on failure else 0.
149 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100150
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700151 virtual void RegisterVideoSendPayload(int payload_type,
152 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100153
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700154 // Unregisters a send payload.
155 // |payload_type| - payload type of codec
156 // Returns -1 on failure else 0.
157 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100158
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700159 // (De)registers RTP header extension type and id.
160 // Returns -1 on failure else 0.
161 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
162 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100163
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700164 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100165
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700166 // Returns start timestamp.
167 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100168
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700169 // Sets start timestamp. Start timestamp is set to a random value if this
170 // function is never called.
171 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100172
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700173 // Returns SequenceNumber.
174 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100175
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700176 // Sets SequenceNumber, default is a random number.
177 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100178
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700179 virtual void SetRtpState(const RtpState& rtp_state) = 0;
180 virtual void SetRtxState(const RtpState& rtp_state) = 0;
181 virtual RtpState GetRtpState() const = 0;
182 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100183
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700184 // Returns SSRC.
185 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100186
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700187 // Sets SSRC, default is a random number.
188 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100189
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700190 // Sets CSRC.
191 // |csrcs| - vector of CSRCs
192 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100193
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700194 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
195 // of values of the enumerator RtxMode.
196 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100197
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700198 // Returns status of sending RTX (RFC 4588). The returned value can be
199 // a combination of values of the enumerator RtxMode.
200 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100201
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700202 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
203 // only the SSRC is set.
204 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100205
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700206 // Sets the payload type to use when sending RTX packets. Note that this
207 // doesn't enable RTX, only the payload type is set.
208 virtual void SetRtxSendPayloadType(int payload_type,
209 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100210
brandtr9dfff292016-11-14 05:14:50 -0800211 // Returns the FlexFEC SSRC, if there is one.
212 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
213
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700214 // Sets sending status. Sends kRtcpByeCode when going from true to false.
215 // Returns -1 on failure else 0.
216 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100217
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700218 // Returns current sending status.
219 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100220
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700221 // Starts/Stops media packets. On by default.
222 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100223
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700224 // Returns current media sending status.
225 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100226
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700227 // Returns current bitrate in Kbit/s.
228 virtual void BitrateSent(uint32_t* total_rate,
229 uint32_t* video_rate,
230 uint32_t* fec_rate,
231 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100232
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700233 // Used by the codec module to deliver a video or audio frame for
234 // packetization.
235 // |frame_type| - type of frame to send
236 // |payload_type| - payload type of frame to send
237 // |timestamp| - timestamp of frame to send
238 // |payload_data| - payload buffer of frame to send
239 // |payload_size| - size of payload buffer to send
240 // |fragmentation| - fragmentation offset data for fragmented frames such
241 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700242 // |transport_frame_id_out| - set to RTP timestamp.
243 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700244 virtual bool SendOutgoingData(FrameType frame_type,
245 int8_t payload_type,
246 uint32_t timestamp,
247 int64_t capture_time_ms,
248 const uint8_t* payload_data,
249 size_t payload_size,
250 const RTPFragmentationHeader* fragmentation,
251 const RTPVideoHeader* rtp_video_header,
252 uint32_t* transport_frame_id_out) = 0;
253
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700254 virtual bool TimeToSendPacket(uint32_t ssrc,
255 uint16_t sequence_number,
256 int64_t capture_time_ms,
257 bool retransmission,
258 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100259
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700260 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100261
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700262 // Called on generation of new statistics after an RTP send.
263 virtual void RegisterSendChannelRtpStatisticsCallback(
264 StreamDataCountersCallback* callback) = 0;
265 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
266 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100267
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700268 // **************************************************************************
269 // RTCP
270 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100271
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700272 // Returns RTCP status.
273 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100274
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700275 // Sets RTCP status i.e on(compound or non-compound)/off.
276 // |method| - RTCP method to use.
277 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100278
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700279 // Sets RTCP CName (i.e unique identifier).
280 // Returns -1 on failure else 0.
281 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100282
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700283 // Returns remote CName.
284 // Returns -1 on failure else 0.
285 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
286 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100287
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700288 // Returns remote NTP.
289 // Returns -1 on failure else 0.
290 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
291 uint32_t* received_ntp_frac,
292 uint32_t* rtcp_arrival_time_secs,
293 uint32_t* rtcp_arrival_time_frac,
294 uint32_t* rtcp_timestamp) const = 0;
295
296 // Returns -1 on failure else 0.
297 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100298
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700299 // Returns -1 on failure else 0.
300 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100301
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700302 // Returns current RTT (round-trip time) estimate.
303 // Returns -1 on failure else 0.
304 virtual int32_t RTT(uint32_t remote_ssrc,
305 int64_t* rtt,
306 int64_t* avg_rtt,
307 int64_t* min_rtt,
308 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100309
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700310 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
311 // process function.
312 // Returns -1 on failure else 0.
313 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100314
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700315 // Forces a send of a RTCP packet with more than one packet type.
316 // periodic SR and RR are triggered via the process function
317 // Returns -1 on failure else 0.
318 virtual int32_t SendCompoundRTCP(
319 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100320
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700321 // Notifies the sender about good state of the RTP receiver.
322 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100323
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700324 // Send a RTCP Slice Loss Indication (SLI).
325 // |picture_id| - 6 least significant bits of picture_id.
326 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100327
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700328 // Returns statistics of the amount of data sent.
329 // Returns -1 on failure else 0.
330 virtual int32_t DataCountersRTP(size_t* bytes_sent,
331 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100332
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700333 // Returns send statistics for the RTP and RTX stream.
334 virtual void GetSendStreamDataCounters(
335 StreamDataCounters* rtp_counters,
336 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100337
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700338 // Returns packet loss statistics for the RTP stream.
339 virtual void GetRtpPacketLossStats(
340 bool outgoing,
341 uint32_t ssrc,
342 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100343
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700344 // Returns received RTCP sender info.
345 // Returns -1 on failure else 0.
346 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100347
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700348 // Returns received RTCP report block.
349 // Returns -1 on failure else 0.
350 virtual int32_t RemoteRTCPStat(
351 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100352
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700353 // (APP) Sets application specific data.
354 // Returns -1 on failure else 0.
355 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
356 uint32_t name,
357 const uint8_t* data,
358 uint16_t length) = 0;
359 // (XR) Sets VOIP metric.
360 // Returns -1 on failure else 0.
361 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100362
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700363 // (XR) Sets Receiver Reference Time Report (RTTR) status.
364 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100365
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700366 // Returns current Receiver Reference Time Report (RTTR) status.
367 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100368
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700369 // (REMB) Receiver Estimated Max Bitrate.
370 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100371
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700372 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100373
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700374 virtual void SetREMBData(uint32_t bitrate,
375 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100376
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700377 // (TMMBR) Temporary Max Media Bit Rate
378 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100379
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700380 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100381
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700382 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100383
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700384 // TODO(holmer): Propagate this API to VideoEngine.
385 // Returns the currently configured selective retransmission settings.
386 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100387
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700388 // TODO(holmer): Propagate this API to VideoEngine.
389 // Sets the selective retransmission settings, which will decide which
390 // packets will be retransmitted if NACKed. Settings are constructed by
391 // combining the constants in enum RetransmissionMode with bitwise OR.
392 // All packets are retransmitted if kRetransmitAllPackets is set, while no
393 // packets are retransmitted if kRetransmitOff is set.
394 // By default all packets except FEC packets are retransmitted. For VP8
395 // with temporal scalability only base layer packets are retransmitted.
396 // Returns -1 on failure, otherwise 0.
397 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100398
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700399 // Sends a Negative acknowledgement packet.
400 // Returns -1 on failure else 0.
401 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
402 // because we want a function that actually send NACK for the specified
403 // packets.
404 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100405
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700406 // Sends NACK for the packets specified.
407 // Note: This assumes the caller keeps track of timing and doesn't rely on
408 // the RTP module to do this.
409 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100410
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700411 // Store the sent packets, needed to answer to a Negative acknowledgment
412 // requests.
413 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800414
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700415 // Returns true if the module is configured to store packets.
416 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100417
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700418 // Called on receipt of RTCP report block from remote side.
419 virtual void RegisterRtcpStatisticsCallback(
420 RtcpStatisticsCallback* callback) = 0;
421 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
422 // BWE feedback packets.
423 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100424
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700425 // **************************************************************************
426 // Audio
427 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100428
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700429 // Sets audio packet size, used to determine when it's time to send a DTMF
430 // packet in silence (CNG).
431 // Returns -1 on failure else 0.
432 virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100433
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700434 // Sends a TelephoneEvent tone using RFC 2833 (4733).
435 // Returns -1 on failure else 0.
436 virtual int32_t SendTelephoneEventOutband(uint8_t key,
437 uint16_t time_ms,
438 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100439
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700440 // Store the audio level in dBov for header-extension-for-audio-level-
441 // indication.
442 // This API shall be called before transmision of an RTP packet to ensure
443 // that the |level| part of the extended RTP header is updated.
444 // return -1 on failure else 0.
445 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100446
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700447 // **************************************************************************
448 // Video
449 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100450
brandtrf1bb4762016-11-07 03:05:06 -0800451 // Set RED and ULPFEC payload types. A payload type of -1 means that the
452 // corresponding feature is turned off. Note that we DO NOT support enabling
453 // ULPFEC without enabling RED. However, we DO support enabling RED without
454 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
455 // assumes that RTX packets carry RED if RED has been configured in the SDP,
456 // regardless of what RTX payload type mapping was negotiated in the SDP.
457 // TODO(brandtr): Update this comment when we have removed the RED/RTX
458 // send-side workaround, i.e., when we do not support enabling RED without
459 // enabling ULPFEC.
460 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800461 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100462
brandtr1743a192016-11-07 03:36:05 -0800463 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
464 // Returns false on failure.
465 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
466 const FecProtectionParams& key_params) = 0;
467
468 // Deprecated version of member function above.
469 RTC_DEPRECATED
470 int32_t SetFecParameters(const FecProtectionParams* delta_params,
471 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100472
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700473 // Set method for requestion a new key frame.
474 // Returns -1 on failure else 0.
475 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100476
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700477 // Sends a request for a keyframe.
478 // Returns -1 on failure else 0.
479 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100480};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700481
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100482} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700483
danilchap5c1def82015-12-10 09:51:54 -0800484#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_