blob: 28dfe239de891e3420063dbff29638e5b7b558e5 [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.
michaelt4da30442016-11-17 01:38:43 -080030class OverheadObserver;
sprangcd349d92016-07-13 09:11:28 -070031class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010032class ReceiveStatistics;
33class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070034class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010035class RtpReceiver;
36class Transport;
spranga790d832016-12-02 07:29:44 -080037class VideoBitrateAllocationObserver;
terelius429c3452016-01-21 05:42:04 -080038
Peter Boström9c017252016-02-26 16:26:20 +010039RTPExtensionType StringToRtpExtensionType(const std::string& extension);
40
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010041namespace rtcp {
42class TransportFeedback;
43}
44
45class RtpRtcp : public Module {
46 public:
47 struct Configuration {
48 Configuration();
49
Sergey Ulanovec4f0682016-07-28 15:19:10 -070050 // True for a audio version of the RTP/RTCP module object false will create
51 // a video version.
52 bool audio = false;
53 bool receiver_only = false;
54
55 // The clock to use to read time. If nullptr then system clock will be used.
56 Clock* clock = nullptr;
57
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010058 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070059
60 // Transport object that will be called when packets are ready to be sent
61 // out on the network.
62 Transport* outgoing_transport = nullptr;
63
64 // Called when the receiver request a intra frame.
65 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
66
67 // Called when we receive a changed estimate from the receiver of out
68 // stream.
69 RtcpBandwidthObserver* bandwidth_callback = nullptr;
70
71 TransportFeedbackObserver* transport_feedback_callback = nullptr;
spranga790d832016-12-02 07:29:44 -080072 VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070073 RtcpRttStats* rtt_stats = nullptr;
74 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
75
76 // Estimates the bandwidth available for a set of streams from the same
77 // client.
78 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
79
80 // Spread any bursts of packets into smaller bursts to minimize packet loss.
81 RtpPacketSender* paced_sender = nullptr;
82
brandtre950cad2016-11-15 05:25:41 -080083 // Generate FlexFEC packets.
84 // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender.
85 FlexfecSender* flexfec_sender = nullptr;
86
Sergey Ulanovec4f0682016-07-28 15:19:10 -070087 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
88 nullptr;
89 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
90 FrameCountObserver* send_frame_count_observer = nullptr;
91 SendSideDelayObserver* send_side_delay_observer = nullptr;
92 RtcEventLog* event_log = nullptr;
93 SendPacketObserver* send_packet_observer = nullptr;
94 RateLimiter* retransmission_rate_limiter = nullptr;
michaelt4da30442016-11-17 01:38:43 -080095 OverheadObserver* overhead_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070096
97 private:
terelius429c3452016-01-21 05:42:04 -080098 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010099 };
100
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700101 // Create a RTP/RTCP module object using the system clock.
102 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100103 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
104
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700105 // **************************************************************************
106 // Receiver functions
107 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100108
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700109 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
110 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100111
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700112 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100113
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700114 // **************************************************************************
115 // Sender
116 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100117
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700118 // Sets MTU.
119 // |size| - Max transfer unit in bytes, default is 1500.
120 // Returns -1 on failure else 0.
121 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100122
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700123 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
124 // |tcp| - true for TCP false UDP.
125 // |ipv6| - true for IP version 6 false for version 4.
126 // |authentication_overhead| - number of bytes to leave for an authentication
127 // header.
128 // Returns -1 on failure else 0
michaelt79e05882016-11-08 02:50:09 -0800129 // TODO(michaelt): deprecate the function.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700130 virtual int32_t SetTransportOverhead(bool tcp,
131 bool ipv6,
132 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100133
brandtr768d6252016-11-29 06:19:40 -0800134 // Sets transport overhead per packet.
michaelt79e05882016-11-08 02:50:09 -0800135 virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0;
136
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700137 // Returns max payload length, which is a combination of the configuration
138 // MaxTransferUnit and TransportOverhead.
139 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
140 // enabled).
141 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100142
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700143 // Returns max data payload length, which is a combination of the
144 // configuration MaxTransferUnit, headers and TransportOverhead.
145 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
146 // enabled).
147 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100148
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700149 // Sets codec name and payload type. Returns -1 on failure else 0.
150 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100151
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700152 // Sets codec name and payload type. Return -1 on failure else 0.
153 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100154
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700155 virtual void RegisterVideoSendPayload(int payload_type,
156 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100157
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700158 // Unregisters a send payload.
159 // |payload_type| - payload type of codec
160 // Returns -1 on failure else 0.
161 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100162
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700163 // (De)registers RTP header extension type and id.
164 // Returns -1 on failure else 0.
165 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
166 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100167
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700168 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100169
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700170 // Returns start timestamp.
171 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100172
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700173 // Sets start timestamp. Start timestamp is set to a random value if this
174 // function is never called.
175 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100176
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700177 // Returns SequenceNumber.
178 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100179
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700180 // Sets SequenceNumber, default is a random number.
181 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100182
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700183 virtual void SetRtpState(const RtpState& rtp_state) = 0;
184 virtual void SetRtxState(const RtpState& rtp_state) = 0;
185 virtual RtpState GetRtpState() const = 0;
186 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100187
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700188 // Returns SSRC.
189 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100190
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700191 // Sets SSRC, default is a random number.
192 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100193
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700194 // Sets CSRC.
195 // |csrcs| - vector of CSRCs
196 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100197
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700198 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
199 // of values of the enumerator RtxMode.
200 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100201
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700202 // Returns status of sending RTX (RFC 4588). The returned value can be
203 // a combination of values of the enumerator RtxMode.
204 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100205
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700206 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
207 // only the SSRC is set.
208 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100209
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700210 // Sets the payload type to use when sending RTX packets. Note that this
211 // doesn't enable RTX, only the payload type is set.
212 virtual void SetRtxSendPayloadType(int payload_type,
213 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100214
brandtr9dfff292016-11-14 05:14:50 -0800215 // Returns the FlexFEC SSRC, if there is one.
216 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
217
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700218 // Sets sending status. Sends kRtcpByeCode when going from true to false.
219 // Returns -1 on failure else 0.
220 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100221
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700222 // Returns current sending status.
223 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100224
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700225 // Starts/Stops media packets. On by default.
226 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100227
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700228 // Returns current media sending status.
229 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100230
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700231 // Returns current bitrate in Kbit/s.
232 virtual void BitrateSent(uint32_t* total_rate,
233 uint32_t* video_rate,
234 uint32_t* fec_rate,
235 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100236
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700237 // Used by the codec module to deliver a video or audio frame for
238 // packetization.
239 // |frame_type| - type of frame to send
240 // |payload_type| - payload type of frame to send
241 // |timestamp| - timestamp of frame to send
242 // |payload_data| - payload buffer of frame to send
243 // |payload_size| - size of payload buffer to send
244 // |fragmentation| - fragmentation offset data for fragmented frames such
245 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700246 // |transport_frame_id_out| - set to RTP timestamp.
247 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700248 virtual bool SendOutgoingData(FrameType frame_type,
249 int8_t payload_type,
250 uint32_t timestamp,
251 int64_t capture_time_ms,
252 const uint8_t* payload_data,
253 size_t payload_size,
254 const RTPFragmentationHeader* fragmentation,
255 const RTPVideoHeader* rtp_video_header,
256 uint32_t* transport_frame_id_out) = 0;
257
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700258 virtual bool TimeToSendPacket(uint32_t ssrc,
259 uint16_t sequence_number,
260 int64_t capture_time_ms,
261 bool retransmission,
262 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100263
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700264 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100265
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700266 // Called on generation of new statistics after an RTP send.
267 virtual void RegisterSendChannelRtpStatisticsCallback(
268 StreamDataCountersCallback* callback) = 0;
269 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
270 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100271
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700272 // **************************************************************************
273 // RTCP
274 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100275
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700276 // Returns RTCP status.
277 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100278
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700279 // Sets RTCP status i.e on(compound or non-compound)/off.
280 // |method| - RTCP method to use.
281 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100282
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700283 // Sets RTCP CName (i.e unique identifier).
284 // Returns -1 on failure else 0.
285 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100286
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700287 // Returns remote CName.
288 // Returns -1 on failure else 0.
289 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
290 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100291
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700292 // Returns remote NTP.
293 // Returns -1 on failure else 0.
294 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
295 uint32_t* received_ntp_frac,
296 uint32_t* rtcp_arrival_time_secs,
297 uint32_t* rtcp_arrival_time_frac,
298 uint32_t* rtcp_timestamp) const = 0;
299
300 // Returns -1 on failure else 0.
301 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100302
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700303 // Returns -1 on failure else 0.
304 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100305
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700306 // Returns current RTT (round-trip time) estimate.
307 // Returns -1 on failure else 0.
308 virtual int32_t RTT(uint32_t remote_ssrc,
309 int64_t* rtt,
310 int64_t* avg_rtt,
311 int64_t* min_rtt,
312 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100313
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700314 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
315 // process function.
316 // Returns -1 on failure else 0.
317 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100318
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700319 // Forces a send of a RTCP packet with more than one packet type.
320 // periodic SR and RR are triggered via the process function
321 // Returns -1 on failure else 0.
322 virtual int32_t SendCompoundRTCP(
323 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100324
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700325 // Notifies the sender about good state of the RTP receiver.
326 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100327
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700328 // Send a RTCP Slice Loss Indication (SLI).
329 // |picture_id| - 6 least significant bits of picture_id.
330 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100331
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700332 // Returns statistics of the amount of data sent.
333 // Returns -1 on failure else 0.
334 virtual int32_t DataCountersRTP(size_t* bytes_sent,
335 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100336
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700337 // Returns send statistics for the RTP and RTX stream.
338 virtual void GetSendStreamDataCounters(
339 StreamDataCounters* rtp_counters,
340 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100341
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700342 // Returns packet loss statistics for the RTP stream.
343 virtual void GetRtpPacketLossStats(
344 bool outgoing,
345 uint32_t ssrc,
346 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100347
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700348 // Returns received RTCP sender info.
349 // Returns -1 on failure else 0.
350 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100351
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700352 // Returns received RTCP report block.
353 // Returns -1 on failure else 0.
354 virtual int32_t RemoteRTCPStat(
355 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100356
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700357 // (APP) Sets application specific data.
358 // Returns -1 on failure else 0.
359 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
360 uint32_t name,
361 const uint8_t* data,
362 uint16_t length) = 0;
363 // (XR) Sets VOIP metric.
364 // Returns -1 on failure else 0.
365 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100366
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700367 // (XR) Sets Receiver Reference Time Report (RTTR) status.
368 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100369
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700370 // Returns current Receiver Reference Time Report (RTTR) status.
371 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100372
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700373 // (REMB) Receiver Estimated Max Bitrate.
374 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100375
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700376 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100377
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700378 virtual void SetREMBData(uint32_t bitrate,
379 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100380
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700381 // (TMMBR) Temporary Max Media Bit Rate
382 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100383
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700384 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100385
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700386 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100387
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700388 // TODO(holmer): Propagate this API to VideoEngine.
389 // Returns the currently configured selective retransmission settings.
390 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100391
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700392 // TODO(holmer): Propagate this API to VideoEngine.
393 // Sets the selective retransmission settings, which will decide which
394 // packets will be retransmitted if NACKed. Settings are constructed by
395 // combining the constants in enum RetransmissionMode with bitwise OR.
396 // All packets are retransmitted if kRetransmitAllPackets is set, while no
397 // packets are retransmitted if kRetransmitOff is set.
398 // By default all packets except FEC packets are retransmitted. For VP8
399 // with temporal scalability only base layer packets are retransmitted.
400 // Returns -1 on failure, otherwise 0.
401 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100402
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700403 // Sends a Negative acknowledgement packet.
404 // Returns -1 on failure else 0.
405 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
406 // because we want a function that actually send NACK for the specified
407 // packets.
408 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100409
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700410 // Sends NACK for the packets specified.
411 // Note: This assumes the caller keeps track of timing and doesn't rely on
412 // the RTP module to do this.
413 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100414
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700415 // Store the sent packets, needed to answer to a Negative acknowledgment
416 // requests.
417 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800418
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700419 // Returns true if the module is configured to store packets.
420 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100421
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700422 // Called on receipt of RTCP report block from remote side.
423 virtual void RegisterRtcpStatisticsCallback(
424 RtcpStatisticsCallback* callback) = 0;
425 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
426 // BWE feedback packets.
427 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100428
sprang5e38c962016-12-01 05:18:09 -0800429 virtual void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) = 0;
430
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700431 // **************************************************************************
432 // Audio
433 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100434
ossu00bceb12016-12-02 02:40:02 -0800435 // This function is deprecated. It was previously used to determine when it
436 // was time to send a DTMF packet in silence (CNG).
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700437 // Returns -1 on failure else 0.
ossu00bceb12016-12-02 02:40:02 -0800438 RTC_DEPRECATED virtual int32_t SetAudioPacketSize(
439 uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100440
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700441 // Sends a TelephoneEvent tone using RFC 2833 (4733).
442 // Returns -1 on failure else 0.
443 virtual int32_t SendTelephoneEventOutband(uint8_t key,
444 uint16_t time_ms,
445 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100446
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700447 // Store the audio level in dBov for header-extension-for-audio-level-
448 // indication.
449 // This API shall be called before transmision of an RTP packet to ensure
450 // that the |level| part of the extended RTP header is updated.
451 // return -1 on failure else 0.
452 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100453
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700454 // **************************************************************************
455 // Video
456 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100457
brandtrf1bb4762016-11-07 03:05:06 -0800458 // Set RED and ULPFEC payload types. A payload type of -1 means that the
459 // corresponding feature is turned off. Note that we DO NOT support enabling
460 // ULPFEC without enabling RED. However, we DO support enabling RED without
461 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
462 // assumes that RTX packets carry RED if RED has been configured in the SDP,
463 // regardless of what RTX payload type mapping was negotiated in the SDP.
464 // TODO(brandtr): Update this comment when we have removed the RED/RTX
465 // send-side workaround, i.e., when we do not support enabling RED without
466 // enabling ULPFEC.
467 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800468 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100469
brandtr1743a192016-11-07 03:36:05 -0800470 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
471 // Returns false on failure.
472 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
473 const FecProtectionParams& key_params) = 0;
474
475 // Deprecated version of member function above.
476 RTC_DEPRECATED
477 int32_t SetFecParameters(const FecProtectionParams* delta_params,
478 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100479
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700480 // Set method for requestion a new key frame.
481 // Returns -1 on failure else 0.
482 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100483
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700484 // Sends a request for a keyframe.
485 // Returns -1 on failure else 0.
486 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100487};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700488
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100489} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700490
danilchap5c1def82015-12-10 09:51:54 -0800491#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_