blob: 94853d2f6b40537ffb69a72384214e84bc92487f [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;
terelius429c3452016-01-21 05:42:04 -080037
Peter Boström9c017252016-02-26 16:26:20 +010038RTPExtensionType StringToRtpExtensionType(const std::string& extension);
39
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010040namespace rtcp {
41class TransportFeedback;
42}
43
44class RtpRtcp : public Module {
45 public:
46 struct Configuration {
47 Configuration();
48
Sergey Ulanovec4f0682016-07-28 15:19:10 -070049 // True for a audio version of the RTP/RTCP module object false will create
50 // a video version.
51 bool audio = false;
52 bool receiver_only = false;
53
54 // The clock to use to read time. If nullptr then system clock will be used.
55 Clock* clock = nullptr;
56
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010057 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070058
59 // Transport object that will be called when packets are ready to be sent
60 // out on the network.
61 Transport* outgoing_transport = nullptr;
62
63 // Called when the receiver request a intra frame.
64 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
65
66 // Called when we receive a changed estimate from the receiver of out
67 // stream.
68 RtcpBandwidthObserver* bandwidth_callback = nullptr;
69
70 TransportFeedbackObserver* transport_feedback_callback = nullptr;
71 RtcpRttStats* rtt_stats = nullptr;
72 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
73
74 // Estimates the bandwidth available for a set of streams from the same
75 // client.
76 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
77
78 // Spread any bursts of packets into smaller bursts to minimize packet loss.
79 RtpPacketSender* paced_sender = nullptr;
80
brandtre950cad2016-11-15 05:25:41 -080081 // Generate FlexFEC packets.
82 // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender.
83 FlexfecSender* flexfec_sender = nullptr;
84
Sergey Ulanovec4f0682016-07-28 15:19:10 -070085 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
86 nullptr;
87 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
88 FrameCountObserver* send_frame_count_observer = nullptr;
89 SendSideDelayObserver* send_side_delay_observer = nullptr;
90 RtcEventLog* event_log = nullptr;
91 SendPacketObserver* send_packet_observer = nullptr;
92 RateLimiter* retransmission_rate_limiter = nullptr;
michaelt4da30442016-11-17 01:38:43 -080093 OverheadObserver* overhead_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070094
95 private:
terelius429c3452016-01-21 05:42:04 -080096 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010097 };
98
Sergey Ulanovec4f0682016-07-28 15:19:10 -070099 // Create a RTP/RTCP module object using the system clock.
100 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100101 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
102
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700103 // **************************************************************************
104 // Receiver functions
105 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100106
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700107 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
108 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100109
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700110 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100111
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700112 // **************************************************************************
113 // Sender
114 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100115
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700116 // Sets MTU.
117 // |size| - Max transfer unit in bytes, default is 1500.
118 // Returns -1 on failure else 0.
119 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100120
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700121 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
122 // |tcp| - true for TCP false UDP.
123 // |ipv6| - true for IP version 6 false for version 4.
124 // |authentication_overhead| - number of bytes to leave for an authentication
125 // header.
126 // Returns -1 on failure else 0
michaelt79e05882016-11-08 02:50:09 -0800127 // TODO(michaelt): deprecate the function.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700128 virtual int32_t SetTransportOverhead(bool tcp,
129 bool ipv6,
130 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100131
brandtr768d6252016-11-29 06:19:40 -0800132 // Sets transport overhead per packet.
michaelt79e05882016-11-08 02:50:09 -0800133 virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0;
134
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700135 // Returns max payload length, which is a combination of the configuration
136 // MaxTransferUnit and TransportOverhead.
137 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
138 // enabled).
139 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100140
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700141 // Returns max data payload length, which is a combination of the
142 // configuration MaxTransferUnit, headers and TransportOverhead.
143 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
144 // enabled).
145 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100146
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700147 // Sets codec name and payload type. Returns -1 on failure else 0.
148 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100149
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700150 // Sets codec name and payload type. Return -1 on failure else 0.
151 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100152
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700153 virtual void RegisterVideoSendPayload(int payload_type,
154 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100155
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700156 // Unregisters a send payload.
157 // |payload_type| - payload type of codec
158 // Returns -1 on failure else 0.
159 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100160
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700161 // (De)registers RTP header extension type and id.
162 // Returns -1 on failure else 0.
163 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
164 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100165
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700166 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100167
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700168 // Returns start timestamp.
169 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100170
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700171 // Sets start timestamp. Start timestamp is set to a random value if this
172 // function is never called.
173 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100174
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700175 // Returns SequenceNumber.
176 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100177
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700178 // Sets SequenceNumber, default is a random number.
179 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100180
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700181 virtual void SetRtpState(const RtpState& rtp_state) = 0;
182 virtual void SetRtxState(const RtpState& rtp_state) = 0;
183 virtual RtpState GetRtpState() const = 0;
184 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100185
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700186 // Returns SSRC.
187 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100188
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700189 // Sets SSRC, default is a random number.
190 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100191
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700192 // Sets CSRC.
193 // |csrcs| - vector of CSRCs
194 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100195
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700196 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
197 // of values of the enumerator RtxMode.
198 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100199
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700200 // Returns status of sending RTX (RFC 4588). The returned value can be
201 // a combination of values of the enumerator RtxMode.
202 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100203
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700204 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
205 // only the SSRC is set.
206 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100207
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700208 // Sets the payload type to use when sending RTX packets. Note that this
209 // doesn't enable RTX, only the payload type is set.
210 virtual void SetRtxSendPayloadType(int payload_type,
211 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100212
brandtr9dfff292016-11-14 05:14:50 -0800213 // Returns the FlexFEC SSRC, if there is one.
214 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
215
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700216 // Sets sending status. Sends kRtcpByeCode when going from true to false.
217 // Returns -1 on failure else 0.
218 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100219
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700220 // Returns current sending status.
221 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100222
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700223 // Starts/Stops media packets. On by default.
224 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100225
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700226 // Returns current media sending status.
227 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100228
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700229 // Returns current bitrate in Kbit/s.
230 virtual void BitrateSent(uint32_t* total_rate,
231 uint32_t* video_rate,
232 uint32_t* fec_rate,
233 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100234
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700235 // Used by the codec module to deliver a video or audio frame for
236 // packetization.
237 // |frame_type| - type of frame to send
238 // |payload_type| - payload type of frame to send
239 // |timestamp| - timestamp of frame to send
240 // |payload_data| - payload buffer of frame to send
241 // |payload_size| - size of payload buffer to send
242 // |fragmentation| - fragmentation offset data for fragmented frames such
243 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700244 // |transport_frame_id_out| - set to RTP timestamp.
245 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700246 virtual bool SendOutgoingData(FrameType frame_type,
247 int8_t payload_type,
248 uint32_t timestamp,
249 int64_t capture_time_ms,
250 const uint8_t* payload_data,
251 size_t payload_size,
252 const RTPFragmentationHeader* fragmentation,
253 const RTPVideoHeader* rtp_video_header,
254 uint32_t* transport_frame_id_out) = 0;
255
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700256 virtual bool TimeToSendPacket(uint32_t ssrc,
257 uint16_t sequence_number,
258 int64_t capture_time_ms,
259 bool retransmission,
260 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100261
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700262 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100263
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700264 // Called on generation of new statistics after an RTP send.
265 virtual void RegisterSendChannelRtpStatisticsCallback(
266 StreamDataCountersCallback* callback) = 0;
267 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
268 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100269
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700270 // **************************************************************************
271 // RTCP
272 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100273
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700274 // Returns RTCP status.
275 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100276
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700277 // Sets RTCP status i.e on(compound or non-compound)/off.
278 // |method| - RTCP method to use.
279 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100280
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700281 // Sets RTCP CName (i.e unique identifier).
282 // Returns -1 on failure else 0.
283 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100284
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700285 // Returns remote CName.
286 // Returns -1 on failure else 0.
287 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
288 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100289
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700290 // Returns remote NTP.
291 // Returns -1 on failure else 0.
292 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
293 uint32_t* received_ntp_frac,
294 uint32_t* rtcp_arrival_time_secs,
295 uint32_t* rtcp_arrival_time_frac,
296 uint32_t* rtcp_timestamp) const = 0;
297
298 // Returns -1 on failure else 0.
299 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100300
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700301 // Returns -1 on failure else 0.
302 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100303
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700304 // Returns current RTT (round-trip time) estimate.
305 // Returns -1 on failure else 0.
306 virtual int32_t RTT(uint32_t remote_ssrc,
307 int64_t* rtt,
308 int64_t* avg_rtt,
309 int64_t* min_rtt,
310 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100311
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700312 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
313 // process function.
314 // Returns -1 on failure else 0.
315 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100316
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700317 // Forces a send of a RTCP packet with more than one packet type.
318 // periodic SR and RR are triggered via the process function
319 // Returns -1 on failure else 0.
320 virtual int32_t SendCompoundRTCP(
321 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100322
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700323 // Notifies the sender about good state of the RTP receiver.
324 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100325
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700326 // Send a RTCP Slice Loss Indication (SLI).
327 // |picture_id| - 6 least significant bits of picture_id.
328 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100329
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700330 // Returns statistics of the amount of data sent.
331 // Returns -1 on failure else 0.
332 virtual int32_t DataCountersRTP(size_t* bytes_sent,
333 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100334
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700335 // Returns send statistics for the RTP and RTX stream.
336 virtual void GetSendStreamDataCounters(
337 StreamDataCounters* rtp_counters,
338 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100339
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700340 // Returns packet loss statistics for the RTP stream.
341 virtual void GetRtpPacketLossStats(
342 bool outgoing,
343 uint32_t ssrc,
344 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100345
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700346 // Returns received RTCP sender info.
347 // Returns -1 on failure else 0.
348 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100349
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700350 // Returns received RTCP report block.
351 // Returns -1 on failure else 0.
352 virtual int32_t RemoteRTCPStat(
353 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100354
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700355 // (APP) Sets application specific data.
356 // Returns -1 on failure else 0.
357 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
358 uint32_t name,
359 const uint8_t* data,
360 uint16_t length) = 0;
361 // (XR) Sets VOIP metric.
362 // Returns -1 on failure else 0.
363 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100364
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700365 // (XR) Sets Receiver Reference Time Report (RTTR) status.
366 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100367
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700368 // Returns current Receiver Reference Time Report (RTTR) status.
369 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100370
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700371 // (REMB) Receiver Estimated Max Bitrate.
372 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100373
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700374 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100375
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700376 virtual void SetREMBData(uint32_t bitrate,
377 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100378
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700379 // (TMMBR) Temporary Max Media Bit Rate
380 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100381
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700382 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100383
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700384 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100385
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700386 // TODO(holmer): Propagate this API to VideoEngine.
387 // Returns the currently configured selective retransmission settings.
388 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100389
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700390 // TODO(holmer): Propagate this API to VideoEngine.
391 // Sets the selective retransmission settings, which will decide which
392 // packets will be retransmitted if NACKed. Settings are constructed by
393 // combining the constants in enum RetransmissionMode with bitwise OR.
394 // All packets are retransmitted if kRetransmitAllPackets is set, while no
395 // packets are retransmitted if kRetransmitOff is set.
396 // By default all packets except FEC packets are retransmitted. For VP8
397 // with temporal scalability only base layer packets are retransmitted.
398 // Returns -1 on failure, otherwise 0.
399 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100400
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700401 // Sends a Negative acknowledgement packet.
402 // Returns -1 on failure else 0.
403 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
404 // because we want a function that actually send NACK for the specified
405 // packets.
406 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100407
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700408 // Sends NACK for the packets specified.
409 // Note: This assumes the caller keeps track of timing and doesn't rely on
410 // the RTP module to do this.
411 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100412
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700413 // Store the sent packets, needed to answer to a Negative acknowledgment
414 // requests.
415 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800416
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700417 // Returns true if the module is configured to store packets.
418 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100419
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700420 // Called on receipt of RTCP report block from remote side.
421 virtual void RegisterRtcpStatisticsCallback(
422 RtcpStatisticsCallback* callback) = 0;
423 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
424 // BWE feedback packets.
425 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100426
sprang5e38c962016-12-01 05:18:09 -0800427 virtual void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) = 0;
428
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700429 // **************************************************************************
430 // Audio
431 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100432
ossu00bceb12016-12-02 02:40:02 -0800433 // This function is deprecated. It was previously used to determine when it
434 // was time to send a DTMF packet in silence (CNG).
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700435 // Returns -1 on failure else 0.
ossu00bceb12016-12-02 02:40:02 -0800436 RTC_DEPRECATED virtual int32_t SetAudioPacketSize(
437 uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100438
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700439 // Sends a TelephoneEvent tone using RFC 2833 (4733).
440 // Returns -1 on failure else 0.
441 virtual int32_t SendTelephoneEventOutband(uint8_t key,
442 uint16_t time_ms,
443 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100444
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700445 // Store the audio level in dBov for header-extension-for-audio-level-
446 // indication.
447 // This API shall be called before transmision of an RTP packet to ensure
448 // that the |level| part of the extended RTP header is updated.
449 // return -1 on failure else 0.
450 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100451
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700452 // **************************************************************************
453 // Video
454 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100455
brandtrf1bb4762016-11-07 03:05:06 -0800456 // Set RED and ULPFEC payload types. A payload type of -1 means that the
457 // corresponding feature is turned off. Note that we DO NOT support enabling
458 // ULPFEC without enabling RED. However, we DO support enabling RED without
459 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
460 // assumes that RTX packets carry RED if RED has been configured in the SDP,
461 // regardless of what RTX payload type mapping was negotiated in the SDP.
462 // TODO(brandtr): Update this comment when we have removed the RED/RTX
463 // send-side workaround, i.e., when we do not support enabling RED without
464 // enabling ULPFEC.
465 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800466 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100467
brandtr1743a192016-11-07 03:36:05 -0800468 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
469 // Returns false on failure.
470 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
471 const FecProtectionParams& key_params) = 0;
472
473 // Deprecated version of member function above.
474 RTC_DEPRECATED
475 int32_t SetFecParameters(const FecProtectionParams* delta_params,
476 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100477
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700478 // Set method for requestion a new key frame.
479 // Returns -1 on failure else 0.
480 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100481
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700482 // Sends a request for a keyframe.
483 // Returns -1 on failure else 0.
484 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100485};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700486
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100487} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700488
danilchap5c1def82015-12-10 09:51:54 -0800489#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_