Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 1 | /* |
| 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öm | 9c01725 | 2016-02-26 16:26:20 +0100 | [diff] [blame] | 15 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 16 | #include <utility> |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 19 | #include "webrtc/base/constructormagic.h" |
brandtr | 1743a19 | 2016-11-07 03:36:05 -0800 | [diff] [blame] | 20 | #include "webrtc/base/deprecation.h" |
brandtr | 9dfff29 | 2016-11-14 05:14:50 -0800 | [diff] [blame] | 21 | #include "webrtc/base/optional.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 22 | #include "webrtc/modules/include/module.h" |
brandtr | e950cad | 2016-11-15 05:25:41 -0800 | [diff] [blame] | 23 | #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 24 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
philipel | 83f831a | 2016-03-12 03:30:23 -0800 | [diff] [blame] | 25 | #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 26 | |
| 27 | namespace webrtc { |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 28 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 29 | // Forward declarations. |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 30 | class OverheadObserver; |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 31 | class RateLimiter; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 32 | class ReceiveStatistics; |
| 33 | class RemoteBitrateEstimator; |
sprang | cd349d9 | 2016-07-13 09:11:28 -0700 | [diff] [blame] | 34 | class RtcEventLog; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 35 | class RtpReceiver; |
| 36 | class Transport; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame^] | 37 | class VideoBitrateAllocationObserver; |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 38 | |
Peter Boström | 9c01725 | 2016-02-26 16:26:20 +0100 | [diff] [blame] | 39 | RTPExtensionType StringToRtpExtensionType(const std::string& extension); |
| 40 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 41 | namespace rtcp { |
| 42 | class TransportFeedback; |
| 43 | } |
| 44 | |
| 45 | class RtpRtcp : public Module { |
| 46 | public: |
| 47 | struct Configuration { |
| 48 | Configuration(); |
| 49 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 50 | // 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 Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 58 | ReceiveStatistics* receive_statistics; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 59 | |
| 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; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame^] | 72 | VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 73 | 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 | |
brandtr | e950cad | 2016-11-15 05:25:41 -0800 | [diff] [blame] | 83 | // Generate FlexFEC packets. |
| 84 | // TODO(brandtr): Remove when FlexfecSender is wired up to PacedSender. |
| 85 | FlexfecSender* flexfec_sender = nullptr; |
| 86 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 87 | 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; |
michaelt | 4da3044 | 2016-11-17 01:38:43 -0800 | [diff] [blame] | 95 | OverheadObserver* overhead_observer = nullptr; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 96 | |
| 97 | private: |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 98 | RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 99 | }; |
| 100 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 101 | // Create a RTP/RTCP module object using the system clock. |
| 102 | // |configuration| - Configuration of the RTP/RTCP module. |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 103 | static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); |
| 104 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 105 | // ************************************************************************** |
| 106 | // Receiver functions |
| 107 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 108 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 109 | virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, |
| 110 | size_t incoming_packet_length) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 111 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 112 | virtual void SetRemoteSSRC(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 113 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 114 | // ************************************************************************** |
| 115 | // Sender |
| 116 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 117 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 118 | // Sets MTU. |
| 119 | // |size| - Max transfer unit in bytes, default is 1500. |
| 120 | // Returns -1 on failure else 0. |
| 121 | virtual int32_t SetMaxTransferUnit(uint16_t size) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 122 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 123 | // Sets transtport overhead. Default is IPv4 and UDP with no encryption. |
| 124 | // |tcp| - true for TCP false UDP. |
| 125 | // |ipv6| - true for IP version 6 false for version 4. |
| 126 | // |authentication_overhead| - number of bytes to leave for an authentication |
| 127 | // header. |
| 128 | // Returns -1 on failure else 0 |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 129 | // TODO(michaelt): deprecate the function. |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 130 | virtual int32_t SetTransportOverhead(bool tcp, |
| 131 | bool ipv6, |
| 132 | uint8_t authentication_overhead = 0) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 133 | |
brandtr | 768d625 | 2016-11-29 06:19:40 -0800 | [diff] [blame] | 134 | // Sets transport overhead per packet. |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 135 | virtual void SetTransportOverhead(int transport_overhead_per_packet) = 0; |
| 136 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 137 | // Returns max payload length, which is a combination of the configuration |
| 138 | // MaxTransferUnit and TransportOverhead. |
| 139 | // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is |
| 140 | // enabled). |
| 141 | virtual uint16_t MaxPayloadLength() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 142 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 143 | // Returns max data payload length, which is a combination of the |
| 144 | // configuration MaxTransferUnit, headers and TransportOverhead. |
| 145 | // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is |
| 146 | // enabled). |
| 147 | virtual uint16_t MaxDataPayloadLength() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 148 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 149 | // Sets codec name and payload type. Returns -1 on failure else 0. |
| 150 | virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 151 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 152 | // Sets codec name and payload type. Return -1 on failure else 0. |
| 153 | virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 154 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 155 | virtual void RegisterVideoSendPayload(int payload_type, |
| 156 | const char* payload_name) = 0; |
Peter Boström | 8b79b07 | 2016-02-26 16:31:37 +0100 | [diff] [blame] | 157 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 158 | // Unregisters a send payload. |
| 159 | // |payload_type| - payload type of codec |
| 160 | // Returns -1 on failure else 0. |
| 161 | virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 162 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 163 | // (De)registers RTP header extension type and id. |
| 164 | // Returns -1 on failure else 0. |
| 165 | virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type, |
| 166 | uint8_t id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 167 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 168 | virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 169 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 170 | // Returns start timestamp. |
| 171 | virtual uint32_t StartTimestamp() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 172 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 173 | // Sets start timestamp. Start timestamp is set to a random value if this |
| 174 | // function is never called. |
| 175 | virtual void SetStartTimestamp(uint32_t timestamp) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 176 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 177 | // Returns SequenceNumber. |
| 178 | virtual uint16_t SequenceNumber() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 179 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 180 | // Sets SequenceNumber, default is a random number. |
| 181 | virtual void SetSequenceNumber(uint16_t seq) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 182 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 183 | virtual void SetRtpState(const RtpState& rtp_state) = 0; |
| 184 | virtual void SetRtxState(const RtpState& rtp_state) = 0; |
| 185 | virtual RtpState GetRtpState() const = 0; |
| 186 | virtual RtpState GetRtxState() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 187 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 188 | // Returns SSRC. |
| 189 | virtual uint32_t SSRC() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 190 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 191 | // Sets SSRC, default is a random number. |
| 192 | virtual void SetSSRC(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 193 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 194 | // Sets CSRC. |
| 195 | // |csrcs| - vector of CSRCs |
| 196 | virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 197 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 198 | // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination |
| 199 | // of values of the enumerator RtxMode. |
| 200 | virtual void SetRtxSendStatus(int modes) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 201 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 202 | // Returns status of sending RTX (RFC 4588). The returned value can be |
| 203 | // a combination of values of the enumerator RtxMode. |
| 204 | virtual int RtxSendStatus() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 205 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 206 | // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX, |
| 207 | // only the SSRC is set. |
| 208 | virtual void SetRtxSsrc(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 209 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 210 | // Sets the payload type to use when sending RTX packets. Note that this |
| 211 | // doesn't enable RTX, only the payload type is set. |
| 212 | virtual void SetRtxSendPayloadType(int payload_type, |
| 213 | int associated_payload_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 214 | |
brandtr | 9dfff29 | 2016-11-14 05:14:50 -0800 | [diff] [blame] | 215 | // Returns the FlexFEC SSRC, if there is one. |
| 216 | virtual rtc::Optional<uint32_t> FlexfecSsrc() const = 0; |
| 217 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 218 | // Sets sending status. Sends kRtcpByeCode when going from true to false. |
| 219 | // Returns -1 on failure else 0. |
| 220 | virtual int32_t SetSendingStatus(bool sending) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 221 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 222 | // Returns current sending status. |
| 223 | virtual bool Sending() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 224 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 225 | // Starts/Stops media packets. On by default. |
| 226 | virtual void SetSendingMediaStatus(bool sending) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 227 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 228 | // Returns current media sending status. |
| 229 | virtual bool SendingMedia() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 230 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 231 | // Returns current bitrate in Kbit/s. |
| 232 | virtual void BitrateSent(uint32_t* total_rate, |
| 233 | uint32_t* video_rate, |
| 234 | uint32_t* fec_rate, |
| 235 | uint32_t* nack_rate) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 236 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 237 | // Used by the codec module to deliver a video or audio frame for |
| 238 | // packetization. |
| 239 | // |frame_type| - type of frame to send |
| 240 | // |payload_type| - payload type of frame to send |
| 241 | // |timestamp| - timestamp of frame to send |
| 242 | // |payload_data| - payload buffer of frame to send |
| 243 | // |payload_size| - size of payload buffer to send |
| 244 | // |fragmentation| - fragmentation offset data for fragmented frames such |
| 245 | // as layers or RED |
Sergey Ulanov | 525df3f | 2016-08-02 17:46:41 -0700 | [diff] [blame] | 246 | // |transport_frame_id_out| - set to RTP timestamp. |
| 247 | // Returns true on success. |
Sergey Ulanov | 525df3f | 2016-08-02 17:46:41 -0700 | [diff] [blame] | 248 | virtual bool SendOutgoingData(FrameType frame_type, |
| 249 | int8_t payload_type, |
| 250 | uint32_t timestamp, |
| 251 | int64_t capture_time_ms, |
| 252 | const uint8_t* payload_data, |
| 253 | size_t payload_size, |
| 254 | const RTPFragmentationHeader* fragmentation, |
| 255 | const RTPVideoHeader* rtp_video_header, |
| 256 | uint32_t* transport_frame_id_out) = 0; |
| 257 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 258 | virtual bool TimeToSendPacket(uint32_t ssrc, |
| 259 | uint16_t sequence_number, |
| 260 | int64_t capture_time_ms, |
| 261 | bool retransmission, |
| 262 | int probe_cluster_id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 263 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 264 | virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 265 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 266 | // Called on generation of new statistics after an RTP send. |
| 267 | virtual void RegisterSendChannelRtpStatisticsCallback( |
| 268 | StreamDataCountersCallback* callback) = 0; |
| 269 | virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback() |
| 270 | const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 271 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 272 | // ************************************************************************** |
| 273 | // RTCP |
| 274 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 275 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 276 | // Returns RTCP status. |
| 277 | virtual RtcpMode RTCP() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 278 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 279 | // Sets RTCP status i.e on(compound or non-compound)/off. |
| 280 | // |method| - RTCP method to use. |
| 281 | virtual void SetRTCPStatus(RtcpMode method) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 282 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 283 | // Sets RTCP CName (i.e unique identifier). |
| 284 | // Returns -1 on failure else 0. |
| 285 | virtual int32_t SetCNAME(const char* cname) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 286 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 287 | // Returns remote CName. |
| 288 | // Returns -1 on failure else 0. |
| 289 | virtual int32_t RemoteCNAME(uint32_t remote_ssrc, |
| 290 | char cname[RTCP_CNAME_SIZE]) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 291 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 292 | // Returns remote NTP. |
| 293 | // Returns -1 on failure else 0. |
| 294 | virtual int32_t RemoteNTP(uint32_t* received_ntp_secs, |
| 295 | uint32_t* received_ntp_frac, |
| 296 | uint32_t* rtcp_arrival_time_secs, |
| 297 | uint32_t* rtcp_arrival_time_frac, |
| 298 | uint32_t* rtcp_timestamp) const = 0; |
| 299 | |
| 300 | // Returns -1 on failure else 0. |
| 301 | virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 302 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 303 | // Returns -1 on failure else 0. |
| 304 | virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 305 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 306 | // Returns current RTT (round-trip time) estimate. |
| 307 | // Returns -1 on failure else 0. |
| 308 | virtual int32_t RTT(uint32_t remote_ssrc, |
| 309 | int64_t* rtt, |
| 310 | int64_t* avg_rtt, |
| 311 | int64_t* min_rtt, |
| 312 | int64_t* max_rtt) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 313 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 314 | // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the |
| 315 | // process function. |
| 316 | // Returns -1 on failure else 0. |
| 317 | virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 318 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 319 | // Forces a send of a RTCP packet with more than one packet type. |
| 320 | // periodic SR and RR are triggered via the process function |
| 321 | // Returns -1 on failure else 0. |
| 322 | virtual int32_t SendCompoundRTCP( |
| 323 | const std::set<RTCPPacketType>& rtcp_packet_types) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 324 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 325 | // Notifies the sender about good state of the RTP receiver. |
| 326 | virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 327 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 328 | // Send a RTCP Slice Loss Indication (SLI). |
| 329 | // |picture_id| - 6 least significant bits of picture_id. |
| 330 | virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 331 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 332 | // Returns statistics of the amount of data sent. |
| 333 | // Returns -1 on failure else 0. |
| 334 | virtual int32_t DataCountersRTP(size_t* bytes_sent, |
| 335 | uint32_t* packets_sent) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 336 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 337 | // Returns send statistics for the RTP and RTX stream. |
| 338 | virtual void GetSendStreamDataCounters( |
| 339 | StreamDataCounters* rtp_counters, |
| 340 | StreamDataCounters* rtx_counters) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 341 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 342 | // Returns packet loss statistics for the RTP stream. |
| 343 | virtual void GetRtpPacketLossStats( |
| 344 | bool outgoing, |
| 345 | uint32_t ssrc, |
| 346 | struct RtpPacketLossStats* loss_stats) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 347 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 348 | // Returns received RTCP sender info. |
| 349 | // Returns -1 on failure else 0. |
| 350 | virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 351 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 352 | // Returns received RTCP report block. |
| 353 | // Returns -1 on failure else 0. |
| 354 | virtual int32_t RemoteRTCPStat( |
| 355 | std::vector<RTCPReportBlock>* receive_blocks) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 356 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 357 | // (APP) Sets application specific data. |
| 358 | // Returns -1 on failure else 0. |
| 359 | virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type, |
| 360 | uint32_t name, |
| 361 | const uint8_t* data, |
| 362 | uint16_t length) = 0; |
| 363 | // (XR) Sets VOIP metric. |
| 364 | // Returns -1 on failure else 0. |
| 365 | virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 366 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 367 | // (XR) Sets Receiver Reference Time Report (RTTR) status. |
| 368 | virtual void SetRtcpXrRrtrStatus(bool enable) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 369 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 370 | // Returns current Receiver Reference Time Report (RTTR) status. |
| 371 | virtual bool RtcpXrRrtrStatus() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 372 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 373 | // (REMB) Receiver Estimated Max Bitrate. |
| 374 | virtual bool REMB() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 375 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 376 | virtual void SetREMBStatus(bool enable) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 377 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 378 | virtual void SetREMBData(uint32_t bitrate, |
| 379 | const std::vector<uint32_t>& ssrcs) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 380 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 381 | // (TMMBR) Temporary Max Media Bit Rate |
| 382 | virtual bool TMMBR() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 383 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 384 | virtual void SetTMMBRStatus(bool enable) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 385 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 386 | // (NACK) |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 387 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 388 | // TODO(holmer): Propagate this API to VideoEngine. |
| 389 | // Returns the currently configured selective retransmission settings. |
| 390 | virtual int SelectiveRetransmissions() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 391 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 392 | // TODO(holmer): Propagate this API to VideoEngine. |
| 393 | // Sets the selective retransmission settings, which will decide which |
| 394 | // packets will be retransmitted if NACKed. Settings are constructed by |
| 395 | // combining the constants in enum RetransmissionMode with bitwise OR. |
| 396 | // All packets are retransmitted if kRetransmitAllPackets is set, while no |
| 397 | // packets are retransmitted if kRetransmitOff is set. |
| 398 | // By default all packets except FEC packets are retransmitted. For VP8 |
| 399 | // with temporal scalability only base layer packets are retransmitted. |
| 400 | // Returns -1 on failure, otherwise 0. |
| 401 | virtual int SetSelectiveRetransmissions(uint8_t settings) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 402 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 403 | // Sends a Negative acknowledgement packet. |
| 404 | // Returns -1 on failure else 0. |
| 405 | // TODO(philipel): Deprecate this and start using SendNack instead, mostly |
| 406 | // because we want a function that actually send NACK for the specified |
| 407 | // packets. |
| 408 | virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 409 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 410 | // Sends NACK for the packets specified. |
| 411 | // Note: This assumes the caller keeps track of timing and doesn't rely on |
| 412 | // the RTP module to do this. |
| 413 | virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 414 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 415 | // Store the sent packets, needed to answer to a Negative acknowledgment |
| 416 | // requests. |
| 417 | virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0; |
philipel | 83f831a | 2016-03-12 03:30:23 -0800 | [diff] [blame] | 418 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 419 | // Returns true if the module is configured to store packets. |
| 420 | virtual bool StorePackets() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 421 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 422 | // Called on receipt of RTCP report block from remote side. |
| 423 | virtual void RegisterRtcpStatisticsCallback( |
| 424 | RtcpStatisticsCallback* callback) = 0; |
| 425 | virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0; |
| 426 | // BWE feedback packets. |
| 427 | virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 428 | |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 429 | virtual void SetVideoBitrateAllocation(const BitrateAllocation& bitrate) = 0; |
| 430 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 431 | // ************************************************************************** |
| 432 | // Audio |
| 433 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 434 | |
ossu | 00bceb1 | 2016-12-02 02:40:02 -0800 | [diff] [blame] | 435 | // This function is deprecated. It was previously used to determine when it |
| 436 | // was time to send a DTMF packet in silence (CNG). |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 437 | // Returns -1 on failure else 0. |
ossu | 00bceb1 | 2016-12-02 02:40:02 -0800 | [diff] [blame] | 438 | RTC_DEPRECATED virtual int32_t SetAudioPacketSize( |
| 439 | uint16_t packet_size_samples) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 440 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 441 | // Sends a TelephoneEvent tone using RFC 2833 (4733). |
| 442 | // Returns -1 on failure else 0. |
| 443 | virtual int32_t SendTelephoneEventOutband(uint8_t key, |
| 444 | uint16_t time_ms, |
| 445 | uint8_t level) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 446 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 447 | // Store the audio level in dBov for header-extension-for-audio-level- |
| 448 | // indication. |
| 449 | // This API shall be called before transmision of an RTP packet to ensure |
| 450 | // that the |level| part of the extended RTP header is updated. |
| 451 | // return -1 on failure else 0. |
| 452 | virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 453 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 454 | // ************************************************************************** |
| 455 | // Video |
| 456 | // ************************************************************************** |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 457 | |
brandtr | f1bb476 | 2016-11-07 03:05:06 -0800 | [diff] [blame] | 458 | // Set RED and ULPFEC payload types. A payload type of -1 means that the |
| 459 | // corresponding feature is turned off. Note that we DO NOT support enabling |
| 460 | // ULPFEC without enabling RED. However, we DO support enabling RED without |
| 461 | // enabling ULPFEC. This is due to an RED/RTX workaround, where the receiver |
| 462 | // assumes that RTX packets carry RED if RED has been configured in the SDP, |
| 463 | // regardless of what RTX payload type mapping was negotiated in the SDP. |
| 464 | // TODO(brandtr): Update this comment when we have removed the RED/RTX |
| 465 | // send-side workaround, i.e., when we do not support enabling RED without |
| 466 | // enabling ULPFEC. |
| 467 | virtual void SetUlpfecConfig(int red_payload_type, |
brandtr | d804895 | 2016-11-07 02:08:51 -0800 | [diff] [blame] | 468 | int ulpfec_payload_type) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 469 | |
brandtr | 1743a19 | 2016-11-07 03:36:05 -0800 | [diff] [blame] | 470 | // Set FEC rates, max frames before FEC is sent, and type of FEC masks. |
| 471 | // Returns false on failure. |
| 472 | virtual bool SetFecParameters(const FecProtectionParams& delta_params, |
| 473 | const FecProtectionParams& key_params) = 0; |
| 474 | |
| 475 | // Deprecated version of member function above. |
| 476 | RTC_DEPRECATED |
| 477 | int32_t SetFecParameters(const FecProtectionParams* delta_params, |
| 478 | const FecProtectionParams* key_params); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 479 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 480 | // Set method for requestion a new key frame. |
| 481 | // Returns -1 on failure else 0. |
| 482 | virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 483 | |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 484 | // Sends a request for a keyframe. |
| 485 | // Returns -1 on failure else 0. |
| 486 | virtual int32_t RequestKeyFrame() = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 487 | }; |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 488 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 489 | } // namespace webrtc |
Sergey Ulanov | ec4f068 | 2016-07-28 15:19:10 -0700 | [diff] [blame] | 490 | |
danilchap | 5c1def8 | 2015-12-10 09:51:54 -0800 | [diff] [blame] | 491 | #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |