blob: a5d1b0b0d7ae3cb34875a757ea243a14de5ce752 [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
Henrik Kjellanderdca1e092017-07-01 16:42:22 +020019#include "webrtc/base/constructormagic.h"
20#include "webrtc/base/deprecation.h"
21#include "webrtc/base/optional.h"
sprang168794c2017-07-06 04:38:06 -070022#include "webrtc/common_types.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010023#include "webrtc/modules/include/module.h"
brandtre950cad2016-11-15 05:25:41 -080024#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010025#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
26
27namespace webrtc {
Sergey Ulanovec4f0682016-07-28 15:19:10 -070028
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010029// Forward declarations.
michaelt4da30442016-11-17 01:38:43 -080030class OverheadObserver;
sprangcd349d92016-07-13 09:11:28 -070031class RateLimiter;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010032class ReceiveStatistics;
33class RemoteBitrateEstimator;
sprangcd349d92016-07-13 09:11:28 -070034class RtcEventLog;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010035class RtpReceiver;
36class Transport;
spranga790d832016-12-02 07:29:44 -080037class VideoBitrateAllocationObserver;
terelius429c3452016-01-21 05:42:04 -080038
Peter Boström9c017252016-02-26 16:26:20 +010039RTPExtensionType StringToRtpExtensionType(const std::string& extension);
40
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010041namespace rtcp {
42class TransportFeedback;
43}
44
45class RtpRtcp : public Module {
46 public:
47 struct Configuration {
48 Configuration();
49
Sergey Ulanovec4f0682016-07-28 15:19:10 -070050 // True for a audio version of the RTP/RTCP module object false will create
51 // a video version.
52 bool audio = false;
53 bool receiver_only = false;
54
55 // The clock to use to read time. If nullptr then system clock will be used.
56 Clock* clock = nullptr;
57
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010058 ReceiveStatistics* receive_statistics;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070059
60 // Transport object that will be called when packets are ready to be sent
61 // out on the network.
62 Transport* outgoing_transport = nullptr;
63
64 // Called when the receiver request a intra frame.
65 RtcpIntraFrameObserver* intra_frame_callback = nullptr;
66
67 // Called when we receive a changed estimate from the receiver of out
68 // stream.
69 RtcpBandwidthObserver* bandwidth_callback = nullptr;
70
71 TransportFeedbackObserver* transport_feedback_callback = nullptr;
spranga790d832016-12-02 07:29:44 -080072 VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070073 RtcpRttStats* rtt_stats = nullptr;
74 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
75
76 // Estimates the bandwidth available for a set of streams from the same
77 // client.
78 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
79
80 // Spread any bursts of packets into smaller bursts to minimize packet loss.
81 RtpPacketSender* paced_sender = nullptr;
82
brandtre950cad2016-11-15 05:25:41 -080083 // Generate FlexFEC packets.
84 // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender.
85 FlexfecSender* flexfec_sender = nullptr;
86
Sergey Ulanovec4f0682016-07-28 15:19:10 -070087 TransportSequenceNumberAllocator* transport_sequence_number_allocator =
88 nullptr;
89 BitrateStatisticsObserver* send_bitrate_observer = nullptr;
90 FrameCountObserver* send_frame_count_observer = nullptr;
91 SendSideDelayObserver* send_side_delay_observer = nullptr;
92 RtcEventLog* event_log = nullptr;
93 SendPacketObserver* send_packet_observer = nullptr;
94 RateLimiter* retransmission_rate_limiter = nullptr;
michaelt4da30442016-11-17 01:38:43 -080095 OverheadObserver* overhead_observer = nullptr;
sprang168794c2017-07-06 04:38:06 -070096 RtpKeepAliveConfig keepalive_config;
Sergey Ulanovec4f0682016-07-28 15:19:10 -070097
98 private:
terelius429c3452016-01-21 05:42:04 -080099 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100100 };
101
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700102 // Create a RTP/RTCP module object using the system clock.
103 // |configuration| - Configuration of the RTP/RTCP module.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100104 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
105
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700106 // **************************************************************************
107 // Receiver functions
108 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100109
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700110 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
111 size_t incoming_packet_length) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100112
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700113 virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100114
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700115 // **************************************************************************
116 // Sender
117 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100118
nisse284542b2017-01-10 08:58:32 -0800119 // TODO(nisse): Deprecated. Kept temporarily, as an alias for the
120 // new function which has slighly different semantics. Delete as
121 // soon as known applications are updated.
122 virtual int32_t SetMaxTransferUnit(uint16_t size) {
123 SetMaxRtpPacketSize(size);
124 return 0;
125 }
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100126
nisse284542b2017-01-10 08:58:32 -0800127 // Sets the maximum size of an RTP packet, including RTP headers.
128 virtual void SetMaxRtpPacketSize(size_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100129
nisse284542b2017-01-10 08:58:32 -0800130 // Returns max RTP packet size. Takes into account RTP headers and
131 // FEC/ULP/RED overhead (when FEC is enabled).
132 virtual size_t MaxRtpPacketSize() 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
stefan53b6cc32017-02-03 08:13:57 -0800155 virtual bool HasBweExtensions() const = 0;
156
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700157 // Returns start timestamp.
158 virtual uint32_t StartTimestamp() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100159
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700160 // Sets start timestamp. Start timestamp is set to a random value if this
161 // function is never called.
162 virtual void SetStartTimestamp(uint32_t timestamp) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100163
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700164 // Returns SequenceNumber.
165 virtual uint16_t SequenceNumber() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100166
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700167 // Sets SequenceNumber, default is a random number.
168 virtual void SetSequenceNumber(uint16_t seq) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100169
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700170 virtual void SetRtpState(const RtpState& rtp_state) = 0;
171 virtual void SetRtxState(const RtpState& rtp_state) = 0;
172 virtual RtpState GetRtpState() const = 0;
173 virtual RtpState GetRtxState() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100174
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700175 // Returns SSRC.
176 virtual uint32_t SSRC() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100177
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700178 // Sets SSRC, default is a random number.
179 virtual void SetSSRC(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100180
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700181 // Sets CSRC.
182 // |csrcs| - vector of CSRCs
183 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100184
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700185 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
186 // of values of the enumerator RtxMode.
187 virtual void SetRtxSendStatus(int modes) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100188
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700189 // Returns status of sending RTX (RFC 4588). The returned value can be
190 // a combination of values of the enumerator RtxMode.
191 virtual int RtxSendStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100192
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700193 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
194 // only the SSRC is set.
195 virtual void SetRtxSsrc(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100196
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700197 // Sets the payload type to use when sending RTX packets. Note that this
198 // doesn't enable RTX, only the payload type is set.
199 virtual void SetRtxSendPayloadType(int payload_type,
200 int associated_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100201
brandtr9dfff292016-11-14 05:14:50 -0800202 // Returns the FlexFEC SSRC, if there is one.
203 virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0;
204
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,
philipelc7bf32a2017-02-17 03:59:43 -0800249 const PacedPacketInfo& pacing_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100250
philipelc7bf32a2017-02-17 03:59:43 -0800251 virtual size_t TimeToSendPadding(size_t bytes,
252 const PacedPacketInfo& pacing_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100253
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700254 // Called on generation of new statistics after an RTP send.
255 virtual void RegisterSendChannelRtpStatisticsCallback(
256 StreamDataCountersCallback* callback) = 0;
257 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
258 const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100259
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700260 // **************************************************************************
261 // RTCP
262 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100263
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700264 // Returns RTCP status.
265 virtual RtcpMode RTCP() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100266
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700267 // Sets RTCP status i.e on(compound or non-compound)/off.
268 // |method| - RTCP method to use.
269 virtual void SetRTCPStatus(RtcpMode method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100270
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700271 // Sets RTCP CName (i.e unique identifier).
272 // Returns -1 on failure else 0.
273 virtual int32_t SetCNAME(const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100274
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700275 // Returns remote CName.
276 // Returns -1 on failure else 0.
277 virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
278 char cname[RTCP_CNAME_SIZE]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100279
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700280 // Returns remote NTP.
281 // Returns -1 on failure else 0.
282 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
283 uint32_t* received_ntp_frac,
284 uint32_t* rtcp_arrival_time_secs,
285 uint32_t* rtcp_arrival_time_frac,
286 uint32_t* rtcp_timestamp) const = 0;
287
288 // Returns -1 on failure else 0.
289 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100290
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700291 // Returns -1 on failure else 0.
292 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100293
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700294 // Returns current RTT (round-trip time) estimate.
295 // Returns -1 on failure else 0.
296 virtual int32_t RTT(uint32_t remote_ssrc,
297 int64_t* rtt,
298 int64_t* avg_rtt,
299 int64_t* min_rtt,
300 int64_t* max_rtt) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100301
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700302 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
303 // process function.
304 // Returns -1 on failure else 0.
305 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100306
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700307 // Forces a send of a RTCP packet with more than one packet type.
308 // periodic SR and RR are triggered via the process function
309 // Returns -1 on failure else 0.
310 virtual int32_t SendCompoundRTCP(
311 const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100312
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700313 // Returns statistics of the amount of data sent.
314 // Returns -1 on failure else 0.
315 virtual int32_t DataCountersRTP(size_t* bytes_sent,
316 uint32_t* packets_sent) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100317
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700318 // Returns send statistics for the RTP and RTX stream.
319 virtual void GetSendStreamDataCounters(
320 StreamDataCounters* rtp_counters,
321 StreamDataCounters* rtx_counters) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100322
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700323 // Returns packet loss statistics for the RTP stream.
324 virtual void GetRtpPacketLossStats(
325 bool outgoing,
326 uint32_t ssrc,
327 struct RtpPacketLossStats* loss_stats) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100328
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700329 // Returns received RTCP sender info.
330 // Returns -1 on failure else 0.
331 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100332
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700333 // Returns received RTCP report block.
334 // Returns -1 on failure else 0.
335 virtual int32_t RemoteRTCPStat(
336 std::vector<RTCPReportBlock>* receive_blocks) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100337
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700338 // (APP) Sets application specific data.
339 // Returns -1 on failure else 0.
340 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
341 uint32_t name,
342 const uint8_t* data,
343 uint16_t length) = 0;
344 // (XR) Sets VOIP metric.
345 // Returns -1 on failure else 0.
346 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100347
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700348 // (XR) Sets Receiver Reference Time Report (RTTR) status.
349 virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100350
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700351 // Returns current Receiver Reference Time Report (RTTR) status.
352 virtual bool RtcpXrRrtrStatus() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100353
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700354 // (REMB) Receiver Estimated Max Bitrate.
355 virtual bool REMB() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100356
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700357 virtual void SetREMBStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100358
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700359 virtual void SetREMBData(uint32_t bitrate,
360 const std::vector<uint32_t>& ssrcs) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100361
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700362 // (TMMBR) Temporary Max Media Bit Rate
363 virtual bool TMMBR() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100364
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700365 virtual void SetTMMBRStatus(bool enable) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100366
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700367 // (NACK)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100368
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700369 // TODO(holmer): Propagate this API to VideoEngine.
370 // Returns the currently configured selective retransmission settings.
371 virtual int SelectiveRetransmissions() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100372
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700373 // TODO(holmer): Propagate this API to VideoEngine.
374 // Sets the selective retransmission settings, which will decide which
375 // packets will be retransmitted if NACKed. Settings are constructed by
376 // combining the constants in enum RetransmissionMode with bitwise OR.
377 // All packets are retransmitted if kRetransmitAllPackets is set, while no
378 // packets are retransmitted if kRetransmitOff is set.
379 // By default all packets except FEC packets are retransmitted. For VP8
380 // with temporal scalability only base layer packets are retransmitted.
381 // Returns -1 on failure, otherwise 0.
382 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100383
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700384 // Sends a Negative acknowledgement packet.
385 // Returns -1 on failure else 0.
386 // TODO(philipel): Deprecate this and start using SendNack instead, mostly
387 // because we want a function that actually send NACK for the specified
388 // packets.
389 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100390
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700391 // Sends NACK for the packets specified.
392 // Note: This assumes the caller keeps track of timing and doesn't rely on
393 // the RTP module to do this.
394 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100395
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700396 // Store the sent packets, needed to answer to a Negative acknowledgment
397 // requests.
398 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
philipel83f831a2016-03-12 03:30:23 -0800399
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700400 // Returns true if the module is configured to store packets.
401 virtual bool StorePackets() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100402
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700403 // Called on receipt of RTCP report block from remote side.
404 virtual void RegisterRtcpStatisticsCallback(
405 RtcpStatisticsCallback* callback) = 0;
406 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
407 // BWE feedback packets.
408 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100409
sprang5e38c962016-12-01 05:18:09 -0800410 virtual void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) = 0;
411
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700412 // **************************************************************************
413 // Audio
414 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100415
ossu00bceb12016-12-02 02:40:02 -0800416 // This function is deprecated. It was previously used to determine when it
417 // was time to send a DTMF packet in silence (CNG).
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700418 // Returns -1 on failure else 0.
ossu00bceb12016-12-02 02:40:02 -0800419 RTC_DEPRECATED virtual int32_t SetAudioPacketSize(
420 uint16_t packet_size_samples) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100421
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700422 // Sends a TelephoneEvent tone using RFC 2833 (4733).
423 // Returns -1 on failure else 0.
424 virtual int32_t SendTelephoneEventOutband(uint8_t key,
425 uint16_t time_ms,
426 uint8_t level) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100427
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700428 // Store the audio level in dBov for header-extension-for-audio-level-
429 // indication.
430 // This API shall be called before transmision of an RTP packet to ensure
431 // that the |level| part of the extended RTP header is updated.
432 // return -1 on failure else 0.
433 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100434
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700435 // **************************************************************************
436 // Video
437 // **************************************************************************
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100438
brandtrf1bb4762016-11-07 03:05:06 -0800439 // Set RED and ULPFEC payload types. A payload type of -1 means that the
440 // corresponding feature is turned off. Note that we DO NOT support enabling
441 // ULPFEC without enabling RED. However, we DO support enabling RED without
442 // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver
443 // assumes that RTX packets carry RED if RED has been configured in the SDP,
444 // regardless of what RTX payload type mapping was negotiated in the SDP.
445 // TODO(brandtr): Update this comment when we have removed the RED/RTX
446 // send-side workaround, i.e., when we do not support enabling RED without
447 // enabling ULPFEC.
448 virtual void SetUlpfecConfig(int red_payload_type,
brandtrd8048952016-11-07 02:08:51 -0800449 int ulpfec_payload_type) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100450
brandtr1743a192016-11-07 03:36:05 -0800451 // Set FEC rates, max frames before FEC is sent, and type of FEC masks.
452 // Returns false on failure.
453 virtual bool SetFecParameters(const FecProtectionParams& delta_params,
454 const FecProtectionParams& key_params) = 0;
455
456 // Deprecated version of member function above.
457 RTC_DEPRECATED
458 int32_t SetFecParameters(const FecProtectionParams* delta_params,
459 const FecProtectionParams* key_params);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100460
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700461 // Set method for requestion a new key frame.
462 // Returns -1 on failure else 0.
463 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100464
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700465 // Sends a request for a keyframe.
466 // Returns -1 on failure else 0.
467 virtual int32_t RequestKeyFrame() = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100468};
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700469
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100470} // namespace webrtc
Sergey Ulanovec4f0682016-07-28 15:19:10 -0700471
danilchap5c1def82015-12-10 09:51:54 -0800472#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_