blob: be3d0f453baa82a8124e9cc03741cd6041f1dfca [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"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010020#include "webrtc/modules/include/module.h"
21#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
philipel83f831a2016-03-12 03:30:23 -080022#include "webrtc/modules/video_coding/include/video_coding_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010023
24namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070025
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010026// Forward declarations.
sprangcd349d92016-07-13 09:11:28 -070027class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028class ReceiveStatistics;
29class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070030class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010031class RtpReceiver;
32class Transport;
terelius429c3452016-01-21 05:42:04 -080033
Peter Boström9c017252016-02-26 16:26:20 +010034RTPExtensionType StringToRtpExtensionType(const std::string& extension);
35
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010036namespace rtcp {
37class TransportFeedback;
38}
39
40class RtpRtcp : public Module {
41 public:
42 struct Configuration {
43 Configuration();
44
Sergey Ulanovec4f0682016-07-28 15:19:10 -070045 // True for a audio version of the RTP/RTCP module object false will create
46 // a video version.
47 bool audio = false;
48 bool receiver_only = false;
49
50 // The clock to use to read time. If nullptr then system clock will be used.
51 Clock* clock = nullptr;
52
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010053 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070054
55 // Transport object that will be called when packets are ready to be sent
56 // out on the network.
57 Transport* outgoing_transport = nullptr;
58
59 // Called when the receiver request a intra frame.
60 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
61
62 // Called when we receive a changed estimate from the receiver of out
63 // stream.
64 RtcpBandwidthObserver* bandwidth_callback = nullptr;
65
66 TransportFeedbackObserver* transport_feedback_callback = nullptr;
67 RtcpRttStats* rtt_stats = nullptr;
68 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
69
70 // Estimates the bandwidth available for a set of streams from the same
71 // client.
72 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
73
74 // Spread any bursts of packets into smaller bursts to minimize packet loss.
75 RtpPacketSender* paced_sender = nullptr;
76
77 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
78 nullptr;
79 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
80 FrameCountObserver* send_frame_count_observer = nullptr;
81 SendSideDelayObserver* send_side_delay_observer = nullptr;
82 RtcEventLog* event_log = nullptr;
83 SendPacketObserver* send_packet_observer = nullptr;
84 RateLimiter* retransmission_rate_limiter = nullptr;
85
86 private:
terelius429c3452016-01-21 05:42:04 -080087 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010088 };
89
Sergey Ulanovec4f0682016-07-28 15:19:10 -070090 // Create a RTP/RTCP module object using the system clock.
91 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010092 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
93
Sergey Ulanovec4f0682016-07-28 15:19:10 -070094 // **************************************************************************
95 // Receiver functions
96 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010097
Sergey Ulanovec4f0682016-07-28 15:19:10 -070098 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
99 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100100
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700101 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100102
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700103 // **************************************************************************
104 // Sender
105 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100106
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700107 // Sets MTU.
108 // |size| - Max transfer unit in bytes, default is 1500.
109 // Returns -1 on failure else 0.
110 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100111
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700112 // Sets transtport overhead. Default is IPv4 and UDP with no encryption.
113 // |tcp| - true for TCP false UDP.
114 // |ipv6| - true for IP version 6 false for version 4.
115 // |authentication_overhead| - number of bytes to leave for an authentication
116 // header.
117 // Returns -1 on failure else 0
118 virtual int32_t SetTransportOverhead(bool tcp,
119 bool ipv6,
120 uint8_t authentication_overhead = 0) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100121
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700122 // Returns max payload length, which is a combination of the configuration
123 // MaxTransferUnit and TransportOverhead.
124 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
125 // enabled).
126 virtual uint16_t MaxPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100127
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700128 // Returns max data payload length, which is a combination of the
129 // configuration MaxTransferUnit, headers and TransportOverhead.
130 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
131 // enabled).
132 virtual uint16_t MaxDataPayloadLength() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100133
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700134 // Sets codec name and payload type. Returns -1 on failure else 0.
135 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100136
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700137 // Sets codec name and payload type. Return -1 on failure else 0.
138 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100139
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700140 virtual void RegisterVideoSendPayload(int payload_type,
141 const char* payload_name) = 0;
Peter Boström8b79b072016-02-26 16:31:37 +0100142
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700143 // Unregisters a send payload.
144 // |payload_type| - payload type of codec
145 // Returns -1 on failure else 0.
146 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100147
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700148 // (De)registers RTP header extension type and id.
149 // Returns -1 on failure else 0.
150 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
151 uint8_t id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100152
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700153 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100154
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700155 // Returns start timestamp.
156 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100157
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700158 // Sets start timestamp. Start timestamp is set to a random value if this
159 // function is never called.
160 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100161
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700162 // Returns SequenceNumber.
163 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100164
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700165 // Sets SequenceNumber, default is a random number.
166 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100167
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700168 virtual void SetRtpState(const RtpState& rtp_state) = 0;
169 virtual void SetRtxState(const RtpState& rtp_state) = 0;
170 virtual RtpState GetRtpState() const = 0;
171 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100172
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700173 // Returns SSRC.
174 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100175
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700176 // Sets SSRC, default is a random number.
177 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100178
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700179 // Sets CSRC.
180 // |csrcs| - vector of CSRCs
181 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100182
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700183 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
184 // of values of the enumerator RtxMode.
185 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100186
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700187 // Returns status of sending RTX (RFC 4588). The returned value can be
188 // a combination of values of the enumerator RtxMode.
189 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100190
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700191 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
192 // only the SSRC is set.
193 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100194
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700195 // Sets the payload type to use when sending RTX packets. Note that this
196 // doesn't enable RTX, only the payload type is set.
197 virtual void SetRtxSendPayloadType(int payload_type,
198 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100199
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700200 // Sets sending status. Sends kRtcpByeCode when going from true to false.
201 // Returns -1 on failure else 0.
202 virtual int32_t SetSendingStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100203
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700204 // Returns current sending status.
205 virtual bool Sending() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100206
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700207 // Starts/Stops media packets. On by default.
208 virtual void SetSendingMediaStatus(bool sending) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100209
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700210 // Returns current media sending status.
211 virtual bool SendingMedia() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100212
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700213 // Returns current bitrate in Kbit/s.
214 virtual void BitrateSent(uint32_t* total_rate,
215 uint32_t* video_rate,
216 uint32_t* fec_rate,
217 uint32_t* nack_rate) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100218
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700219 // Used by the codec module to deliver a video or audio frame for
220 // packetization.
221 // |frame_type| - type of frame to send
222 // |payload_type| - payload type of frame to send
223 // |timestamp| - timestamp of frame to send
224 // |payload_data| - payload buffer of frame to send
225 // |payload_size| - size of payload buffer to send
226 // |fragmentation| - fragmentation offset data for fragmented frames such
227 // as layers or RED
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700228 // |transport_frame_id_out| - set to RTP timestamp.
229 // Returns true on success.
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700230 virtual bool SendOutgoingData(FrameType frame_type,
231 int8_t payload_type,
232 uint32_t timestamp,
233 int64_t capture_time_ms,
234 const uint8_t* payload_data,
235 size_t payload_size,
236 const RTPFragmentationHeader* fragmentation,
237 const RTPVideoHeader* rtp_video_header,
238 uint32_t* transport_frame_id_out) = 0;
239
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700240 virtual bool TimeToSendPacket(uint32_t ssrc,
241 uint16_t sequence_number,
242 int64_t capture_time_ms,
243 bool retransmission,
244 int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100245
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700246 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100247
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700248 // Called on generation of new statistics after an RTP send.
249 virtual void RegisterSendChannelRtpStatisticsCallback(
250 StreamDataCountersCallback* callback) = 0;
251 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
252 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100253
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700254 // **************************************************************************
255 // RTCP
256 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100257
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700258 // Returns RTCP status.
259 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100260
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700261 // Sets RTCP status i.e on(compound or non-compound)/off.
262 // |method| - RTCP method to use.
263 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100264
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700265 // Sets RTCP CName (i.e unique identifier).
266 // Returns -1 on failure else 0.
267 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100268
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700269 // Returns remote CName.
270 // Returns -1 on failure else 0.
271 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
272 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100273
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700274 // Returns remote NTP.
275 // Returns -1 on failure else 0.
276 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
277 uint32_t* received_ntp_frac,
278 uint32_t* rtcp_arrival_time_secs,
279 uint32_t* rtcp_arrival_time_frac,
280 uint32_t* rtcp_timestamp) const = 0;
281
282 // Returns -1 on failure else 0.
283 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100284
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700285 // Returns -1 on failure else 0.
286 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100287
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700288 // Returns current RTT (round-trip time) estimate.
289 // Returns -1 on failure else 0.
290 virtual int32_t RTT(uint32_t remote_ssrc,
291 int64_t* rtt,
292 int64_t* avg_rtt,
293 int64_t* min_rtt,
294 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100295
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700296 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
297 // process function.
298 // Returns -1 on failure else 0.
299 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100300
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700301 // Forces a send of a RTCP packet with more than one packet type.
302 // periodic SR and RR are triggered via the process function
303 // Returns -1 on failure else 0.
304 virtual int32_t SendCompoundRTCP(
305 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100306
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700307 // Notifies the sender about good state of the RTP receiver.
308 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100309
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700310 // Send a RTCP Slice Loss Indication (SLI).
311 // |picture_id| - 6 least significant bits of picture_id.
312 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100313
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700314 // Returns statistics of the amount of data sent.
315 // Returns -1 on failure else 0.
316 virtual int32_t DataCountersRTP(size_t* bytes_sent,
317 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100318
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700319 // Returns send statistics for the RTP and RTX stream.
320 virtual void GetSendStreamDataCounters(
321 StreamDataCounters* rtp_counters,
322 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100323
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700324 // Returns packet loss statistics for the RTP stream.
325 virtual void GetRtpPacketLossStats(
326 bool outgoing,
327 uint32_t ssrc,
328 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100329
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700330 // Returns received RTCP sender info.
331 // Returns -1 on failure else 0.
332 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100333
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700334 // Returns received RTCP report block.
335 // Returns -1 on failure else 0.
336 virtual int32_t RemoteRTCPStat(
337 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100338
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700339 // (APP) Sets application specific data.
340 // Returns -1 on failure else 0.
341 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
342 uint32_t name,
343 const uint8_t* data,
344 uint16_t length) = 0;
345 // (XR) Sets VOIP metric.
346 // Returns -1 on failure else 0.
347 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100348
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700349 // (XR) Sets Receiver Reference Time Report (RTTR) status.
350 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100351
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700352 // Returns current Receiver Reference Time Report (RTTR) status.
353 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100354
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700355 // (REMB) Receiver Estimated Max Bitrate.
356 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100357
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700358 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100359
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700360 virtual void SetREMBData(uint32_t bitrate,
361 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100362
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700363 // (TMMBR) Temporary Max Media Bit Rate
364 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100365
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700366 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100367
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700368 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100369
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700370 // TODO(holmer): Propagate this API to VideoEngine.
371 // Returns the currently configured selective retransmission settings.
372 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100373
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700374 // TODO(holmer): Propagate this API to VideoEngine.
375 // Sets the selective retransmission settings, which will decide which
376 // packets will be retransmitted if NACKed. Settings are constructed by
377 // combining the constants in enum RetransmissionMode with bitwise OR.
378 // All packets are retransmitted if kRetransmitAllPackets is set, while no
379 // packets are retransmitted if kRetransmitOff is set.
380 // By default all packets except FEC packets are retransmitted. For VP8
381 // with temporal scalability only base layer packets are retransmitted.
382 // Returns -1 on failure, otherwise 0.
383 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100384
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700385 // Sends a Negative acknowledgement packet.
386 // Returns -1 on failure else 0.
387 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
388 // because we want a function that actually send NACK for the specified
389 // packets.
390 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100391
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700392 // Sends NACK for the packets specified.
393 // Note: This assumes the caller keeps track of timing and doesn't rely on
394 // the RTP module to do this.
395 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100396
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700397 // Store the sent packets, needed to answer to a Negative acknowledgment
398 // requests.
399 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800400
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700401 // Returns true if the module is configured to store packets.
402 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100403
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700404 // Called on receipt of RTCP report block from remote side.
405 virtual void RegisterRtcpStatisticsCallback(
406 RtcpStatisticsCallback* callback) = 0;
407 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
408 // BWE feedback packets.
409 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100410
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700411 // **************************************************************************
412 // Audio
413 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100414
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700415 // Sets audio packet size, used to determine when it's time to send a DTMF
416 // packet in silence (CNG).
417 // Returns -1 on failure else 0.
418 virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100419
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700420 // Sends a TelephoneEvent tone using RFC 2833 (4733).
421 // Returns -1 on failure else 0.
422 virtual int32_t SendTelephoneEventOutband(uint8_t key,
423 uint16_t time_ms,
424 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100425
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700426 // Store the audio level in dBov for header-extension-for-audio-level-
427 // indication.
428 // This API shall be called before transmision of an RTP packet to ensure
429 // that the |level| part of the extended RTP header is updated.
430 // return -1 on failure else 0.
431 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100432
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700433 // **************************************************************************
434 // Video
435 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100436
brandtrd8048952016-11-07 02:08:51 -0800437 // Turn on/off ULPFEC.
438 virtual void SetUlpfecConfig(bool enabled,
439 int red_payload_type,
440 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100441
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700442 virtual int32_t SetFecParameters(const FecProtectionParams* delta_params,
443 const FecProtectionParams* key_params) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100444
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700445 // Set method for requestion a new key frame.
446 // Returns -1 on failure else 0.
447 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100448
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700449 // Sends a request for a keyframe.
450 // Returns -1 on failure else 0.
451 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100452};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700453
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100454} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700455
danilchap5c1def82015-12-10 09:51:54 -0800456#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_