Asterisk - The Open Source Telephony Project  18.5.0
rtp_engine.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2009, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
7  * Joshua Colp <[email protected]>
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19 
20 /*! \file
21  * \brief Pluggable RTP Architecture
22  * \author Joshua Colp <[email protected]>
23  * \ref AstRTPEngine
24  */
25 
26 /*!
27  * \page AstRTPEngine Asterisk RTP Engine API
28  *
29  * The purpose of this API is to provide a way for multiple RTP stacks to be
30  * used inside of Asterisk without any module that uses RTP knowing any
31  * different. To the module each RTP stack behaves the same.
32  *
33  * An RTP session is called an instance and is made up of a combination of codec
34  * information, RTP engine, RTP properties, and address information. An engine
35  * name may be passed in to explicitly choose an RTP stack to be used but a
36  * default one will be used if none is provided. An address to use for RTP may
37  * also be provided but the underlying RTP engine may choose a different address
38  * depending on it's configuration.
39  *
40  * An RTP engine is the layer between the RTP engine core and the RTP stack
41  * itself. The RTP engine core provides a set of callbacks to do various things
42  * (such as write audio out) that the RTP engine has to have implemented.
43  *
44  * Glue is what binds an RTP instance to a channel. It is used to retrieve RTP
45  * instance information when performing remote or local bridging and is used to
46  * have the channel driver tell the remote side to change destination of the RTP
47  * stream.
48  *
49  * Statistics from an RTP instance can be retrieved using the
50  * ast_rtp_instance_get_stats API call. This essentially asks the RTP engine in
51  * use to fill in a structure with the requested values. It is not required for
52  * an RTP engine to support all statistic values.
53  *
54  * Properties allow behavior of the RTP engine and RTP engine core to be
55  * changed. For example, there is a property named AST_RTP_PROPERTY_NAT which is
56  * used to tell the RTP engine to enable symmetric RTP if it supports it. It is
57  * not required for an RTP engine to support all properties.
58  *
59  * Codec information is stored using a separate data structure which has it's
60  * own set of API calls to add/remove/retrieve information. They are used by the
61  * module after an RTP instance is created so that payload information is
62  * available for the RTP engine.
63  */
64 
65 #ifndef _ASTERISK_RTP_ENGINE_H
66 #define _ASTERISK_RTP_ENGINE_H
67 
68 #if defined(__cplusplus) || defined(c_plusplus)
69 extern "C" {
70 #endif
71 
72 #include "asterisk/astobj2.h"
73 #include "asterisk/frame.h"
74 #include "asterisk/format_cap.h"
75 #include "asterisk/netsock2.h"
76 #include "asterisk/sched.h"
77 #include "asterisk/res_srtp.h"
78 #include "asterisk/stasis.h"
79 #include "asterisk/vector.h"
81 
82 /*! Maximum number of payload types RTP can support. */
83 #define AST_RTP_MAX_PT 128
84 
85 /*!
86  * Last RTP payload type statically assigned, see
87  * http://www.iana.org/assignments/rtp-parameters
88  */
89 #define AST_RTP_PT_LAST_STATIC 34
90 
91 /*! First dynamic RTP payload type */
92 #define AST_RTP_PT_FIRST_DYNAMIC 96
93 
94 /*! Last reassignable RTP payload type */
95 #define AST_RTP_PT_LAST_REASSIGN 63
96 
97 /*! Maximum number of generations */
98 #define AST_RED_MAX_GENERATION 5
99 
100 /*!
101  * Maximum size of an internal Asterisk channel unique ID.
102  *
103  * \note Must match the AST_MAX_UNIQUEID(AST_MAX_PUBLIC_UNIQUEID) value.
104  * We don't use that defined value directly here to avoid a hard
105  * dependency on channel.h.
106  */
107 #define MAX_CHANNEL_ID 152
108 
109 struct ast_rtp_instance;
110 struct ast_rtp_glue;
111 
112 /*! RTP Properties that can be set on an RTP instance */
114  /*! Enable symmetric RTP support */
116  /*! RTP instance will be carrying DTMF (using RFC2833) */
118  /*! Expect unreliable DTMF from remote party */
120  /*! Enable STUN support */
122  /*! Enable RTCP support */
124  /*! Enable Asymmetric RTP Codecs */
126  /*! Enable packet retransmission for received packets */
128  /*! Enable packet retransmission for sent packets */
130  /*! Enable REMB sending and receiving passthrough support */
132 
133  /*!
134  * \brief Maximum number of RTP properties supported
135  *
136  * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
137  */
139 };
140 
141 /*! Additional RTP options */
143  /*! Remote side is using non-standard G.726 */
145 };
146 
147 /*! RTP DTMF Modes */
149  /*! No DTMF is being carried over the RTP stream */
151  /*! DTMF is being carried out of band using RFC2833 */
153  /*! DTMF is being carried inband over the RTP stream */
155 };
156 
157 /*! Result codes when RTP glue is queried for information */
159  /*! No remote or local bridging is permitted */
161  /*! Move RTP stream to be remote between devices directly */
163  /*! Perform RTP engine level bridging if possible */
165 };
166 
167 /*! Field statistics that can be retrieved from an RTP instance */
169  /*! Retrieve quality information */
171  /*! Retrieve quality information about jitter */
173  /*! Retrieve quality information about packet loss */
175  /*! Retrieve quality information about round trip time */
177 };
178 
179 /*! Statistics that can be retrieved from an RTP instance */
181  /*! Retrieve all statistics */
183  /*! Retrieve number of packets transmitted */
185  /*! Retrieve number of packets received */
187  /*! Retrieve ALL statistics relating to packet loss */
189  /*! Retrieve number of packets lost for transmitting */
191  /*! Retrieve number of packets lost for receiving */
193  /*! Retrieve maximum number of packets lost on remote side */
195  /*! Retrieve minimum number of packets lost on remote side */
197  /*! Retrieve average number of packets lost on remote side */
199  /*! Retrieve standard deviation of packets lost on remote side */
201  /*! Retrieve maximum number of packets lost on local side */
203  /*! Retrieve minimum number of packets lost on local side */
205  /*! Retrieve average number of packets lost on local side */
207  /*! Retrieve standard deviation of packets lost on local side */
209  /*! Retrieve ALL statistics relating to jitter */
211  /*! Retrieve jitter on transmitted packets */
213  /*! Retrieve jitter on received packets */
215  /*! Retrieve maximum jitter on remote side */
217  /*! Retrieve minimum jitter on remote side */
219  /*! Retrieve average jitter on remote side */
221  /*! Retrieve standard deviation jitter on remote side */
223  /*! Retrieve maximum jitter on local side */
225  /*! Retrieve minimum jitter on local side */
227  /*! Retrieve average jitter on local side */
229  /*! Retrieve standard deviation jitter on local side */
231  /*! Retrieve ALL statistics relating to round trip time */
233  /*! Retrieve round trip time */
235  /*! Retrieve maximum round trip time */
237  /*! Retrieve minimum round trip time */
239  /*! Retrieve average round trip time */
241  /*! Retrieve standard deviation round trip time */
243  /*! Retrieve local SSRC */
245  /*! Retrieve remote SSRC */
247  /*! Retrieve channel unique ID */
249  /*! Retrieve number of octets transmitted */
251  /*! Retrieve number of octets received */
253 };
254 
256  /*! RTCP should not be sent/received */
258  /*! RTCP should be sent/received based on standard port rules */
260  /*! RTCP should be sent/received on the same port as RTP */
262 };
263 
264 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
265 /*! DTMF (RFC2833) */
266 #define AST_RTP_DTMF (1 << 0)
267 /*! 'Comfort Noise' (RFC3389) */
268 #define AST_RTP_CN (1 << 1)
269 /*! DTMF (Cisco Proprietary) */
270 #define AST_RTP_CISCO_DTMF (1 << 2)
271 /*! Maximum RTP-specific code */
272 #define AST_RTP_MAX AST_RTP_CISCO_DTMF
273 
274 /*! Structure that represents a payload */
276  /*! If asterisk_format is set, this is the internal
277  * asterisk format represented by the payload */
279  /*! Is this an Asterisk value */
281  /*! Actual internal RTP specific value of the payload */
282  int rtp_code;
283  /*! Actual payload number */
284  int payload;
285  /*! TRUE if this is the primary mapping to the format. */
286  unsigned int primary_mapping:1;
287  /*! When the payload type became non-primary. */
288  struct timeval when_retired;
289 };
290 
291 /* Common RTCP report types */
292 /*! Sender Report */
293 #define AST_RTP_RTCP_SR 200
294 /*! Receiver Report */
295 #define AST_RTP_RTCP_RR 201
296 /*! Transport Layer Feed Back (From RFC4585 also RFC5104) */
297 #define AST_RTP_RTCP_RTPFB 205
298 /*! Payload Specific Feed Back (From RFC4585 also RFC5104) */
299 #define AST_RTP_RTCP_PSFB 206
300 
301 /* Common RTCP feedback message types */
302 /*! Generic NACK (From RFC4585 also RFC5104) */
303 #define AST_RTP_RTCP_FMT_NACK 1
304 /*! Picture loss indication (From RFC4585) */
305 #define AST_RTP_RTCP_FMT_PLI 1
306 /*! Full INTRA-frame Request (From RFC5104) */
307 #define AST_RTP_RTCP_FMT_FIR 4
308 /*! REMB Information (From draft-alvestrand-rmcat-remb-03) */
309 #define AST_RTP_RTCP_FMT_REMB 15
310 /*! Transport-wide congestion control feedback (From draft-holmer-rmcat-transport-wide-cc-extensions-01) */
311 #define AST_RTP_RTCP_FMT_TRANSPORT_WIDE_CC 15
312 
313 /*!
314  * \since 12
315  * \brief A report block within a SR/RR report */
317  unsigned int source_ssrc; /*< The SSRC of the source for this report block */
318  struct {
319  unsigned short fraction; /*< The fraction of packets lost since last SR/RR */
320  unsigned int packets; /*< The cumulative packets since the beginning */
321  } lost_count; /*< Statistics regarding missed packets */
322  unsigned int highest_seq_no; /*< Extended highest sequence number received */
323  unsigned int ia_jitter; /*< Calculated interarrival jitter */
324  unsigned int lsr; /*< The time the last SR report was received */
325  unsigned int dlsr; /*< Delay in sending this report */
326 };
327 
328 /*!
329  * \since 12
330  * \brief An object that represents data sent during a SR/RR RTCP report */
332  unsigned short reception_report_count; /*< The number of report blocks */
333  unsigned int ssrc; /*< Our SSRC */
334  unsigned int type; /*< The type of report. 200=SR; 201=RR */
335  struct {
336  struct timeval ntp_timestamp; /*< Our NTP timestamp */
337  unsigned int rtp_timestamp; /*< Our last RTP timestamp */
338  unsigned int packet_count; /*< Number of packets sent */
339  unsigned int octet_count; /*< Number of bytes sent */
340  } sender_information; /*< Sender information for SR */
341  /*! A dynamic array of report blocks. The number of elements is given by
342  * \c reception_report_count.
343  */
344  struct ast_rtp_rtcp_report_block *report_block[0];
345 };
346 
347 /*!
348  * \since 15.4.0
349  * \brief A REMB feedback message (see draft-alvestrand-rmcat-remb-03 for details) */
351  unsigned int br_exp; /*!< Exponential scaling of the mantissa for the maximum total media bit rate value */
352  unsigned int br_mantissa; /*!< The mantissa of the maximum total media bit rate */
353 };
354 
355 /*!
356  * \since 15.4.0
357  * \brief An object that represents data received in a feedback report */
359  unsigned int fmt; /*!< The feedback message type */
360  union {
361  struct ast_rtp_rtcp_feedback_remb remb; /*!< REMB feedback information */
362  };
363 };
364 
365 /*! Structure that represents statistics from an RTP instance */
367  /*! Number of packets transmitted */
368  unsigned int txcount;
369  /*! Number of packets received */
370  unsigned int rxcount;
371  /*! Jitter on transmitted packets */
372  double txjitter;
373  /*! Jitter on received packets */
374  double rxjitter;
375  /*! Maximum jitter on remote side */
377  /*! Minimum jitter on remote side */
379  /*! Average jitter on remote side */
381  /*! Standard deviation jitter on remote side */
383  /*! Maximum jitter on local side */
385  /*! Minimum jitter on local side */
387  /*! Average jitter on local side */
389  /*! Standard deviation jitter on local side */
391  /*! Number of transmitted packets lost */
392  unsigned int txploss;
393  /*! Number of received packets lost */
394  unsigned int rxploss;
395  /*! Maximum number of packets lost on remote side */
397  /*! Minimum number of packets lost on remote side */
399  /*! Average number of packets lost on remote side */
401  /*! Standard deviation packets lost on remote side */
403  /*! Maximum number of packets lost on local side */
405  /*! Minimum number of packets lost on local side */
407  /*! Average number of packets lost on local side */
409  /*! Standard deviation packets lost on local side */
411  /*! Total round trip time */
412  double rtt;
413  /*! Maximum round trip time */
414  double maxrtt;
415  /*! Minimum round trip time */
416  double minrtt;
417  /*! Average round trip time */
418  double normdevrtt;
419  /*! Standard deviation round trip time */
420  double stdevrtt;
421  /*! Our SSRC */
422  unsigned int local_ssrc;
423  /*! Their SSRC */
424  unsigned int remote_ssrc;
425  /*! The Asterisk channel's unique ID that owns this instance */
426  char channel_uniqueid[MAX_CHANNEL_ID];
427  /*! Number of octets transmitted */
428  unsigned int txoctetcount;
429  /*! Number of octets received */
430  unsigned int rxoctetcount;
431 };
432 
433 #define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
434 if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == stat)) { \
435 placement = value; \
436 if (stat == current_stat) { \
437 return 0; \
438 } \
439 }
440 
441 #define AST_RTP_STAT_STRCPY(current_stat, combined, placement, value) \
442 if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == stat)) { \
443  ast_copy_string(placement, value, sizeof(placement)); \
444  if (stat == current_stat) { \
445  return 0; \
446  } \
447 }
448 
449 #define AST_RTP_STAT_TERMINATOR(combined) \
450 if (stat == combined) { \
451 return 0; \
452 }
453 
454 /*! \brief ICE candidate types */
456  AST_RTP_ICE_CANDIDATE_TYPE_HOST, /*!< ICE host candidate. A host candidate represents the actual local transport address in the host. */
457  AST_RTP_ICE_CANDIDATE_TYPE_SRFLX, /*!< ICE server reflexive candidate, which represents the public mapped address of the local address. */
458  AST_RTP_ICE_CANDIDATE_TYPE_RELAYED, /*!< ICE relayed candidate, which represents the address allocated in TURN server. */
459 };
460 
461 /*! \brief ICE component types */
465 };
466 
467 /*! \brief ICE role during negotiation */
471 };
472 
473 /*! \brief Structure for an ICE candidate */
475  char *foundation; /*!< Foundation identifier */
476  enum ast_rtp_ice_component_type id; /*!< Component identifier */
477  char *transport; /*!< Transport for the media */
478  int priority; /*!< Priority which is used if multiple candidates can be used */
479  struct ast_sockaddr address; /*!< Address of the candidate */
480  struct ast_sockaddr relay_address; /*!< Relay address for the candidate */
481  enum ast_rtp_ice_candidate_type type; /*!< Type of candidate */
482 };
483 
484 /*! \brief Structure that represents the optional ICE support within an RTP engine */
486  /*! Callback for setting received authentication information */
487  void (*set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password);
488  /*! Callback for adding a remote candidate */
489  void (*add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate);
490  /*! Callback for starting ICE negotiation */
491  void (*start)(struct ast_rtp_instance *instance);
492  /*! Callback for stopping ICE support */
493  void (*stop)(struct ast_rtp_instance *instance);
494  /*! Callback for getting local username */
495  const char *(*get_ufrag)(struct ast_rtp_instance *instance);
496  /*! Callback for getting local password */
497  const char *(*get_password)(struct ast_rtp_instance *instance);
498  /*! Callback for getting local candidates */
499  struct ao2_container *(*get_local_candidates)(struct ast_rtp_instance *instance);
500  /*! Callback for telling the ICE support that it is talking to an ice-lite implementation */
501  void (*ice_lite)(struct ast_rtp_instance *instance);
502  /*! Callback for changing our role in negotiation */
503  void (*set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role);
504  /*! Callback for requesting a TURN session */
505  void (*turn_request)(struct ast_rtp_instance *instance, enum ast_rtp_ice_component_type component,
506  enum ast_transport transport, const char *server, unsigned int port,
507  const char *username, const char *password);
508  /*! Callback to alter the number of ICE components on a session */
509  void (*change_components)(struct ast_rtp_instance *instance, int num_components);
510 };
511 
512 /*! \brief DTLS setup types */
514  AST_RTP_DTLS_SETUP_ACTIVE, /*!< Endpoint is willing to inititate connections */
515  AST_RTP_DTLS_SETUP_PASSIVE, /*!< Endpoint is willing to accept connections */
516  AST_RTP_DTLS_SETUP_ACTPASS, /*!< Endpoint is willing to both accept and initiate connections */
517  AST_RTP_DTLS_SETUP_HOLDCONN, /*!< Endpoint does not want the connection to be established right now */
518 };
519 
520 /*! \brief DTLS connection states */
522  AST_RTP_DTLS_CONNECTION_NEW, /*!< Endpoint wants to use a new connection */
523  AST_RTP_DTLS_CONNECTION_EXISTING, /*!< Endpoint wishes to use existing connection */
524 };
525 
526 /*! \brief DTLS fingerprint hashes */
528  AST_RTP_DTLS_HASH_SHA256, /*!< SHA-256 fingerprint hash */
529  AST_RTP_DTLS_HASH_SHA1, /*!< SHA-1 fingerprint hash */
530 };
531 
532 /*! \brief DTLS verification settings */
534  AST_RTP_DTLS_VERIFY_NONE = 0, /*!< Don't verify anything */
535  AST_RTP_DTLS_VERIFY_FINGERPRINT = (1 << 0), /*!< Verify the fingerprint */
536  AST_RTP_DTLS_VERIFY_CERTIFICATE = (1 << 1), /*!< Verify the certificate */
537 };
538 
539 /*!
540  * \brief Known RTP extensions
541  */
543  /*! Per the RFC 0 should not be used, so we treat it as an unsupported extension placeholder */
545  /*! abs-send-time from https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03 */
547  /*! transport-cc from https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01 */
549  /*! The maximum number of known RTP extensions */
551 };
552 
553 /*! \brief DTLS configuration structure */
555  unsigned int enabled:1; /*!< Whether DTLS support is enabled or not */
556  unsigned int rekey; /*!< Interval at which to renegotiate and rekey - defaults to 0 (off) */
557  enum ast_rtp_dtls_setup default_setup; /*!< Default setup type to use for outgoing */
558  enum ast_srtp_suite suite; /*!< Crypto suite in use */
559  enum ast_rtp_dtls_hash hash; /*!< Hash to use for fingerprint */
560  enum ast_rtp_dtls_verify verify; /*!< What should be verified */
561  char *certfile; /*!< Certificate file */
562  char *pvtfile; /*!< Private key file */
563  char *cipher; /*!< Cipher to use */
564  char *cafile; /*!< Certificate authority file */
565  char *capath; /*!< Path to certificate authority */
566  unsigned int ephemeral_cert:1; /*!< Whether to not to generate an ephemeral certificate - defaults to 0 (off) */
567 };
568 
569 /*! \brief Structure that represents the optional DTLS SRTP support within an RTP engine */
571  /*! Set the configuration of the DTLS support on the instance */
572  int (*set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg);
573  /*! Get if the DTLS SRTP support is active or not */
574  int (*active)(struct ast_rtp_instance *instance);
575  /*! Stop and terminate DTLS SRTP support */
576  void (*stop)(struct ast_rtp_instance *instance);
577  /*! Reset the connection and start fresh */
578  void (*reset)(struct ast_rtp_instance *instance);
579  /*! Get the current connection state */
580  enum ast_rtp_dtls_connection (*get_connection)(struct ast_rtp_instance *instance);
581  /*! Get the current setup state */
582  enum ast_rtp_dtls_setup (*get_setup)(struct ast_rtp_instance *instance);
583  /*! Set the remote setup state */
584  void (*set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup);
585  /*! Set the remote fingerprint */
586  void (*set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint);
587  /*! Get the local fingerprint hash type */
588  enum ast_rtp_dtls_hash (*get_fingerprint_hash)(struct ast_rtp_instance *instance);
589  /*! Get the local fingerprint */
590  const char *(*get_fingerprint)(struct ast_rtp_instance *instance);
591 };
592 
593 #ifdef TEST_FRAMEWORK
594 /*! \brief Structure that represents the test functionality for res_rtp_asterisk unit tests */
596  /*! Drops RTP packets while this has a value greater than 0 */
598  /*! Sends a SR/RR instead of RTP the next time RTP would be sent */
600  /*! Set to 1 whenever SDES is received */
602  /*! Get the number of packets in the receive buffer for a RTP instance */
603  size_t (*recv_buffer_count)(struct ast_rtp_instance *instance);
604  /*! Get the maximum number of packets the receive buffer can hold for a RTP instance */
605  size_t (*recv_buffer_max)(struct ast_rtp_instance *instance);
606  /*! Get the number of packets in the send buffer for a RTP instance */
607  size_t (*send_buffer_count)(struct ast_rtp_instance *instance);
608  /*! Set the schedid for RTCP */
609  void (*set_schedid)(struct ast_rtp_instance *instance, int id);
610 };
611 #endif
612 
613 /*! Structure that represents an RTP stack (engine) */
615  /*! Name of the RTP engine, used when explicitly requested */
616  const char *name;
617  /*! Module this RTP engine came from, used for reference counting */
618  struct ast_module *mod;
619  /*! Callback for setting up a new RTP instance */
620  int (*new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data);
621  /*! Callback for destroying an RTP instance */
622  int (*destroy)(struct ast_rtp_instance *instance);
623  /*! Callback for writing out a frame */
624  int (*write)(struct ast_rtp_instance *instance, struct ast_frame *frame);
625  /*! Callback for stopping the RTP instance */
626  void (*stop)(struct ast_rtp_instance *instance);
627  /*! Callback for starting RFC2833 DTMF transmission */
628  int (*dtmf_begin)(struct ast_rtp_instance *instance, char digit);
629  /*! Callback for stopping RFC2833 DTMF transmission */
630  int (*dtmf_end)(struct ast_rtp_instance *instance, char digit);
631  int (*dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration);
632  /*! Callback to indicate that we should update the marker bit */
633  void (*update_source)(struct ast_rtp_instance *instance);
634  /*! Callback to indicate that we should update the marker bit and ssrc */
635  void (*change_source)(struct ast_rtp_instance *instance);
636  /*! Callback for setting an extended RTP property */
637  int (*extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value);
638  /*! Callback for getting an extended RTP property */
639  void *(*extended_prop_get)(struct ast_rtp_instance *instance, int property);
640  /*! Callback for setting an RTP property */
641  void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
642  /*! Callback for setting a payload. If asterisk is to be used, asterisk_format will be set, otherwise value in code is used. */
643  void (*payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code);
644  /*! Callback for setting the remote address that RTP is to be sent to */
645  void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
646  /*! Callback for changing DTMF mode */
647  int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
648  /*! Callback for getting DTMF mode */
649  enum ast_rtp_dtmf_mode (*dtmf_mode_get)(struct ast_rtp_instance *instance);
650  /*! Callback for retrieving statistics */
651  int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
652  /*! Callback for setting QoS values */
653  int (*qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
654  /*! Callback for retrieving a file descriptor to poll on, not always required */
655  int (*fd)(struct ast_rtp_instance *instance, int rtcp);
656  /*! Callback for initializing RED support */
657  int (*red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
658  /*! Callback for buffering a frame using RED */
659  int (*red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame);
660  /*! Callback for reading a frame from the RTP engine */
661  struct ast_frame *(*read)(struct ast_rtp_instance *instance, int rtcp);
662  /*! Callback to locally bridge two RTP instances */
663  int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
664  /*! Callback to set the read format */
665  int (*set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format);
666  /*! Callback to set the write format */
667  int (*set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format);
668  /*! Callback to make two instances compatible */
669  int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
670  /*! Callback to see if two instances are compatible with DTMF */
671  int (*dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
672  /*! Callback to indicate that packets will now flow */
673  int (*activate)(struct ast_rtp_instance *instance);
674  /*! Callback to request that the RTP engine send a STUN BIND request */
675  void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
676  /*! Callback to get the transcodeable formats supported. result returned in ast_format_cap *result */
677  void (*available_formats)(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result);
678  /*! Callback to send CNG */
679  int (*sendcng)(struct ast_rtp_instance *instance, int level);
680  /*! Callback to retrieve local SSRC */
681  unsigned int (*ssrc_get)(struct ast_rtp_instance *instance);
682  /*! Callback to retrieve RTCP SDES CNAME */
683  const char *(*cname_get)(struct ast_rtp_instance *instance);
684  /*! Callback to bundle an RTP instance to another */
685  int (*bundle)(struct ast_rtp_instance *child, struct ast_rtp_instance *parent);
686  /*! Callback to set remote SSRC information */
687  void (*set_remote_ssrc)(struct ast_rtp_instance *instance, unsigned int ssrc);
688  /*! Callback to set the stream identifier */
689  void (*set_stream_num)(struct ast_rtp_instance *instance, int stream_num);
690  /*! Callback to pointer for optional ICE support */
692  /*! Callback to pointer for optional DTLS SRTP support */
694 #ifdef TEST_FRAMEWORK
695  /*! Callback to pointer for test callbacks for RTP/RTCP unit tests */
697 #endif
698  /*! Callback to enable an RTP extension (returns non-zero if supported) */
699  int (*extension_enable)(struct ast_rtp_instance *instance, enum ast_rtp_extension extension);
700  /*! Linked list information */
702 };
703 
704 /*! Structure that represents codec and packetization information */
706  /*! RW lock that protects elements in this structure */
708  /*! Rx payload type mapping exceptions */
709  AST_VECTOR(, struct ast_rtp_payload_type *) payload_mapping_rx;
710  /*! Tx payload type mapping */
711  AST_VECTOR(, struct ast_rtp_payload_type *) payload_mapping_tx;
712  /*! The framing for this media session */
713  unsigned int framing;
714 };
715 
716 #define AST_RTP_CODECS_NULL_INIT \
717  { .codecs_lock = AST_RWLOCK_INIT_VALUE, .payload_mapping_rx = { 0, }, .payload_mapping_tx = { 0, }, .framing = 0, }
718 
719 /*! Structure that represents the glue that binds an RTP instance to a channel */
720 struct ast_rtp_glue {
721  /*! Name of the channel driver that this glue is responsible for */
722  const char *type;
723  /*! Module that the RTP glue came from */
724  struct ast_module *mod;
725  /*!
726  * \brief Callback for retrieving the RTP instance carrying audio
727  * \note This function increases the reference count on the returned RTP instance.
728  */
729  enum ast_rtp_glue_result (*get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
730  /*!
731  * \brief Used to prevent two channels from remotely bridging audio rtp if the channel tech has a
732  * reason for prohibiting it based on qualities that need to be compared from both channels.
733  * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used.
734  */
735  int (*allow_rtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance);
736  /*!
737  * \brief Callback for retrieving the RTP instance carrying video
738  * \note This function increases the reference count on the returned RTP instance.
739  * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used.
740  */
741  enum ast_rtp_glue_result (*get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
742  /*!
743  * \brief Used to prevent two channels from remotely bridging video rtp if the channel tech has a
744  * reason for prohibiting it based on qualities that need to be compared from both channels.
745  * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used.
746  */
747  int (*allow_vrtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance);
748 
749  /*!
750  * \brief Callback for retrieving the RTP instance carrying text
751  * \note This function increases the reference count on the returned RTP instance.
752  * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used.
753  */
754  enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
755  /*! Callback for updating the destination that the remote side should send RTP to */
756  int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, const struct ast_format_cap *cap, int nat_active);
757  /*!
758  * \brief Callback for retrieving codecs that the channel can do. Result returned in result_cap.
759  * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, this function is not used.
760  */
761  void (*get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap);
762  /*! Linked list information */
764 };
765 
766 /*!
767  * \brief Directions for RTP extensions
768  */
770  /*! The extension is not negotiated and is not flowing */
772  /*! Send and receive */
774  /*! Send only */
776  /*! Receive only */
778  /*! Negotiated but not sending or receiving */
780 };
781 
782 /*!
783  * \brief Allocation routine for \ref ast_rtp_payload_type
784  *
785  * \retval NULL on error
786  * \retval An ao2 ref counted \c ast_rtp_payload_type on success.
787  *
788  * \note The \c ast_rtp_payload_type returned by this function is an
789  * ao2 ref counted object.
790  *
791  */
793 
794 #define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, AST_MODULE_SELF)
795 
796 /*!
797  * \brief Register an RTP engine
798  *
799  * \param engine Structure of the RTP engine to register
800  * \param module Module that the RTP engine is part of
801  *
802  * \retval 0 success
803  * \retval -1 failure
804  *
805  * Example usage:
806  *
807  * \code
808  * ast_rtp_engine_register2(&example_rtp_engine, NULL);
809  * \endcode
810  *
811  * This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not
812  * associate a module with it.
813  *
814  * \note It is recommended that you use the ast_rtp_engine_register macro so that the module is
815  * associated with the RTP engine and use counting is performed.
816  *
817  * \since 1.8
818  */
819 int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module);
820 
821 /*!
822  * \brief Unregister an RTP engine
823  *
824  * \param engine Structure of the RTP engine to unregister
825  *
826  * \retval 0 success
827  * \retval -1 failure
828  *
829  * Example usage:
830  *
831  * \code
832  * ast_rtp_engine_unregister(&example_rtp_engine);
833  * \endcode
834  *
835  * This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module
836  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
837  *
838  * \since 1.8
839  */
840 int ast_rtp_engine_unregister(struct ast_rtp_engine *engine);
841 
843 
846 
847 #define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, AST_MODULE_SELF)
848 
849 /*!
850  * \brief Register RTP glue
851  *
852  * \param glue The glue to register
853  * \param module Module that the RTP glue is part of
854  *
855  * \retval 0 success
856  * \retval -1 failure
857  *
858  * Example usage:
859  *
860  * \code
861  * ast_rtp_glue_register2(&example_rtp_glue, NULL);
862  * \endcode
863  *
864  * This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not
865  * associate a module with it.
866  *
867  * \note It is recommended that you use the ast_rtp_glue_register macro so that the module is
868  * associated with the RTP glue and use counting is performed.
869  *
870  * \since 1.8
871  */
872 int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module);
873 
874 /*!
875  * \brief Unregister RTP glue
876  *
877  * \param glue The glue to unregister
878  *
879  * \retval 0 success
880  * \retval -1 failure
881  *
882  * Example usage:
883  *
884  * \code
885  * ast_rtp_glue_unregister(&example_rtp_glue);
886  * \endcode
887  *
888  * This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module
889  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
890  *
891  * \since 1.8
892  */
893 int ast_rtp_glue_unregister(struct ast_rtp_glue *glue);
894 
895 /*!
896  * \brief Create a new RTP instance
897  *
898  * \param engine_name Name of the engine to use for the RTP instance
899  * \param sched Scheduler context that the RTP engine may want to use
900  * \param sa Address we want to bind to
901  * \param data Unique data for the engine
902  *
903  * \retval non-NULL success
904  * \retval NULL failure
905  *
906  * Example usage:
907  *
908  * \code
909  * struct ast_rtp_instance *instance = NULL;
910  * instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);
911  * \endcode
912  *
913  * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given
914  * in the address structure.
915  *
916  * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use
917  * another depending on it's own configuration.
918  *
919  * \since 1.8
920  */
921 struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
922  struct ast_sched_context *sched, const struct ast_sockaddr *sa,
923  void *data);
924 
925 /*!
926  * \brief Destroy an RTP instance
927  *
928  * \param instance The RTP instance to destroy
929  *
930  * \retval 0 success
931  * \retval -1 failure
932  *
933  * Example usage:
934  *
935  * \code
936  * ast_rtp_instance_destroy(instance);
937  * \endcode
938  *
939  * This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid
940  * memory and may not be used again.
941  *
942  * \since 1.8
943  */
944 int ast_rtp_instance_destroy(struct ast_rtp_instance *instance);
945 
946 /*!
947  * \brief Set the data portion of an RTP instance
948  *
949  * \param instance The RTP instance to manipulate
950  * \param data Pointer to data
951  *
952  * Example usage:
953  *
954  * \code
955  * ast_rtp_instance_set_data(instance, blob);
956  * \endcode
957  *
958  * This sets the data pointer on the RTP instance pointed to by 'instance' to
959  * blob.
960  *
961  * \since 1.8
962  */
963 void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data);
964 
965 /*!
966  * \brief Get the data portion of an RTP instance
967  *
968  * \param instance The RTP instance we want the data portion from
969  *
970  * Example usage:
971  *
972  * \code
973  * struct *blob = ast_rtp_instance_get_data(instance);
974  ( \endcode
975  *
976  * This gets the data pointer on the RTP instance pointed to by 'instance'.
977  *
978  * \since 1.8
979  */
980 void *ast_rtp_instance_get_data(struct ast_rtp_instance *instance);
981 
982 /*!
983  * \brief Send a frame out over RTP
984  *
985  * \param instance The RTP instance to send frame out on
986  * \param frame the frame to send out
987  *
988  * \retval 0 success
989  * \retval -1 failure
990  *
991  * Example usage:
992  *
993  * \code
994  * ast_rtp_instance_write(instance, frame);
995  * \endcode
996  *
997  * This gives the frame pointed to by frame to the RTP engine being used for the instance
998  * and asks that it be transmitted to the current remote address set on the RTP instance.
999  *
1000  * \since 1.8
1001  */
1002 int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
1003 
1004 /*!
1005  * \brief Receive a frame over RTP
1006  *
1007  * \param instance The RTP instance to receive frame on
1008  * \param rtcp Whether to read in RTCP or not
1009  *
1010  * \retval non-NULL success
1011  * \retval NULL failure
1012  *
1013  * Example usage:
1014  *
1015  * \code
1016  * struct ast_frame *frame;
1017  * frame = ast_rtp_instance_read(instance, 0);
1018  * \endcode
1019  *
1020  * This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.
1021  *
1022  * \since 1.8
1023  */
1024 struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp);
1025 
1026 /*!
1027  * \brief Set the incoming source address of the remote endpoint that we are sending RTP to
1028  *
1029  * This sets the incoming source address the engine is sending RTP to. Usually this
1030  * will be the same as the requested target address, however in the case where
1031  * the engine "learns" the address (for instance, symmetric RTP enabled) this
1032  * will then contain the learned address.
1033  *
1034  * \param instance The RTP instance to change the address on
1035  * \param address Address to set it to
1036  *
1037  * \retval 0 success
1038  * \retval -1 failure
1039  */
1041  const struct ast_sockaddr *address);
1042 
1043 /*!
1044  * \brief Set the requested target address of the remote endpoint
1045  *
1046  * This should always be the address of the remote endpoint. Consequently, this can differ
1047  * from the address the engine is sending RTP to. However, usually they will be the same
1048  * except in some circumstances (for instance when the engine "learns" the address if
1049  * symmetric RTP is enabled).
1050  *
1051  * \param instance The RTP instance to change the address on
1052  * \param address Address to set it to
1053  *
1054  * \retval 0 success
1055  * \retval -1 failure
1056  */
1058  const struct ast_sockaddr *address);
1059 
1060 /*!
1061  * \brief Set the address of the remote endpoint that we are sending RTP to
1062  *
1063  * \param instance The RTP instance to change the address on
1064  * \param address Address to set it to
1065  *
1066  * \retval 0 success
1067  * \retval -1 failure
1068  *
1069  * Example usage:
1070  *
1071  * \code
1072  * ast_rtp_instance_set_remote_address(instance, &sin);
1073  * \endcode
1074  *
1075  * This changes the remote address that RTP will be sent to on instance to the address given in the sin
1076  * structure.
1077  *
1078  * \since 1.8
1079  */
1080 #define ast_rtp_instance_set_remote_address(instance, address) \
1081  ast_rtp_instance_set_requested_target_address((instance), (address))
1082 
1083 /*!
1084  * \brief Set the address that we are expecting to receive RTP on
1085  *
1086  * \param instance The RTP instance to change the address on
1087  * \param address Address to set it to
1088  *
1089  * \retval 0 success
1090  * \retval -1 failure
1091  *
1092  * Example usage:
1093  *
1094  * \code
1095  * ast_rtp_instance_set_local_address(instance, &sin);
1096  * \endcode
1097  *
1098  * This changes the local address that RTP is expected on to the address given in the sin
1099  * structure.
1100  *
1101  * \since 1.8
1102  */
1104  const struct ast_sockaddr *address);
1105 
1106 /*!
1107  * \brief Get the local address that we are expecting RTP on
1108  *
1109  * \param instance The RTP instance to get the address from
1110  * \param address The variable to store the address in
1111  *
1112  * Example usage:
1113  *
1114  * \code
1115  * struct ast_sockaddr address;
1116  * ast_rtp_instance_get_local_address(instance, &address);
1117  * \endcode
1118  *
1119  * This gets the local address that we are expecting RTP on and stores it in the 'address' structure.
1120  *
1121  * \since 1.8
1122  */
1124 
1125 /*!
1126  * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
1127  *
1128  * \param instance The instance that we want to get the local address for
1129  * \param address An initialized address that may be overwritten if the local address is different
1130  *
1131  * \retval 0 address was not changed
1132  * \retval 1 address was changed
1133  * Example usage:
1134  *
1135  * \code
1136  * struct ast_sockaddr address;
1137  * int ret;
1138  * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
1139  * \endcode
1140  *
1141  * This retrieves the current local address set on the instance pointed to by instance and puts the value
1142  * into the address structure.
1143  *
1144  * \since 1.8
1145  */
1147 
1148 /*!
1149  * \brief Get the incoming source address of the remote endpoint
1150  *
1151  * This returns the remote address the engine is sending RTP to. Usually this
1152  * will be the same as the requested target address, however in the case where
1153  * the engine "learns" the address (for instance, symmetric RTP enabled) this
1154  * will then contain the learned address.
1155  *
1156  * \param instance The instance that we want to get the incoming source address for
1157  * \param address A structure to put the address into
1158  */
1160 
1161 /*!
1162  * \brief Get the requested target address of the remote endpoint
1163  *
1164  * This returns the explicitly set address of a remote endpoint. Meaning this won't change unless
1165  * specifically told to change. In most cases this should be the same as the incoming source
1166  * address, except in cases where the engine "learns" the address in which case this and the
1167  * incoming source address might differ.
1168  *
1169  * \param instance The instance that we want to get the requested target address for
1170  * \param address A structure to put the address into
1171  */
1173 
1174 /*!
1175  * \brief Get the address of the remote endpoint that we are sending RTP to
1176  *
1177  * \param instance The instance that we want to get the remote address for
1178  * \param address A structure to put the address into
1179  *
1180  * Example usage:
1181  *
1182  * \code
1183  * struct ast_sockaddr address;
1184  * ast_rtp_instance_get_remote_address(instance, &address);
1185  * \endcode
1186  *
1187  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
1188  * into the address structure.
1189  *
1190  * \since 1.8
1191  */
1192 #define ast_rtp_instance_get_remote_address(instance, address) \
1193  ast_rtp_instance_get_incoming_source_address((instance), (address))
1194 
1195 /*!
1196  * \brief Get the requested target address of the remote endpoint and
1197  * compare it to the given address
1198  *
1199  * \param instance The instance that we want to get the remote address for
1200  * \param address An initialized address that may be overwritten addresses differ
1201  *
1202  * \retval 0 address was not changed
1203  * \retval 1 address was changed
1204  */
1206 
1207 /*!
1208  * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
1209  *
1210  * \param instance The instance that we want to get the remote address for
1211  * \param address An initialized address that may be overwritten if the remote address is different
1212  *
1213  * \retval 0 address was not changed
1214  * \retval 1 address was changed
1215  * Example usage:
1216  *
1217  * \code
1218  * struct ast_sockaddr address;
1219  * int ret;
1220  * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
1221  * \endcode
1222  *
1223  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
1224  * into the address structure.
1225  *
1226  * \since 1.8
1227  */
1228 #define ast_rtp_instance_get_and_cmp_remote_address(instance, address) \
1229  ast_rtp_instance_get_and_cmp_requested_target_address((instance), (address))
1230 
1231 /*!
1232  * \brief Set the value of an RTP instance extended property
1233  *
1234  * \param instance The RTP instance to set the extended property on
1235  * \param property The extended property to set
1236  * \param value The value to set the extended property to
1237  *
1238  * \since 1.8
1239  */
1240 void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value);
1241 
1242 /*!
1243  * \brief Get the value of an RTP instance extended property
1244  *
1245  * \param instance The RTP instance to get the extended property on
1246  * \param property The extended property to get
1247  *
1248  * \since 1.8
1249  */
1250 void *ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property);
1251 
1252 /*!
1253  * \brief Set the value of an RTP instance property
1254  *
1255  * \param instance The RTP instance to set the property on
1256  * \param property The property to modify
1257  * \param value The value to set the property to
1258  *
1259  * Example usage:
1260  *
1261  * \code
1262  * ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1);
1263  * \endcode
1264  *
1265  * This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.
1266  *
1267  * \since 1.8
1268  */
1269 void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
1270 
1271 /*!
1272  * \brief Get the value of an RTP instance property
1273  *
1274  * \param instance The RTP instance to get the property from
1275  * \param property The property to get
1276  *
1277  * \retval Current value of the property
1278  *
1279  * Example usage:
1280  *
1281  * \code
1282  * ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT);
1283  * \endcode
1284  *
1285  * This returns the current value of the NAT property on the instance pointed to by instance.
1286  *
1287  * \since 1.8
1288  */
1289 int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property);
1290 
1291 /*!
1292  * \brief Get the codecs structure of an RTP instance
1293  *
1294  * \param instance The RTP instance to get the codecs structure from
1295  *
1296  * Example usage:
1297  *
1298  * \code
1299  * struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance);
1300  * \endcode
1301  *
1302  * This gets the codecs structure on the RTP instance pointed to by 'instance'.
1303  *
1304  * \since 1.8
1305  */
1307 
1308 /*!
1309  * \brief Enable support for an RTP extension on an instance
1310  *
1311  * \param instance The RTP instance to enable the extension on
1312  * \param id The unique local identifier to use for this extension (-1 to have one auto selected)
1313  * \param extension The RTP extension
1314  * \param direction The initial direction that the RTP extension should be used in
1315  *
1316  * \retval 0 success
1317  * \retval -1 failure
1318  *
1319  * \since 15.5.0
1320  */
1323 
1324 /*!
1325  * \brief Negotiate received RTP extension information
1326  *
1327  * \param instance The RTP instance to set the extension on
1328  * \param id The local identifier for the extension
1329  * \param direction The direction that the extension should be used in
1330  * \param uri The unique URI for the extension
1331  * \param attributes Attributes specific to this extension (if NULL or empty then no attributes)
1332  *
1333  * \retval 0 success
1334  * \retval -1 failure
1335  *
1336  * \since 15.5.0
1337  */
1339  const char *uri, const char *attributes);
1340 
1341 /*!
1342  * \brief Clear negotiated RTP extension information
1343  *
1344  * \param instance The RTP instance to clear negotiated extension information on
1345  */
1346 void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance);
1347 
1348 /*!
1349  * \brief Retrieve the id for an RTP extension
1350  *
1351  * \param instance The RTP instance to retrieve the id from
1352  * \param extension The RTP extension
1353  *
1354  * \retval -1 not negotiated
1355  * \retval id if negotiated
1356  *
1357  * \since 15.5.0
1358  */
1360 
1361 /*!
1362  * \brief Get the number of known unique identifiers
1363  *
1364  * \param instance The RTP instance to retrieve the count from
1365  *
1366  * \return the number of known unique identifiers
1367  *
1368  * \since 15.5.0
1369  */
1370 size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance);
1371 
1372 /*!
1373  * \brief Retrieve the extension for an RTP extension id
1374  *
1375  * \param instance The RTP instance to retrieve the extension from
1376  * \param id The negotiated RTP extension id
1377  *
1378  * \retval extension the extension that maps to the id
1379  *
1380  * \since 15.5.0
1381  *
1382  * \note This will return AST_RTP_EXTENSION_UNSUPPORTED if an extension was proposed for this unique identifier
1383  * but it is not supported or if the unique identifier is unused.
1384  */
1386 
1387 /*!
1388  * \brief Retrieve the negotiated direction for an RTP extension id
1389  *
1390  * \param instance The RTP instance to retrieve the direction from
1391  * \param id The negotiated RTP extension id
1392  *
1393  * \retval direction the direction that has been negotiated
1394  *
1395  * \since 15.5.0
1396  */
1398 
1399 /*!
1400  * \brief Retrieve the URI for an RTP extension id
1401  *
1402  * \param instance The RTP instance to retrieve the direction from
1403  * \param id The negotiated RTP extension id
1404  *
1405  * \retval uri The URI for the RTP extension
1406  *
1407  * \since 15.5.0
1408  */
1409 const char *ast_rtp_instance_extmap_get_uri(struct ast_rtp_instance *instance, int id);
1410 
1411 /*!
1412  * \brief Initialize an RTP codecs structure
1413  *
1414  * \param codecs The codecs structure to initialize
1415  *
1416  * \retval 0 success
1417  * \retval -1 failure
1418  *
1419  * Example usage:
1420  *
1421  * \code
1422  * struct ast_rtp_codecs codecs;
1423  * ast_rtp_codecs_payloads_initialize(&codecs);
1424  * \endcode
1425  *
1426  * \since 11
1427  */
1429 
1430 /*!
1431  * \brief Destroy the contents of an RTP codecs structure (but not the structure itself)
1432  *
1433  * \param codecs The codecs structure to destroy the contents of
1434  *
1435  * Example usage:
1436  *
1437  * \code
1438  * struct ast_rtp_codecs codecs;
1439  * ast_rtp_codecs_payloads_destroy(&codecs);
1440  * \endcode
1441  *
1442  * \since 11
1443  */
1445 
1446 /*!
1447  * \brief Clear rx and tx payload mapping information from an RTP instance
1448  *
1449  * \param codecs The codecs structure that payloads will be cleared from
1450  * \param instance Optionally the instance that the codecs structure belongs to
1451  *
1452  * Example usage:
1453  *
1454  * \code
1455  * struct ast_rtp_codecs codecs;
1456  * ast_rtp_codecs_payloads_clear(&codecs, NULL);
1457  * \endcode
1458  *
1459  * This clears the codecs structure and puts it into a pristine state.
1460  *
1461  * \since 1.8
1462  */
1464 
1465 /*!
1466  * \brief Copy payload information from one RTP instance to another
1467  *
1468  * \param src The source codecs structure
1469  * \param dest The destination codecs structure that the values from src will be copied to
1470  * \param instance Optionally the instance that the dst codecs structure belongs to
1471  *
1472  * Example usage:
1473  *
1474  * \code
1475  * ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);
1476  * \endcode
1477  *
1478  * This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.
1479  *
1480  * \since 1.8
1481  */
1482 void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
1483 
1484 /*!
1485  * \brief Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
1486  * \since 14.0.0
1487  *
1488  * \param src The source codecs structure
1489  * \param dest The destination codecs structure that the values from src will be copied to
1490  * \param instance Optionally the instance that the dst codecs structure belongs to
1491  *
1492  * \return Nothing
1493  */
1494 void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
1495 
1496 /*!
1497  * \brief Record tx payload type information that was seen in an m= SDP line
1498  *
1499  * \param codecs The codecs structure to muck with
1500  * \param instance Optionally the instance that the codecs structure belongs to
1501  * \param payload Numerical payload that was seen in the m= SDP line
1502  *
1503  * Example usage:
1504  *
1505  * \code
1506  * ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0);
1507  * \endcode
1508  *
1509  * This records that the numerical payload '0' was seen in the codecs structure.
1510  *
1511  * \since 1.8
1512  */
1514 
1515 /*!
1516  * \brief Record tx payload type information that was seen in an a=rtpmap: SDP line
1517  *
1518  * \param codecs The codecs structure to muck with
1519  * \param instance Optionally the instance that the codecs structure belongs to
1520  * \param payload Numerical payload that was seen in the a=rtpmap: SDP line
1521  * \param mimetype The string mime type that was seen
1522  * \param mimesubtype The strin mime sub type that was seen
1523  * \param options Optional options that may change the behavior of this specific payload
1524  *
1525  * \retval 0 success
1526  * \retval -1 failure, invalid payload numbe
1527  * \retval -2 failure, unknown mimetype
1528  *
1529  * Example usage:
1530  *
1531  * \code
1532  * ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);
1533  * \endcode
1534  *
1535  * This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.
1536  *
1537  * \since 1.8
1538  */
1539 int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options);
1540 
1541 /*!
1542  * \brief Set tx payload type to a known MIME media type for a codec with a specific sample rate
1543  *
1544  * \param codecs RTP structure to modify
1545  * \param instance Optionally the instance that the codecs structure belongs to
1546  * \param pt Payload type entry to modify
1547  * \param mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.)
1548  * \param mimesubtype MIME subtype of media stream (typically a codec name)
1549  * \param options Zero or more flags from the ast_rtp_options enum
1550  * \param sample_rate The sample rate of the media stream
1551  *
1552  * This function 'fills in' an entry in the list of possible formats for
1553  * a media stream associated with an RTP structure.
1554  *
1555  * \retval 0 on success
1556  * \retval -1 if the payload type is out of range
1557  * \retval -2 if the mimeType/mimeSubtype combination was not found
1558  *
1559  * \since 1.8
1560  */
1562  char *mimetype, char *mimesubtype,
1563  enum ast_rtp_options options,
1564  unsigned int sample_rate);
1565 
1566 /*!
1567  * \brief Remove tx payload type mapped information
1568  *
1569  * \param codecs The codecs structure to muck with
1570  * \param instance Optionally the instance that the codecs structure belongs to
1571  * \param payload Numerical payload to unset
1572  *
1573  * Example usage:
1574  *
1575  * \code
1576  * ast_rtp_codecs_payloads_unset(&codecs, NULL, 0);
1577  * \endcode
1578  *
1579  * This clears the payload '0' from the codecs structure. It will be as if it was never set.
1580  *
1581  * \since 1.8
1582  */
1583 void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
1584 
1585 /*!
1586  * \brief Determine the type of RTP stream media from the codecs mapped.
1587  * \since 13.19.0
1588  *
1589  * \param codecs Codecs structure to look in
1590  *
1591  * \return Media type or AST_MEDIA_TYPE_UNKNOWN if no codecs mapped.
1592  */
1594 
1595 /*!
1596  * \brief Retrieve rx payload mapped information by payload type
1597  *
1598  * \param codecs Codecs structure to look in
1599  * \param payload Numerical payload to look up
1600  *
1601  * \retval Payload information.
1602  * \retval NULL if payload does not exist.
1603  *
1604  * \note The payload returned by this function has its reference count increased.
1605  * Callers are responsible for decrementing the reference count.
1606  *
1607  * Example usage:
1608  *
1609  * \code
1610  * struct ast_rtp_payload_type *payload_type;
1611  * payload_type = ast_rtp_codecs_get_payload(&codecs, 0);
1612  * \endcode
1613  *
1614  * This looks up the information for payload '0' from the codecs structure.
1615  */
1617 
1618 /*!
1619  * \brief Update the format associated with a tx payload type in a codecs structure
1620  *
1621  * \param codecs Codecs structure to operate on
1622  * \param payload Numerical payload type to look up
1623  * \param format The format to replace the existing one
1624  *
1625  * \retval 0 success
1626  * \retval -1 failure
1627  *
1628  * \since 13
1629  */
1631 
1632 /*!
1633  * \brief Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type
1634  *
1635  * \param codecs Codecs structure to look in
1636  * \param payload Numerical payload type to look up
1637  *
1638  * \retval pointer to format structure on success
1639  * \retval NULL on failure
1640  *
1641  * \note The format returned by this function has its reference count increased.
1642  * Callers are responsible for decrementing the reference count.
1643  *
1644  * \since 10.0
1645  */
1647 
1648 /*!
1649  * \brief Set the framing used for a set of codecs
1650  *
1651  * \param codecs Codecs structure to set framing on
1652  * \param framing The framing value to set on the codecs
1653  *
1654  * \since 13.0.0
1655  */
1656 void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing);
1657 
1658 /*!
1659  * \brief Get the framing used for a set of codecs
1660  *
1661  * \param codecs Codecs structure to get the framing from
1662  *
1663  * \retval The framing to be used for the media stream associated with these codecs
1664  *
1665  * \since 13.0.0
1666  */
1667 unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs);
1668 
1669 /*!
1670  * \brief Get the sample rate associated with known RTP payload types
1671  *
1672  * \param asterisk_format True if the value in format is to be used.
1673  * \param format An asterisk format
1674  * \param code from AST_RTP list
1675  *
1676  * \return the sample rate if the format was found, zero if it was not found
1677  *
1678  * \since 1.8
1679  */
1681  const struct ast_format *format, int code);
1682 
1683 /*!
1684  * \brief Retrieve all formats that were found
1685  *
1686  * \param codecs Codecs structure to look in
1687  * \param astformats A capabilities structure to put the Asterisk formats in.
1688  * \param nonastformats An integer to put the non-Asterisk formats in
1689  *
1690  * Example usage:
1691  *
1692  * \code
1693  * struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
1694  * int nonastformats;
1695  * ast_rtp_codecs_payload_formats(&codecs, astformats, &nonastformats);
1696  * \endcode
1697  *
1698  * This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer
1699  * pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.
1700  *
1701  * \since 1.8
1702  */
1703 void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats);
1704 
1705 /*!
1706  * \brief Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code
1707  *
1708  * \param codecs Codecs structure to look in
1709  * \param asterisk_format Non-zero if the given Asterisk format is present
1710  * \param format Asterisk format to look for
1711  * \param code The format to look for
1712  *
1713  * \details
1714  * Find the currently assigned rx mapped payload type based on whether it
1715  * is an Asterisk format or non-format code. If one is currently not
1716  * assigned then create a rx payload type mapping.
1717  *
1718  * \retval Numerical payload type
1719  * \retval -1 if could not assign.
1720  *
1721  * Example usage:
1722  *
1723  * \code
1724  * int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0);
1725  * \endcode
1726  *
1727  * This looks for the numerical payload for ULAW in the codecs structure.
1728  *
1729  * \since 1.8
1730  */
1732 
1733 /*!
1734  * \brief Set a payload code for use with a specific Asterisk format
1735  *
1736  * \param codecs Codecs structure to manipulate
1737  * \param code The payload code
1738  * \param format Asterisk format
1739  *
1740  * \retval 0 Payload was set to the given format
1741  * \retval -1 Payload was in use or could not be set
1742  *
1743  * \since 15.0.0
1744  */
1745 int ast_rtp_codecs_payload_set_rx(struct ast_rtp_codecs *codecs, int code, struct ast_format *format);
1746 
1747 /*!
1748  * \brief Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code
1749  * \since 14.0.0
1750  *
1751  * \param codecs Codecs structure to look in
1752  * \param asterisk_format Non-zero if the given Asterisk format is present
1753  * \param format Asterisk format to look for
1754  * \param code The format to look for
1755  *
1756  * \retval Numerical payload type
1757  * \retval -1 if not found.
1758  */
1759 int ast_rtp_codecs_payload_code_tx(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code);
1760 
1761 /*!
1762  * \brief Search for the tx payload type in the ast_rtp_codecs structure
1763  *
1764  * \param codecs Codecs structure to look in
1765  * \param payload The payload type format to look for
1766  *
1767  * \retval Numerical payload type or -1 if unable to find payload in codecs
1768  *
1769  * Example usage:
1770  *
1771  * \code
1772  * int payload = ast_rtp_codecs_find_payload_code(&codecs, 0);
1773  * \endcode
1774  *
1775  * This looks for the numerical payload for ULAW in the codecs structure.
1776  */
1778 
1779 /*!
1780  * \brief Retrieve mime subtype information on a payload
1781  *
1782  * \param asterisk_format Non-zero to look up using Asterisk format
1783  * \param format Asterisk format to look up
1784  * \param code RTP code to look up
1785  * \param options Additional options that may change the result
1786  *
1787  * \retval Mime subtype success
1788  * \retval NULL failure
1789  *
1790  * Example usage:
1791  *
1792  * \code
1793  * const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0);
1794  * \endcode
1795  *
1796  * This looks up the mime subtype for the ULAW format.
1797  *
1798  * \since 1.8
1799  */
1800 const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format,
1801  const struct ast_format *format, int code, enum ast_rtp_options options);
1802 
1803 /*!
1804  * \brief Convert formats into a string and put them into a buffer
1805  *
1806  * \param buf Buffer to put the mime output into
1807  * \param ast_format_capability Asterisk Formats we are looking up.
1808  * \param rtp_capability RTP codes that we are looking up
1809  * \param asterisk_format Non-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used
1810  * \param options Additional options that may change the result
1811  *
1812  * \retval non-NULL success
1813  * \retval NULL failure
1814  *
1815  * Example usage:
1816  *
1817  * \code
1818  * char buf[256] = "";
1819  * struct ast_format tmp_fmt;
1820  * struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
1821  * ast_format_cap_append(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
1822  * ast_format_cap_append(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
1823  * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
1824  * ast_format_cap_destroy(cap);
1825  * \endcode
1826  *
1827  * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
1828  *
1829  * \since 1.8
1830  */
1831 char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options);
1832 
1833 /*!
1834  * \brief Begin sending a DTMF digit
1835  *
1836  * \param instance The RTP instance to send the DTMF on
1837  * \param digit What DTMF digit to send
1838  *
1839  * \retval 0 success
1840  * \retval -1 failure
1841  *
1842  * Example usage:
1843  *
1844  * \code
1845  * ast_rtp_instance_dtmf_begin(instance, '1');
1846  * \endcode
1847  *
1848  * This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will
1849  * continue being sent until it is ended.
1850  *
1851  * \since 1.8
1852  */
1853 int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit);
1854 
1855 /*!
1856  * \brief Stop sending a DTMF digit
1857  *
1858  * \param instance The RTP instance to stop the DTMF on
1859  * \param digit What DTMF digit to stop
1860  *
1861  * \retval 0 success
1862  * \retval -1 failure
1863  *
1864  * Example usage:
1865  *
1866  * \code
1867  * ast_rtp_instance_dtmf_end(instance, '1');
1868  * \endcode
1869  *
1870  * This stops sending the DTMF '1' on the RTP instance pointed to by instance.
1871  *
1872  * \since 1.8
1873  */
1874 int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit);
1875 int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration);
1876 
1877 /*!
1878  * \brief Set the DTMF mode that should be used
1879  *
1880  * \param instance the RTP instance to set DTMF mode on
1881  * \param dtmf_mode The DTMF mode that is in use
1882  *
1883  * \retval 0 success
1884  * \retval -1 failure
1885  *
1886  * Example usage:
1887  *
1888  * \code
1889  * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833);
1890  * \endcode
1891  *
1892  * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
1893  *
1894  * \since 1.8
1895  */
1896 int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
1897 
1898 /*!
1899  * \brief Get the DTMF mode of an RTP instance
1900  *
1901  * \param instance The RTP instance to get the DTMF mode of
1902  *
1903  * \retval DTMF mode
1904  *
1905  * Example usage:
1906  *
1907  * \code
1908  * enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance);
1909  * \endcode
1910  *
1911  * This gets the DTMF mode set on the RTP instance pointed to by 'instance'.
1912  *
1913  * \since 1.8
1914  */
1916 
1917 /*!
1918  * \brief Indicate that the RTP marker bit should be set on an RTP stream
1919  *
1920  * \param instance Instance that the new media source is feeding into
1921  *
1922  * Example usage:
1923  *
1924  * \code
1925  * ast_rtp_instance_update_source(instance);
1926  * \endcode
1927  *
1928  * This indicates that the source of media that is feeding the instance pointed to by
1929  * instance has been updated and that the marker bit should be set.
1930  *
1931  * \since 1.8
1932  */
1933 void ast_rtp_instance_update_source(struct ast_rtp_instance *instance);
1934 
1935 /*!
1936  * \brief Indicate a new source of audio has dropped in and the ssrc should change
1937  *
1938  * \param instance Instance that the new media source is feeding into
1939  *
1940  * Example usage:
1941  *
1942  * \code
1943  * ast_rtp_instance_change_source(instance);
1944  * \endcode
1945  *
1946  * This indicates that the source of media that is feeding the instance pointed to by
1947  * instance has changed and that the marker bit should be set and the SSRC updated.
1948  *
1949  * \since 1.8
1950  */
1951 void ast_rtp_instance_change_source(struct ast_rtp_instance *instance);
1952 
1953 /*!
1954  * \brief Set QoS parameters on an RTP session
1955  *
1956  * \param instance Instance to set the QoS parameters on
1957  * \param tos Terms of service value
1958  * \param cos Class of service value
1959  * \param desc What is setting the QoS values
1960  *
1961  * \retval 0 success
1962  * \retval -1 failure
1963  *
1964  * Example usage:
1965  *
1966  * \code
1967  * ast_rtp_instance_set_qos(instance, 0, 0, "Example");
1968  * \endcode
1969  *
1970  * This sets the TOS and COS values to 0 on the instance pointed to by instance.
1971  *
1972  * \since 1.8
1973  */
1974 int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
1975 
1976 /*!
1977  * \brief Stop an RTP instance
1978  *
1979  * \param instance Instance that media is no longer going to at this time
1980  *
1981  * Example usage:
1982  *
1983  * \code
1984  * ast_rtp_instance_stop(instance);
1985  * \endcode
1986  *
1987  * This tells the RTP engine being used for the instance pointed to by instance
1988  * that media is no longer going to it at this time, but may in the future.
1989  *
1990  * \since 1.8
1991  */
1992 void ast_rtp_instance_stop(struct ast_rtp_instance *instance);
1993 
1994 /*!
1995  * \brief Get the file descriptor for an RTP session (or RTCP)
1996  *
1997  * \param instance Instance to get the file descriptor for
1998  * \param rtcp Whether to retrieve the file descriptor for RTCP or not
1999  *
2000  * \retval fd success
2001  * \retval -1 failure
2002  *
2003  * Example usage:
2004  *
2005  * \code
2006  * int rtp_fd = ast_rtp_instance_fd(instance, 0);
2007  * \endcode
2008  *
2009  * This retrieves the file descriptor for the socket carrying media on the instance
2010  * pointed to by instance.
2011  *
2012  * \since 1.8
2013  */
2014 int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp);
2015 
2016 /*!
2017  * \brief Get the RTP glue that binds a channel to the RTP engine
2018  *
2019  * \param type Name of the glue we want
2020  *
2021  * \retval non-NULL success
2022  * \retval NULL failure
2023  *
2024  * Example usage:
2025  *
2026  * \code
2027  * struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");
2028  * \endcode
2029  *
2030  * This retrieves the RTP glue that has the name 'Example'.
2031  *
2032  * \since 1.8
2033  */
2034 struct ast_rtp_glue *ast_rtp_instance_get_glue(const char *type);
2035 
2036 /*!
2037  * \brief Get the unique ID of the channel that owns this RTP instance
2038  *
2039  * Note that this should remain valid for the lifetime of the RTP instance.
2040  *
2041  * \param instance The RTP instance
2042  *
2043  * \retval The unique ID of the channel
2044  * \retval Empty string if no channel owns this RTP instance
2045  *
2046  * \since 12
2047  */
2048 const char *ast_rtp_instance_get_channel_id(struct ast_rtp_instance *instance);
2049 
2050 /*!
2051  * \brief Set the channel that owns this RTP instance
2052  *
2053  * \param instance The RTP instance
2054  * \param uniqueid The uniqueid of the channel
2055  *
2056  * \since 12
2057  */
2058 void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid);
2059 
2060 /*!
2061  * \brief Get the other RTP instance that an instance is bridged to
2062  *
2063  * \param instance The RTP instance that we want
2064  *
2065  * \retval non-NULL success
2066  * \retval NULL failure
2067  *
2068  * Example usage:
2069  *
2070  * \code
2071  * struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0);
2072  * \endcode
2073  *
2074  * This gets the RTP instance that instance0 is bridged to.
2075  *
2076  * \since 1.8
2077  */
2079 
2080 /*!
2081  * \brief Set the other RTP instance that an instance is bridged to
2082  *
2083  * \param instance The RTP instance that we want to set the bridged value on
2084  * \param bridged The RTP instance they are bridged to
2085  *
2086  * \since 12
2087  */
2089 
2090 /*!
2091  * \brief Make two channels compatible for early bridging
2092  *
2093  * \param c_dst Destination channel to copy to
2094  * \param c_src Source channel to copy from
2095  *
2096  * \since 1.8
2097  */
2098 void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src);
2099 
2100 /*!
2101  * \brief Early bridge two channels that use RTP instances
2102  *
2103  * \param c0 First channel part of the bridge
2104  * \param c1 Second channel part of the bridge
2105  *
2106  * \retval 0 success
2107  * \retval -1 failure
2108  *
2109  * \note This should only be used by channel drivers in their technology declaration.
2110  *
2111  * \since 1.8
2112  */
2113 int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2114 
2115 /*!
2116  * \brief Initialize RED support on an RTP instance
2117  *
2118  * \param instance The instance to initialize RED support on
2119  * \param buffer_time How long to buffer before sending
2120  * \param payloads Payload values
2121  * \param generations Number of generations
2122  *
2123  * \retval 0 success
2124  * \retval -1 failure
2125  *
2126  * \since 1.8
2127  */
2128 int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
2129 
2130 /*!
2131  * \brief Buffer a frame in an RTP instance for RED
2132  *
2133  * \param instance The instance to buffer the frame on
2134  * \param frame Frame that we want to buffer
2135  *
2136  * \retval 0 success
2137  * \retval -1 failure
2138  *
2139  * \since 1.8
2140  */
2141 int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
2142 
2143 /*!
2144  * \brief Retrieve statistics about an RTP instance
2145  *
2146  * \param instance Instance to get statistics on
2147  * \param stats Structure to put results into
2148  * \param stat What statistic(s) to retrieve
2149  *
2150  * \retval 0 success
2151  * \retval -1 failure
2152  *
2153  * Example usage:
2154  *
2155  * \code
2156  * struct ast_rtp_instance_stats stats;
2157  * ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL);
2158  * \endcode
2159  *
2160  * This retrieves all statistics the underlying RTP engine supports and puts the values into the
2161  * stats structure.
2162  *
2163  * \since 1.8
2164  */
2165 int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
2166 
2167 /*!
2168  * \brief Set standard statistics from an RTP instance on a channel
2169  *
2170  * \param chan Channel to set the statistics on
2171  * \param instance The RTP instance that statistics will be retrieved from
2172  *
2173  * \note Absolutely _NO_ channel locks should be held before calling this function.
2174  *
2175  * Example usage:
2176  *
2177  * \code
2178  * ast_rtp_instance_set_stats_vars(chan, rtp);
2179  * \endcode
2180  *
2181  * This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to
2182  * by chan.
2183  *
2184  * \since 1.8
2185  */
2186 void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance);
2187 
2188 /*!
2189  * \brief Retrieve quality statistics about an RTP instance
2190  *
2191  * \param instance Instance to get statistics on
2192  * \param field What quality statistic to retrieve
2193  * \param buf What buffer to put the result into
2194  * \param size Size of the above buffer
2195  *
2196  * \retval non-NULL success
2197  * \retval NULL failure
2198  *
2199  * Example usage:
2200  *
2201  * \code
2202  * char quality[AST_MAX_USER_FIELD];
2203  * ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf));
2204  * \endcode
2205  *
2206  * This retrieves general quality statistics and places a text representation into the buf pointed to by buf.
2207  *
2208  * \since 1.8
2209  */
2210 char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size);
2211 
2212 /*!
2213  * \brief Request that the underlying RTP engine provide audio frames in a specific format
2214  *
2215  * \param instance The RTP instance to change read format on
2216  * \param format Format that frames are wanted in
2217  *
2218  * \retval 0 success
2219  * \retval -1 failure
2220  *
2221  * Example usage:
2222  *
2223  * \code
2224  * struct ast_format tmp_fmt;
2225  * ast_rtp_instance_set_read_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
2226  * \endcode
2227  *
2228  * This requests that the RTP engine provide audio frames in the ULAW format.
2229  *
2230  * \since 1.8
2231  */
2233 
2234 /*!
2235  * \brief Tell underlying RTP engine that audio frames will be provided in a specific format
2236  *
2237  * \param instance The RTP instance to change write format on
2238  * \param format Format that frames will be provided in
2239  *
2240  * \retval 0 success
2241  * \retval -1 failure
2242  *
2243  * Example usage:
2244  *
2245  * \code
2246  * struct ast_format tmp_fmt;
2247  * ast_rtp_instance_set_write_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
2248  * \endcode
2249  *
2250  * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
2251  *
2252  * \since 1.8
2253  */
2255 
2256 /*!
2257  * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
2258  *
2259  * \param chan Our own Asterisk channel
2260  * \param instance The first RTP instance
2261  * \param peer The peer Asterisk channel
2262  *
2263  * \retval 0 success
2264  * \retval -1 failure
2265  *
2266  * Example usage:
2267  *
2268  * \code
2269  * ast_rtp_instance_make_compatible(instance, peer);
2270  * \endcode
2271  *
2272  * This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.
2273  *
2274  * \since 1.8
2275  */
2276 int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer);
2277 
2278 /*! \brief Request the formats that can be transcoded
2279  *
2280  * \param instance The RTP instance
2281  * \param to_endpoint Formats being sent/received towards the endpoint
2282  * \param to_asterisk Formats being sent/received towards Asterisk
2283  * \param result capabilities structure to store and return supported formats in.
2284  *
2285  * Example usage:
2286  *
2287  * \code
2288  * ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);
2289  * \endcode
2290  *
2291  * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
2292  *
2293  * \since 1.8
2294  */
2295 void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result);
2296 
2297 /*!
2298  * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
2299  *
2300  * \param instance The RTP instance
2301  *
2302  * \retval 0 success
2303  * \retval -1 failure
2304  *
2305  * Example usage:
2306  *
2307  * \code
2308  * ast_rtp_instance_activate(instance);
2309  * \endcode
2310  *
2311  * This tells the underlying RTP engine of instance that packets will now flow.
2312  *
2313  * \since 1.8
2314  */
2315 int ast_rtp_instance_activate(struct ast_rtp_instance *instance);
2316 
2317 /*!
2318  * \brief Request that the underlying RTP engine send a STUN BIND request
2319  *
2320  * \param instance The RTP instance
2321  * \param suggestion The suggested destination
2322  * \param username Optionally a username for the request
2323  *
2324  * Example usage:
2325  *
2326  * \code
2327  * ast_rtp_instance_stun_request(instance, NULL, NULL);
2328  * \endcode
2329  *
2330  * This requests that the RTP engine send a STUN BIND request on the session pointed to by
2331  * 'instance'.
2332  *
2333  * \since 1.8
2334  */
2335 void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
2336 
2337 /*!
2338  * \brief Set the RTP timeout value
2339  *
2340  * \param instance The RTP instance
2341  * \param timeout Value to set the timeout to
2342  *
2343  * Example usage:
2344  *
2345  * \code
2346  * ast_rtp_instance_set_timeout(instance, 5000);
2347  * \endcode
2348  *
2349  * This sets the RTP timeout value on 'instance' to be 5000.
2350  *
2351  * \since 1.8
2352  */
2353 void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout);
2354 
2355 /*!
2356  * \brief Set the RTP timeout value for when the instance is on hold
2357  *
2358  * \param instance The RTP instance
2359  * \param timeout Value to set the timeout to
2360  *
2361  * Example usage:
2362  *
2363  * \code
2364  * ast_rtp_instance_set_hold_timeout(instance, 5000);
2365  * \endcode
2366  *
2367  * This sets the RTP hold timeout value on 'instance' to be 5000.
2368  *
2369  * \since 1.8
2370  */
2371 void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout);
2372 
2373 /*!
2374  * \brief Set the RTP keepalive interval
2375  *
2376  * \param instance The RTP instance
2377  * \param timeout Value to set the keepalive interval to
2378  *
2379  * Example usage:
2380  *
2381  * \code
2382  * ast_rtp_instance_set_keepalive(instance, 5000);
2383  * \endcode
2384  *
2385  * This sets the RTP keepalive interval on 'instance' to be 5000.
2386  *
2387  * \since 1.8
2388  */
2389 void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout);
2390 
2391 /*!
2392  * \brief Get the RTP timeout value
2393  *
2394  * \param instance The RTP instance
2395  *
2396  * \retval timeout value
2397  *
2398  * Example usage:
2399  *
2400  * \code
2401  * int timeout = ast_rtp_instance_get_timeout(instance);
2402  * \endcode
2403  *
2404  * This gets the RTP timeout value for the RTP instance pointed to by 'instance'.
2405  *
2406  * \since 1.8
2407  */
2408 int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance);
2409 
2410 /*!
2411  * \brief Get the RTP timeout value for when an RTP instance is on hold
2412  *
2413  * \param instance The RTP instance
2414  *
2415  * \retval timeout value
2416  *
2417  * Example usage:
2418  *
2419  * \code
2420  * int timeout = ast_rtp_instance_get_hold_timeout(instance);
2421  * \endcode
2422  *
2423  * This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.
2424  *
2425  * \since 1.8
2426  */
2428 
2429 /*!
2430  * \brief Get the RTP keepalive interval
2431  *
2432  * \param instance The RTP instance
2433  *
2434  * \retval period Keepalive interval value
2435  *
2436  * Example usage:
2437  *
2438  * \code
2439  * int interval = ast_rtp_instance_get_keepalive(instance);
2440  * \endcode
2441  *
2442  * This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.
2443  *
2444  * \since 1.8
2445  */
2446 int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance);
2447 
2448 /*!
2449  * \brief Get the RTP engine in use on an RTP instance
2450  *
2451  * \param instance The RTP instance
2452  *
2453  * \retval pointer to the engine
2454  *
2455  * Example usage:
2456  *
2457  * \code
2458  * struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);
2459  * \endcode
2460  *
2461  * This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.
2462  *
2463  * \since 1.8
2464  */
2466 
2467 /*!
2468  * \brief Get the RTP glue in use on an RTP instance
2469  *
2470  * \param instance The RTP instance
2471  *
2472  * \retval pointer to the glue
2473  *
2474  * Example:
2475  *
2476  * \code
2477  * struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance);
2478  * \endcode
2479  *
2480  * This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.
2481  *
2482  * \since 1.8
2483  */
2485 
2486 /*!
2487  * \brief Send a comfort noise packet to the RTP instance
2488  *
2489  * \param instance The RTP instance
2490  * \param level Magnitude of the noise level
2491  *
2492  * \retval 0 Success
2493  * \retval non-zero Failure
2494  */
2495 int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level);
2496 
2497 /*!
2498  * \brief Add or replace the SRTP policies for the given RTP instance
2499  *
2500  * \param instance the RTP instance
2501  * \param remote_policy the remote endpoint's policy
2502  * \param local_policy our policy for this RTP instance's remote endpoint
2503  * \param rtcp 1 for dedicated RTCP policies
2504  *
2505  * \retval 0 Success
2506  * \retval non-zero Failure
2507  *
2508  * \note If no remote policy is provided any existing SRTP policies are left and the new local policy is added
2509  */
2510 int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy* remote_policy, struct ast_srtp_policy *local_policy, int rtcp);
2511 
2512 /*!
2513  * \brief Obtain the SRTP instance associated with an RTP instance
2514  *
2515  * \param instance the RTP instance
2516  * \param rtcp 1 to request instance for RTCP
2517  * \retval the SRTP instance on success
2518  * \retval NULL if no SRTP instance exists
2519  */
2520 struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance, int rtcp);
2521 
2522 /*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine
2523  * so their mime type can payload number can be initialized. */
2525 
2526 /*! \brief Formats requiring the use of a format attribute interface must have that
2527  * interface registered in order for the rtp engine to handle it correctly. If an
2528  * attribute interface is unloaded, this function must be called to notify the rtp_engine. */
2530 
2531 /*!
2532  * \brief Obtain a pointer to the ICE support present on an RTP instance
2533  *
2534  * \param instance the RTP instance
2535  *
2536  * \retval ICE support if present
2537  * \retval NULL if no ICE support available
2538  */
2540 
2541 #ifdef TEST_FRAMEWORK
2542 /*!
2543  * \brief Obtain a pointer to the test callbacks on an RTP instance
2544  *
2545  * \param instance the RTP instance
2546  *
2547  * \retval test callbacks if present
2548  * \retval NULL if not present
2549  */
2551 #endif
2552 
2553 /*!
2554  * \brief Obtain a pointer to the DTLS support present on an RTP instance
2555  *
2556  * \param instance the RTP instance
2557  *
2558  * \retval DTLS support if present
2559  * \retval NULL if no DTLS support available
2560  */
2562 
2563 /*!
2564  * \brief Parse DTLS related configuration options
2565  *
2566  * \param dtls_cfg a DTLS configuration structure
2567  * \param name name of the configuration option
2568  * \param value value of the configuration option
2569  *
2570  * \retval 0 if handled
2571  * \retval -1 if not handled
2572  */
2573 int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value);
2574 
2575 /*!
2576  * \brief Validates DTLS related configuration options
2577  *
2578  * \param dtls_cfg a DTLS configuration structure
2579  *
2580  * \retval 0 if valid
2581  * \retval -1 if invalid
2582  */
2583 int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg);
2584 
2585 /*!
2586  * \brief Copy contents of a DTLS configuration structure
2587  *
2588  * \param src_cfg source DTLS configuration structure
2589  * \param dst_cfg destination DTLS configuration structure
2590  */
2591 void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg);
2592 
2593 /*!
2594  * \brief Free contents of a DTLS configuration structure
2595  *
2596  * \param dtls_cfg a DTLS configuration structure
2597  */
2598 void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg);
2599 
2600 struct ast_json;
2601 
2602 /*!
2603  * \brief Allocate an ao2 ref counted instance of \ref ast_rtp_rtcp_report
2604  *
2605  * \param report_blocks The number of report blocks to allocate
2606  * \retval An ao2 ref counted \ref ast_rtp_rtcp_report object on success
2607  * \retval NULL on error
2608  */
2609 struct ast_rtp_rtcp_report *ast_rtp_rtcp_report_alloc(unsigned int report_blocks);
2610 
2611 /*!
2612  * \since 12
2613  * \brief Publish an RTCP message to \ref stasis
2614  *
2615  * \param rtp The rtp instance object
2616  * \param message_type The RTP message type to publish
2617  * \param report The RTCP report object to publish. This should be an ao2 ref counted
2618  * object. This routine will increase the reference count of the object.
2619  * \param blob Additional JSON objects to publish along with the RTCP information
2620  */
2622  struct stasis_message_type *message_type,
2623  struct ast_rtp_rtcp_report *report,
2624  struct ast_json *blob);
2625 
2626 /*!
2627  * \brief Get the last RTP transmission time
2628  *
2629  * \param rtp The instance from which to get the last transmission time
2630  * \return The last RTP transmission time
2631  */
2632 time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp);
2633 
2634 /*!
2635  * \brief Set the last RTP transmission time
2636  *
2637  * \param rtp The instance on which to set the last transmission time
2638  * \param time The last transmission time
2639  */
2640 void ast_rtp_instance_set_last_tx(struct ast_rtp_instance *rtp, time_t time);
2641 
2642 /*
2643  * \brief Get the last RTP reception time
2644  *
2645  * \param rtp The instance from which to get the last reception time
2646  * \return The last RTP reception time
2647  */
2648 time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp);
2649 
2650 /*!
2651  * \brief Set the last RTP reception time
2652  *
2653  * \param rtp The instance on which to set the last reception time
2654  * \param time The last reception time
2655  */
2656 void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time);
2657 
2658 /*!
2659  * \brief Retrieve the local SSRC value that we will be using
2660  *
2661  * \param rtp The RTP instance
2662  * \return The SSRC value
2663  */
2664 unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp);
2665 
2666 /*!
2667  * \brief Retrieve the CNAME used in RTCP SDES items
2668  *
2669  * This is a pointer directly into the RTP struct, not a copy.
2670  *
2671  * \param rtp The RTP instance
2672  * \return the CNAME
2673  */
2674 const char *ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp);
2675 
2676 /*!
2677  * \brief Request that an RTP instance be bundled with another
2678  * \since 15.0.0
2679  *
2680  * \param child The child RTP instance
2681  * \param parent The parent RTP instance the child should be bundled with
2682  *
2683  * \retval 0 success
2684  * \retval -1 failure
2685  */
2686 int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent);
2687 
2688 /*!
2689  * \brief Set the remote SSRC for an RTP instance
2690  * \since 15.0.0
2691  *
2692  * \param rtp The RTP instance
2693  * \param ssrc The remote SSRC
2694  */
2695 void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc);
2696 
2697 /*!
2698  * \brief Set the stream number for an RTP instance
2699  * \since 15.0.0
2700  *
2701  * \param rtp The RTP instance
2702  * \param stream_num The stream identifier number
2703  */
2704 void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num);
2705 
2706 /*! \addtogroup StasisTopicsAndMessages
2707  * @{
2708  */
2709 
2710 /*!
2711  * \since 12
2712  * \brief Message type for an RTCP message sent from this Asterisk instance
2713  *
2714  * \retval A stasis message type
2715  */
2717 
2718 /*!
2719  * \since 12
2720  * \brief Message type for an RTCP message received from some external source
2721  *
2722  * \retval A stasis message type
2723  */
2725 
2726 #ifdef TEST_FRAMEWORK
2727 /*!
2728  * \brief Get the maximum size of the receive buffer
2729  *
2730  * \param instance The RTP instance
2731  * \retval The recv_buffer max size if it exists, else 0
2732  */
2734 
2735 /*!
2736  * \brief Get the current size of the receive buffer
2737  *
2738  * \param instance The RTP instance
2739  * \retval The recv_buffer size if it exists, else 0
2740  */
2742 
2743 /*!
2744  * \brief Get the current size of the send buffer
2745  *
2746  * \param instance The RTP instance
2747  * \retval The send_buffer size if it exists, else 0
2748  */
2750 
2751 /*!
2752  * \brief Set the schedid for RTCP
2753  *
2754  * \param instance The RTP instance
2755  * \param id The number to set schedid to
2756  */
2757 void ast_rtp_instance_set_schedid(struct ast_rtp_instance *instance, int id);
2758 
2759 /*!
2760  * \brief Set the number of packets to drop on RTP read
2761  *
2762  * \param instance The RTP instance
2763  * \param num The number of packets to drop
2764  */
2765 void ast_rtp_instance_drop_packets(struct ast_rtp_instance *instance, int num);
2766 
2767 /*!
2768  * \brief Sends a SR/RR report the next time RTP would be sent
2769  *
2770  * \param instance The RTP instance
2771  */
2772 void ast_rtp_instance_queue_report(struct ast_rtp_instance *instance);
2773 
2774 /*!
2775  * \brief Get the value of sdes_received on the test engine
2776  *
2777  * \param instance The RTP instance
2778  * \retval 1 if sdes_received, else 0
2779  */
2781 
2782 /*!
2783  * \brief Resets all the fields to default values for the test engine
2784  *
2785  * \param instance The RTP instance
2786  */
2788 #endif
2789 
2790 /*!
2791  * \brief Convert given stat instance into json format
2792  * \param stats
2793  * \retval A json format stat
2794  */
2795 struct ast_json *ast_rtp_convert_stats_json(const struct ast_rtp_instance_stats *stats);
2796 
2797 /*!
2798  * \brief Retrieve statistics about an RTP instance in json format
2799  * \param instance
2800  * \retval json object of stats
2801  */
2803 
2804 /*!
2805  * \brief Retrieve the sample rate of a format according to RTP specifications
2806  * \since 16.7.0
2807  * \since 17.1.0
2808  *
2809  * \param format The media format
2810  *
2811  * \retval The sample rate
2812  */
2813 int ast_rtp_get_rate(const struct ast_format *format);
2814 
2815 /*!
2816  * \since 12
2817  * \brief \ref stasis topic for RTP and RTCP related messages
2818  *
2819  * \retval A \ref stasis topic
2820  */
2821 struct stasis_topic *ast_rtp_topic(void);
2822 
2823 /* RTP debug logging category name */
2824 #define AST_LOG_CATEGORY_RTP "rtp"
2825 /* RTP packet debug logging category name */
2826 #define AST_LOG_CATEGORY_RTP_PACKET "rtp_packet"
2827 /* RTCP debug logging category name */
2828 #define AST_LOG_CATEGORY_RTCP "rtcp"
2829 /* RTCP packet debug logging category name */
2830 #define AST_LOG_CATEGORY_RTCP_PACKET "rtcp_packet"
2831 /* DTLS debug logging category name */
2832 #define AST_LOG_CATEGORY_DTLS "dtls"
2833 /* DTLS packet debug logging category name */
2834 #define AST_LOG_CATEGORY_DTLS_PACKET "dtls_packet"
2835 /* ICE debug logging category name */
2836 #define AST_LOG_CATEGORY_ICE "ice"
2837 
2838 uintmax_t ast_debug_category_rtp_id(void);
2839 uintmax_t ast_debug_category_rtp_packet_id(void);
2840 uintmax_t ast_debug_category_rtcp_id(void);
2841 uintmax_t ast_debug_category_rtcp_packet_id(void);
2842 uintmax_t ast_debug_category_dtls_id(void);
2843 uintmax_t ast_debug_category_dtls_packet_id(void);
2844 uintmax_t ast_debug_category_ice_id(void);
2845 
2846 #define AST_DEBUG_CATEGORY_RTP ast_debug_category_rtp_id() /* RTP debug logging category id */
2847 #define AST_DEBUG_CATEGORY_RTP_PACKET ast_debug_category_rtp_packet_id() /* RTP packet debug logging category id */
2848 #define AST_DEBUG_CATEGORY_RTCP ast_debug_category_rtcp_id() /* RTCP debug logging category id */
2849 #define AST_DEBUG_CATEGORY_RTCP_PACKET ast_debug_category_rtcp_packet_id() /* RTCP packet debug logging category id */
2850 #define AST_DEBUG_CATEGORY_DTLS ast_debug_category_dtls_id() /* DTLS debug logging category id */
2851 #define AST_DEBUG_CATEGORY_DTLS_PACKET ast_debug_category_dtls_packet_id() /* DTLS packet debug logging category id */
2852 #define AST_DEBUG_CATEGORY_ICE ast_debug_category_ice_id() /* ICE debug logging category id */
2853 
2854 /*!
2855  * \brief Log debug level RTP information
2856  *
2857  * \param sublevel Debug output sublevel (>= 0)
2858  * \param ... String format and any associated arguments
2859  */
2860 #define ast_debug_rtp(sublevel, ...) \
2861  ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTP, __VA_ARGS__)
2862 
2863 /* Allow logging of RTP packets? */
2864 #define ast_debug_rtp_packet_is_allowed \
2865  ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP_PACKET)
2866 
2867 /*!
2868  * \brief Log debug level RTCP information
2869  *
2870  * \param sublevel Debug output sublevel (>= 0)
2871  * \param ... String format and any associated arguments
2872  */
2873 #define ast_debug_rtcp(sublevel, ...) \
2874  ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTCP, __VA_ARGS__)
2875 
2876 /* Allow logging of RTCP packets? */
2877 #define ast_debug_rtcp_packet_is_allowed \
2878  ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP_PACKET)
2879 
2880 /*!
2881  * \brief Log debug level DTLS information
2882  *
2883  * \param sublevel Debug output sublevel (>= 0)
2884  * \param ... String format and any associated arguments
2885  */
2886 #define ast_debug_dtls(sublevel, ...) \
2887  ast_debug_category(sublevel, AST_DEBUG_CATEGORY_DTLS, __VA_ARGS__)
2888 
2889 /* Allow logging of DTLS packets? */
2890 #define ast_debug_dtls_packet_is_allowed \
2891  ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_DTLS_PACKET)
2892 /*!
2893  * \brief Log debug level ICE information
2894  *
2895  * \param sublevel Debug output sublevel (>= 0)
2896  * \param ... String format and any associated arguments
2897  */
2898 #define ast_debug_ice(sublevel, ...) \
2899  ast_debug_category(sublevel, AST_DEBUG_CATEGORY_ICE, __VA_ARGS__)
2900 
2901 /* @} */
2902 
2903 #if defined(__cplusplus) || defined(c_plusplus)
2904 }
2905 #endif
2906 
2907 #endif /* _ASTERISK_RTP_ENGINE_H */
uintmax_t ast_debug_category_rtcp_packet_id(void)
Definition: rtp_engine.c:3559
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
Definition: rtp_engine.c:1580
struct stasis_message_type * ast_rtp_rtcp_sent_type(void)
Message type for an RTCP message sent from this Asterisk instance.
static const char type[]
Definition: chan_ooh323.c:109
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance...
Definition: rtp_engine.c:2647
An object that represents data sent during a SR/RR RTCP report.
Definition: rtp_engine.h:331
char digit
int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value)
Parse DTLS related configuration options.
Definition: rtp_engine.c:3020
Main Channel structure associated with a channel.
unsigned int cos
Definition: chan_iax2.c:352
int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Initialize RED support on an RTP instance.
Definition: rtp_engine.c:2418
ast_rtp_dtls_verify
DTLS verification settings.
Definition: rtp_engine.h:533
ast_rtp_options
Definition: rtp_engine.h:142
struct ast_rtp_payload_type * ast_rtp_codecs_get_payload(struct ast_rtp_codecs *codecs, int payload)
Retrieve rx payload mapped information by payload type.
Definition: rtp_engine.c:1479
void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result)
Request the formats that can be transcoded.
Definition: rtp_engine.c:2633
unsigned int framing
Definition: rtp_engine.h:713
int ast_rtp_instance_extmap_get_id(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Retrieve the id for an RTP extension.
Definition: rtp_engine.c:886
static struct ast_sched_context * sched
Definition: chan_ooh323.c:400
int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
Update the format associated with a tx payload type in a codecs structure.
Definition: rtp_engine.c:1503
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
Definition: rtp_engine.c:553
void * ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property)
Get the value of an RTP instance extended property.
Definition: rtp_engine.c:690
unsigned int highest_seq_no
Definition: rtp_engine.h:322
int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Set the DTMF mode that should be used.
Definition: rtp_engine.c:2123
static int verify(const struct ast_sip_auth *auth, pjsip_rx_data *rdata, pj_pool_t *pool)
astobj2 callback for verifying incoming credentials
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
Definition: rtp_engine.c:2160
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
Definition: rtp_engine.c:2446
int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Request that an RTP instance be bundled with another.
Definition: rtp_engine.c:3804
static struct @111 qos
size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance)
Get the number of known unique identifiers.
Definition: rtp_engine.c:899
char * address
Definition: f2c.h:59
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
uintmax_t ast_debug_category_rtp_id(void)
Definition: rtp_engine.c:3538
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
Definition: rtp_engine.c:2685
ast_transport
Definition: netsock2.h:59
int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module)
Register RTP glue.
Definition: rtp_engine.c:379
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition: rtp_engine.c:727
uintmax_t ast_debug_category_dtls_packet_id(void)
Definition: rtp_engine.c:3573
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct ast_rtp_glue * ast_rtp_instance_get_active_glue(struct ast_rtp_instance *instance)
Get the RTP glue in use on an RTP instance.
Definition: rtp_engine.c:2705
void ast_rtp_instance_set_schedid(struct ast_rtp_instance *instance, int id)
Set the schedid for RTCP.
Definition: rtp_engine.c:3891
struct ast_rtp_engine_test * ast_rtp_instance_get_test(struct ast_rtp_instance *instance)
Obtain a pointer to the test callbacks on an RTP instance.
Definition: rtp_engine.c:2901
unsigned int txcount
Definition: rtp_engine.h:368
static int timeout
Definition: cdr_mysql.c:86
int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Early bridge two channels that use RTP instances.
Definition: rtp_engine.c:2337
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
Definition: rtp_engine.c:2169
struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type(void)
Allocation routine for ast_rtp_payload_type.
Definition: rtp_engine.c:325
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition: rtp_engine.c:568
unsigned short reception_report_count
Definition: rtp_engine.h:332
An object that represents data received in a feedback report.
Definition: rtp_engine.h:358
void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
Definition: rtp_engine.c:1257
Definition: sched.c:76
unsigned int rxploss
Definition: rtp_engine.h:394
static const char desc[]
Definition: cdr_mysql.c:73
unsigned int stop
Definition: app_meetme.c:1096
struct ast_rtp_engine_ice * ast_rtp_instance_get_ice(struct ast_rtp_instance *instance)
Obtain a pointer to the ICE support present on an RTP instance.
Definition: rtp_engine.c:2891
Definition of a media format.
Definition: format.c:43
void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance)
Clear negotiated RTP extension information.
Definition: rtp_engine.c:862
struct ast_srtp * ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance, int rtcp)
Obtain the SRTP instance associated with an RTP instance.
Definition: rtp_engine.c:2763
ast_rtp_extension
Known RTP extensions.
Definition: rtp_engine.h:542
A report block within a SR/RR report.
Definition: rtp_engine.h:316
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Definition: rtp_engine.c:2670
ast_rtp_ice_candidate_type
ICE candidate types.
Definition: rtp_engine.h:455
uintmax_t ast_debug_category_rtp_packet_id(void)
Definition: rtp_engine.c:3545
void ast_rtp_instance_set_last_tx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP transmission time.
Definition: rtp_engine.c:3763
int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer)
Request that the underlying RTP engine make two RTP instances compatible with eachother.
Definition: rtp_engine.c:2589
unsigned int fmt
Definition: rtp_engine.h:359
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
Definition: rtp_engine.c:1558
A REMB feedback message (see draft-alvestrand-rmcat-remb-03 for details)
Definition: rtp_engine.h:350
int ast_rtp_instance_get_and_cmp_requested_target_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the requested target address of the remote endpoint and compare it to the given address...
Definition: rtp_engine.c:651
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
int value
Definition: syslog.c:37
unsigned int rtp_timestamp
Definition: rtp_engine.h:337
int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy *remote_policy, struct ast_srtp_policy *local_policy, int rtcp)
Add or replace the SRTP policies for the given RTP instance.
Definition: rtp_engine.c:2736
static struct ast_srtp_res srtp_res
Definition: res_srtp.c:102
Structure for an ICE candidate.
Definition: rtp_engine.h:474
int ast_rtp_engine_unload_format(struct ast_format *format)
Formats requiring the use of a format attribute interface must have that interface registered in orde...
Definition: rtp_engine.c:3245
Socket address structure.
Definition: netsock2.h:97
static struct ast_str * password
Definition: cdr_mysql.c:77
void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num)
Set the stream number for an RTP instance.
Definition: rtp_engine.c:3830
const char * type
Definition: rtp_engine.h:722
int ast_rtp_codecs_payload_code_tx(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code...
Definition: rtp_engine.c:1928
void ast_rtp_engine_unregister_srtp(void)
Definition: rtp_engine.c:2725
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
Definition: rtp_engine.c:1569
uintmax_t ast_debug_category_ice_id(void)
Definition: rtp_engine.c:3580
struct stasis_message_type * ast_rtp_rtcp_received_type(void)
Message type for an RTCP message received from some external source.
const char * ast_rtp_instance_get_channel_id(struct ast_rtp_instance *instance)
Get the unique ID of the channel that owns this RTP instance.
Definition: rtp_engine.c:548
unsigned int tos
Definition: chan_iax2.c:351
int ast_rtp_instance_extmap_enable(struct ast_rtp_instance *instance, int id, enum ast_rtp_extension extension, enum ast_rtp_extension_direction direction)
Enable support for an RTP extension on an instance.
Definition: rtp_engine.c:732
void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Request that the underlying RTP engine send a STUN BIND request.
Definition: rtp_engine.c:2661
ast_rtp_instance_rtcp
Definition: rtp_engine.h:255
void ast_rtp_instance_set_bridged(struct ast_rtp_instance *instance, struct ast_rtp_instance *bridged)
Set the other RTP instance that an instance is bridged to.
Definition: rtp_engine.c:2244
int ast_rtp_instance_get_sdes_received(struct ast_rtp_instance *instance)
Get the value of sdes_received on the test engine.
Definition: rtp_engine.c:3929
struct ast_rtp_engine_dtls * dtls
Definition: rtp_engine.h:693
struct ast_format * ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload)
Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type...
Definition: rtp_engine.c:1537
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Definition: rtp_engine.c:2183
unsigned short fraction
Definition: rtp_engine.h:319
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
Definition: rtp_engine.c:1992
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
Definition: rtp_engine.c:364
size_t ast_rtp_instance_get_send_buffer_count(struct ast_rtp_instance *instance)
Get the current size of the send buffer.
Definition: rtp_engine.c:3874
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
Definition: rtp_engine.c:558
ast_rtp_instance_stat
Definition: rtp_engine.h:180
Maximum number of RTP properties supported.
Definition: rtp_engine.h:138
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code...
Definition: rtp_engine.c:1873
void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc)
Set the remote SSRC for an RTP instance.
Definition: rtp_engine.c:3821
ast_rtp_ice_role
ICE role during negotiation.
Definition: rtp_engine.h:468
static struct ao2_container * codecs
Registered codecs.
Definition: codec.c:48
struct ast_rtp_engine_test * test
Definition: rtp_engine.h:696
Scheduler Routines (derived from cheops)
structure to hold extensions
Asterisk internal frame definitions.
ast_rtp_ice_component_type
ICE component types.
Definition: rtp_engine.h:462
struct ast_rtp_engine * ast_rtp_instance_get_engine(struct ast_rtp_instance *instance)
Get the RTP engine in use on an RTP instance.
Definition: rtp_engine.c:2700
int ast_rtp_instance_extmap_negotiate(struct ast_rtp_instance *instance, int id, enum ast_rtp_extension_direction direction, const char *uri, const char *attributes)
Negotiate received RTP extension information.
Definition: rtp_engine.c:818
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44
void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value)
Set the value of an RTP instance extended property.
Definition: rtp_engine.c:681
char * ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size)
Retrieve quality statistics about an RTP instance.
Definition: rtp_engine.c:2460
void ast_rtp_publish_rtcp_message(struct ast_rtp_instance *rtp, struct stasis_message_type *message_type, struct ast_rtp_rtcp_report *report, struct ast_json *blob)
Publish an RTCP message to Stasis Message Bus API.
Definition: rtp_engine.c:3485
unsigned int txoctetcount
Definition: rtp_engine.h:428
ast_rtp_glue_result
Definition: rtp_engine.h:158
static struct ast_srtp_policy_res policy_res
Definition: res_srtp.c:114
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record tx payload type information that was seen in an a=rtpmap: SDP line.
Definition: rtp_engine.c:1428
Network socket handling.
int ast_rtp_get_rate(const struct ast_format *format)
Retrieve the sample rate of a format according to RTP specifications.
Definition: rtp_engine.c:4030
struct ast_rtp_rtcp_report * ast_rtp_rtcp_report_alloc(unsigned int report_blocks)
Allocate an ao2 ref counted instance of ast_rtp_rtcp_report.
Definition: rtp_engine.c:3474
Structure that represents the optional DTLS SRTP support within an RTP engine.
Definition: rtp_engine.h:570
unsigned int rxcount
Definition: rtp_engine.h:370
int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address that we are expecting to receive RTP on.
Definition: rtp_engine.c:588
Format Capabilities API.
ast_rtp_dtls_setup
DTLS setup types.
Definition: rtp_engine.h:513
struct ast_module * mod
Definition: rtp_engine.h:618
int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
Definition: rtp_engine.c:2710
int ast_rtp_instance_get_hold_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value for when an RTP instance is on hold.
Definition: rtp_engine.c:2690
unsigned int enabled
Definition: rtp_engine.h:555
time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp)
Get the last RTP transmission time.
Definition: rtp_engine.c:3758
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
unsigned int rxoctetcount
Definition: rtp_engine.h:430
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
struct ast_rtp_engine_dtls * ast_rtp_instance_get_dtls(struct ast_rtp_instance *instance)
Obtain a pointer to the DTLS support present on an RTP instance.
Definition: rtp_engine.c:3011
ast_rtp_extension_direction
Directions for RTP extensions.
Definition: rtp_engine.h:769
enum ast_rtp_extension_direction ast_rtp_instance_extmap_get_direction(struct ast_rtp_instance *instance, int id)
Retrieve the negotiated direction for an RTP extension id.
Definition: rtp_engine.c:930
unsigned int local_ssrc
Definition: rtp_engine.h:422
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
Definition: rtp_engine.c:2772
ast_rtp_dtls_connection
DTLS connection states.
Definition: rtp_engine.h:521
struct ast_rtp_engine_ice * ice
Definition: rtp_engine.h:691
struct ast_format * format
Definition: rtp_engine.h:278
struct ast_module * mod
Definition: rtp_engine.h:724
unsigned int packet_count
Definition: rtp_engine.h:338
unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp)
Retrieve the local SSRC value that we will be using.
Definition: rtp_engine.c:3778
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
Definition: rtp_engine.c:2081
unsigned int ssrc
Definition: rtp_engine.h:333
ast_rtp_dtls_hash
DTLS fingerprint hashes.
Definition: rtp_engine.h:527
int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg)
Validates DTLS related configuration options.
Definition: rtp_engine.c:3094
int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format)
Request that the underlying RTP engine provide audio frames in a specific format. ...
Definition: rtp_engine.c:2560
unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, const struct ast_format *format, int code)
Get the sample rate associated with known RTP payload types.
Definition: rtp_engine.c:2022
static const char name[]
Definition: cdr_mysql.c:74
unsigned int txploss
Definition: rtp_engine.h:392
time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp)
Definition: rtp_engine.c:3768
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
Definition: rtp_engine.c:563
static void destroy(struct ast_trans_pvt *pvt)
Definition: translate.c:291
uintmax_t ast_debug_category_dtls_id(void)
Definition: rtp_engine.c:3566
void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value for when the instance is on hold.
Definition: rtp_engine.c:2675
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:2192
const char * ast_rtp_instance_extmap_get_uri(struct ast_rtp_instance *instance, int id)
Retrieve the URI for an RTP extension id.
Definition: rtp_engine.c:946
const char * name
Definition: rtp_engine.h:616
Vector container support.
size_t ast_rtp_instance_get_recv_buffer_count(struct ast_rtp_instance *instance)
Get the current size of the receive buffer.
Definition: rtp_engine.c:3857
unsigned int ephemeral_cert
Definition: rtp_engine.h:566
ast_rtp_dtmf_mode
Definition: rtp_engine.h:148
Structure that represents the test functionality for res_rtp_asterisk unit tests. ...
Definition: rtp_engine.h:595
void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
Clear rx and tx payload mapping information from an RTP instance.
Definition: rtp_engine.c:994
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
Definition: rtp_engine.c:974
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition: rtp_engine.c:643
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition: rtp_engine.c:458
unsigned int type
Definition: rtp_engine.h:334
ast_rtp_property
Definition: rtp_engine.h:113
void ast_rtp_instance_drop_packets(struct ast_rtp_instance *instance, int num)
Set the number of packets to drop on RTP read.
Definition: rtp_engine.c:3905
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:414
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
Definition: rtp_engine.c:2680
struct ast_rtp_instance * bridged
Definition: rtp_engine.c:203
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Copy payload information from one RTP instance to another.
Definition: rtp_engine.c:1224
ast_rtp_instance_stat_field
Definition: rtp_engine.h:168
int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format)
Tell underlying RTP engine that audio frames will be provided in a specific format.
Definition: rtp_engine.c:2574
size_t ast_rtp_instance_get_recv_buffer_max(struct ast_rtp_instance *instance)
Get the maximum size of the receive buffer.
Definition: rtp_engine.c:3840
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
Definition: rtp_engine.c:958
char * ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options)
Convert formats into a string and put them into a buffer.
Definition: rtp_engine.c:2045
Structure for rwlock and tracking information.
Definition: lock.h:156
int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
Buffer a frame in an RTP instance for RED.
Definition: rtp_engine.c:2432
void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Remove tx payload type mapped information.
Definition: rtp_engine.c:1433
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
Definition: rtp_engine.c:3131
struct ast_rtp_instance * ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance)
Get the other RTP instance that an instance is bridged to.
Definition: rtp_engine.c:2234
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
Definition: rtp_engine.c:3531
void ast_rtp_instance_get_requested_target_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the requested target address of the remote endpoint.
Definition: rtp_engine.c:673
int ast_rtp_engine_srtp_is_registered(void)
Definition: rtp_engine.c:2731
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition: rtp_engine.c:408
int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property)
Get the value of an RTP instance property.
Definition: rtp_engine.c:716
static PGresult * result
Definition: cel_pgsql.c:88
int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt, char *mimetype, char *mimesubtype, enum ast_rtp_options options, unsigned int sample_rate)
Set tx payload type to a known MIME media type for a codec with a specific sample rate...
Definition: rtp_engine.c:1343
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
Definition: rtp_engine.c:2137
void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance)
Set standard statistics from an RTP instance on a channel.
Definition: rtp_engine.c:2500
Data structure associated with a single frame of data.
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
Definition: rtp_engine.c:2695
int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int payload)
Search for the tx payload type in the ast_rtp_codecs structure.
Definition: rtp_engine.c:1975
int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the local endpoint that we are sending RTP to, comparing its address to another...
Definition: rtp_engine.c:629
Structure that represents the optional ICE support within an RTP engine.
Definition: rtp_engine.h:485
Abstract JSON element (object, array, string, int, ...).
SRTP resource.
int ast_rtp_engine_load_format(struct ast_format *format)
Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine so their mim...
Definition: rtp_engine.c:3229
int ast_rtp_codecs_payload_set_rx(struct ast_rtp_codecs *codecs, int code, struct ast_format *format)
Set a payload code for use with a specific Asterisk format.
Definition: rtp_engine.c:1923
Definition: search.h:40
static void update_peer(struct sip_peer *p, int expire)
Update peer data in database (if used)
Definition: chan_sip.c:5382
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
Definition: rtp_engine.c:705
enum queue_result id
Definition: app_queue.c:1507
ast_media_type
Types of media.
Definition: codec.h:30
Generic container type.
static struct test_options options
int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition: rtp_engine.c:2109
unsigned int octet_count
Definition: rtp_engine.h:339
void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg)
Copy contents of a DTLS configuration structure.
Definition: rtp_engine.c:3113
unsigned int primary_mapping
Definition: rtp_engine.h:286
struct timeval when_retired
Definition: rtp_engine.h:288
enum ast_media_type ast_rtp_codecs_get_stream_type(struct ast_rtp_codecs *codecs)
Determine the type of RTP stream media from the codecs mapped.
Definition: rtp_engine.c:1460
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition: rtp_engine.c:465
direction
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
Definition: rtp_engine.c:2206
#define MAX_CHANNEL_ID
Definition: rtp_engine.h:107
void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src)
Make two channels compatible for early bridging.
Definition: rtp_engine.c:2251
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
Definition: rtp_engine.c:2151
ast_srtp_suite
Definition: res_srtp.h:56
unsigned int rekey
Definition: rtp_engine.h:556
const char * ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp)
Retrieve the CNAME used in RTCP SDES items.
Definition: rtp_engine.c:3791
struct ast_json * ast_rtp_convert_stats_json(const struct ast_rtp_instance_stats *stats)
Convert given stat instance into json format.
Definition: rtp_engine.c:3956
enum ast_rtp_extension ast_rtp_instance_extmap_get_extension(struct ast_rtp_instance *instance, int id)
Retrieve the extension for an RTP extension id.
Definition: rtp_engine.c:910
unsigned int source_ssrc
Definition: rtp_engine.h:317
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record tx payload type information that was seen in an m= SDP line.
Definition: rtp_engine.c:1301
int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
Register an RTP engine.
Definition: rtp_engine.c:330
int ast_rtp_instance_set_incoming_source_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the incoming source address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.c:606
void ast_rtp_instance_queue_report(struct ast_rtp_instance *instance)
Sends a SR/RR report the next time RTP would be sent.
Definition: rtp_engine.c:3917
void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP reception time.
Definition: rtp_engine.c:3773
int ast_rtp_instance_set_requested_target_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the requested target address of the remote endpoint.
Definition: rtp_engine.c:616
void ast_rtp_instance_reset_test_engine(struct ast_rtp_instance *instance)
Resets all the fields to default values for the test engine.
Definition: rtp_engine.c:3941
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition: rtp_engine.c:578
void ast_rtp_instance_get_incoming_source_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the incoming source address of the remote endpoint.
Definition: rtp_engine.c:665
DTLS configuration structure.
Definition: rtp_engine.h:554
unsigned int remote_ssrc
Definition: rtp_engine.h:424
struct ast_json * ast_rtp_instance_get_stats_all_json(struct ast_rtp_instance *instance)
Retrieve statistics about an RTP instance in json format.
Definition: rtp_engine.c:4019
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
Definition: rtp_engine.c:2095
uintmax_t ast_debug_category_rtcp_id(void)
Definition: rtp_engine.c:3552