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