blob: a2c7098722baa52776be24eefecdd3ce7f828e73 [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"
23#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
philipel83f831a2016-03-12 03:30:23 -080024#include "webrtc/modules/video_coding/include/video_coding_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010025
26namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070027
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028// Forward declarations.
sprangcd349d92016-07-13 09:11:28 -070029class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010030class ReceiveStatistics;
31class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070032class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010033class RtpReceiver;
34class Transport;
terelius429c3452016-01-21 05:42:04 -080035
Peter Boström9c017252016-02-26 16:26:20 +010036RTPExtensionType StringToRtpExtensionType(const std::string& extension);
37
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010038namespace rtcp {
39class TransportFeedback;
40}
41
42class RtpRtcp : public Module {
43 public:
44 struct Configuration {
45 Configuration();
46
Sergey Ulanovec4f0682016-07-28 15:19:10 -070047 // True for a audio version of the RTP/RTCP module object false will create
48 // a video version.
49 bool audio = false;
50 bool receiver_only = false;
51
52 // The clock to use to read time. If nullptr then system clock will be used.
53 Clock* clock = nullptr;
54
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010055 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070056
57 // Transport object that will be called when packets are ready to be sent
58 // out on the network.
59 Transport* outgoing_transport = nullptr;
60
61 // Called when the receiver request a intra frame.
62 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
63
64 // Called when we receive a changed estimate from the receiver of out
65 // stream.
66 RtcpBandwidthObserver* bandwidth_callback = nullptr;
67
68 TransportFeedbackObserver* transport_feedback_callback = nullptr;
69 RtcpRttStats* rtt_stats = nullptr;
70 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
71
72 // Estimates the bandwidth available for a set of streams from the same
73 // client.
74 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
75
76 // Spread any bursts of packets into smaller bursts to minimize packet loss.
77 RtpPacketSender* paced_sender = nullptr;
78
79 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
80 nullptr;
81 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
82 FrameCountObserver* send_frame_count_observer = nullptr;
83 SendSideDelayObserver* send_side_delay_observer = nullptr;
84 RtcEventLog* event_log = nullptr;
85 SendPacketObserver* send_packet_observer = nullptr;
86 RateLimiter* retransmission_rate_limiter = nullptr;
87
88 private:
terelius429c3452016-01-21 05:42:04 -080089 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010090 };
91
Sergey Ulanovec4f0682016-07-28 15:19:10 -070092 // Create a RTP/RTCP module object using the system clock.
93 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010094 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
95
Sergey Ulanovec4f0682016-07-28 15:19:10 -070096 // **************************************************************************
97 // Receiver functions
98 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010099
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700100 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
101 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100102
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700103 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100104
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700105 // **************************************************************************
106 // Sender
107 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100108
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700109 // Sets MTU.
110 // |size| - Max transfer unit in bytes, default is 1500.
111 // Returns -1 on failure else 0.
112 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100113
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700114 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
115 // |tcp| - true for TCP false UDP.
116 // |ipv6| - true for IP version 6 false for version 4.
117 // |authentication_overhead| - number of bytes to leave for an authentication
118 // header.
119 // Returns -1 on failure else 0
michaelt79e05882016-11-08 02:50:09 -0800120 // TODO(michaelt): deprecate the function.
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700121 virtual int32_t SetTransportOverhead(bool tcp,
122 bool ipv6,
123 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100124
michaelt79e05882016-11-08 02:50:09 -0800125 // Sets transtport overhead per packet.
126 virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0;
127
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700128 // Returns max payload length, which is a combination of the configuration
129 // MaxTransferUnit and TransportOverhead.
130 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
131 // enabled).
132 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100133
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700134 // Returns max data payload length, which is a combination of the
135 // configuration MaxTransferUnit, headers and TransportOverhead.
136 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
137 // enabled).
138 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100139
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700140 // Sets codec name and payload type. Returns -1 on failure else 0.
141 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100142
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700143 // Sets codec name and payload type. Return -1 on failure else 0.
144 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100145
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700146 virtual void RegisterVideoSendPayload(int payload_type,
147 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100148
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700149 // Unregisters a send payload.
150 // |payload_type| - payload type of codec
151 // Returns -1 on failure else 0.
152 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100153
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700154 // (De)registers RTP header extension type and id.
155 // Returns -1 on failure else 0.
156 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
157 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100158
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700159 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100160
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700161 // Returns start timestamp.
162 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100163
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700164 // Sets start timestamp. Start timestamp is set to a random value if this
165 // function is never called.
166 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100167
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700168 // Returns SequenceNumber.
169 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100170
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700171 // Sets SequenceNumber, default is a random number.
172 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100173
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700174 virtual void SetRtpState(const RtpState& rtp_state) = 0;
175 virtual void SetRtxState(const RtpState& rtp_state) = 0;
176 virtual RtpState GetRtpState() const = 0;
177 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100178
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700179 // Returns SSRC.
180 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100181
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700182 // Sets SSRC, default is a random number.
183 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100184
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700185 // Sets CSRC.
186 // |csrcs| - vector of CSRCs
187 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100188
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700189 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
190 // of values of the enumerator RtxMode.
191 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100192
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700193 // Returns status of sending RTX (RFC 4588). The returned value can be
194 // a combination of values of the enumerator RtxMode.
195 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100196
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700197 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
198 // only the SSRC is set.
199 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100200
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700201 // Sets the payload type to use when sending RTX packets. Note that this
202 // doesn't enable RTX, only the payload type is set.
203 virtual void SetRtxSendPayloadType(int payload_type,
204 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100205
brandtr9dfff292016-11-14 05:14:50 -0800206 // Returns the FlexFEC SSRC, if there is one.
207 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
208
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700209 // Sets sending status. Sends kRtcpByeCode when going from true to false.
210 // Returns -1 on failure else 0.
211 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100212
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700213 // Returns current sending status.
214 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100215
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700216 // Starts/Stops media packets. On by default.
217 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100218
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700219 // Returns current media sending status.
220 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100221
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700222 // Returns current bitrate in Kbit/s.
223 virtual void BitrateSent(uint32_t* total_rate,
224 uint32_t* video_rate,
225 uint32_t* fec_rate,
226 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100227
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700228 // Used by the codec module to deliver a video or audio frame for
229 // packetization.
230 // |frame_type| - type of frame to send
231 // |payload_type| - payload type of frame to send
232 // |timestamp| - timestamp of frame to send
233 // |payload_data| - payload buffer of frame to send
234 // |payload_size| - size of payload buffer to send
235 // |fragmentation| - fragmentation offset data for fragmented frames such
236 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700237 // |transport_frame_id_out| - set to RTP timestamp.
238 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700239 virtual bool SendOutgoingData(FrameType frame_type,
240 int8_t payload_type,
241 uint32_t timestamp,
242 int64_t capture_time_ms,
243 const uint8_t* payload_data,
244 size_t payload_size,
245 const RTPFragmentationHeader* fragmentation,
246 const RTPVideoHeader* rtp_video_header,
247 uint32_t* transport_frame_id_out) = 0;
248
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700249 virtual bool TimeToSendPacket(uint32_t ssrc,
250 uint16_t sequence_number,
251 int64_t capture_time_ms,
252 bool retransmission,
253 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100254
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700255 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100256
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700257 // Called on generation of new statistics after an RTP send.
258 virtual void RegisterSendChannelRtpStatisticsCallback(
259 StreamDataCountersCallback* callback) = 0;
260 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
261 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100262
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700263 // **************************************************************************
264 // RTCP
265 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100266
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700267 // Returns RTCP status.
268 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100269
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700270 // Sets RTCP status i.e on(compound or non-compound)/off.
271 // |method| - RTCP method to use.
272 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100273
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700274 // Sets RTCP CName (i.e unique identifier).
275 // Returns -1 on failure else 0.
276 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100277
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700278 // Returns remote CName.
279 // Returns -1 on failure else 0.
280 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
281 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100282
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700283 // Returns remote NTP.
284 // Returns -1 on failure else 0.
285 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
286 uint32_t* received_ntp_frac,
287 uint32_t* rtcp_arrival_time_secs,
288 uint32_t* rtcp_arrival_time_frac,
289 uint32_t* rtcp_timestamp) const = 0;
290
291 // Returns -1 on failure else 0.
292 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100293
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700294 // Returns -1 on failure else 0.
295 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100296
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700297 // Returns current RTT (round-trip time) estimate.
298 // Returns -1 on failure else 0.
299 virtual int32_t RTT(uint32_t remote_ssrc,
300 int64_t* rtt,
301 int64_t* avg_rtt,
302 int64_t* min_rtt,
303 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100304
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700305 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
306 // process function.
307 // Returns -1 on failure else 0.
308 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100309
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700310 // Forces a send of a RTCP packet with more than one packet type.
311 // periodic SR and RR are triggered via the process function
312 // Returns -1 on failure else 0.
313 virtual int32_t SendCompoundRTCP(
314 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100315
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700316 // Notifies the sender about good state of the RTP receiver.
317 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100318
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700319 // Send a RTCP Slice Loss Indication (SLI).
320 // |picture_id| - 6 least significant bits of picture_id.
321 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100322
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700323 // Returns statistics of the amount of data sent.
324 // Returns -1 on failure else 0.
325 virtual int32_t DataCountersRTP(size_t* bytes_sent,
326 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100327
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700328 // Returns send statistics for the RTP and RTX stream.
329 virtual void GetSendStreamDataCounters(
330 StreamDataCounters* rtp_counters,
331 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100332
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700333 // Returns packet loss statistics for the RTP stream.
334 virtual void GetRtpPacketLossStats(
335 bool outgoing,
336 uint32_t ssrc,
337 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100338
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700339 // Returns received RTCP sender info.
340 // Returns -1 on failure else 0.
341 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100342
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700343 // Returns received RTCP report block.
344 // Returns -1 on failure else 0.
345 virtual int32_t RemoteRTCPStat(
346 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100347
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700348 // (APP) Sets application specific data.
349 // Returns -1 on failure else 0.
350 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
351 uint32_t name,
352 const uint8_t* data,
353 uint16_t length) = 0;
354 // (XR) Sets VOIP metric.
355 // Returns -1 on failure else 0.
356 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100357
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700358 // (XR) Sets Receiver Reference Time Report (RTTR) status.
359 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100360
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700361 // Returns current Receiver Reference Time Report (RTTR) status.
362 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100363
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700364 // (REMB) Receiver Estimated Max Bitrate.
365 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100366
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700367 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100368
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700369 virtual void SetREMBData(uint32_t bitrate,
370 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100371
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700372 // (TMMBR) Temporary Max Media Bit Rate
373 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100374
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700375 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100376
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700377 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100378
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700379 // TODO(holmer): Propagate this API to VideoEngine.
380 // Returns the currently configured selective retransmission settings.
381 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100382
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700383 // TODO(holmer): Propagate this API to VideoEngine.
384 // Sets the selective retransmission settings, which will decide which
385 // packets will be retransmitted if NACKed. Settings are constructed by
386 // combining the constants in enum RetransmissionMode with bitwise OR.
387 // All packets are retransmitted if kRetransmitAllPackets is set, while no
388 // packets are retransmitted if kRetransmitOff is set.
389 // By default all packets except FEC packets are retransmitted. For VP8
390 // with temporal scalability only base layer packets are retransmitted.
391 // Returns -1 on failure, otherwise 0.
392 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100393
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700394 // Sends a Negative acknowledgement packet.
395 // Returns -1 on failure else 0.
396 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
397 // because we want a function that actually send NACK for the specified
398 // packets.
399 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100400
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700401 // Sends NACK for the packets specified.
402 // Note: This assumes the caller keeps track of timing and doesn't rely on
403 // the RTP module to do this.
404 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100405
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700406 // Store the sent packets, needed to answer to a Negative acknowledgment
407 // requests.
408 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800409
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700410 // Returns true if the module is configured to store packets.
411 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100412
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700413 // Called on receipt of RTCP report block from remote side.
414 virtual void RegisterRtcpStatisticsCallback(
415 RtcpStatisticsCallback* callback) = 0;
416 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
417 // BWE feedback packets.
418 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100419
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700420 // **************************************************************************
421 // Audio
422 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100423
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700424 // Sets audio packet size, used to determine when it's time to send a DTMF
425 // packet in silence (CNG).
426 // Returns -1 on failure else 0.
427 virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100428
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700429 // Sends a TelephoneEvent tone using RFC 2833 (4733).
430 // Returns -1 on failure else 0.
431 virtual int32_t SendTelephoneEventOutband(uint8_t key,
432 uint16_t time_ms,
433 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100434
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700435 // Store the audio level in dBov for header-extension-for-audio-level-
436 // indication.
437 // This API shall be called before transmision of an RTP packet to ensure
438 // that the |level| part of the extended RTP header is updated.
439 // return -1 on failure else 0.
440 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100441
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700442 // **************************************************************************
443 // Video
444 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100445
brandtrf1bb4762016-11-07 03:05:06 -0800446 // Set RED and ULPFEC payload types. A payload type of -1 means that the
447 // corresponding feature is turned off. Note that we DO NOT support enabling
448 // ULPFEC without enabling RED. However, we DO support enabling RED without
449 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
450 // assumes that RTX packets carry RED if RED has been configured in the SDP,
451 // regardless of what RTX payload type mapping was negotiated in the SDP.
452 // TODO(brandtr): Update this comment when we have removed the RED/RTX
453 // send-side workaround, i.e., when we do not support enabling RED without
454 // enabling ULPFEC.
455 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800456 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100457
brandtr1743a192016-11-07 03:36:05 -0800458 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
459 // Returns false on failure.
460 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
461 const FecProtectionParams& key_params) = 0;
462
463 // Deprecated version of member function above.
464 RTC_DEPRECATED
465 int32_t SetFecParameters(const FecProtectionParams* delta_params,
466 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100467
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700468 // Set method for requestion a new key frame.
469 // Returns -1 on failure else 0.
470 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100471
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700472 // Sends a request for a keyframe.
473 // Returns -1 on failure else 0.
474 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100475};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700476
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100477} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700478
danilchap5c1def82015-12-10 09:51:54 -0800479#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_