blob: 1e4da64220d1d91577a38ed3e1277a349bcdff59 [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"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010021#include "webrtc/modules/include/module.h"
22#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
philipel83f831a2016-03-12 03:30:23 -080023#include "webrtc/modules/video_coding/include/video_coding_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010024
25namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070026
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010027// Forward declarations.
sprangcd349d92016-07-13 09:11:28 -070028class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010029class ReceiveStatistics;
30class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070031class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010032class RtpReceiver;
33class Transport;
terelius429c3452016-01-21 05:42:04 -080034
Peter Boström9c017252016-02-26 16:26:20 +010035RTPExtensionType StringToRtpExtensionType(const std::string& extension);
36
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010037namespace rtcp {
38class TransportFeedback;
39}
40
41class RtpRtcp : public Module {
42 public:
43 struct Configuration {
44 Configuration();
45
Sergey Ulanovec4f0682016-07-28 15:19:10 -070046 // True for a audio version of the RTP/RTCP module object false will create
47 // a video version.
48 bool audio = false;
49 bool receiver_only = false;
50
51 // The clock to use to read time. If nullptr then system clock will be used.
52 Clock* clock = nullptr;
53
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010054 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070055
56 // Transport object that will be called when packets are ready to be sent
57 // out on the network.
58 Transport* outgoing_transport = nullptr;
59
60 // Called when the receiver request a intra frame.
61 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
62
63 // Called when we receive a changed estimate from the receiver of out
64 // stream.
65 RtcpBandwidthObserver* bandwidth_callback = nullptr;
66
67 TransportFeedbackObserver* transport_feedback_callback = nullptr;
68 RtcpRttStats* rtt_stats = nullptr;
69 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
70
71 // Estimates the bandwidth available for a set of streams from the same
72 // client.
73 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
74
75 // Spread any bursts of packets into smaller bursts to minimize packet loss.
76 RtpPacketSender* paced_sender = nullptr;
77
78 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
79 nullptr;
80 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
81 FrameCountObserver* send_frame_count_observer = nullptr;
82 SendSideDelayObserver* send_side_delay_observer = nullptr;
83 RtcEventLog* event_log = nullptr;
84 SendPacketObserver* send_packet_observer = nullptr;
85 RateLimiter* retransmission_rate_limiter = nullptr;
86
87 private:
terelius429c3452016-01-21 05:42:04 -080088 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010089 };
90
Sergey Ulanovec4f0682016-07-28 15:19:10 -070091 // Create a RTP/RTCP module object using the system clock.
92 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010093 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
94
Sergey Ulanovec4f0682016-07-28 15:19:10 -070095 // **************************************************************************
96 // Receiver functions
97 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010098
Sergey Ulanovec4f0682016-07-28 15:19:10 -070099 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
100 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100101
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700102 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100103
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700104 // **************************************************************************
105 // Sender
106 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100107
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700108 // Sets MTU.
109 // |size| - Max transfer unit in bytes, default is 1500.
110 // Returns -1 on failure else 0.
111 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100112
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700113 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
114 // |tcp| - true for TCP false UDP.
115 // |ipv6| - true for IP version 6 false for version 4.
116 // |authentication_overhead| - number of bytes to leave for an authentication
117 // header.
118 // Returns -1 on failure else 0
michaelt79e05882016-11-08 02:50:09 -0800119 // TODO(michaelt): deprecate the function.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700120 virtual int32_t SetTransportOverhead(bool tcp,
121 bool ipv6,
122 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100123
michaelt79e05882016-11-08 02:50:09 -0800124 // Sets transtport overhead per packet.
125 virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0;
126
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700127 // Returns max payload length, which is a combination of the configuration
128 // MaxTransferUnit and TransportOverhead.
129 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
130 // enabled).
131 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100132
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700133 // Returns max data payload length, which is a combination of the
134 // configuration MaxTransferUnit, headers and TransportOverhead.
135 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
136 // enabled).
137 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100138
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700139 // Sets codec name and payload type. Returns -1 on failure else 0.
140 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100141
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700142 // Sets codec name and payload type. Return -1 on failure else 0.
143 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100144
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700145 virtual void RegisterVideoSendPayload(int payload_type,
146 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100147
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700148 // Unregisters a send payload.
149 // |payload_type| - payload type of codec
150 // Returns -1 on failure else 0.
151 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100152
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700153 // (De)registers RTP header extension type and id.
154 // Returns -1 on failure else 0.
155 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
156 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100157
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700158 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100159
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
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700205 // Sets sending status. Sends kRtcpByeCode when going from true to false.
206 // Returns -1 on failure else 0.
207 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100208
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700209 // Returns current sending status.
210 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100211
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700212 // Starts/Stops media packets. On by default.
213 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100214
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700215 // Returns current media sending status.
216 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100217
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700218 // Returns current bitrate in Kbit/s.
219 virtual void BitrateSent(uint32_t* total_rate,
220 uint32_t* video_rate,
221 uint32_t* fec_rate,
222 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100223
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700224 // Used by the codec module to deliver a video or audio frame for
225 // packetization.
226 // |frame_type| - type of frame to send
227 // |payload_type| - payload type of frame to send
228 // |timestamp| - timestamp of frame to send
229 // |payload_data| - payload buffer of frame to send
230 // |payload_size| - size of payload buffer to send
231 // |fragmentation| - fragmentation offset data for fragmented frames such
232 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700233 // |transport_frame_id_out| - set to RTP timestamp.
234 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700235 virtual bool SendOutgoingData(FrameType frame_type,
236 int8_t payload_type,
237 uint32_t timestamp,
238 int64_t capture_time_ms,
239 const uint8_t* payload_data,
240 size_t payload_size,
241 const RTPFragmentationHeader* fragmentation,
242 const RTPVideoHeader* rtp_video_header,
243 uint32_t* transport_frame_id_out) = 0;
244
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700245 virtual bool TimeToSendPacket(uint32_t ssrc,
246 uint16_t sequence_number,
247 int64_t capture_time_ms,
248 bool retransmission,
249 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100250
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700251 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100252
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700253 // Called on generation of new statistics after an RTP send.
254 virtual void RegisterSendChannelRtpStatisticsCallback(
255 StreamDataCountersCallback* callback) = 0;
256 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
257 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100258
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700259 // **************************************************************************
260 // RTCP
261 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100262
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700263 // Returns RTCP status.
264 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100265
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700266 // Sets RTCP status i.e on(compound or non-compound)/off.
267 // |method| - RTCP method to use.
268 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100269
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700270 // Sets RTCP CName (i.e unique identifier).
271 // Returns -1 on failure else 0.
272 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100273
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700274 // Returns remote CName.
275 // Returns -1 on failure else 0.
276 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
277 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100278
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700279 // Returns remote NTP.
280 // Returns -1 on failure else 0.
281 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
282 uint32_t* received_ntp_frac,
283 uint32_t* rtcp_arrival_time_secs,
284 uint32_t* rtcp_arrival_time_frac,
285 uint32_t* rtcp_timestamp) const = 0;
286
287 // Returns -1 on failure else 0.
288 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100289
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700290 // Returns -1 on failure else 0.
291 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100292
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700293 // Returns current RTT (round-trip time) estimate.
294 // Returns -1 on failure else 0.
295 virtual int32_t RTT(uint32_t remote_ssrc,
296 int64_t* rtt,
297 int64_t* avg_rtt,
298 int64_t* min_rtt,
299 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100300
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700301 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
302 // process function.
303 // Returns -1 on failure else 0.
304 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100305
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700306 // Forces a send of a RTCP packet with more than one packet type.
307 // periodic SR and RR are triggered via the process function
308 // Returns -1 on failure else 0.
309 virtual int32_t SendCompoundRTCP(
310 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100311
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700312 // Notifies the sender about good state of the RTP receiver.
313 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100314
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700315 // Send a RTCP Slice Loss Indication (SLI).
316 // |picture_id| - 6 least significant bits of picture_id.
317 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100318
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700319 // Returns statistics of the amount of data sent.
320 // Returns -1 on failure else 0.
321 virtual int32_t DataCountersRTP(size_t* bytes_sent,
322 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100323
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700324 // Returns send statistics for the RTP and RTX stream.
325 virtual void GetSendStreamDataCounters(
326 StreamDataCounters* rtp_counters,
327 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100328
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700329 // Returns packet loss statistics for the RTP stream.
330 virtual void GetRtpPacketLossStats(
331 bool outgoing,
332 uint32_t ssrc,
333 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100334
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700335 // Returns received RTCP sender info.
336 // Returns -1 on failure else 0.
337 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100338
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700339 // Returns received RTCP report block.
340 // Returns -1 on failure else 0.
341 virtual int32_t RemoteRTCPStat(
342 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100343
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700344 // (APP) Sets application specific data.
345 // Returns -1 on failure else 0.
346 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
347 uint32_t name,
348 const uint8_t* data,
349 uint16_t length) = 0;
350 // (XR) Sets VOIP metric.
351 // Returns -1 on failure else 0.
352 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100353
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700354 // (XR) Sets Receiver Reference Time Report (RTTR) status.
355 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100356
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700357 // Returns current Receiver Reference Time Report (RTTR) status.
358 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100359
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700360 // (REMB) Receiver Estimated Max Bitrate.
361 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100362
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700363 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100364
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700365 virtual void SetREMBData(uint32_t bitrate,
366 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100367
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700368 // (TMMBR) Temporary Max Media Bit Rate
369 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100370
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700371 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100372
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700373 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100374
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700375 // TODO(holmer): Propagate this API to VideoEngine.
376 // Returns the currently configured selective retransmission settings.
377 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100378
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700379 // TODO(holmer): Propagate this API to VideoEngine.
380 // Sets the selective retransmission settings, which will decide which
381 // packets will be retransmitted if NACKed. Settings are constructed by
382 // combining the constants in enum RetransmissionMode with bitwise OR.
383 // All packets are retransmitted if kRetransmitAllPackets is set, while no
384 // packets are retransmitted if kRetransmitOff is set.
385 // By default all packets except FEC packets are retransmitted. For VP8
386 // with temporal scalability only base layer packets are retransmitted.
387 // Returns -1 on failure, otherwise 0.
388 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100389
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700390 // Sends a Negative acknowledgement packet.
391 // Returns -1 on failure else 0.
392 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
393 // because we want a function that actually send NACK for the specified
394 // packets.
395 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100396
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700397 // Sends NACK for the packets specified.
398 // Note: This assumes the caller keeps track of timing and doesn't rely on
399 // the RTP module to do this.
400 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100401
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700402 // Store the sent packets, needed to answer to a Negative acknowledgment
403 // requests.
404 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800405
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700406 // Returns true if the module is configured to store packets.
407 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100408
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700409 // Called on receipt of RTCP report block from remote side.
410 virtual void RegisterRtcpStatisticsCallback(
411 RtcpStatisticsCallback* callback) = 0;
412 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
413 // BWE feedback packets.
414 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100415
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700416 // **************************************************************************
417 // Audio
418 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100419
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700420 // Sets audio packet size, used to determine when it's time to send a DTMF
421 // packet in silence (CNG).
422 // Returns -1 on failure else 0.
423 virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100424
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700425 // Sends a TelephoneEvent tone using RFC 2833 (4733).
426 // Returns -1 on failure else 0.
427 virtual int32_t SendTelephoneEventOutband(uint8_t key,
428 uint16_t time_ms,
429 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100430
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700431 // Store the audio level in dBov for header-extension-for-audio-level-
432 // indication.
433 // This API shall be called before transmision of an RTP packet to ensure
434 // that the |level| part of the extended RTP header is updated.
435 // return -1 on failure else 0.
436 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100437
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700438 // **************************************************************************
439 // Video
440 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100441
brandtrf1bb4762016-11-07 03:05:06 -0800442 // Set RED and ULPFEC payload types. A payload type of -1 means that the
443 // corresponding feature is turned off. Note that we DO NOT support enabling
444 // ULPFEC without enabling RED. However, we DO support enabling RED without
445 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
446 // assumes that RTX packets carry RED if RED has been configured in the SDP,
447 // regardless of what RTX payload type mapping was negotiated in the SDP.
448 // TODO(brandtr): Update this comment when we have removed the RED/RTX
449 // send-side workaround, i.e., when we do not support enabling RED without
450 // enabling ULPFEC.
451 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800452 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100453
brandtr1743a192016-11-07 03:36:05 -0800454 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
455 // Returns false on failure.
456 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
457 const FecProtectionParams& key_params) = 0;
458
459 // Deprecated version of member function above.
460 RTC_DEPRECATED
461 int32_t SetFecParameters(const FecProtectionParams* delta_params,
462 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100463
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700464 // Set method for requestion a new key frame.
465 // Returns -1 on failure else 0.
466 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100467
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700468 // Sends a request for a keyframe.
469 // Returns -1 on failure else 0.
470 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100471};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700472
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100473} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700474
danilchap5c1def82015-12-10 09:51:54 -0800475#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_