blob: 5ebb252c258db35ec3efc9140235f21415428074 [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"
25
26namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070027
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028// Forward declarations.
michaelt4da30442016-11-17 01:38:43 -080029class OverheadObserver;
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;
spranga790d832016-12-02 07:29:44 -080036class VideoBitrateAllocationObserver;
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;
spranga790d832016-12-02 07:29:44 -080071 VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070072 RtcpRttStats* rtt_stats = nullptr;
73 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
74
75 // Estimates the bandwidth available for a set of streams from the same
76 // client.
77 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
78
79 // Spread any bursts of packets into smaller bursts to minimize packet loss.
80 RtpPacketSender* paced_sender = nullptr;
81
brandtre950cad2016-11-15 05:25:41 -080082 // Generate FlexFEC packets.
83 // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender.
84 FlexfecSender* flexfec_sender = nullptr;
85
Sergey Ulanovec4f0682016-07-28 15:19:10 -070086 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
87 nullptr;
88 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
89 FrameCountObserver* send_frame_count_observer = nullptr;
90 SendSideDelayObserver* send_side_delay_observer = nullptr;
91 RtcEventLog* event_log = nullptr;
92 SendPacketObserver* send_packet_observer = nullptr;
93 RateLimiter* retransmission_rate_limiter = nullptr;
michaelt4da30442016-11-17 01:38:43 -080094 OverheadObserver* overhead_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070095
96 private:
terelius429c3452016-01-21 05:42:04 -080097 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010098 };
99
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700100 // Create a RTP/RTCP module object using the system clock.
101 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100102 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
103
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700104 // **************************************************************************
105 // Receiver functions
106 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100107
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700108 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
109 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100110
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700111 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100112
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700113 // **************************************************************************
114 // Sender
115 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100116
nisse284542b2017-01-10 08:58:32 -0800117 // TODO(nisse): Deprecated. Kept temporarily, as an alias for the
118 // new function which has slighly different semantics. Delete as
119 // soon as known applications are updated.
120 virtual int32_t SetMaxTransferUnit(uint16_t size) {
121 SetMaxRtpPacketSize(size);
122 return 0;
123 }
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100124
nisse284542b2017-01-10 08:58:32 -0800125 // Sets the maximum size of an RTP packet, including RTP headers.
126 virtual void SetMaxRtpPacketSize(size_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100127
nisse284542b2017-01-10 08:58:32 -0800128 // Returns max payload length.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700129 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
130 // enabled).
nisse284542b2017-01-10 08:58:32 -0800131 virtual size_t MaxPayloadSize() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100132
nisse284542b2017-01-10 08:58:32 -0800133 // Returns max RTP packet size. Takes into account RTP headers and
134 // FEC/ULP/RED overhead (when FEC is enabled).
135 virtual size_t MaxRtpPacketSize() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100136
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700137 // Sets codec name and payload type. Returns -1 on failure else 0.
138 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100139
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700140 // Sets codec name and payload type. Return -1 on failure else 0.
141 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100142
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700143 virtual void RegisterVideoSendPayload(int payload_type,
144 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100145
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700146 // Unregisters a send payload.
147 // |payload_type| - payload type of codec
148 // Returns -1 on failure else 0.
149 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100150
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700151 // (De)registers RTP header extension type and id.
152 // Returns -1 on failure else 0.
153 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
154 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100155
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700156 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100157
stefan53b6cc32017-02-03 08:13:57 -0800158 virtual bool HasBweExtensions() const = 0;
159
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700160 // Returns start timestamp.
161 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100162
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700163 // Sets start timestamp. Start timestamp is set to a random value if this
164 // function is never called.
165 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100166
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700167 // Returns SequenceNumber.
168 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100169
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700170 // Sets SequenceNumber, default is a random number.
171 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100172
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700173 virtual void SetRtpState(const RtpState& rtp_state) = 0;
174 virtual void SetRtxState(const RtpState& rtp_state) = 0;
175 virtual RtpState GetRtpState() const = 0;
176 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100177
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700178 // Returns SSRC.
179 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100180
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700181 // Sets SSRC, default is a random number.
182 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100183
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700184 // Sets CSRC.
185 // |csrcs| - vector of CSRCs
186 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100187
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700188 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
189 // of values of the enumerator RtxMode.
190 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100191
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700192 // Returns status of sending RTX (RFC 4588). The returned value can be
193 // a combination of values of the enumerator RtxMode.
194 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100195
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700196 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
197 // only the SSRC is set.
198 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100199
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700200 // Sets the payload type to use when sending RTX packets. Note that this
201 // doesn't enable RTX, only the payload type is set.
202 virtual void SetRtxSendPayloadType(int payload_type,
203 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100204
brandtr9dfff292016-11-14 05:14:50 -0800205 // Returns the FlexFEC SSRC, if there is one.
206 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
207
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700208 // Sets sending status. Sends kRtcpByeCode when going from true to false.
209 // Returns -1 on failure else 0.
210 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100211
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700212 // Returns current sending status.
213 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100214
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700215 // Starts/Stops media packets. On by default.
216 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100217
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700218 // Returns current media sending status.
219 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100220
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700221 // Returns current bitrate in Kbit/s.
222 virtual void BitrateSent(uint32_t* total_rate,
223 uint32_t* video_rate,
224 uint32_t* fec_rate,
225 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100226
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700227 // Used by the codec module to deliver a video or audio frame for
228 // packetization.
229 // |frame_type| - type of frame to send
230 // |payload_type| - payload type of frame to send
231 // |timestamp| - timestamp of frame to send
232 // |payload_data| - payload buffer of frame to send
233 // |payload_size| - size of payload buffer to send
234 // |fragmentation| - fragmentation offset data for fragmented frames such
235 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700236 // |transport_frame_id_out| - set to RTP timestamp.
237 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700238 virtual bool SendOutgoingData(FrameType frame_type,
239 int8_t payload_type,
240 uint32_t timestamp,
241 int64_t capture_time_ms,
242 const uint8_t* payload_data,
243 size_t payload_size,
244 const RTPFragmentationHeader* fragmentation,
245 const RTPVideoHeader* rtp_video_header,
246 uint32_t* transport_frame_id_out) = 0;
247
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700248 virtual bool TimeToSendPacket(uint32_t ssrc,
249 uint16_t sequence_number,
250 int64_t capture_time_ms,
251 bool retransmission,
252 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100253
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700254 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100255
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700256 // Called on generation of new statistics after an RTP send.
257 virtual void RegisterSendChannelRtpStatisticsCallback(
258 StreamDataCountersCallback* callback) = 0;
259 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
260 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100261
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700262 // **************************************************************************
263 // RTCP
264 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100265
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700266 // Returns RTCP status.
267 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100268
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700269 // Sets RTCP status i.e on(compound or non-compound)/off.
270 // |method| - RTCP method to use.
271 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100272
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700273 // Sets RTCP CName (i.e unique identifier).
274 // Returns -1 on failure else 0.
275 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100276
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700277 // Returns remote CName.
278 // Returns -1 on failure else 0.
279 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
280 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100281
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700282 // Returns remote NTP.
283 // Returns -1 on failure else 0.
284 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
285 uint32_t* received_ntp_frac,
286 uint32_t* rtcp_arrival_time_secs,
287 uint32_t* rtcp_arrival_time_frac,
288 uint32_t* rtcp_timestamp) const = 0;
289
290 // Returns -1 on failure else 0.
291 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100292
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700293 // Returns -1 on failure else 0.
294 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100295
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700296 // Returns current RTT (round-trip time) estimate.
297 // Returns -1 on failure else 0.
298 virtual int32_t RTT(uint32_t remote_ssrc,
299 int64_t* rtt,
300 int64_t* avg_rtt,
301 int64_t* min_rtt,
302 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100303
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700304 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
305 // process function.
306 // Returns -1 on failure else 0.
307 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100308
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700309 // Forces a send of a RTCP packet with more than one packet type.
310 // periodic SR and RR are triggered via the process function
311 // Returns -1 on failure else 0.
312 virtual int32_t SendCompoundRTCP(
313 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100314
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700315 // Notifies the sender about good state of the RTP receiver.
316 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100317
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700318 // Send a RTCP Slice Loss Indication (SLI).
319 // |picture_id| - 6 least significant bits of picture_id.
320 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100321
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700322 // Returns statistics of the amount of data sent.
323 // Returns -1 on failure else 0.
324 virtual int32_t DataCountersRTP(size_t* bytes_sent,
325 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100326
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700327 // Returns send statistics for the RTP and RTX stream.
328 virtual void GetSendStreamDataCounters(
329 StreamDataCounters* rtp_counters,
330 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100331
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700332 // Returns packet loss statistics for the RTP stream.
333 virtual void GetRtpPacketLossStats(
334 bool outgoing,
335 uint32_t ssrc,
336 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100337
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700338 // Returns received RTCP sender info.
339 // Returns -1 on failure else 0.
340 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100341
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700342 // Returns received RTCP report block.
343 // Returns -1 on failure else 0.
344 virtual int32_t RemoteRTCPStat(
345 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100346
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700347 // (APP) Sets application specific data.
348 // Returns -1 on failure else 0.
349 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
350 uint32_t name,
351 const uint8_t* data,
352 uint16_t length) = 0;
353 // (XR) Sets VOIP metric.
354 // Returns -1 on failure else 0.
355 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100356
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700357 // (XR) Sets Receiver Reference Time Report (RTTR) status.
358 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100359
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700360 // Returns current Receiver Reference Time Report (RTTR) status.
361 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100362
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700363 // (REMB) Receiver Estimated Max Bitrate.
364 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100365
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700366 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100367
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700368 virtual void SetREMBData(uint32_t bitrate,
369 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100370
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700371 // (TMMBR) Temporary Max Media Bit Rate
372 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100373
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700374 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100375
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700376 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100377
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700378 // TODO(holmer): Propagate this API to VideoEngine.
379 // Returns the currently configured selective retransmission settings.
380 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100381
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700382 // TODO(holmer): Propagate this API to VideoEngine.
383 // Sets the selective retransmission settings, which will decide which
384 // packets will be retransmitted if NACKed. Settings are constructed by
385 // combining the constants in enum RetransmissionMode with bitwise OR.
386 // All packets are retransmitted if kRetransmitAllPackets is set, while no
387 // packets are retransmitted if kRetransmitOff is set.
388 // By default all packets except FEC packets are retransmitted. For VP8
389 // with temporal scalability only base layer packets are retransmitted.
390 // Returns -1 on failure, otherwise 0.
391 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100392
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700393 // Sends a Negative acknowledgement packet.
394 // Returns -1 on failure else 0.
395 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
396 // because we want a function that actually send NACK for the specified
397 // packets.
398 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100399
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700400 // Sends NACK for the packets specified.
401 // Note: This assumes the caller keeps track of timing and doesn't rely on
402 // the RTP module to do this.
403 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100404
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700405 // Store the sent packets, needed to answer to a Negative acknowledgment
406 // requests.
407 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800408
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700409 // Returns true if the module is configured to store packets.
410 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100411
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700412 // Called on receipt of RTCP report block from remote side.
413 virtual void RegisterRtcpStatisticsCallback(
414 RtcpStatisticsCallback* callback) = 0;
415 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
416 // BWE feedback packets.
417 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100418
sprang5e38c962016-12-01 05:18:09 -0800419 virtual void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) = 0;
420
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700421 // **************************************************************************
422 // Audio
423 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100424
ossu00bceb12016-12-02 02:40:02 -0800425 // This function is deprecated. It was previously used to determine when it
426 // was time to send a DTMF packet in silence (CNG).
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700427 // Returns -1 on failure else 0.
ossu00bceb12016-12-02 02:40:02 -0800428 RTC_DEPRECATED virtual int32_t SetAudioPacketSize(
429 uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100430
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700431 // Sends a TelephoneEvent tone using RFC 2833 (4733).
432 // Returns -1 on failure else 0.
433 virtual int32_t SendTelephoneEventOutband(uint8_t key,
434 uint16_t time_ms,
435 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100436
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700437 // Store the audio level in dBov for header-extension-for-audio-level-
438 // indication.
439 // This API shall be called before transmision of an RTP packet to ensure
440 // that the |level| part of the extended RTP header is updated.
441 // return -1 on failure else 0.
442 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100443
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700444 // **************************************************************************
445 // Video
446 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100447
brandtrf1bb4762016-11-07 03:05:06 -0800448 // Set RED and ULPFEC payload types. A payload type of -1 means that the
449 // corresponding feature is turned off. Note that we DO NOT support enabling
450 // ULPFEC without enabling RED. However, we DO support enabling RED without
451 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
452 // assumes that RTX packets carry RED if RED has been configured in the SDP,
453 // regardless of what RTX payload type mapping was negotiated in the SDP.
454 // TODO(brandtr): Update this comment when we have removed the RED/RTX
455 // send-side workaround, i.e., when we do not support enabling RED without
456 // enabling ULPFEC.
457 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800458 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100459
brandtr1743a192016-11-07 03:36:05 -0800460 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
461 // Returns false on failure.
462 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
463 const FecProtectionParams& key_params) = 0;
464
465 // Deprecated version of member function above.
466 RTC_DEPRECATED
467 int32_t SetFecParameters(const FecProtectionParams* delta_params,
468 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100469
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700470 // Set method for requestion a new key frame.
471 // Returns -1 on failure else 0.
472 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100473
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700474 // Sends a request for a keyframe.
475 // Returns -1 on failure else 0.
476 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100477};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700478
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100479} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700480
danilchap5c1def82015-12-10 09:51:54 -0800481#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_