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