OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
20 #include "webrtc/modules/include/module.h" | 20 #include "webrtc/modules/include/module.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
22 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 22 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 // Forward declarations. | 25 |
26 class ReceiveStatistics; | 26 class ReceiveStatistics; |
27 class RemoteBitrateEstimator; | 27 class RemoteBitrateEstimator; |
28 class RtpReceiver; | 28 class RtpReceiver; |
29 class Transport; | 29 class Transport; |
30 class RtcEventLog; | 30 class RtcEventLog; |
31 | 31 |
32 RTPExtensionType StringToRtpExtensionType(const std::string& extension); | 32 RTPExtensionType StringToRtpExtensionType(const std::string& extension); |
33 | 33 |
34 namespace rtcp { | 34 namespace rtcp { |
35 class TransportFeedback; | 35 class TransportFeedback; |
36 } | 36 } |
37 | 37 |
38 class RtpRtcp : public Module { | 38 class RtpRtcp : public Module { |
39 public: | 39 public: |
40 struct Configuration { | 40 struct Configuration { |
41 Configuration(); | 41 Configuration(); |
42 | 42 |
43 /* id - Unique identifier of this RTP/RTCP module object | 43 // True for a audio version of the RTP/RTCP module object false will create |
44 * audio - True for a audio version of the RTP/RTCP module | 44 // a video version. |
45 * object false will create a video version | 45 bool audio = false; |
46 * clock - The clock to use to read time. If NULL object | 46 bool receiver_only = false; |
47 * will be using the system clock. | 47 |
48 * incoming_data - Callback object that will receive the incoming | 48 // The clock to use to read time. If nullptr then system clock will be used. |
49 * data. May not be NULL; default callback will do | 49 Clock* clock = nullptr; |
50 * nothing. | 50 |
51 * incoming_messages - Callback object that will receive the incoming | |
52 * RTP messages. May not be NULL; default callback | |
53 * will do nothing. | |
54 * outgoing_transport - Transport object that will be called when packets | |
55 * are ready to be sent out on the network | |
56 * intra_frame_callback - Called when the receiver request a intra frame. | |
57 * bandwidth_callback - Called when we receive a changed estimate from | |
58 * the receiver of out stream. | |
59 * remote_bitrate_estimator - Estimates the bandwidth available for a set of | |
60 * streams from the same client. | |
61 * paced_sender - Spread any bursts of packets into smaller | |
62 * bursts to minimize packet loss. | |
63 */ | |
64 bool audio; | |
65 bool receiver_only; | |
66 Clock* clock; | |
67 ReceiveStatistics* receive_statistics; | 51 ReceiveStatistics* receive_statistics; |
68 Transport* outgoing_transport; | 52 |
69 RtcpIntraFrameObserver* intra_frame_callback; | 53 // Transport object that will be called when packets are ready to be sent |
70 RtcpBandwidthObserver* bandwidth_callback; | 54 // out on the network. |
71 TransportFeedbackObserver* transport_feedback_callback; | 55 Transport* outgoing_transport = nullptr; |
72 RtcpRttStats* rtt_stats; | 56 |
73 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer; | 57 // Called when the receiver request a intra frame. |
74 RemoteBitrateEstimator* remote_bitrate_estimator; | 58 RtcpIntraFrameObserver* intra_frame_callback = nullptr; |
75 RtpPacketSender* paced_sender; | 59 |
76 TransportSequenceNumberAllocator* transport_sequence_number_allocator; | 60 // Called when we receive a changed estimate from the receiver of out |
77 BitrateStatisticsObserver* send_bitrate_observer; | 61 // stream. |
78 FrameCountObserver* send_frame_count_observer; | 62 RtcpBandwidthObserver* bandwidth_callback = nullptr; |
79 SendSideDelayObserver* send_side_delay_observer; | 63 |
80 RtcEventLog* event_log; | 64 TransportFeedbackObserver* transport_feedback_callback = nullptr; |
81 SendPacketObserver* send_packet_observer; | 65 RtcpRttStats* rtt_stats = nullptr; |
66 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr; | |
67 | |
68 // Estimates the bandwidth available for a set of streams from the same | |
69 // client. | |
70 RemoteBitrateEstimator* remote_bitrate_estimator = nullptr; | |
71 | |
72 // Spread any bursts of packets into smaller bursts to minimize packet loss. | |
73 RtpPacketSender* paced_sender = nullptr; | |
74 | |
75 TransportSequenceNumberAllocator* transport_sequence_number_allocator = | |
76 nullptr; | |
77 BitrateStatisticsObserver* send_bitrate_observer = nullptr; | |
78 FrameCountObserver* send_frame_count_observer = nullptr; | |
79 SendSideDelayObserver* send_side_delay_observer = nullptr; | |
80 RtcEventLog* event_log = nullptr; | |
81 SendPacketObserver* send_packet_observer = nullptr; | |
82 | |
83 private: | |
82 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); | 84 RTC_DISALLOW_COPY_AND_ASSIGN(Configuration); |
83 }; | 85 }; |
84 | 86 |
85 /* | 87 // Create a RTP/RTCP module object using the system clock. |
86 * Create a RTP/RTCP module object using the system clock. | 88 // |configuration| - Configuration of the RTP/RTCP module. |
87 * | |
88 * configuration - Configuration of the RTP/RTCP module. | |
89 */ | |
90 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); | 89 static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration); |
91 | 90 |
91 // ************************************************************************** | |
92 // Receiver functions | |
93 // ************************************************************************** | |
94 | |
95 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, | |
96 size_t incoming_packet_length) = 0; | |
97 | |
98 virtual void SetRemoteSSRC(uint32_t ssrc) = 0; | |
99 | |
100 // ************************************************************************** | |
101 // Sender | |
102 // ************************************************************************** | |
103 | |
104 // Sets MTU. | |
105 // |size| - Max transfer unit in bytes, default is 1500. | |
106 // Returns -1 on failure else 0. | |
107 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0; | |
108 | |
109 // Sets transtport overhead. Default is IPv4 and UDP with no encryption. | |
110 // |tcp| - true for TCP false UDP. | |
111 // |ipv6| - true for IP version 6 false for version 4. | |
112 // |authentication_overhead| - number of bytes to leave for an authentication | |
113 // header. | |
114 // Returns -1 on failure else 0 | |
115 virtual int32_t SetTransportOverhead(bool tcp, | |
116 bool ipv6, | |
117 uint8_t authentication_overhead = 0) = 0; | |
118 | |
119 // Returns max payload length, which is a combination of the configuration | |
120 // MaxTransferUnit and TransportOverhead. | |
121 // Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is | |
122 // enabled). | |
123 virtual uint16_t MaxPayloadLength() const = 0; | |
124 | |
125 // Returns max data payload length, which is a combination of the | |
126 // configuration MaxTransferUnit, headers and TransportOverhead. | |
127 // Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is | |
128 // enabled). | |
129 virtual uint16_t MaxDataPayloadLength() const = 0; | |
130 | |
131 // Sets codec name and payload type. Returns -1 on failure else 0. | |
132 virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0; | |
133 | |
134 // Sets codec name and payload type. Return -1 on failure else 0. | |
135 virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0; | |
136 | |
137 virtual void RegisterVideoSendPayload(int payload_type, | |
138 const char* payload_name) = 0; | |
139 | |
140 // Unregisters a send payload. | |
141 // |payload_type| - payload type of codec | |
142 // Returns -1 on failure else 0. | |
143 virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0; | |
144 | |
145 // (De)registers RTP header extension type and id. | |
146 // Returns -1 on failure else 0. | |
147 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type, | |
148 uint8_t id) = 0; | |
149 | |
150 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0; | |
151 | |
152 // Returns start timestamp. | |
153 virtual uint32_t StartTimestamp() const = 0; | |
154 | |
155 // Sets start timestamp. Start timestamp is set to a random value if this | |
156 // function is never called. | |
157 virtual void SetStartTimestamp(uint32_t timestamp) = 0; | |
158 | |
159 // Returns SequenceNumber. | |
160 virtual uint16_t SequenceNumber() const = 0; | |
161 | |
162 // Sets SequenceNumber, default is a random number. | |
163 virtual void SetSequenceNumber(uint16_t seq) = 0; | |
164 | |
165 virtual void SetRtpState(const RtpState& rtp_state) = 0; | |
166 virtual void SetRtxState(const RtpState& rtp_state) = 0; | |
167 virtual RtpState GetRtpState() const = 0; | |
168 virtual RtpState GetRtxState() const = 0; | |
169 | |
170 // Returns SSRC. | |
171 virtual uint32_t SSRC() const = 0; | |
172 | |
173 // Sets SSRC, default is a random number. | |
174 virtual void SetSSRC(uint32_t ssrc) = 0; | |
175 | |
176 // Sets CSRC. | |
177 // |csrcs| - vector of CSRCs | |
178 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0; | |
179 | |
180 // Turns on/off sending RTX (RFC 4588). The modes can be set as a combination | |
181 // of values of the enumerator RtxMode. | |
182 virtual void SetRtxSendStatus(int modes) = 0; | |
183 | |
184 // Returns status of sending RTX (RFC 4588). The returned value can be | |
185 // a combination of values of the enumerator RtxMode. | |
186 virtual int RtxSendStatus() const = 0; | |
187 | |
188 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX, | |
189 // only the SSRC is set. | |
190 virtual void SetRtxSsrc(uint32_t ssrc) = 0; | |
191 | |
192 // Sets the payload type to use when sending RTX packets. Note that this | |
193 // doesn't enable RTX, only the payload type is set. | |
194 virtual void SetRtxSendPayloadType(int payload_type, | |
195 int associated_payload_type) = 0; | |
196 | |
197 // Sets sending status. Sends kRtcpByeCode when going from true to false. | |
198 // Returns -1 on failure else 0. | |
199 virtual int32_t SetSendingStatus(bool sending) = 0; | |
200 | |
201 // Returns current sending status. | |
202 virtual bool Sending() const = 0; | |
203 | |
204 // Starts/Stops media packets. On by default. | |
205 virtual void SetSendingMediaStatus(bool sending) = 0; | |
206 | |
207 // Returns current media sending status. | |
208 virtual bool SendingMedia() const = 0; | |
209 | |
210 // Returns current bitrate in Kbit/s. | |
211 virtual void BitrateSent(uint32_t* total_rate, | |
212 uint32_t* video_rate, | |
213 uint32_t* fec_rate, | |
214 uint32_t* nack_rate) const = 0; | |
215 | |
216 // Used by the codec module to deliver a video or audio frame for | |
217 // packetization. | |
218 // |frame_type| - type of frame to send | |
219 // |payload_type| - payload type of frame to send | |
220 // |timestamp| - timestamp of frame to send | |
221 // |payload_data| - payload buffer of frame to send | |
222 // |payload_size| - size of payload buffer to send | |
223 // |fragmentation| - fragmentation offset data for fragmented frames such | |
224 // as layers or RED | |
225 // Returns -1 on failure else 0. | |
226 virtual int32_t SendOutgoingData( | |
227 FrameType frame_type, | |
228 int8_t payload_type, | |
229 uint32_t timestamp, | |
230 int64_t capture_time_ms, | |
231 const uint8_t* payload_data, | |
232 size_t payload_size, | |
233 const RTPFragmentationHeader* fragmentation = nullptr, | |
234 const RTPVideoHeader* rtp_video_header = nullptr) = 0; | |
235 | |
236 virtual bool TimeToSendPacket(uint32_t ssrc, | |
237 uint16_t sequence_number, | |
238 int64_t capture_time_ms, | |
239 bool retransmission, | |
240 int probe_cluster_id) = 0; | |
241 | |
242 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0; | |
243 | |
244 // Called on generation of new statistics after an RTP send. | |
245 virtual void RegisterSendChannelRtpStatisticsCallback( | |
246 StreamDataCountersCallback* callback) = 0; | |
247 virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback() | |
248 const = 0; | |
249 | |
250 // ************************************************************************** | |
251 // RTCP | |
252 // ************************************************************************** | |
253 | |
254 // Returns RTCP status. | |
255 virtual RtcpMode RTCP() const = 0; | |
256 | |
257 // Sets RTCP status i.e on(compound or non-compound)/off. | |
258 // |method| - RTCP method to use. | |
259 virtual void SetRTCPStatus(RtcpMode method) = 0; | |
260 | |
261 // Sets RTCP CName (i.e unique identifier). | |
262 // Returns -1 on failure else 0. | |
263 virtual int32_t SetCNAME(const char* cname) = 0; | |
264 | |
265 // Returns remote CName. | |
266 // Returns -1 on failure else 0. | |
267 virtual int32_t RemoteCNAME(uint32_t remote_ssrc, | |
268 char cname[RTCP_CNAME_SIZE]) const = 0; | |
269 | |
270 // Returns remote NTP. | |
271 // Returns -1 on failure else 0. | |
272 virtual int32_t RemoteNTP(uint32_t* received_ntp_secs, | |
273 uint32_t* received_ntp_frac, | |
274 uint32_t* rtcp_arrival_time_secs, | |
275 uint32_t* rtcp_arrival_time_frac, | |
276 uint32_t* rtcp_timestamp) const = 0; | |
277 | |
278 // Returns -1 on failure else 0. | |
279 virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0; | |
280 | |
281 // Returns -1 on failure else 0. | |
282 virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0; | |
283 | |
284 // Returns current RTT (round-trip time) estimate. | |
285 // Returns -1 on failure else 0. | |
286 virtual int32_t RTT(uint32_t remote_ssrc, | |
287 int64_t* rtt, | |
288 int64_t* avg_rtt, | |
289 int64_t* min_rtt, | |
290 int64_t* max_rtt) const = 0; | |
291 | |
292 // Forces a send of a RTCP packet. Periodic SR and RR are triggered via the | |
293 // process function. | |
294 // Returns -1 on failure else 0. | |
295 virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0; | |
296 | |
297 // Forces a send of a RTCP packet with more than one packet type. | |
298 // periodic SR and RR are triggered via the process function | |
299 // Returns -1 on failure else 0. | |
300 virtual int32_t SendCompoundRTCP( | |
301 const std::set<RTCPPacketType>& rtcp_packet_types) = 0; | |
302 | |
303 // Notifies the sender about good state of the RTP receiver. | |
304 virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0; | |
305 | |
306 // Send a RTCP Slice Loss Indication (SLI). | |
307 // |picture_id| - 6 least significant bits of picture_id. | |
308 virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0; | |
309 | |
310 // Returns statistics of the amount of data sent. | |
311 // Returns -1 on failure else 0. | |
312 virtual int32_t DataCountersRTP(size_t* bytes_sent, | |
313 uint32_t* packets_sent) const = 0; | |
314 | |
315 // Returns send statistics for the RTP and RTX stream. | |
316 virtual void GetSendStreamDataCounters( | |
317 StreamDataCounters* rtp_counters, | |
318 StreamDataCounters* rtx_counters) const = 0; | |
319 | |
320 // Returns packet loss statistics for the RTP stream. | |
321 virtual void GetRtpPacketLossStats( | |
322 bool outgoing, | |
323 uint32_t ssrc, | |
324 struct RtpPacketLossStats* loss_stats) const = 0; | |
325 | |
326 // Returns received RTCP sender info. | |
327 // Returns -1 on failure else 0. | |
328 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0; | |
329 | |
330 // Returns received RTCP report block. | |
331 // Returns -1 on failure else 0. | |
332 virtual int32_t RemoteRTCPStat( | |
333 std::vector<RTCPReportBlock>* receive_blocks) const = 0; | |
334 | |
335 // (APP) Sets application specific data. | |
336 // Returns -1 on failure else 0. | |
337 virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type, | |
338 uint32_t name, | |
339 const uint8_t* data, | |
340 uint16_t length) = 0; | |
341 // (XR) Sets VOIP metric. | |
342 // Returns -1 on failure else 0. | |
343 virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0; | |
344 | |
345 // (XR) Sets Receiver Reference Time Report (RTTR) status. | |
346 virtual void SetRtcpXrRrtrStatus(bool enable) = 0; | |
347 | |
348 // Returns current Receiver Reference Time Report (RTTR) status. | |
349 virtual bool RtcpXrRrtrStatus() const = 0; | |
350 | |
351 // (REMB) Receiver Estimated Max Bitrate. | |
352 virtual bool REMB() const = 0; | |
353 | |
354 virtual void SetREMBStatus(bool enable) = 0; | |
355 | |
356 virtual void SetREMBData(uint32_t bitrate, | |
357 const std::vector<uint32_t>& ssrcs) = 0; | |
358 | |
359 // (TMMBR) Temporary Max Media Bit Rate | |
360 virtual bool TMMBR() const = 0; | |
361 | |
362 virtual void SetTMMBRStatus(bool enable) = 0; | |
363 | |
364 // (NACK) | |
365 | |
366 // TODO(holmer): Propagate this API to VideoEngine. | |
367 // Returns the currently configured selective retransmission settings. | |
368 virtual int SelectiveRetransmissions() const = 0; | |
369 | |
370 // TODO(holmer): Propagate this API to VideoEngine. | |
371 // Sets the selective retransmission settings, which will decide which | |
372 // packets will be retransmitted if NACKed. Settings are constructed by | |
373 // combining the constants in enum RetransmissionMode with bitwise OR. | |
374 // All packets are retransmitted if kRetransmitAllPackets is set, while no | |
375 // packets are retransmitted if kRetransmitOff is set. | |
376 // By default all packets except FEC packets are retransmitted. For VP8 | |
377 // with temporal scalability only base layer packets are retransmitted. | |
378 // Returns -1 on failure, otherwise 0. | |
379 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0; | |
380 | |
381 // Sends a Negative acknowledgement packet. | |
382 // Returns -1 on failure else 0. | |
383 // TODO(philipel): Deprecate this and start using SendNack instead, mostly | |
384 // because we want a function that actually send NACK for the specified | |
385 // packets. | |
386 virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0; | |
387 | |
388 // Sends NACK for the packets specified. | |
389 // Note: This assumes the caller keeps track of timing and doesn't rely on | |
390 // the RTP module to do this. | |
391 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; | |
392 | |
393 // Store the sent packets, needed to answer to a Negative acknowledgment | |
394 // requests. | |
395 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0; | |
396 | |
397 // Returns true if the module is configured to store packets. | |
398 virtual bool StorePackets() const = 0; | |
399 | |
400 // Called on receipt of RTCP report block from remote side. | |
401 virtual void RegisterRtcpStatisticsCallback( | |
402 RtcpStatisticsCallback* callback) = 0; | |
403 virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0; | |
404 // BWE feedback packets. | |
405 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0; | |
406 | |
92 /************************************************************************** | 407 /************************************************************************** |
93 * | 408 // Audio |
94 * Receiver functions | 409 ***************************************************************************/ |
stefan-webrtc
2016/07/28 09:31:42
Could you clean up these mixed style comments?
Sergey Ulanov
2016/07/28 18:01:34
Done.
| |
95 * | 410 |
96 ***************************************************************************/ | 411 // Sets audio packet size, used to determine when it's time to send a DTMF |
97 | 412 // packet in silence (CNG). |
98 virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, | 413 // Returns -1 on failure else 0. |
99 size_t incoming_packet_length) = 0; | 414 virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0; |
100 | 415 |
101 virtual void SetRemoteSSRC(uint32_t ssrc) = 0; | 416 // Sends a TelephoneEvent tone using RFC 2833 (4733). |
102 | 417 // Returns -1 on failure else 0. |
103 /************************************************************************** | 418 virtual int32_t SendTelephoneEventOutband(uint8_t key, |
104 * | 419 uint16_t time_ms, |
105 * Sender | 420 uint8_t level) = 0; |
106 * | 421 |
107 ***************************************************************************/ | 422 // Sets payload type for Redundant Audio Data RFC 2198. |
108 | 423 // Returns -1 on failure else 0. |
109 /* | 424 virtual int32_t SetSendREDPayloadType(int8_t payload_type) = 0; |
110 * set MTU | 425 |
111 * | 426 // Get payload type for Redundant Audio Data RFC 2198. |
112 * size - Max transfer unit in bytes, default is 1500 | 427 // Returns -1 on failure else 0. |
113 * | 428 virtual int32_t SendREDPayloadType(int8_t* payload_type) const = 0; |
114 * return -1 on failure else 0 | 429 |
115 */ | 430 // Store the audio level in dBov for header-extension-for-audio-level- |
116 virtual int32_t SetMaxTransferUnit(uint16_t size) = 0; | 431 // indication. |
117 | 432 // This API shall be called before transmision of an RTP packet to ensure |
118 /* | 433 // that the |level| part of the extended RTP header is updated. |
119 * set transtport overhead | 434 // return -1 on failure else 0. |
120 * default is IPv4 and UDP with no encryption | 435 virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0; |
121 * | 436 |
122 * TCP - true for TCP false UDP | 437 /************************************************************************** |
123 * IPv6 - true for IP version 6 false for version 4 | 438 // Video |
124 * authenticationOverhead - number of bytes to leave for an | 439 ***************************************************************************/ |
125 * authentication header | 440 |
126 * | 441 // Set the target send bitrate. |
127 * return -1 on failure else 0 | 442 virtual void SetTargetSendBitrate(uint32_t bitrate_bps) = 0; |
128 */ | 443 |
129 virtual int32_t SetTransportOverhead( | 444 // Turn on/off generic FEC. |
130 bool TCP, | 445 virtual void SetGenericFECStatus(bool enable, |
131 bool IPV6, | 446 uint8_t payload_type_red, |
132 uint8_t authenticationOverhead = 0) = 0; | 447 uint8_t payload_type_fec) = 0; |
133 | 448 |
134 /* | 449 // Get generic FEC setting. |
135 * Get max payload length | 450 virtual void GenericFECStatus(bool* enable, |
136 * | 451 uint8_t* payload_type_red, |
137 * A combination of the configuration MaxTransferUnit and | 452 uint8_t* payload_type_fec) = 0; |
138 * TransportOverhead. | 453 |
139 * Does not account FEC/ULP/RED overhead if FEC is enabled. | 454 virtual int32_t SetFecParameters(const FecProtectionParams* delta_params, |
140 * Does not account for RTP headers | 455 const FecProtectionParams* key_params) = 0; |
141 */ | 456 |
142 virtual uint16_t MaxPayloadLength() const = 0; | 457 // Set method for requestion a new key frame. |
143 | 458 // Returns -1 on failure else 0. |
144 /* | 459 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0; |
145 * Get max data payload length | 460 |
146 * | 461 // Sends a request for a keyframe. |
147 * A combination of the configuration MaxTransferUnit, headers and | 462 // Returns -1 on failure else 0. |
148 * TransportOverhead. | 463 virtual int32_t RequestKeyFrame() = 0; |
149 * Takes into account FEC/ULP/RED overhead if FEC is enabled. | |
150 * Takes into account RTP headers | |
151 */ | |
152 virtual uint16_t MaxDataPayloadLength() const = 0; | |
153 | |
154 /* | |
155 * set codec name and payload type | |
156 * | |
157 * return -1 on failure else 0 | |
158 */ | |
159 virtual int32_t RegisterSendPayload( | |
160 const CodecInst& voiceCodec) = 0; | |
161 | |
162 /* | |
163 * set codec name and payload type | |
164 * | |
165 * return -1 on failure else 0 | |
166 */ | |
167 virtual int32_t RegisterSendPayload( | |
168 const VideoCodec& videoCodec) = 0; | |
169 | |
170 virtual void RegisterVideoSendPayload(int payload_type, | |
171 const char* payload_name) = 0; | |
172 | |
173 /* | |
174 * Unregister a send payload | |
175 * | |
176 * payloadType - payload type of codec | |
177 * | |
178 * return -1 on failure else 0 | |
179 */ | |
180 virtual int32_t DeRegisterSendPayload(int8_t payloadType) = 0; | |
181 | |
182 /* | |
183 * (De)register RTP header extension type and id. | |
184 * | |
185 * return -1 on failure else 0 | |
186 */ | |
187 virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type, | |
188 uint8_t id) = 0; | |
189 | |
190 virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0; | |
191 | |
192 /* | |
193 * get start timestamp | |
194 */ | |
195 virtual uint32_t StartTimestamp() const = 0; | |
196 | |
197 /* | |
198 * configure start timestamp, default is a random number | |
199 * | |
200 * timestamp - start timestamp | |
201 */ | |
202 virtual void SetStartTimestamp(uint32_t timestamp) = 0; | |
203 | |
204 /* | |
205 * Get SequenceNumber | |
206 */ | |
207 virtual uint16_t SequenceNumber() const = 0; | |
208 | |
209 /* | |
210 * Set SequenceNumber, default is a random number | |
211 */ | |
212 virtual void SetSequenceNumber(uint16_t seq) = 0; | |
213 | |
214 virtual void SetRtpState(const RtpState& rtp_state) = 0; | |
215 virtual void SetRtxState(const RtpState& rtp_state) = 0; | |
216 virtual RtpState GetRtpState() const = 0; | |
217 virtual RtpState GetRtxState() const = 0; | |
218 | |
219 /* | |
220 * Get SSRC | |
221 */ | |
222 virtual uint32_t SSRC() const = 0; | |
223 | |
224 /* | |
225 * configure SSRC, default is a random number | |
226 */ | |
227 virtual void SetSSRC(uint32_t ssrc) = 0; | |
228 | |
229 /* | |
230 * Set CSRC | |
231 * | |
232 * csrcs - vector of CSRCs | |
233 */ | |
234 virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0; | |
235 | |
236 /* | |
237 * Turn on/off sending RTX (RFC 4588). The modes can be set as a combination | |
238 * of values of the enumerator RtxMode. | |
239 */ | |
240 virtual void SetRtxSendStatus(int modes) = 0; | |
241 | |
242 /* | |
243 * Get status of sending RTX (RFC 4588). The returned value can be | |
244 * a combination of values of the enumerator RtxMode. | |
245 */ | |
246 virtual int RtxSendStatus() const = 0; | |
247 | |
248 // Sets the SSRC to use when sending RTX packets. This doesn't enable RTX, | |
249 // only the SSRC is set. | |
250 virtual void SetRtxSsrc(uint32_t ssrc) = 0; | |
251 | |
252 // Sets the payload type to use when sending RTX packets. Note that this | |
253 // doesn't enable RTX, only the payload type is set. | |
254 virtual void SetRtxSendPayloadType(int payload_type, | |
255 int associated_payload_type) = 0; | |
256 | |
257 /* | |
258 * sends kRtcpByeCode when going from true to false | |
259 * | |
260 * sending - on/off | |
261 * | |
262 * return -1 on failure else 0 | |
263 */ | |
264 virtual int32_t SetSendingStatus(bool sending) = 0; | |
265 | |
266 /* | |
267 * get send status | |
268 */ | |
269 virtual bool Sending() const = 0; | |
270 | |
271 /* | |
272 * Starts/Stops media packets, on by default | |
273 * | |
274 * sending - on/off | |
275 */ | |
276 virtual void SetSendingMediaStatus(bool sending) = 0; | |
277 | |
278 /* | |
279 * get send status | |
280 */ | |
281 virtual bool SendingMedia() const = 0; | |
282 | |
283 /* | |
284 * get sent bitrate in Kbit/s | |
285 */ | |
286 virtual void BitrateSent(uint32_t* totalRate, | |
287 uint32_t* videoRate, | |
288 uint32_t* fecRate, | |
289 uint32_t* nackRate) const = 0; | |
290 | |
291 /* | |
292 * Used by the codec module to deliver a video or audio frame for | |
293 * packetization. | |
294 * | |
295 * frameType - type of frame to send | |
296 * payloadType - payload type of frame to send | |
297 * timestamp - timestamp of frame to send | |
298 * payloadData - payload buffer of frame to send | |
299 * payloadSize - size of payload buffer to send | |
300 * fragmentation - fragmentation offset data for fragmented frames such | |
301 * as layers or RED | |
302 * | |
303 * return -1 on failure else 0 | |
304 */ | |
305 virtual int32_t SendOutgoingData( | |
306 FrameType frameType, | |
307 int8_t payloadType, | |
308 uint32_t timeStamp, | |
309 int64_t capture_time_ms, | |
310 const uint8_t* payloadData, | |
311 size_t payloadSize, | |
312 const RTPFragmentationHeader* fragmentation = NULL, | |
313 const RTPVideoHeader* rtpVideoHdr = NULL) = 0; | |
314 | |
315 virtual bool TimeToSendPacket(uint32_t ssrc, | |
316 uint16_t sequence_number, | |
317 int64_t capture_time_ms, | |
318 bool retransmission, | |
319 int probe_cluster_id) = 0; | |
320 | |
321 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0; | |
322 | |
323 // Called on generation of new statistics after an RTP send. | |
324 virtual void RegisterSendChannelRtpStatisticsCallback( | |
325 StreamDataCountersCallback* callback) = 0; | |
326 virtual StreamDataCountersCallback* | |
327 GetSendChannelRtpStatisticsCallback() const = 0; | |
328 | |
329 /************************************************************************** | |
330 * | |
331 * RTCP | |
332 * | |
333 ***************************************************************************/ | |
334 | |
335 /* | |
336 * Get RTCP status | |
337 */ | |
338 virtual RtcpMode RTCP() const = 0; | |
339 | |
340 /* | |
341 * configure RTCP status i.e on(compound or non- compound)/off | |
342 * | |
343 * method - RTCP method to use | |
344 */ | |
345 virtual void SetRTCPStatus(RtcpMode method) = 0; | |
346 | |
347 /* | |
348 * Set RTCP CName (i.e unique identifier) | |
349 * | |
350 * return -1 on failure else 0 | |
351 */ | |
352 virtual int32_t SetCNAME(const char* c_name) = 0; | |
353 | |
354 /* | |
355 * Get remote CName | |
356 * | |
357 * return -1 on failure else 0 | |
358 */ | |
359 virtual int32_t RemoteCNAME(uint32_t remoteSSRC, | |
360 char cName[RTCP_CNAME_SIZE]) const = 0; | |
361 | |
362 /* | |
363 * Get remote NTP | |
364 * | |
365 * return -1 on failure else 0 | |
366 */ | |
367 virtual int32_t RemoteNTP( | |
368 uint32_t *ReceivedNTPsecs, | |
369 uint32_t *ReceivedNTPfrac, | |
370 uint32_t *RTCPArrivalTimeSecs, | |
371 uint32_t *RTCPArrivalTimeFrac, | |
372 uint32_t *rtcp_timestamp) const = 0; | |
373 | |
374 /* | |
375 * AddMixedCNAME | |
376 * | |
377 * return -1 on failure else 0 | |
378 */ | |
379 virtual int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name) = 0; | |
380 | |
381 /* | |
382 * RemoveMixedCNAME | |
383 * | |
384 * return -1 on failure else 0 | |
385 */ | |
386 virtual int32_t RemoveMixedCNAME(uint32_t SSRC) = 0; | |
387 | |
388 /* | |
389 * Get RoundTripTime | |
390 * | |
391 * return -1 on failure else 0 | |
392 */ | |
393 virtual int32_t RTT(uint32_t remoteSSRC, | |
394 int64_t* RTT, | |
395 int64_t* avgRTT, | |
396 int64_t* minRTT, | |
397 int64_t* maxRTT) const = 0; | |
398 | |
399 /* | |
400 * Force a send of a RTCP packet | |
401 * periodic SR and RR are triggered via the process function | |
402 * | |
403 * return -1 on failure else 0 | |
404 */ | |
405 virtual int32_t SendRTCP(RTCPPacketType rtcpPacketType) = 0; | |
406 | |
407 /* | |
408 * Force a send of a RTCP packet with more than one packet type. | |
409 * periodic SR and RR are triggered via the process function | |
410 * | |
411 * return -1 on failure else 0 | |
412 */ | |
413 virtual int32_t SendCompoundRTCP( | |
414 const std::set<RTCPPacketType>& rtcpPacketTypes) = 0; | |
415 | |
416 /* | |
417 * Good state of RTP receiver inform sender | |
418 */ | |
419 virtual int32_t SendRTCPReferencePictureSelection(uint64_t pictureID) = 0; | |
420 | |
421 /* | |
422 * Send a RTCP Slice Loss Indication (SLI) | |
423 * 6 least significant bits of pictureID | |
424 */ | |
425 virtual int32_t SendRTCPSliceLossIndication(uint8_t pictureID) = 0; | |
426 | |
427 /* | |
428 * Statistics of the amount of data sent | |
429 * | |
430 * return -1 on failure else 0 | |
431 */ | |
432 virtual int32_t DataCountersRTP( | |
433 size_t* bytesSent, | |
434 uint32_t* packetsSent) const = 0; | |
435 | |
436 /* | |
437 * Get send statistics for the RTP and RTX stream. | |
438 */ | |
439 virtual void GetSendStreamDataCounters( | |
440 StreamDataCounters* rtp_counters, | |
441 StreamDataCounters* rtx_counters) const = 0; | |
442 | |
443 /* | |
444 * Get packet loss statistics for the RTP stream. | |
445 */ | |
446 virtual void GetRtpPacketLossStats( | |
447 bool outgoing, | |
448 uint32_t ssrc, | |
449 struct RtpPacketLossStats* loss_stats) const = 0; | |
450 | |
451 /* | |
452 * Get received RTCP sender info | |
453 * | |
454 * return -1 on failure else 0 | |
455 */ | |
456 virtual int32_t RemoteRTCPStat(RTCPSenderInfo* senderInfo) = 0; | |
457 | |
458 /* | |
459 * Get received RTCP report block | |
460 * | |
461 * return -1 on failure else 0 | |
462 */ | |
463 virtual int32_t RemoteRTCPStat( | |
464 std::vector<RTCPReportBlock>* receiveBlocks) const = 0; | |
465 | |
466 /* | |
467 * (APP) Application specific data | |
468 * | |
469 * return -1 on failure else 0 | |
470 */ | |
471 virtual int32_t SetRTCPApplicationSpecificData(uint8_t subType, | |
472 uint32_t name, | |
473 const uint8_t* data, | |
474 uint16_t length) = 0; | |
475 /* | |
476 * (XR) VOIP metric | |
477 * | |
478 * return -1 on failure else 0 | |
479 */ | |
480 virtual int32_t SetRTCPVoIPMetrics( | |
481 const RTCPVoIPMetric* VoIPMetric) = 0; | |
482 | |
483 /* | |
484 * (XR) Receiver Reference Time Report | |
485 */ | |
486 virtual void SetRtcpXrRrtrStatus(bool enable) = 0; | |
487 | |
488 virtual bool RtcpXrRrtrStatus() const = 0; | |
489 | |
490 /* | |
491 * (REMB) Receiver Estimated Max Bitrate | |
492 */ | |
493 virtual bool REMB() const = 0; | |
494 | |
495 virtual void SetREMBStatus(bool enable) = 0; | |
496 | |
497 virtual void SetREMBData(uint32_t bitrate, | |
498 const std::vector<uint32_t>& ssrcs) = 0; | |
499 | |
500 /* | |
501 * (TMMBR) Temporary Max Media Bit Rate | |
502 */ | |
503 virtual bool TMMBR() const = 0; | |
504 | |
505 virtual void SetTMMBRStatus(bool enable) = 0; | |
506 | |
507 /* | |
508 * (NACK) | |
509 */ | |
510 | |
511 /* | |
512 * TODO(holmer): Propagate this API to VideoEngine. | |
513 * Returns the currently configured selective retransmission settings. | |
514 */ | |
515 virtual int SelectiveRetransmissions() const = 0; | |
516 | |
517 /* | |
518 * TODO(holmer): Propagate this API to VideoEngine. | |
519 * Sets the selective retransmission settings, which will decide which | |
520 * packets will be retransmitted if NACKed. Settings are constructed by | |
521 * combining the constants in enum RetransmissionMode with bitwise OR. | |
522 * All packets are retransmitted if kRetransmitAllPackets is set, while no | |
523 * packets are retransmitted if kRetransmitOff is set. | |
524 * By default all packets except FEC packets are retransmitted. For VP8 | |
525 * with temporal scalability only base layer packets are retransmitted. | |
526 * | |
527 * Returns -1 on failure, otherwise 0. | |
528 */ | |
529 virtual int SetSelectiveRetransmissions(uint8_t settings) = 0; | |
530 | |
531 /* | |
532 * Send a Negative acknowledgement packet | |
533 * | |
534 * return -1 on failure else 0 | |
535 */ | |
536 // TODO(philipel): Deprecate this and start using SendNack instead, | |
537 // mostly because we want a function that actually send | |
538 // NACK for the specified packets. | |
539 virtual int32_t SendNACK(const uint16_t* nackList, uint16_t size) = 0; | |
540 | |
541 /* | |
542 * Send NACK for the packets specified. | |
543 * | |
544 * Note: This assumes the caller keeps track of timing and doesn't rely on | |
545 * the RTP module to do this. | |
546 */ | |
547 virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0; | |
548 | |
549 /* | |
550 * Store the sent packets, needed to answer to a Negative acknowledgement | |
551 * requests | |
552 */ | |
553 virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0; | |
554 | |
555 // Returns true if the module is configured to store packets. | |
556 virtual bool StorePackets() const = 0; | |
557 | |
558 // Called on receipt of RTCP report block from remote side. | |
559 virtual void RegisterRtcpStatisticsCallback( | |
560 RtcpStatisticsCallback* callback) = 0; | |
561 virtual RtcpStatisticsCallback* | |
562 GetRtcpStatisticsCallback() = 0; | |
563 // BWE feedback packets. | |
564 virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0; | |
565 | |
566 /************************************************************************** | |
567 * | |
568 * Audio | |
569 * | |
570 ***************************************************************************/ | |
571 | |
572 /* | |
573 * set audio packet size, used to determine when it's time to send a DTMF | |
574 * packet in silence (CNG) | |
575 * | |
576 * return -1 on failure else 0 | |
577 */ | |
578 virtual int32_t SetAudioPacketSize(uint16_t packetSizeSamples) = 0; | |
579 | |
580 /* | |
581 * Send a TelephoneEvent tone using RFC 2833 (4733) | |
582 * | |
583 * return -1 on failure else 0 | |
584 */ | |
585 virtual int32_t SendTelephoneEventOutband(uint8_t key, | |
586 uint16_t time_ms, | |
587 uint8_t level) = 0; | |
588 | |
589 /* | |
590 * Set payload type for Redundant Audio Data RFC 2198 | |
591 * | |
592 * return -1 on failure else 0 | |
593 */ | |
594 virtual int32_t SetSendREDPayloadType(int8_t payloadType) = 0; | |
595 | |
596 /* | |
597 * Get payload type for Redundant Audio Data RFC 2198 | |
598 * | |
599 * return -1 on failure else 0 | |
600 */ | |
601 virtual int32_t SendREDPayloadType(int8_t* payload_type) const = 0; | |
602 /* | |
603 * Store the audio level in dBov for header-extension-for-audio-level- | |
604 * indication. | |
605 * This API shall be called before transmision of an RTP packet to ensure | |
606 * that the |level| part of the extended RTP header is updated. | |
607 * | |
608 * return -1 on failure else 0. | |
609 */ | |
610 virtual int32_t SetAudioLevel(uint8_t level_dBov) = 0; | |
611 | |
612 /************************************************************************** | |
613 * | |
614 * Video | |
615 * | |
616 ***************************************************************************/ | |
617 | |
618 /* | |
619 * Set the target send bitrate | |
620 */ | |
621 virtual void SetTargetSendBitrate(uint32_t bitrate_bps) = 0; | |
622 | |
623 /* | |
624 * Turn on/off generic FEC | |
625 */ | |
626 virtual void SetGenericFECStatus(bool enable, | |
627 uint8_t payload_type_red, | |
628 uint8_t payload_type_fec) = 0; | |
629 | |
630 /* | |
631 * Get generic FEC setting | |
632 */ | |
633 virtual void GenericFECStatus(bool* enable, | |
634 uint8_t* payload_type_red, | |
635 uint8_t* payload_type_fec) = 0; | |
636 | |
637 virtual int32_t SetFecParameters( | |
638 const FecProtectionParams* delta_params, | |
639 const FecProtectionParams* key_params) = 0; | |
640 | |
641 /* | |
642 * Set method for requestion a new key frame | |
643 * | |
644 * return -1 on failure else 0 | |
645 */ | |
646 virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0; | |
647 | |
648 /* | |
649 * send a request for a keyframe | |
650 * | |
651 * return -1 on failure else 0 | |
652 */ | |
653 virtual int32_t RequestKeyFrame() = 0; | |
654 }; | 464 }; |
465 | |
655 } // namespace webrtc | 466 } // namespace webrtc |
467 | |
656 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ | 468 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_ |
OLD | NEW |