Asterisk - The Open Source Telephony Project GIT-master-7988d11
Loading...
Searching...
No Matches
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)
69extern "C" {
70#endif
71
72#include "asterisk/astobj2.h"
73#include "asterisk/frame.h"
74#include "asterisk/format_cap.h"
75#include "asterisk/netsock2.h"
76#include "asterisk/sched.h"
77#include "asterisk/res_srtp.h"
78#include "asterisk/stasis.h"
79#include "asterisk/vector.h"
81
82/*! Maximum number of payload types RTP can support. */
83#define AST_RTP_MAX_PT 128
84
85/*!
86 * Last RTP payload type statically assigned, see
87 * http://www.iana.org/assignments/rtp-parameters
88 */
89#define AST_RTP_PT_LAST_STATIC 34
90
91/*! First dynamic RTP payload type */
92#define AST_RTP_PT_FIRST_DYNAMIC 96
93
94/*! Last reassignable RTP payload type */
95#define AST_RTP_PT_LAST_REASSIGN 63
96
97/*! Maximum number of generations */
98#define AST_RED_MAX_GENERATION 5
99
100/*!
101 * Maximum size of an internal Asterisk channel unique ID.
102 *
103 * \note Must match the AST_MAX_UNIQUEID(AST_MAX_PUBLIC_UNIQUEID) value.
104 * We don't use that defined value directly here to avoid a hard
105 * dependency on channel.h.
106 */
107#define MAX_CHANNEL_ID 152
108
109/*!< DTMF samples per second */
110#define DEFAULT_DTMF_SAMPLE_RATE_MS 8000
111
112struct ast_rtp_instance;
113struct 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 */
311 /*! Actual payload number */
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 */
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 */
476 /*! Minimum MES on local side */
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) \
485if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == stat)) { \
486placement = value; \
487if (stat == current_stat) { \
488return 0; \
489} \
490}
491
492#define AST_RTP_STAT_STRCPY(current_stat, combined, placement, value) \
493if (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) \
501if (stat == combined) { \
502return 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 */
517
518/*! \brief ICE role during negotiation */
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 */
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 */
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 */
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 */
646struct 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 */
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 */
700 enum ast_rtp_dtmf_mode (*dtmf_mode_get)(struct ast_rtp_instance *instance);
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 */
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 */
761 /*! Tx payload type mapping */
763 /*! The framing for this media session */
764 unsigned int framing;
765 /*! The preferred format, as the mappings are numerically sorted */
767 /*! The preferred dtmf sample rate */
769 /*! The preferred dtmf payload type */
771};
772
773#define AST_RTP_CODECS_NULL_INIT \
774 { .codecs_lock = AST_RWLOCK_INIT_VALUE, .payload_mapping_rx = { 0, }, .payload_mapping_tx = { 0, }, .framing = 0, .preferred_format = NULL, \
775 .preferred_dtmf_rate = -1, .preferred_dtmf_pt = -1}
776
777/*! Structure that represents the glue that binds an RTP instance to a channel */
779 /*! Name of the channel driver that this glue is responsible for */
780 const char *type;
781 /*! Module that the RTP glue came from */
783 /*!
784 * \brief Callback for retrieving the RTP instance carrying audio
785 * \note This function increases the reference count on the returned RTP instance.
786 */
787 enum ast_rtp_glue_result (*get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
788 /*!
789 * \brief Used to prevent two channels from remotely bridging audio rtp if the channel tech has a
790 * reason for prohibiting it based on qualities that need to be compared from both channels.
791 * \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.
792 */
793 int (*allow_rtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance);
794 /*!
795 * \brief Callback for retrieving the RTP instance carrying video
796 * \note This function increases the reference count on the returned RTP instance.
797 * \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.
798 */
799 enum ast_rtp_glue_result (*get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
800 /*!
801 * \brief Used to prevent two channels from remotely bridging video rtp if the channel tech has a
802 * reason for prohibiting it based on qualities that need to be compared from both channels.
803 * \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.
804 */
805 int (*allow_vrtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance);
806
807 /*!
808 * \brief Callback for retrieving the RTP instance carrying text
809 * \note This function increases the reference count on the returned RTP instance.
810 * \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.
811 */
812 enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
813 /*! Callback for updating the destination that the remote side should send RTP to */
814 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);
815 /*!
816 * \brief Callback for retrieving codecs that the channel can do. Result returned in result_cap.
817 * \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.
818 */
819 void (*get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap);
820 /*! Linked list information */
822};
823
824/*!
825 * \brief Directions for RTP extensions
826 */
828 /*! The extension is not negotiated and is not flowing */
830 /*! Send and receive */
832 /*! Send only */
834 /*! Receive only */
836 /*! Negotiated but not sending or receiving */
838};
839
840/*!
841 * \brief Allocation routine for \ref ast_rtp_payload_type
842 *
843 * \retval NULL on error
844 * \return An ao2 ref counted \c ast_rtp_payload_type on success.
845 *
846 * \note The \c ast_rtp_payload_type returned by this function is an
847 * ao2 ref counted object.
848 *
849 */
851
852#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, AST_MODULE_SELF)
853
854/*!
855 * \brief Register an RTP engine
856 *
857 * \param engine Structure of the RTP engine to register
858 * \param module Module that the RTP engine is part of
859 *
860 * \retval 0 success
861 * \retval -1 failure
862 *
863 * Example usage:
864 *
865 * \code
866 * ast_rtp_engine_register2(&example_rtp_engine, NULL);
867 * \endcode
868 *
869 * This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not
870 * associate a module with it.
871 *
872 * \note It is recommended that you use the ast_rtp_engine_register macro so that the module is
873 * associated with the RTP engine and use counting is performed.
874 *
875 * \since 1.8
876 */
877int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module);
878
879/*!
880 * \brief Unregister an RTP engine
881 *
882 * \param engine Structure of the RTP engine to unregister
883 *
884 * \retval 0 success
885 * \retval -1 failure
886 *
887 * Example usage:
888 *
889 * \code
890 * ast_rtp_engine_unregister(&example_rtp_engine);
891 * \endcode
892 *
893 * This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module
894 * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
895 *
896 * \since 1.8
897 */
898int ast_rtp_engine_unregister(struct ast_rtp_engine *engine);
899
901
904
905#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, AST_MODULE_SELF)
906
907/*!
908 * \brief Register RTP glue
909 *
910 * \param glue The glue to register
911 * \param module Module that the RTP glue is part of
912 *
913 * \retval 0 success
914 * \retval -1 failure
915 *
916 * Example usage:
917 *
918 * \code
919 * ast_rtp_glue_register2(&example_rtp_glue, NULL);
920 * \endcode
921 *
922 * This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not
923 * associate a module with it.
924 *
925 * \note It is recommended that you use the ast_rtp_glue_register macro so that the module is
926 * associated with the RTP glue and use counting is performed.
927 *
928 * \since 1.8
929 */
930int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module);
931
932/*!
933 * \brief Unregister RTP glue
934 *
935 * \param glue The glue to unregister
936 *
937 * \retval 0 success
938 * \retval -1 failure
939 *
940 * Example usage:
941 *
942 * \code
943 * ast_rtp_glue_unregister(&example_rtp_glue);
944 * \endcode
945 *
946 * This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module
947 * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
948 *
949 * \since 1.8
950 */
951int ast_rtp_glue_unregister(struct ast_rtp_glue *glue);
952
953/*!
954 * \brief Create a new RTP instance
955 *
956 * \param engine_name Name of the engine to use for the RTP instance
957 * \param sched Scheduler context that the RTP engine may want to use
958 * \param sa Address we want to bind to
959 * \param data Unique data for the engine
960 *
961 * \retval non-NULL success
962 * \retval NULL failure
963 *
964 * Example usage:
965 *
966 * \code
967 * struct ast_rtp_instance *instance = NULL;
968 * instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);
969 * \endcode
970 *
971 * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given
972 * in the address structure.
973 *
974 * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use
975 * another depending on it's own configuration.
976 *
977 * \since 1.8
978 */
979struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
980 struct ast_sched_context *sched, const struct ast_sockaddr *sa,
981 void *data);
982
983/*!
984 * \brief Options for creating a new RTP instance
985 *
986 * This structure allows passing additional options when creating an
987 * RTP instance via \ref ast_rtp_instance_new_with_options. New fields
988 * can be added in the future without changing the function signature.
989 *
990 * \since 20.20.0
991 * \since 22.10.0
992 * \since 23.4.0
993 */
995 /*! Starting port number for this instance (0 to use global) */
996 unsigned int port_start;
997 /*! Ending port number for this instance (0 to use global) */
998 unsigned int port_end;
999};
1000
1001/*!
1002 * \brief Create a new RTP instance with additional options
1003 *
1004 * \param engine_name Name of the engine to use for the RTP instance
1005 * \param sched Scheduler context that the RTP engine may want to use
1006 * \param sa Address we want to bind to
1007 * \param data Unique data for the engine
1008 * \param options Pointer to options struct, or NULL to use defaults
1009 *
1010 * \retval non-NULL success
1011 * \retval NULL failure
1012 *
1013 * Example usage:
1014 *
1015 * \code
1016 * struct ast_rtp_instance_options options = { .port_start = 15000, .port_end = 15010 };
1017 * struct ast_rtp_instance *instance = NULL;
1018 * instance = ast_rtp_instance_new_with_options(NULL, sched, &sin, NULL, &options);
1019 * \endcode
1020 *
1021 * This creates a new RTP instance using the specified options. When a
1022 * per-instance port range is provided the global rtp.conf range is ignored.
1023 * If options is NULL or port values are both 0 the global range is used.
1024 *
1025 * \note The per-instance port range overrides the global rtp.conf settings
1026 * for this specific RTP instance only. It does not need to be a
1027 * subset of the global range.
1028 *
1029 * \since 20.20.0
1030 * \since 22.10.0
1031 * \since 23.4.0
1032 */
1033struct ast_rtp_instance *ast_rtp_instance_new_with_options(const char *engine_name,
1034 struct ast_sched_context *sched, const struct ast_sockaddr *sa,
1035 void *data, const struct ast_rtp_instance_options *options);
1036
1037/*!
1038 * \brief Destroy an RTP instance
1039 *
1040 * \param instance The RTP instance to destroy
1041 *
1042 * \retval 0 success
1043 * \retval -1 failure
1044 *
1045 * Example usage:
1046 *
1047 * \code
1048 * ast_rtp_instance_destroy(instance);
1049 * \endcode
1050 *
1051 * This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid
1052 * memory and may not be used again.
1053 *
1054 * \since 1.8
1055 */
1056int ast_rtp_instance_destroy(struct ast_rtp_instance *instance);
1057
1058/*!
1059 * \brief Set the data portion of an RTP instance
1060 *
1061 * \param instance The RTP instance to manipulate
1062 * \param data Pointer to data
1063 *
1064 * Example usage:
1065 *
1066 * \code
1067 * ast_rtp_instance_set_data(instance, blob);
1068 * \endcode
1069 *
1070 * This sets the data pointer on the RTP instance pointed to by 'instance' to
1071 * blob.
1072 *
1073 * \since 1.8
1074 */
1075void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data);
1076
1077/*!
1078 * \brief Get the data portion of an RTP instance
1079 *
1080 * \param instance The RTP instance we want the data portion from
1081 *
1082 * Example usage:
1083 *
1084 * \code
1085 * struct *blob = ast_rtp_instance_get_data(instance);
1086 ( \endcode
1087 *
1088 * This gets the data pointer on the RTP instance pointed to by 'instance'.
1089 *
1090 * \since 1.8
1091 */
1092void *ast_rtp_instance_get_data(struct ast_rtp_instance *instance);
1093
1094/*!
1095 * \brief Send a frame out over RTP
1096 *
1097 * \param instance The RTP instance to send frame out on
1098 * \param frame the frame to send out
1099 *
1100 * \retval 0 success
1101 * \retval -1 failure
1102 *
1103 * Example usage:
1104 *
1105 * \code
1106 * ast_rtp_instance_write(instance, frame);
1107 * \endcode
1108 *
1109 * This gives the frame pointed to by frame to the RTP engine being used for the instance
1110 * and asks that it be transmitted to the current remote address set on the RTP instance.
1111 *
1112 * \since 1.8
1113 */
1114int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
1115
1116/*!
1117 * \brief Receive a frame over RTP
1118 *
1119 * \param instance The RTP instance to receive frame on
1120 * \param rtcp Whether to read in RTCP or not
1121 *
1122 * \retval non-NULL success
1123 * \retval NULL failure
1124 *
1125 * Example usage:
1126 *
1127 * \code
1128 * struct ast_frame *frame;
1129 * frame = ast_rtp_instance_read(instance, 0);
1130 * \endcode
1131 *
1132 * This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.
1133 *
1134 * \since 1.8
1135 */
1136struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp);
1137
1138/*!
1139 * \brief Set the incoming source address of the remote endpoint that we are sending RTP to
1140 *
1141 * This sets the incoming source address the engine is sending RTP to. Usually this
1142 * will be the same as the requested target address, however in the case where
1143 * the engine "learns" the address (for instance, symmetric RTP enabled) this
1144 * will then contain the learned address.
1145 *
1146 * \param instance The RTP instance to change the address on
1147 * \param address Address to set it to
1148 *
1149 * \retval 0 success
1150 * \retval -1 failure
1151 */
1153 const struct ast_sockaddr *address);
1154
1155/*!
1156 * \brief Set the requested target address of the remote endpoint
1157 *
1158 * This should always be the address of the remote endpoint. Consequently, this can differ
1159 * from the address the engine is sending RTP to. However, usually they will be the same
1160 * except in some circumstances (for instance when the engine "learns" the address if
1161 * symmetric RTP is enabled).
1162 *
1163 * \param instance The RTP instance to change the address on
1164 * \param address Address to set it to
1165 *
1166 * \retval 0 success
1167 * \retval -1 failure
1168 */
1170 const struct ast_sockaddr *address);
1171
1172/*!
1173 * \brief Set the address of the remote endpoint that we are sending RTP to
1174 *
1175 * \param instance The RTP instance to change the address on
1176 * \param address Address to set it to
1177 *
1178 * \retval 0 success
1179 * \retval -1 failure
1180 *
1181 * Example usage:
1182 *
1183 * \code
1184 * ast_rtp_instance_set_remote_address(instance, &sin);
1185 * \endcode
1186 *
1187 * This changes the remote address that RTP will be sent to on instance to the address given in the sin
1188 * structure.
1189 *
1190 * \since 1.8
1191 */
1192#define ast_rtp_instance_set_remote_address(instance, address) \
1193 ast_rtp_instance_set_requested_target_address((instance), (address))
1194
1195/*!
1196 * \brief Set the address that we are expecting to receive RTP on
1197 *
1198 * \param instance The RTP instance to change the address on
1199 * \param address Address to set it to
1200 *
1201 * \retval 0 success
1202 * \retval -1 failure
1203 *
1204 * Example usage:
1205 *
1206 * \code
1207 * ast_rtp_instance_set_local_address(instance, &sin);
1208 * \endcode
1209 *
1210 * This changes the local address that RTP is expected on to the address given in the sin
1211 * structure.
1212 *
1213 * \since 1.8
1214 */
1216 const struct ast_sockaddr *address);
1217
1218/*!
1219 * \brief Get the local address that we are expecting RTP on
1220 *
1221 * \param instance The RTP instance to get the address from
1222 * \param address The variable to store the address in
1223 *
1224 * Example usage:
1225 *
1226 * \code
1227 * struct ast_sockaddr address;
1228 * ast_rtp_instance_get_local_address(instance, &address);
1229 * \endcode
1230 *
1231 * This gets the local address that we are expecting RTP on and stores it in the 'address' structure.
1232 *
1233 * \since 1.8
1234 */
1236
1237/*!
1238 * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
1239 *
1240 * \param instance The instance that we want to get the local address for
1241 * \param address An initialized address that may be overwritten if the local address is different
1242 *
1243 * \retval 0 address was not changed
1244 * \retval 1 address was changed
1245 * Example usage:
1246 *
1247 * \code
1248 * struct ast_sockaddr address;
1249 * int ret;
1250 * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
1251 * \endcode
1252 *
1253 * This retrieves the current local address set on the instance pointed to by instance and puts the value
1254 * into the address structure.
1255 *
1256 * \since 1.8
1257 */
1259
1260/*!
1261 * \brief Get the incoming source address of the remote endpoint
1262 *
1263 * This returns the remote address the engine is sending RTP to. Usually this
1264 * will be the same as the requested target address, however in the case where
1265 * the engine "learns" the address (for instance, symmetric RTP enabled) this
1266 * will then contain the learned address.
1267 *
1268 * \param instance The instance that we want to get the incoming source address for
1269 * \param address A structure to put the address into
1270 */
1272
1273/*!
1274 * \brief Get the requested target address of the remote endpoint
1275 *
1276 * This returns the explicitly set address of a remote endpoint. Meaning this won't change unless
1277 * specifically told to change. In most cases this should be the same as the incoming source
1278 * address, except in cases where the engine "learns" the address in which case this and the
1279 * incoming source address might differ.
1280 *
1281 * \param instance The instance that we want to get the requested target address for
1282 * \param address A structure to put the address into
1283 */
1285
1286/*!
1287 * \brief Get the address of the remote endpoint that we are sending RTP to
1288 *
1289 * \param instance The instance that we want to get the remote address for
1290 * \param address A structure to put the address into
1291 *
1292 * Example usage:
1293 *
1294 * \code
1295 * struct ast_sockaddr address;
1296 * ast_rtp_instance_get_remote_address(instance, &address);
1297 * \endcode
1298 *
1299 * This retrieves the current remote address set on the instance pointed to by instance and puts the value
1300 * into the address structure.
1301 *
1302 * \since 1.8
1303 */
1304#define ast_rtp_instance_get_remote_address(instance, address) \
1305 ast_rtp_instance_get_incoming_source_address((instance), (address))
1306
1307/*!
1308 * \brief Get the requested target address of the remote endpoint and
1309 * compare it to the given address
1310 *
1311 * \param instance The instance that we want to get the remote address for
1312 * \param address An initialized address that may be overwritten addresses differ
1313 *
1314 * \retval 0 address was not changed
1315 * \retval 1 address was changed
1316 */
1318
1319/*!
1320 * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
1321 *
1322 * \param instance The instance that we want to get the remote address for
1323 * \param address An initialized address that may be overwritten if the remote address is different
1324 *
1325 * \retval 0 address was not changed
1326 * \retval 1 address was changed
1327 * Example usage:
1328 *
1329 * \code
1330 * struct ast_sockaddr address;
1331 * int ret;
1332 * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
1333 * \endcode
1334 *
1335 * This retrieves the current remote address set on the instance pointed to by instance and puts the value
1336 * into the address structure.
1337 *
1338 * \since 1.8
1339 */
1340#define ast_rtp_instance_get_and_cmp_remote_address(instance, address) \
1341 ast_rtp_instance_get_and_cmp_requested_target_address((instance), (address))
1342
1343/*!
1344 * \brief Set the value of an RTP instance extended property
1345 *
1346 * \param instance The RTP instance to set the extended property on
1347 * \param property The extended property to set
1348 * \param value The value to set the extended property to
1349 *
1350 * \since 1.8
1351 */
1352void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value);
1353
1354/*!
1355 * \brief Get the value of an RTP instance extended property
1356 *
1357 * \param instance The RTP instance to get the extended property on
1358 * \param property The extended property to get
1359 *
1360 * \since 1.8
1361 */
1362void *ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property);
1363
1364/*!
1365 * \brief Set the value of an RTP instance property
1366 *
1367 * \param instance The RTP instance to set the property on
1368 * \param property The property to modify
1369 * \param value The value to set the property to
1370 *
1371 * Example usage:
1372 *
1373 * \code
1374 * ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1);
1375 * \endcode
1376 *
1377 * This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.
1378 *
1379 * \since 1.8
1380 */
1381void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
1382
1383/*!
1384 * \brief Get the value of an RTP instance property
1385 *
1386 * \param instance The RTP instance to get the property from
1387 * \param property The property to get
1388 *
1389 * \return Current value of the property
1390 *
1391 * Example usage:
1392 *
1393 * \code
1394 * ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT);
1395 * \endcode
1396 *
1397 * This returns the current value of the NAT property on the instance pointed to by instance.
1398 *
1399 * \since 1.8
1400 */
1401int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property);
1402
1403/*!
1404 * \brief Get the codecs structure of an RTP instance
1405 *
1406 * \param instance The RTP instance to get the codecs structure from
1407 *
1408 * Example usage:
1409 *
1410 * \code
1411 * struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance);
1412 * \endcode
1413 *
1414 * This gets the codecs structure on the RTP instance pointed to by 'instance'.
1415 *
1416 * \since 1.8
1417 */
1419
1420/*!
1421 * \brief Enable support for an RTP extension on an instance
1422 *
1423 * \param instance The RTP instance to enable the extension on
1424 * \param id The unique local identifier to use for this extension (-1 to have one auto selected)
1425 * \param extension The RTP extension
1426 * \param direction The initial direction that the RTP extension should be used in
1427 *
1428 * \retval 0 success
1429 * \retval -1 failure
1430 *
1431 * \since 15.5.0
1432 */
1435
1436/*!
1437 * \brief Negotiate received RTP extension information
1438 *
1439 * \param instance The RTP instance to set the extension on
1440 * \param id The local identifier for the extension
1441 * \param direction The direction that the extension should be used in
1442 * \param uri The unique URI for the extension
1443 * \param attributes Attributes specific to this extension (if NULL or empty then no attributes)
1444 *
1445 * \retval 0 success
1446 * \retval -1 failure
1447 *
1448 * \since 15.5.0
1449 */
1451 const char *uri, const char *attributes);
1452
1453/*!
1454 * \brief Clear negotiated RTP extension information
1455 *
1456 * \param instance The RTP instance to clear negotiated extension information on
1457 */
1458void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance);
1459
1460/*!
1461 * \brief Retrieve the id for an RTP extension
1462 *
1463 * \param instance The RTP instance to retrieve the id from
1464 * \param extension The RTP extension
1465 *
1466 * \retval -1 not negotiated
1467 * \retval id if negotiated
1468 *
1469 * \since 15.5.0
1470 */
1472
1473/*!
1474 * \brief Get the number of known unique identifiers
1475 *
1476 * \param instance The RTP instance to retrieve the count from
1477 *
1478 * \return the number of known unique identifiers
1479 *
1480 * \since 15.5.0
1481 */
1482size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance);
1483
1484/*!
1485 * \brief Retrieve the extension for an RTP extension id
1486 *
1487 * \param instance The RTP instance to retrieve the extension from
1488 * \param id The negotiated RTP extension id
1489 *
1490 * \return extension the extension that maps to the id
1491 *
1492 * \since 15.5.0
1493 *
1494 * \note This will return AST_RTP_EXTENSION_UNSUPPORTED if an extension was proposed for this unique identifier
1495 * but it is not supported or if the unique identifier is unused.
1496 */
1498
1499/*!
1500 * \brief Retrieve the negotiated direction for an RTP extension id
1501 *
1502 * \param instance The RTP instance to retrieve the direction from
1503 * \param id The negotiated RTP extension id
1504 *
1505 * \return direction the direction that has been negotiated
1506 *
1507 * \since 15.5.0
1508 */
1510
1511/*!
1512 * \brief Retrieve the URI for an RTP extension id
1513 *
1514 * \param instance The RTP instance to retrieve the direction from
1515 * \param id The negotiated RTP extension id
1516 *
1517 * \return The URI for the RTP extension
1518 *
1519 * \since 15.5.0
1520 */
1521const char *ast_rtp_instance_extmap_get_uri(struct ast_rtp_instance *instance, int id);
1522
1523/*!
1524 * \brief Initialize an RTP codecs structure
1525 *
1526 * \param codecs The codecs structure to initialize
1527 *
1528 * \retval 0 success
1529 * \retval -1 failure
1530 *
1531 * Example usage:
1532 *
1533 * \code
1534 * struct ast_rtp_codecs codecs;
1535 * ast_rtp_codecs_payloads_initialize(&codecs);
1536 * \endcode
1537 *
1538 * \since 11
1539 */
1541
1542/*!
1543 * \brief Destroy the contents of an RTP codecs structure (but not the structure itself)
1544 *
1545 * \param codecs The codecs structure to destroy the contents of
1546 *
1547 * Example usage:
1548 *
1549 * \code
1550 * struct ast_rtp_codecs codecs;
1551 * ast_rtp_codecs_payloads_destroy(&codecs);
1552 * \endcode
1553 *
1554 * \since 11
1555 */
1557
1558/*!
1559 * \brief Clear rx and tx payload mapping information from an RTP instance
1560 *
1561 * \param codecs The codecs structure that payloads will be cleared from
1562 * \param instance Optionally the instance that the codecs structure belongs to
1563 *
1564 * Example usage:
1565 *
1566 * \code
1567 * struct ast_rtp_codecs codecs;
1568 * ast_rtp_codecs_payloads_clear(&codecs, NULL);
1569 * \endcode
1570 *
1571 * This clears the codecs structure and puts it into a pristine state.
1572 *
1573 * \since 1.8
1574 */
1576
1577/*!
1578 * \brief Copy payload information from one RTP instance to another
1579 *
1580 * \param src The source codecs structure
1581 * \param dest The destination codecs structure that the values from src will be copied to
1582 * \param instance Optionally the instance that the dst codecs structure belongs to
1583 *
1584 * Example usage:
1585 *
1586 * \code
1587 * ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);
1588 * \endcode
1589 *
1590 * This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.
1591 *
1592 * \since 1.8
1593 */
1594void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
1595
1596/*!
1597 * \brief Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
1598 * \since 14.0.0
1599 *
1600 * \param src The source codecs structure
1601 * \param dest The destination codecs structure that the values from src will be copied to
1602 * \param instance Optionally the instance that the dst codecs structure belongs to
1603 */
1604void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
1605
1606/*!
1607 * \brief Record tx payload type information that was seen in an m= SDP line
1608 *
1609 * \param codecs The codecs structure to muck with
1610 * \param instance Optionally the instance that the codecs structure belongs to
1611 * \param payload Numerical payload that was seen in the m= SDP line
1612 *
1613 * Example usage:
1614 *
1615 * \code
1616 * ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0);
1617 * \endcode
1618 *
1619 * This records that the numerical payload '0' was seen in the codecs structure.
1620 *
1621 * \since 1.8
1622 */
1623void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
1624
1625/*!
1626 * \brief Record tx payload type information that was seen in an a=rtpmap: SDP line
1627 *
1628 * \param codecs The codecs structure to muck with
1629 * \param instance Optionally the instance that the codecs structure belongs to
1630 * \param payload Numerical payload that was seen in the a=rtpmap: SDP line
1631 * \param mimetype The string mime type that was seen
1632 * \param mimesubtype The string mime sub type that was seen
1633 * \param options Optional options that may change the behavior of this specific payload
1634 *
1635 * \retval 0 success
1636 * \retval -1 failure, invalid payload numbe
1637 * \retval -2 failure, unknown mimetype
1638 *
1639 * Example usage:
1640 *
1641 * \code
1642 * ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);
1643 * \endcode
1644 *
1645 * This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.
1646 *
1647 * \since 1.8
1648 */
1649int 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);
1650
1651/*!
1652 * \brief Set tx payload type to a known MIME media type for a codec with a specific sample rate
1653 *
1654 * \param codecs RTP structure to modify
1655 * \param instance Optionally the instance that the codecs structure belongs to
1656 * \param pt Payload type entry to modify
1657 * \param mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.)
1658 * \param mimesubtype MIME subtype of media stream (typically a codec name)
1659 * \param options Zero or more flags from the ast_rtp_options enum
1660 * \param sample_rate The sample rate of the media stream
1661 *
1662 * This function 'fills in' an entry in the list of possible formats for
1663 * a media stream associated with an RTP structure.
1664 *
1665 * \retval 0 on success
1666 * \retval -1 if the payload type is out of range
1667 * \retval -2 if the mimeType/mimeSubtype combination was not found
1668 *
1669 * \since 1.8
1670 */
1672 char *mimetype, char *mimesubtype,
1674 unsigned int sample_rate);
1675
1676/*!
1677 * \brief Remove tx payload type mapped information
1678 *
1679 * \param codecs The codecs structure to muck with
1680 * \param instance Optionally the instance that the codecs structure belongs to
1681 * \param payload Numerical payload to unset
1682 *
1683 * Example usage:
1684 *
1685 * \code
1686 * ast_rtp_codecs_payloads_unset(&codecs, NULL, 0);
1687 * \endcode
1688 *
1689 * This clears the payload '0' from the codecs structure. It will be as if it was never set.
1690 *
1691 * \since 1.8
1692 */
1693void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
1694
1695/*!
1696 * \brief Determine the type of RTP stream media from the codecs mapped.
1697 * \since 13.19.0
1698 *
1699 * \param codecs Codecs structure to look in
1700 *
1701 * \return Media type or AST_MEDIA_TYPE_UNKNOWN if no codecs mapped.
1702 */
1704
1705/*!
1706 * \brief Retrieve rx payload mapped information by payload type
1707 *
1708 * \param codecs Codecs structure to look in
1709 * \param payload Numerical payload to look up
1710 *
1711 * \return Payload information.
1712 * \retval NULL if payload does not exist.
1713 *
1714 * \note The payload returned by this function has its reference count increased.
1715 * Callers are responsible for decrementing the reference count.
1716 *
1717 * Example usage:
1718 *
1719 * \code
1720 * struct ast_rtp_payload_type *payload_type;
1721 * payload_type = ast_rtp_codecs_get_payload(&codecs, 0);
1722 * \endcode
1723 *
1724 * This looks up the information for payload '0' from the codecs structure.
1725 */
1727
1728/*!
1729 * \brief Retrieve rx preferred format
1730 *
1731 * \param codecs Codecs structure to look in
1732 *
1733 * \return format information.
1734 * \retval NULL if format does not exist.
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 * Example usage:
1740 *
1741 * \code
1742 * struct ast_format *payload_format;
1743 * payload_format = ast_rtp_codecs_get_preferred_format(&codecs);
1744 * \endcode
1745 *
1746 * This looks up the preferred format on the codec
1747 */
1749
1750/*!
1751 * \brief Set the preferred format
1752 *
1753 * \param codecs Codecs structure to set the preferred format in
1754 * \param format Preferred format to set.
1755 *
1756 * \return 0
1757 *
1758 * \note The format passed this function has its reference count increased. If an existing
1759 * format is set, that format is replaced.
1760 *
1761 * Example usage:
1762 *
1763 * \code
1764 * struct ast_format *preferred_format = ast_format_cap_get_format(joint, 0);
1765 * ast_rtp_codecs_set_preferred_format(&codecs, preferred_format));
1766 * \endcode
1767 *
1768 * This sets the first joint format as the preferred format.
1769 */
1771
1772/*!
1773 * \brief Retrieve rx preferred dtmf format payload type
1774 *
1775 * \param codecs Codecs structure to look in
1776 *
1777 * \return Payload type of preferred dtmf format.
1778 * \retval -1 if not set.
1779 *
1780 * Example usage:
1781 *
1782 * \code
1783 * int payload;
1784 * payload = ast_rtp_codecs_get_preferred_dtmf_format_pt(codec);
1785 * \endcode
1786 *
1787 * This looks up the preferred dtmf format pt on the codec
1788 */
1790
1791/*!
1792 * \brief Retrieve rx preferred dtmf format sample rate
1793 *
1794 * \param codecs Codecs structure to look in
1795 *
1796 * \return Sample rate of preferred dtmf format.
1797 * \retval -1 if not set.
1798 *
1799 * Example usage:
1800 *
1801 * \code
1802 * int sample_rate;
1803 * sample_rate = ast_rtp_codecs_get_preferred_dtmf_format_rate(codec);
1804 * \endcode
1805 *
1806 * This looks up the preferred dtmf format sample rate on the codec
1807 */
1809
1810/*!
1811 * \brief Set the preferred dtmf format pt and sample rate
1812 *
1813 * \param codecs Codecs structure to set the preferred format in
1814 * \param pt Preferred dtmf payload type to set.
1815 * \param rate Preferred dtmf payload rate to set.
1816 *
1817 * \return 0
1818 *
1819 * \note The format passed this function has its reference count increased. If an existing
1820 * format is set, that format is replaced.
1821 *
1822 * Example usage:
1823 *
1824 * \code
1825 * int dtmf_code = atoi(dtmf_pt);
1826 * int dtmf_rate = clock_rate;
1827 * ast_rtp_codecs_set_preferred_dtmf_format(codecs, dtmf_code, dtmf_rate);
1828 * \endcode
1829 *
1830 * This sets the preferred dtmf_code and dtmf_rate on the codec.
1831 */
1833
1834
1835/*!
1836 * \brief Update the format associated with a tx payload type in a codecs structure
1837 *
1838 * \param codecs Codecs structure to operate on
1839 * \param payload Numerical payload type to look up
1840 * \param format The format to replace the existing one
1841 *
1842 * \retval 0 success
1843 * \retval -1 failure
1844 *
1845 * \since 13
1846 */
1847int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format);
1848
1849/*!
1850 * \brief Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type
1851 *
1852 * \param codecs Codecs structure to look in
1853 * \param payload Numerical payload type to look up
1854 *
1855 * \return pointer to format structure on success
1856 * \retval NULL on failure
1857 *
1858 * \note The format returned by this function has its reference count increased.
1859 * Callers are responsible for decrementing the reference count.
1860 *
1861 * \since 10.0
1862 */
1864
1865/*!
1866 * \brief Set the framing used for a set of codecs
1867 *
1868 * \param codecs Codecs structure to set framing on
1869 * \param framing The framing value to set on the codecs
1870 *
1871 * \since 13.0.0
1872 */
1873void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing);
1874
1875/*!
1876 * \brief Get the framing used for a set of codecs
1877 *
1878 * \param codecs Codecs structure to get the framing from
1879 *
1880 * \return The framing to be used for the media stream associated with these codecs
1881 *
1882 * \since 13.0.0
1883 */
1885
1886/*!
1887 * \brief Get the sample rate associated with known RTP payload types
1888 *
1889 * \param asterisk_format True if the value in format is to be used.
1890 * \param format An asterisk format
1891 * \param code from AST_RTP list
1892 *
1893 * \return the sample rate if the format was found, zero if it was not found
1894 *
1895 * \since 1.8
1896 */
1897unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format,
1898 const struct ast_format *format, int code);
1899
1900/*!
1901 * \brief Retrieve all formats that were found
1902 *
1903 * \param codecs Codecs structure to look in
1904 * \param astformats A capabilities structure to put the Asterisk formats in.
1905 * \param nonastformats An integer to put the non-Asterisk formats in
1906 *
1907 * Example usage:
1908 *
1909 * \code
1910 * struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
1911 * int nonastformats;
1912 * ast_rtp_codecs_payload_formats(&codecs, astformats, &nonastformats);
1913 * \endcode
1914 *
1915 * This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer
1916 * pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.
1917 *
1918 * \since 1.8
1919 */
1920void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats);
1921
1922/*!
1923 * \brief Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code
1924 *
1925 * \param codecs Codecs structure to look in
1926 * \param asterisk_format Non-zero if the given Asterisk format is present
1927 * \param format Asterisk format to look for
1928 * \param code The format to look for
1929 *
1930 * \details
1931 * Find the currently assigned rx mapped payload type based on whether it
1932 * is an Asterisk format or non-format code. If one is currently not
1933 * assigned then create a rx payload type mapping.
1934 *
1935 * \return Numerical payload type
1936 * \retval -1 if could not assign.
1937 *
1938 * Example usage:
1939 *
1940 * \code
1941 * int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_ulaw, 0);
1942 * \endcode
1943 *
1944 * This looks for the numerical payload for ULAW in the codecs structure.
1945 *
1946 * \since 1.8
1947 */
1948int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code);
1949
1950
1951/*!
1952 * \brief Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample rate.
1953 *
1954 * \param codecs Codecs structure to look in
1955 * \param asterisk_format Non-zero if the given Asterisk format is present
1956 * \param format Asterisk format to look for
1957 * \param code The format to look for
1958 * \param sample_rate Non-zero if we want to also match on sample rate.
1959 *
1960 * \details
1961 * Find the currently assigned rx mapped payload type based on whether it
1962 * is an Asterisk format or non-format code. If one is currently not
1963 * assigned then create a rx payload type mapping.
1964 *
1965 * \return Numerical payload type
1966 * \retval -1 if could not assign.
1967 *
1968 * Example usage:
1969 *
1970 * \code
1971 * int payload = ast_rtp_codecs_payload_code_sample_rate(&codecs, 0, NULL, AST_RTP_DTMF, 8000);
1972 * \endcode
1973 *
1974 * This looks for the numerical payload for a DTMF type with a sample rate of 8kHz in the codecs structure.
1975 *
1976 * \since 22.0.0
1977 */
1978int 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);
1979
1980/*!
1981 * \brief Set a payload code for use with a specific Asterisk format
1982 *
1983 * \param codecs Codecs structure to manipulate
1984 * \param code The payload code
1985 * \param format Asterisk format
1986 *
1987 * \retval 0 Payload was set to the given format
1988 * \retval -1 Payload was in use or could not be set
1989 *
1990 * \since 15.0.0
1991 */
1992int ast_rtp_codecs_payload_set_rx(struct ast_rtp_codecs *codecs, int code, struct ast_format *format);
1993
1994/*!
1995 * \brief Set a payload code with sample rate for use with a specific Asterisk format
1996 *
1997 * \param codecs Codecs structure to manipulate
1998 * \param code The payload code
1999 * \param format Asterisk format
2000 * \param sample_rate Sample rate of the format, 0 to use the format's default
2001 *
2002 * \retval 0 Payload was set to the given format
2003 * \retval -1 Payload was in use or could not be set
2004 *
2005 * \since 22.0.0
2006 */
2007int ast_rtp_codecs_payload_set_rx_sample_rate(struct ast_rtp_codecs *codecs, int code, struct ast_format *format, unsigned int sample_rate);
2008
2009/*!
2010 * \brief Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code
2011 * \since 14.0.0
2012 *
2013 * \param codecs Codecs structure to look in
2014 * \param asterisk_format Non-zero if the given Asterisk format is present
2015 * \param format Asterisk format to look for
2016 * \param code The format to look for
2017 *
2018 * \return Numerical payload type
2019 * \retval -1 if not found.
2020 */
2021int ast_rtp_codecs_payload_code_tx(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code);
2022
2023/*!
2024 * \brief Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code
2025 * \since 22.0.0
2026 *
2027 * \param codecs Codecs structure to look in
2028 * \param asterisk_format Non-zero if the given Asterisk format is present
2029 * \param format Asterisk format to look for
2030 * \param code The format to look for
2031 * \param sample_rate The sample rate to look for, zero if we don't care
2032 *
2033 * \return Numerical payload type
2034 * \retval -1 if not found.
2035 */
2036int 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);
2037
2038/*!
2039 * \brief Search for the tx payload type in the ast_rtp_codecs structure
2040 *
2041 * \param codecs Codecs structure to look in
2042 * \param payload The payload type format to look for
2043 *
2044 * \return Numerical payload type or -1 if unable to find payload in codecs
2045 *
2046 * Example usage:
2047 *
2048 * \code
2049 * int payload = ast_rtp_codecs_find_payload_code(&codecs, 0);
2050 * \endcode
2051 *
2052 * This looks for the numerical payload for ULAW in the codecs structure.
2053 */
2055
2056/*!
2057 * \brief Retrieve mime subtype information on a payload
2058 *
2059 * \param asterisk_format Non-zero to look up using Asterisk format
2060 * \param format Asterisk format to look up
2061 * \param code RTP code to look up
2062 * \param options Additional options that may change the result
2063 *
2064 * \return Mime subtype success
2065 * \retval NULL failure
2066 *
2067 * Example usage:
2068 *
2069 * \code
2070 * const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_ulaw, 0, 0);
2071 * \endcode
2072 *
2073 * This looks up the mime subtype for the ULAW format.
2074 *
2075 * \since 1.8
2076 */
2077const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format,
2078 const struct ast_format *format, int code, enum ast_rtp_options options);
2079
2080/*!
2081 * \brief Convert formats into a string and put them into a buffer
2082 *
2083 * \param buf Buffer to put the mime output into
2084 * \param ast_format_capability Asterisk Formats we are looking up.
2085 * \param rtp_capability RTP codes that we are looking up
2086 * \param asterisk_format Non-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used
2087 * \param options Additional options that may change the result
2088 *
2089 * \retval non-NULL success
2090 * \retval NULL failure
2091 *
2092 * Example usage:
2093 *
2094 * \code
2095 * char buf[256] = "";
2096 * struct ast_format tmp_fmt;
2097 * struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
2098 * ast_format_cap_append(cap, ast_format_ulaw, 0);
2099 * ast_format_cap_append(cap, ast_format_ulaw, 0);
2100 * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
2101 * ast_format_cap_destroy(cap);
2102 * \endcode
2103 *
2104 * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
2105 *
2106 * \since 1.8
2107 */
2108char *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);
2109
2110/*!
2111 * \brief Begin sending a DTMF digit
2112 *
2113 * \param instance The RTP instance to send the DTMF on
2114 * \param digit What DTMF digit to send
2115 *
2116 * \retval 0 success
2117 * \retval -1 failure
2118 *
2119 * Example usage:
2120 *
2121 * \code
2122 * ast_rtp_instance_dtmf_begin(instance, '1');
2123 * \endcode
2124 *
2125 * This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will
2126 * continue being sent until it is ended.
2127 *
2128 * \since 1.8
2129 */
2130int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit);
2131
2132/*!
2133 * \brief Stop sending a DTMF digit
2134 *
2135 * \param instance The RTP instance to stop the DTMF on
2136 * \param digit What DTMF digit to stop
2137 *
2138 * \retval 0 success
2139 * \retval -1 failure
2140 *
2141 * Example usage:
2142 *
2143 * \code
2144 * ast_rtp_instance_dtmf_end(instance, '1');
2145 * \endcode
2146 *
2147 * This stops sending the DTMF '1' on the RTP instance pointed to by instance.
2148 *
2149 * \since 1.8
2150 */
2151int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit);
2152int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration);
2153
2154/*!
2155 * \brief Set the DTMF mode that should be used
2156 *
2157 * \param instance the RTP instance to set DTMF mode on
2158 * \param dtmf_mode The DTMF mode that is in use
2159 *
2160 * \retval 0 success
2161 * \retval -1 failure
2162 *
2163 * Example usage:
2164 *
2165 * \code
2166 * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833);
2167 * \endcode
2168 *
2169 * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
2170 *
2171 * \since 1.8
2172 */
2173int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
2174
2175/*!
2176 * \brief Get the DTMF mode of an RTP instance
2177 *
2178 * \param instance The RTP instance to get the DTMF mode of
2179 *
2180 * \return DTMF mode
2181 *
2182 * Example usage:
2183 *
2184 * \code
2185 * enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance);
2186 * \endcode
2187 *
2188 * This gets the DTMF mode set on the RTP instance pointed to by 'instance'.
2189 *
2190 * \since 1.8
2191 */
2193
2194/*!
2195 * \brief Indicate that the RTP marker bit should be set on an RTP stream
2196 *
2197 * \param instance Instance that the new media source is feeding into
2198 *
2199 * Example usage:
2200 *
2201 * \code
2202 * ast_rtp_instance_update_source(instance);
2203 * \endcode
2204 *
2205 * This indicates that the source of media that is feeding the instance pointed to by
2206 * instance has been updated and that the marker bit should be set.
2207 *
2208 * \since 1.8
2209 */
2211
2212/*!
2213 * \brief Indicate a new source of audio has dropped in and the ssrc should change
2214 *
2215 * \param instance Instance that the new media source is feeding into
2216 *
2217 * Example usage:
2218 *
2219 * \code
2220 * ast_rtp_instance_change_source(instance);
2221 * \endcode
2222 *
2223 * This indicates that the source of media that is feeding the instance pointed to by
2224 * instance has changed and that the marker bit should be set and the SSRC updated.
2225 *
2226 * \since 1.8
2227 */
2229
2230/*!
2231 * \brief Set QoS parameters on an RTP session
2232 *
2233 * \param instance Instance to set the QoS parameters on
2234 * \param tos Terms of service value
2235 * \param cos Class of service value
2236 * \param desc What is setting the QoS values
2237 *
2238 * \retval 0 success
2239 * \retval -1 failure
2240 *
2241 * Example usage:
2242 *
2243 * \code
2244 * ast_rtp_instance_set_qos(instance, 0, 0, "Example");
2245 * \endcode
2246 *
2247 * This sets the TOS and COS values to 0 on the instance pointed to by instance.
2248 *
2249 * \since 1.8
2250 */
2251int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
2252
2253/*!
2254 * \brief Stop an RTP instance
2255 *
2256 * \param instance Instance that media is no longer going to at this time
2257 *
2258 * Example usage:
2259 *
2260 * \code
2261 * ast_rtp_instance_stop(instance);
2262 * \endcode
2263 *
2264 * This tells the RTP engine being used for the instance pointed to by instance
2265 * that media is no longer going to it at this time, but may in the future.
2266 *
2267 * \since 1.8
2268 */
2269void ast_rtp_instance_stop(struct ast_rtp_instance *instance);
2270
2271/*!
2272 * \brief Get the file descriptor for an RTP session (or RTCP)
2273 *
2274 * \param instance Instance to get the file descriptor for
2275 * \param rtcp Whether to retrieve the file descriptor for RTCP or not
2276 *
2277 * \retval fd success
2278 * \retval -1 failure
2279 *
2280 * Example usage:
2281 *
2282 * \code
2283 * int rtp_fd = ast_rtp_instance_fd(instance, 0);
2284 * \endcode
2285 *
2286 * This retrieves the file descriptor for the socket carrying media on the instance
2287 * pointed to by instance.
2288 *
2289 * \since 1.8
2290 */
2291int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp);
2292
2293/*!
2294 * \brief Get the RTP glue that binds a channel to the RTP engine
2295 *
2296 * \param type Name of the glue we want
2297 *
2298 * \retval non-NULL success
2299 * \retval NULL failure
2300 *
2301 * Example usage:
2302 *
2303 * \code
2304 * struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");
2305 * \endcode
2306 *
2307 * This retrieves the RTP glue that has the name 'Example'.
2308 *
2309 * \since 1.8
2310 */
2311struct ast_rtp_glue *ast_rtp_instance_get_glue(const char *type);
2312
2313/*!
2314 * \brief Get the unique ID of the channel that owns this RTP instance
2315 *
2316 * Note that this should remain valid for the lifetime of the RTP instance.
2317 *
2318 * \param instance The RTP instance
2319 *
2320 * \return The unique ID of the channel
2321 * \retval Empty string if no channel owns this RTP instance
2322 *
2323 * \since 12
2324 */
2325const char *ast_rtp_instance_get_channel_id(struct ast_rtp_instance *instance);
2326
2327/*!
2328 * \brief Set the channel that owns this RTP instance
2329 *
2330 * \param instance The RTP instance
2331 * \param uniqueid The uniqueid of the channel
2332 *
2333 * \since 12
2334 */
2335void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid);
2336
2337/*!
2338 * \brief Get the other RTP instance that an instance is bridged to
2339 *
2340 * \param instance The RTP instance that we want
2341 *
2342 * \retval non-NULL success
2343 * \retval NULL failure
2344 *
2345 * Example usage:
2346 *
2347 * \code
2348 * struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0);
2349 * \endcode
2350 *
2351 * This gets the RTP instance that instance0 is bridged to.
2352 *
2353 * \since 1.8
2354 */
2356
2357/*!
2358 * \brief Set the other RTP instance that an instance is bridged to
2359 *
2360 * \param instance The RTP instance that we want to set the bridged value on
2361 * \param bridged The RTP instance they are bridged to
2362 *
2363 * \since 12
2364 */
2366
2367/*!
2368 * \brief Make two channels compatible for early bridging
2369 *
2370 * \param c_dst Destination channel to copy to
2371 * \param c_src Source channel to copy from
2372 *
2373 * \since 1.8
2374 */
2376
2377/*!
2378 * \brief Early bridge two channels that use RTP instances
2379 *
2380 * \param c0 First channel part of the bridge
2381 * \param c1 Second channel part of the bridge
2382 *
2383 * \retval 0 success
2384 * \retval -1 failure
2385 *
2386 * \note This should only be used by channel drivers in their technology declaration.
2387 *
2388 * \since 1.8
2389 */
2390int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
2391
2392/*!
2393 * \brief Initialize RED support on an RTP instance
2394 *
2395 * \param instance The instance to initialize RED support on
2396 * \param buffer_time How long to buffer before sending
2397 * \param payloads Payload values
2398 * \param generations Number of generations
2399 *
2400 * \retval 0 success
2401 * \retval -1 failure
2402 *
2403 * \since 1.8
2404 */
2405int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
2406
2407/*!
2408 * \brief Buffer a frame in an RTP instance for RED
2409 *
2410 * \param instance The instance to buffer the frame on
2411 * \param frame Frame that we want to buffer
2412 *
2413 * \retval 0 success
2414 * \retval -1 failure
2415 *
2416 * \since 1.8
2417 */
2418int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
2419
2420/*!
2421 * \brief Retrieve statistics about an RTP instance
2422 *
2423 * \param instance Instance to get statistics on
2424 * \param stats Structure to put results into
2425 * \param stat What statistic(s) to retrieve
2426 *
2427 * \retval 0 success
2428 * \retval -1 failure
2429 *
2430 * Example usage:
2431 *
2432 * \code
2433 * struct ast_rtp_instance_stats stats;
2434 * ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL);
2435 * \endcode
2436 *
2437 * This retrieves all statistics the underlying RTP engine supports and puts the values into the
2438 * stats structure.
2439 *
2440 * \since 1.8
2441 */
2442int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
2443
2444/*!
2445 * \brief Set standard statistics from an RTP instance on a channel
2446 *
2447 * \param chan Channel to set the statistics on
2448 * \param instance The RTP instance that statistics will be retrieved from
2449 *
2450 * \warning Absolutely _NO_ channel locks should be held before calling this function.
2451 * If this channel is in a bridge, ast_rtp_instance_set_stats_vars() will
2452 * attempt to lock the bridge peer as well as this channel. This can cause
2453 * a lock inversion if we already have this channel locked and another
2454 * thread tries to set bridge variables on the peer because it will have
2455 * locked the peer first, then this channel. For this reason, we must
2456 * NOT have the channel locked when we call ast_rtp_instance_set_stats_vars().
2457 *
2458 * Example usage:
2459 *
2460 * \code
2461 * ast_rtp_instance_set_stats_vars(chan, rtp);
2462 * \endcode
2463 *
2464 * This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to
2465 * by chan.
2466 *
2467 * \since 1.8
2468 */
2469void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance);
2470
2471/*!
2472 * \brief Retrieve quality statistics about an RTP instance
2473 *
2474 * \param instance Instance to get statistics on
2475 * \param field What quality statistic to retrieve
2476 * \param buf What buffer to put the result into
2477 * \param size Size of the above buffer
2478 *
2479 * \retval non-NULL success
2480 * \retval NULL failure
2481 *
2482 * Example usage:
2483 *
2484 * \code
2485 * char quality[AST_MAX_USER_FIELD];
2486 * ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf));
2487 * \endcode
2488 *
2489 * This retrieves general quality statistics and places a text representation into the buf pointed to by buf.
2490 *
2491 * \since 1.8
2492 */
2493char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size);
2494
2495/*!
2496 * \brief Request that the underlying RTP engine provide audio frames in a specific format
2497 *
2498 * \param instance The RTP instance to change read format on
2499 * \param format Format that frames are wanted in
2500 *
2501 * \retval 0 success
2502 * \retval -1 failure
2503 *
2504 * Example usage:
2505 *
2506 * \code
2507 * struct ast_format tmp_fmt;
2508 * ast_rtp_instance_set_read_format(instance, ast_format_ulaw);
2509 * \endcode
2510 *
2511 * This requests that the RTP engine provide audio frames in the ULAW format.
2512 *
2513 * \since 1.8
2514 */
2515int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format);
2516
2517/*!
2518 * \brief Tell underlying RTP engine that audio frames will be provided in a specific format
2519 *
2520 * \param instance The RTP instance to change write format on
2521 * \param format Format that frames will be provided in
2522 *
2523 * \retval 0 success
2524 * \retval -1 failure
2525 *
2526 * Example usage:
2527 *
2528 * \code
2529 * struct ast_format tmp_fmt;
2530 * ast_rtp_instance_set_write_format(instance, ast_format_ulaw);
2531 * \endcode
2532 *
2533 * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
2534 *
2535 * \since 1.8
2536 */
2537int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format);
2538
2539/*!
2540 * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
2541 *
2542 * \param chan Our own Asterisk channel
2543 * \param instance The first RTP instance
2544 * \param peer The peer Asterisk channel
2545 *
2546 * \retval 0 success
2547 * \retval -1 failure
2548 *
2549 * Example usage:
2550 *
2551 * \code
2552 * ast_rtp_instance_make_compatible(instance, peer);
2553 * \endcode
2554 *
2555 * This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.
2556 *
2557 * \since 1.8
2558 */
2559int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer);
2560
2561/*! \brief Request the formats that can be transcoded
2562 *
2563 * \param instance The RTP instance
2564 * \param to_endpoint Formats being sent/received towards the endpoint
2565 * \param to_asterisk Formats being sent/received towards Asterisk
2566 * \param result capabilities structure to store and return supported formats in.
2567 *
2568 * Example usage:
2569 *
2570 * \code
2571 * ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);
2572 * \endcode
2573 *
2574 * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
2575 *
2576 * \since 1.8
2577 */
2578void 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);
2579
2580/*!
2581 * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
2582 *
2583 * \param instance The RTP instance
2584 *
2585 * \retval 0 success
2586 * \retval -1 failure
2587 *
2588 * Example usage:
2589 *
2590 * \code
2591 * ast_rtp_instance_activate(instance);
2592 * \endcode
2593 *
2594 * This tells the underlying RTP engine of instance that packets will now flow.
2595 *
2596 * \since 1.8
2597 */
2598int ast_rtp_instance_activate(struct ast_rtp_instance *instance);
2599
2600/*!
2601 * \brief Request that the underlying RTP engine send a STUN BIND request
2602 *
2603 * \param instance The RTP instance
2604 * \param suggestion The suggested destination
2605 * \param username Optionally a username for the request
2606 *
2607 * Example usage:
2608 *
2609 * \code
2610 * ast_rtp_instance_stun_request(instance, NULL, NULL);
2611 * \endcode
2612 *
2613 * This requests that the RTP engine send a STUN BIND request on the session pointed to by
2614 * 'instance'.
2615 *
2616 * \since 1.8
2617 */
2618void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
2619
2620/*!
2621 * \brief Set the RTP timeout value
2622 *
2623 * \param instance The RTP instance
2624 * \param timeout Value to set the timeout to
2625 *
2626 * Example usage:
2627 *
2628 * \code
2629 * ast_rtp_instance_set_timeout(instance, 5000);
2630 * \endcode
2631 *
2632 * This sets the RTP timeout value on 'instance' to be 5000.
2633 *
2634 * \since 1.8
2635 */
2636void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout);
2637
2638/*!
2639 * \brief Set the RTP timeout value for when the instance is on hold
2640 *
2641 * \param instance The RTP instance
2642 * \param timeout Value to set the timeout to
2643 *
2644 * Example usage:
2645 *
2646 * \code
2647 * ast_rtp_instance_set_hold_timeout(instance, 5000);
2648 * \endcode
2649 *
2650 * This sets the RTP hold timeout value on 'instance' to be 5000.
2651 *
2652 * \since 1.8
2653 */
2655
2656/*!
2657 * \brief Set the RTP keepalive interval
2658 *
2659 * \param instance The RTP instance
2660 * \param timeout Value to set the keepalive interval to
2661 *
2662 * Example usage:
2663 *
2664 * \code
2665 * ast_rtp_instance_set_keepalive(instance, 5000);
2666 * \endcode
2667 *
2668 * This sets the RTP keepalive interval on 'instance' to be 5000.
2669 *
2670 * \since 1.8
2671 */
2672void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout);
2673
2674/*!
2675 * \brief Get the RTP timeout value
2676 *
2677 * \param instance The RTP instance
2678 *
2679 * \return timeout value
2680 *
2681 * Example usage:
2682 *
2683 * \code
2684 * int timeout = ast_rtp_instance_get_timeout(instance);
2685 * \endcode
2686 *
2687 * This gets the RTP timeout value for the RTP instance pointed to by 'instance'.
2688 *
2689 * \since 1.8
2690 */
2692
2693/*!
2694 * \brief Get the RTP timeout value for when an RTP instance is on hold
2695 *
2696 * \param instance The RTP instance
2697 *
2698 * \return timeout value
2699 *
2700 * Example usage:
2701 *
2702 * \code
2703 * int timeout = ast_rtp_instance_get_hold_timeout(instance);
2704 * \endcode
2705 *
2706 * This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.
2707 *
2708 * \since 1.8
2709 */
2711
2712/*!
2713 * \brief Get the RTP keepalive interval
2714 *
2715 * \param instance The RTP instance
2716 *
2717 * \return period Keepalive interval value
2718 *
2719 * Example usage:
2720 *
2721 * \code
2722 * int interval = ast_rtp_instance_get_keepalive(instance);
2723 * \endcode
2724 *
2725 * This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.
2726 *
2727 * \since 1.8
2728 */
2730
2731/*!
2732 * \brief Get the per-instance RTP port range start
2733 *
2734 * \param instance The RTP instance
2735 *
2736 * \return port start value (0 means use global setting)
2737 *
2738 * \since 20.20.0
2739 * \since 22.10.0
2740 * \since 23.4.0
2741 */
2742unsigned int ast_rtp_instance_get_port_start(struct ast_rtp_instance *instance);
2743
2744/*!
2745 * \brief Get the per-instance RTP port range end
2746 *
2747 * \param instance The RTP instance
2748 *
2749 * \return port end value (0 means use global setting)
2750 *
2751 * \since 20.20.0
2752 * \since 22.10.0
2753 * \since 23.4.0
2754 */
2755unsigned int ast_rtp_instance_get_port_end(struct ast_rtp_instance *instance);
2756
2757/*!
2758 * \brief Get the RTP engine in use on an RTP instance
2759 *
2760 * \param instance The RTP instance
2761 *
2762 * \return pointer to the engine
2763 *
2764 * Example usage:
2765 *
2766 * \code
2767 * struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);
2768 * \endcode
2769 *
2770 * This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.
2771 *
2772 * \since 1.8
2773 */
2775
2776/*!
2777 * \brief Get the RTP glue in use on an RTP instance
2778 *
2779 * \param instance The RTP instance
2780 *
2781 * \return pointer to the glue
2782 *
2783 * Example:
2784 *
2785 * \code
2786 * struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance);
2787 * \endcode
2788 *
2789 * This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.
2790 *
2791 * \since 1.8
2792 */
2794
2795/*!
2796 * \brief Send a comfort noise packet to the RTP instance
2797 *
2798 * \param instance The RTP instance
2799 * \param level Magnitude of the noise level
2800 *
2801 * \retval 0 Success
2802 * \retval non-zero Failure
2803 */
2804int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level);
2805
2806/*!
2807 * \brief Add or replace the SRTP policies for the given RTP instance
2808 *
2809 * \param instance the RTP instance
2810 * \param remote_policy the remote endpoint's policy
2811 * \param local_policy our policy for this RTP instance's remote endpoint
2812 * \param rtcp 1 for dedicated RTCP policies
2813 *
2814 * \retval 0 Success
2815 * \retval non-zero Failure
2816 *
2817 * \note If no remote policy is provided any existing SRTP policies are left and the new local policy is added
2818 */
2819int 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);
2820
2821/*!
2822 * \brief Obtain the SRTP instance associated with an RTP instance
2823 *
2824 * \param instance the RTP instance
2825 * \param rtcp 1 to request instance for RTCP
2826 * \return the SRTP instance on success
2827 * \retval NULL if no SRTP instance exists
2828 */
2829struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance, int rtcp);
2830
2831/*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine
2832 * so their mime type can payload number can be initialized. */
2833int ast_rtp_engine_load_format(struct ast_format *format);
2834
2835/*! \brief Formats requiring the use of a format attribute interface must have that
2836 * interface registered in order for the rtp engine to handle it correctly. If an
2837 * attribute interface is unloaded, this function must be called to notify the rtp_engine. */
2838int ast_rtp_engine_unload_format(struct ast_format *format);
2839
2840/*!
2841 * \brief Obtain a pointer to the ICE support present on an RTP instance
2842 *
2843 * \param instance the RTP instance
2844 *
2845 * \return ICE support if present
2846 * \retval NULL if no ICE support available
2847 */
2849
2850#ifdef TEST_FRAMEWORK
2851/*!
2852 * \brief Obtain a pointer to the test callbacks on an RTP instance
2853 *
2854 * \param instance the RTP instance
2855 *
2856 * \return test callbacks if present
2857 * \retval NULL if not present
2858 */
2859struct ast_rtp_engine_test *ast_rtp_instance_get_test(struct ast_rtp_instance *instance);
2860#endif
2861
2862/*!
2863 * \brief Obtain a pointer to the DTLS support present on an RTP instance
2864 *
2865 * \param instance the RTP instance
2866 *
2867 * \return DTLS support if present
2868 * \retval NULL if no DTLS support available
2869 */
2871
2872/*!
2873 * \brief Parse DTLS related configuration options
2874 *
2875 * \param dtls_cfg a DTLS configuration structure
2876 * \param name name of the configuration option
2877 * \param value value of the configuration option
2878 *
2879 * \retval 0 if handled
2880 * \retval -1 if not handled
2881 */
2882int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value);
2883
2884/*!
2885 * \brief Validates DTLS related configuration options
2886 *
2887 * \param dtls_cfg a DTLS configuration structure
2888 *
2889 * \retval 0 if valid
2890 * \retval -1 if invalid
2891 */
2892int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg);
2893
2894/*!
2895 * \brief Copy contents of a DTLS configuration structure
2896 *
2897 * \param src_cfg source DTLS configuration structure
2898 * \param dst_cfg destination DTLS configuration structure
2899 */
2900void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg);
2901
2902/*!
2903 * \brief Free contents of a DTLS configuration structure
2904 *
2905 * \param dtls_cfg a DTLS configuration structure
2906 */
2907void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg);
2908
2909struct ast_json;
2910
2911/*!
2912 * \brief Allocate an ao2 ref counted instance of \ref ast_rtp_rtcp_report
2913 *
2914 * \param report_blocks The number of report blocks to allocate
2915 * \return An ao2 ref counted \ref ast_rtp_rtcp_report object on success
2916 * \retval NULL on error
2917 */
2918struct ast_rtp_rtcp_report *ast_rtp_rtcp_report_alloc(unsigned int report_blocks);
2919
2920/*!
2921 * \since 12
2922 * \brief Publish an RTCP message to \ref stasis
2923 *
2924 * \param rtp The rtp instance object
2925 * \param message_type The RTP message type to publish
2926 * \param report The RTCP report object to publish. This should be an ao2 ref counted
2927 * object. This routine will increase the reference count of the object.
2928 * \param blob Additional JSON objects to publish along with the RTCP information
2929 */
2931 struct stasis_message_type *message_type,
2932 struct ast_rtp_rtcp_report *report,
2933 struct ast_json *blob);
2934
2935/*!
2936 * \brief Get the last RTP transmission time
2937 *
2938 * \param rtp The instance from which to get the last transmission time
2939 * \return The last RTP transmission time
2940 */
2941time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp);
2942
2943/*!
2944 * \brief Set the last RTP transmission time
2945 *
2946 * \param rtp The instance on which to set the last transmission time
2947 * \param time The last transmission time
2948 */
2949void ast_rtp_instance_set_last_tx(struct ast_rtp_instance *rtp, time_t time);
2950
2951/*!
2952 * \brief Get the last RTP reception time
2953 *
2954 * \param rtp The instance from which to get the last reception time
2955 * \return The last RTP reception time
2956 */
2957time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp);
2958
2959/*!
2960 * \brief Set the last RTP reception time
2961 *
2962 * \param rtp The instance on which to set the last reception time
2963 * \param time The last reception time
2964 */
2965void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time);
2966
2967/*!
2968 * \brief Retrieve the local SSRC value that we will be using
2969 *
2970 * \param rtp The RTP instance
2971 * \return The SSRC value
2972 */
2973unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp);
2974
2975/*!
2976 * \brief Retrieve the CNAME used in RTCP SDES items
2977 *
2978 * This is a pointer directly into the RTP struct, not a copy.
2979 *
2980 * \param rtp The RTP instance
2981 * \return the CNAME
2982 */
2983const char *ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp);
2984
2985/*!
2986 * \brief Request that an RTP instance be bundled with another
2987 * \since 15.0.0
2988 *
2989 * \param child The child RTP instance
2990 * \param parent The parent RTP instance the child should be bundled with
2991 *
2992 * \retval 0 success
2993 * \retval -1 failure
2994 */
2995int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent);
2996
2997/*!
2998 * \brief Set the remote SSRC for an RTP instance
2999 * \since 15.0.0
3000 *
3001 * \param rtp The RTP instance
3002 * \param ssrc The remote SSRC
3003 */
3004void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc);
3005
3006/*!
3007 * \brief Set the stream number for an RTP instance
3008 * \since 15.0.0
3009 *
3010 * \param instance The RTP instance
3011 * \param stream_num The stream identifier number
3012 */
3013void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num);
3014
3015/*! \addtogroup StasisTopicsAndMessages
3016 * @{
3017 */
3018
3019/*!
3020 * \since 12
3021 * \brief Message type for an RTCP message sent from this Asterisk instance
3022 *
3023 * \return A stasis message type
3024 */
3026
3027/*!
3028 * \since 12
3029 * \brief Message type for an RTCP message received from some external source
3030 *
3031 * \return A stasis message type
3032 */
3034
3035/*! @} */
3036
3037#ifdef TEST_FRAMEWORK
3038/*!
3039 * \brief Get the maximum size of the receive buffer
3040 *
3041 * \param instance The RTP instance
3042 * \return The recv_buffer max size if it exists, else 0
3043 */
3044size_t ast_rtp_instance_get_recv_buffer_max(struct ast_rtp_instance *instance);
3045
3046/*!
3047 * \brief Get the current size of the receive buffer
3048 *
3049 * \param instance The RTP instance
3050 * \return The recv_buffer size if it exists, else 0
3051 */
3052size_t ast_rtp_instance_get_recv_buffer_count(struct ast_rtp_instance *instance);
3053
3054/*!
3055 * \brief Get the current size of the send buffer
3056 *
3057 * \param instance The RTP instance
3058 * \return The send_buffer size if it exists, else 0
3059 */
3060size_t ast_rtp_instance_get_send_buffer_count(struct ast_rtp_instance *instance);
3061
3062/*!
3063 * \brief Set the schedid for RTCP
3064 *
3065 * \param instance The RTP instance
3066 * \param id The number to set schedid to
3067 */
3068void ast_rtp_instance_set_schedid(struct ast_rtp_instance *instance, int id);
3069
3070/*!
3071 * \brief Set the number of packets to drop on RTP read
3072 *
3073 * \param instance The RTP instance
3074 * \param num The number of packets to drop
3075 */
3076void ast_rtp_instance_drop_packets(struct ast_rtp_instance *instance, int num);
3077
3078/*!
3079 * \brief Sends a SR/RR report the next time RTP would be sent
3080 *
3081 * \param instance The RTP instance
3082 */
3083void ast_rtp_instance_queue_report(struct ast_rtp_instance *instance);
3084
3085/*!
3086 * \brief Get the value of sdes_received on the test engine
3087 *
3088 * \param instance The RTP instance
3089 * \retval 1 if sdes_received, else 0
3090 */
3091int ast_rtp_instance_get_sdes_received(struct ast_rtp_instance *instance);
3092
3093/*!
3094 * \brief Resets all the fields to default values for the test engine
3095 *
3096 * \param instance The RTP instance
3097 */
3098void ast_rtp_instance_reset_test_engine(struct ast_rtp_instance *instance);
3099#endif
3100
3101/*!
3102 * \brief Convert given stat instance into json format
3103 * \param stats
3104 * \return A json format stat
3105 */
3107
3108/*!
3109 * \brief Retrieve statistics about an RTP instance in json format
3110 * \param instance
3111 * \return json object of stats
3112 */
3114
3115/*!
3116 * \brief Retrieve the sample rate of a format according to RTP specifications
3117 * \since 16.7.0
3118 * \since 17.1.0
3119 *
3120 * \param format The media format
3121 *
3122 * \return The sample rate
3123 */
3124int ast_rtp_get_rate(const struct ast_format *format);
3125
3126/*!
3127 * \since 12
3128 * \brief \ref stasis topic for RTP and RTCP related messages
3129 *
3130 * \return A \ref stasis topic
3131 */
3132struct stasis_topic *ast_rtp_topic(void);
3133
3134/*!
3135 * \brief Determine if a type of payload is already present in mappings.
3136 * \since 18
3137 *
3138 * \param codecs Codecs to be checked for mappings.
3139 * \param to_match Payload type object to compare against.
3140 *
3141 * \note It is assumed that codecs is not locked before calling.
3142 *
3143 * \retval 0 not found
3144 * \retval 1 found
3145 */
3147
3148/* RTP debug logging category name */
3149#define AST_LOG_CATEGORY_RTP "rtp"
3150/* RTP packet debug logging category name */
3151#define AST_LOG_CATEGORY_RTP_PACKET "rtp_packet"
3152/* RTCP debug logging category name */
3153#define AST_LOG_CATEGORY_RTCP "rtcp"
3154/* RTCP packet debug logging category name */
3155#define AST_LOG_CATEGORY_RTCP_PACKET "rtcp_packet"
3156/* DTLS debug logging category name */
3157#define AST_LOG_CATEGORY_DTLS "dtls"
3158/* DTLS packet debug logging category name */
3159#define AST_LOG_CATEGORY_DTLS_PACKET "dtls_packet"
3160/* ICE debug logging category name */
3161#define AST_LOG_CATEGORY_ICE "ice"
3162
3163uintmax_t ast_debug_category_rtp_id(void);
3164uintmax_t ast_debug_category_rtp_packet_id(void);
3165uintmax_t ast_debug_category_rtcp_id(void);
3166uintmax_t ast_debug_category_rtcp_packet_id(void);
3167uintmax_t ast_debug_category_dtls_id(void);
3168uintmax_t ast_debug_category_dtls_packet_id(void);
3169uintmax_t ast_debug_category_ice_id(void);
3170
3171#define AST_DEBUG_CATEGORY_RTP ast_debug_category_rtp_id() /* RTP debug logging category id */
3172#define AST_DEBUG_CATEGORY_RTP_PACKET ast_debug_category_rtp_packet_id() /* RTP packet debug logging category id */
3173#define AST_DEBUG_CATEGORY_RTCP ast_debug_category_rtcp_id() /* RTCP debug logging category id */
3174#define AST_DEBUG_CATEGORY_RTCP_PACKET ast_debug_category_rtcp_packet_id() /* RTCP packet debug logging category id */
3175#define AST_DEBUG_CATEGORY_DTLS ast_debug_category_dtls_id() /* DTLS debug logging category id */
3176#define AST_DEBUG_CATEGORY_DTLS_PACKET ast_debug_category_dtls_packet_id() /* DTLS packet debug logging category id */
3177#define AST_DEBUG_CATEGORY_ICE ast_debug_category_ice_id() /* ICE debug logging category id */
3178
3179/*!
3180 * \brief Log debug level RTP information
3181 *
3182 * \param sublevel Debug output sublevel (>= 0)
3183 * \param ... String format and any associated arguments
3184 */
3185#define ast_debug_rtp(sublevel, ...) \
3186 ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTP, __VA_ARGS__)
3187
3188/* Allow logging of RTP? */
3189#define ast_debug_rtp_is_allowed \
3190 ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP)
3191
3192/* Allow logging of RTP packets? */
3193#define ast_debug_rtp_packet_is_allowed \
3194 ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP_PACKET)
3195
3196/*!
3197 * \brief Log debug level RTCP information
3198 *
3199 * \param sublevel Debug output sublevel (>= 0)
3200 * \param ... String format and any associated arguments
3201 */
3202#define ast_debug_rtcp(sublevel, ...) \
3203 ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTCP, __VA_ARGS__)
3204
3205/* Allow logging of RTCP? */
3206#define ast_debug_rtcp_is_allowed \
3207 ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP)
3208
3209/* Allow logging of RTCP packets? */
3210#define ast_debug_rtcp_packet_is_allowed \
3211 ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP_PACKET)
3212
3213/*!
3214 * \brief Log debug level DTLS information
3215 *
3216 * \param sublevel Debug output sublevel (>= 0)
3217 * \param ... String format and any associated arguments
3218 */
3219#define ast_debug_dtls(sublevel, ...) \
3220 ast_debug_category(sublevel, AST_DEBUG_CATEGORY_DTLS, __VA_ARGS__)
3221
3222/* Allow logging of DTLS packets? */
3223#define ast_debug_dtls_packet_is_allowed \
3224 ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_DTLS_PACKET)
3225/*!
3226 * \brief Log debug level ICE information
3227 *
3228 * \param sublevel Debug output sublevel (>= 0)
3229 * \param ... String format and any associated arguments
3230 */
3231#define ast_debug_ice(sublevel, ...) \
3232 ast_debug_category(sublevel, AST_DEBUG_CATEGORY_ICE, __VA_ARGS__)
3233
3234#if defined(__cplusplus) || defined(c_plusplus)
3235}
3236#endif
3237
3238#endif /* _ASTERISK_RTP_ENGINE_H */
char digit
enum queue_result id
Definition app_queue.c:1790
static const char desc[]
Definition cdr_radius.c:84
static PGresult * result
Definition cel_pgsql.c:84
unsigned int tos
Definition chan_iax2.c:392
unsigned int cos
Definition chan_iax2.c:393
static const char type[]
static struct ao2_container * codecs
Registered codecs.
Definition codec.c:48
ast_media_type
Types of media.
Definition codec.h:30
char buf[BUFSIZE]
Definition eagi_proxy.c:66
char * address
Definition f2c.h:59
Format Capabilities API.
static const char name[]
Definition format_mp3.c:68
direction
struct stasis_message_type * ast_rtp_rtcp_sent_type(void)
Message type for an RTCP message sent from this Asterisk instance.
struct stasis_message_type * ast_rtp_rtcp_received_type(void)
Message type for an RTCP message received from some external source.
Asterisk internal frame definitions.
#define AST_RWLIST_ENTRY
Network socket handling.
ast_transport
Definition netsock2.h:59
static struct ast_srtp_res srtp_res
Definition res_srtp.c:129
static struct ast_srtp_policy_res policy_res
Definition res_srtp.c:141
SRTP resource.
ast_srtp_suite
Definition res_srtp.h:56
ast_rtp_dtls_setup
DTLS setup types.
Definition rtp_engine.h:564
@ AST_RTP_DTLS_SETUP_PASSIVE
Definition rtp_engine.h:566
@ AST_RTP_DTLS_SETUP_HOLDCONN
Definition rtp_engine.h:568
@ AST_RTP_DTLS_SETUP_ACTPASS
Definition rtp_engine.h:567
@ AST_RTP_DTLS_SETUP_ACTIVE
Definition rtp_engine.h:565
uintmax_t ast_debug_category_rtcp_packet_id(void)
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.
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.
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
ast_rtp_ice_role
ICE role during negotiation.
Definition rtp_engine.h:519
@ AST_RTP_ICE_ROLE_CONTROLLING
Definition rtp_engine.h:521
@ AST_RTP_ICE_ROLE_CONTROLLED
Definition rtp_engine.h:520
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.
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:716
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition rtp_engine.c:468
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
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.
struct ast_format * ast_rtp_codecs_get_preferred_format(struct ast_rtp_codecs *codecs)
Retrieve rx preferred format.
struct ast_json * ast_rtp_convert_stats_json(const struct ast_rtp_instance_stats *stats)
Convert given stat instance into json format.
uintmax_t ast_debug_category_rtp_packet_id(void)
ast_rtp_ice_component_type
ICE component types.
Definition rtp_engine.h:513
@ AST_RTP_ICE_COMPONENT_RTCP
Definition rtp_engine.h:515
@ AST_RTP_ICE_COMPONENT_RTP
Definition rtp_engine.h:514
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.
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.
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.
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:680
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.
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:497
#define MAX_CHANNEL_ID
Definition rtp_engine.h:107
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.
void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP reception time.
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:767
int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
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:667
uintmax_t ast_debug_category_ice_id(void)
ast_rtp_dtls_hash
DTLS fingerprint hashes.
Definition rtp_engine.h:578
@ AST_RTP_DTLS_HASH_SHA1
Definition rtp_engine.h:580
@ AST_RTP_DTLS_HASH_SHA256
Definition rtp_engine.h:579
int ast_rtp_engine_srtp_is_registered(void)
ast_rtp_dtmf_mode
Definition rtp_engine.h:151
@ AST_RTP_DTMF_MODE_RFC2833
Definition rtp_engine.h:155
@ AST_RTP_DTMF_MODE_INBAND
Definition rtp_engine.h:157
@ AST_RTP_DTMF_MODE_NONE
Definition rtp_engine.h:153
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.
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
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:702
void ast_rtp_engine_unregister_srtp(void)
ast_rtp_instance_rtcp
Definition rtp_engine.h:283
@ AST_RTP_INSTANCE_RTCP_MUX
Definition rtp_engine.h:289
@ AST_RTP_INSTANCE_RTCP_STANDARD
Definition rtp_engine.h:287
@ AST_RTP_INSTANCE_RTCP_DISABLED
Definition rtp_engine.h:285
uintmax_t ast_debug_category_rtp_id(void)
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.
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.
struct ast_srtp * ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance, int rtcp)
Obtain the SRTP instance associated with an RTP instance.
ast_rtp_instance_stat_field
Definition rtp_engine.h:171
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS
Definition rtp_engine.h:177
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT
Definition rtp_engine.h:179
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY
Definition rtp_engine.h:173
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER
Definition rtp_engine.h:175
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES
Definition rtp_engine.h:181
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.
size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance)
Get the number of known unique identifiers.
Definition rtp_engine.c:950
ast_rtp_dtls_verify
DTLS verification settings.
Definition rtp_engine.h:584
@ AST_RTP_DTLS_VERIFY_NONE
Definition rtp_engine.h:585
@ AST_RTP_DTLS_VERIFY_FINGERPRINT
Definition rtp_engine.h:586
@ AST_RTP_DTLS_VERIFY_CERTIFICATE
Definition rtp_engine.h:587
ast_rtp_glue_result
Definition rtp_engine.h:161
@ AST_RTP_GLUE_RESULT_LOCAL
Definition rtp_engine.h:167
@ AST_RTP_GLUE_RESULT_REMOTE
Definition rtp_engine.h:165
@ AST_RTP_GLUE_RESULT_FORBID
Definition rtp_engine.h:163
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:783
ast_rtp_instance_stat
Definition rtp_engine.h:185
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS
Definition rtp_engine.h:207
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS
Definition rtp_engine.h:203
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS
Definition rtp_engine.h:199
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVMES
Definition rtp_engine.h:270
@ AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER
Definition rtp_engine.h:223
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVMES
Definition rtp_engine.h:278
@ AST_RTP_INSTANCE_STAT_MIN_RTT
Definition rtp_engine.h:243
@ AST_RTP_INSTANCE_STAT_TXMES
Definition rtp_engine.h:262
@ AST_RTP_INSTANCE_STAT_CHANNEL_UNIQUEID
Definition rtp_engine.h:253
@ AST_RTP_INSTANCE_STAT_TXPLOSS
Definition rtp_engine.h:195
@ AST_RTP_INSTANCE_STAT_MAX_RTT
Definition rtp_engine.h:241
@ AST_RTP_INSTANCE_STAT_RXPLOSS
Definition rtp_engine.h:197
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER
Definition rtp_engine.h:221
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER
Definition rtp_engine.h:229
@ AST_RTP_INSTANCE_STAT_REMOTE_MINMES
Definition rtp_engine.h:268
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER
Definition rtp_engine.h:227
@ AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS
Definition rtp_engine.h:201
@ AST_RTP_INSTANCE_STAT_LOCAL_MINMES
Definition rtp_engine.h:276
@ AST_RTP_INSTANCE_STAT_TXOCTETCOUNT
Definition rtp_engine.h:255
@ AST_RTP_INSTANCE_STAT_RXMES
Definition rtp_engine.h:264
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVMES
Definition rtp_engine.h:272
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS
Definition rtp_engine.h:211
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS
Definition rtp_engine.h:205
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS
Definition rtp_engine.h:213
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXMES
Definition rtp_engine.h:266
@ AST_RTP_INSTANCE_STAT_TXCOUNT
Definition rtp_engine.h:189
@ AST_RTP_INSTANCE_STAT_STDEVRTT
Definition rtp_engine.h:247
@ AST_RTP_INSTANCE_STAT_COMBINED_MES
Definition rtp_engine.h:260
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXMES
Definition rtp_engine.h:274
@ AST_RTP_INSTANCE_STAT_RXJITTER
Definition rtp_engine.h:219
@ AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS
Definition rtp_engine.h:209
@ AST_RTP_INSTANCE_STAT_LOCAL_SSRC
Definition rtp_engine.h:249
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER
Definition rtp_engine.h:225
@ AST_RTP_INSTANCE_STAT_COMBINED_JITTER
Definition rtp_engine.h:215
@ AST_RTP_INSTANCE_STAT_TXJITTER
Definition rtp_engine.h:217
@ AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER
Definition rtp_engine.h:231
@ AST_RTP_INSTANCE_STAT_COMBINED_LOSS
Definition rtp_engine.h:193
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER
Definition rtp_engine.h:235
@ AST_RTP_INSTANCE_STAT_COMBINED_RTT
Definition rtp_engine.h:237
@ AST_RTP_INSTANCE_STAT_NORMDEVRTT
Definition rtp_engine.h:245
@ AST_RTP_INSTANCE_STAT_RTT
Definition rtp_engine.h:239
@ AST_RTP_INSTANCE_STAT_RXOCTETCOUNT
Definition rtp_engine.h:257
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVMES
Definition rtp_engine.h:280
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER
Definition rtp_engine.h:233
@ AST_RTP_INSTANCE_STAT_ALL
Definition rtp_engine.h:187
@ AST_RTP_INSTANCE_STAT_RXCOUNT
Definition rtp_engine.h:191
@ AST_RTP_INSTANCE_STAT_REMOTE_SSRC
Definition rtp_engine.h:251
int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Early bridge two channels that use RTP instances.
void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num)
Set the stream number for an RTP instance.
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
Definition rtp_engine.c:614
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.
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.
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
struct ast_rtp_engine * ast_rtp_instance_get_engine(struct ast_rtp_instance *instance)
Get the RTP engine in use on an RTP instance.
const char * ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp)
Retrieve the CNAME used in RTCP SDES items.
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.
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
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.
void ast_rtp_instance_set_last_tx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP transmission time.
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition rtp_engine.c:629
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:609
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.
int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Request that an RTP instance be bundled with another.
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.
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.
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp)
Get the last RTP transmission time.
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.
int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Initialize RED support on an RTP instance.
struct ast_json * ast_rtp_instance_get_stats_all_json(struct ast_rtp_instance *instance)
Retrieve statistics about an RTP instance in json format.
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:756
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.
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.
unsigned int ast_rtp_instance_get_port_end(struct ast_rtp_instance *instance)
Get the per-instance RTP port range end.
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.
int ast_rtp_codecs_get_preferred_dtmf_format_rate(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format sample rate.
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:732
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:694
int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
struct ast_rtp_instance * ast_rtp_instance_new_with_options(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data, const struct ast_rtp_instance_options *options)
Create a new RTP instance with additional options.
Definition rtp_engine.c:505
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.
ast_rtp_ice_candidate_type
ICE candidate types.
Definition rtp_engine.h:506
@ AST_RTP_ICE_CANDIDATE_TYPE_RELAYED
Definition rtp_engine.h:509
@ AST_RTP_ICE_CANDIDATE_TYPE_SRFLX
Definition rtp_engine.h:508
@ AST_RTP_ICE_CANDIDATE_TYPE_HOST
Definition rtp_engine.h:507
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 ...
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:639
int ast_rtp_get_rate(const struct ast_format *format)
Retrieve the sample rate of a format according to RTP specifications.
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.
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:961
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition rtp_engine.c:619
ast_rtp_extension
Known RTP extensions.
Definition rtp_engine.h:593
@ AST_RTP_EXTENSION_MAX
Definition rtp_engine.h:601
@ AST_RTP_EXTENSION_TRANSPORT_WIDE_CC
Definition rtp_engine.h:599
@ AST_RTP_EXTENSION_ABS_SEND_TIME
Definition rtp_engine.h:597
@ AST_RTP_EXTENSION_UNSUPPORTED
Definition rtp_engine.h:595
int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module)
Register RTP glue.
Definition rtp_engine.c:389
uintmax_t ast_debug_category_dtls_packet_id(void)
int ast_rtp_payload_mapping_tx_is_present(struct ast_rtp_codecs *codecs, const struct ast_rtp_payload_type *to_match)
Determine if a type of payload is already present in mappings.
void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Remove tx payload type mapped information.
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
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.
void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc)
Set the remote SSRC for an RTP instance.
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.
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.
ast_rtp_options
Definition rtp_engine.h:145
@ AST_RTP_OPT_G726_NONSTANDARD
Definition rtp_engine.h:147
ast_rtp_dtls_connection
DTLS connection states.
Definition rtp_engine.h:572
@ AST_RTP_DTLS_CONNECTION_NEW
Definition rtp_engine.h:573
@ AST_RTP_DTLS_CONNECTION_EXISTING
Definition rtp_engine.h:574
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
ast_rtp_property
Definition rtp_engine.h:116
@ AST_RTP_PROPERTY_NAT
Definition rtp_engine.h:118
@ AST_RTP_PROPERTY_MAX
Maximum number of RTP properties supported.
Definition rtp_engine.h:141
@ AST_RTP_PROPERTY_RETRANS_RECV
Definition rtp_engine.h:130
@ AST_RTP_PROPERTY_RETRANS_SEND
Definition rtp_engine.h:132
@ AST_RTP_PROPERTY_RTCP
Definition rtp_engine.h:126
@ AST_RTP_PROPERTY_ASYMMETRIC_CODEC
Definition rtp_engine.h:128
@ AST_RTP_PROPERTY_STUN
Definition rtp_engine.h:124
@ AST_RTP_PROPERTY_DTMF
Definition rtp_engine.h:120
@ AST_RTP_PROPERTY_DTMF_COMPENSATE
Definition rtp_engine.h:122
@ AST_RTP_PROPERTY_REMB
Definition rtp_engine.h:134
int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value)
Parse DTLS related configuration options.
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:741
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...
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.
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.
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:724
time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp)
Get the last RTP reception time.
int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
Register an RTP engine.
Definition rtp_engine.c:340
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.
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.
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:604
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.
ast_rtp_extension_direction
Directions for RTP extensions.
Definition rtp_engine.h:827
@ AST_RTP_EXTENSION_DIRECTION_SENDRECV
Definition rtp_engine.h:831
@ AST_RTP_EXTENSION_DIRECTION_NONE
Definition rtp_engine.h:829
@ AST_RTP_EXTENSION_DIRECTION_INACTIVE
Definition rtp_engine.h:837
@ AST_RTP_EXTENSION_DIRECTION_RECVONLY
Definition rtp_engine.h:835
@ AST_RTP_EXTENSION_DIRECTION_SENDONLY
Definition rtp_engine.h:833
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:657
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.
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.
uintmax_t ast_debug_category_rtcp_id(void)
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
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:997
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.
int ast_rtp_codecs_set_preferred_dtmf_format(struct ast_rtp_codecs *codecs, int pt, int rate)
Set the preferred dtmf format pt and sample rate.
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
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:937
int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg)
Validates DTLS related configuration options.
int ast_rtp_codecs_get_preferred_dtmf_format_pt(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format payload type.
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.
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
Definition rtp_engine.c:374
uintmax_t ast_debug_category_dtls_id(void)
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:869
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...
void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance)
Clear negotiated RTP extension information.
Definition rtp_engine.c:913
struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type(void)
Allocation routine for ast_rtp_payload_type.
Definition rtp_engine.c:335
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:778
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.
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:599
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp)
Retrieve the local SSRC value that we will be using.
int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
Buffer a frame in an RTP instance for RED.
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.
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.
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:981
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.
unsigned int ast_rtp_instance_get_port_start(struct ast_rtp_instance *instance)
Get the per-instance RTP port range start.
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.
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition rtp_engine.c:418
int ast_rtp_codecs_set_preferred_format(struct ast_rtp_codecs *codecs, struct ast_format *format)
Set the preferred format.
Scheduler Routines (derived from cheops)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
Generic container type.
Main Channel structure associated with a channel.
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
Definition of a media format.
Definition format.c:43
Data structure associated with a single frame of data.
Abstract JSON element (object, array, string, int, ...).
struct ast_rtp_codecs::@292 payload_mapping_rx
ast_rwlock_t codecs_lock
Definition rtp_engine.h:758
int preferred_dtmf_rate
Definition rtp_engine.h:768
struct ast_rtp_codecs::@293 payload_mapping_tx
struct ast_format * preferred_format
Definition rtp_engine.h:766
unsigned int framing
Definition rtp_engine.h:764
DTLS configuration structure.
Definition rtp_engine.h:605
enum ast_rtp_dtls_setup default_setup
Definition rtp_engine.h:608
enum ast_rtp_dtls_verify verify
Definition rtp_engine.h:611
unsigned int rekey
Definition rtp_engine.h:607
enum ast_rtp_dtls_hash hash
Definition rtp_engine.h:610
unsigned int enabled
Definition rtp_engine.h:606
unsigned int ephemeral_cert
Definition rtp_engine.h:617
enum ast_srtp_suite suite
Definition rtp_engine.h:609
Structure that represents the optional DTLS SRTP support within an RTP engine.
Definition rtp_engine.h:621
int(* set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg)
Definition rtp_engine.h:623
int(* active)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:625
enum ast_rtp_dtls_setup(* get_setup)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:633
void(* stop)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:627
enum ast_rtp_dtls_hash(* get_fingerprint_hash)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:639
void(* reset)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:629
void(* set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint)
Definition rtp_engine.h:637
enum ast_rtp_dtls_connection(* get_connection)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:631
void(* set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup)
Definition rtp_engine.h:635
Structure for an ICE candidate.
Definition rtp_engine.h:525
enum ast_rtp_ice_component_type id
Definition rtp_engine.h:527
struct ast_sockaddr relay_address
Definition rtp_engine.h:531
enum ast_rtp_ice_candidate_type type
Definition rtp_engine.h:532
Structure that represents the optional ICE support within an RTP engine.
Definition rtp_engine.h:536
void(* ice_lite)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:552
void(* stop)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:544
void(* change_components)(struct ast_rtp_instance *instance, int num_components)
Definition rtp_engine.h:560
void(* set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password)
Definition rtp_engine.h:538
void(* start)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:542
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
void(* add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate)
Definition rtp_engine.h:540
void(* set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role)
Definition rtp_engine.h:554
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
int(* write)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition rtp_engine.h:675
int(* qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Definition rtp_engine.h:704
struct ast_rtp_engine::@291 entry
void(* stop)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:677
enum ast_rtp_dtmf_mode(* dtmf_mode_get)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:700
int(* activate)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:724
void(* change_source)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:686
int(* dtmf_end)(struct ast_rtp_instance *instance, char digit)
Definition rtp_engine.h:681
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(* destroy)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:673
int(* fd)(struct ast_rtp_instance *instance, int rtcp)
Definition rtp_engine.h:706
int(* dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Definition rtp_engine.h:698
void(* set_remote_ssrc)(struct ast_rtp_instance *instance, unsigned int ssrc)
Definition rtp_engine.h:738
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
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
struct ast_module * mod
Definition rtp_engine.h:669
int(* red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition rtp_engine.h:710
int(* set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition rtp_engine.h:716
int(* red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Definition rtp_engine.h:708
void(* prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Definition rtp_engine.h:692
const char * name
Definition rtp_engine.h:667
int(* dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition rtp_engine.h:682
int(* set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition rtp_engine.h:718
void(* remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa)
Definition rtp_engine.h:696
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
int(* sendcng)(struct ast_rtp_instance *instance, int level)
Definition rtp_engine.h:730
void(* update_source)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:684
void(* stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Definition rtp_engine.h:726
int(* dtmf_begin)(struct ast_rtp_instance *instance, char digit)
Definition rtp_engine.h:679
struct ast_rtp_engine_ice * ice
Definition rtp_engine.h:742
unsigned int(* ssrc_get)(struct ast_rtp_instance *instance)
Definition rtp_engine.h:732
struct ast_rtp_engine_dtls * dtls
Definition rtp_engine.h:744
void(* set_stream_num)(struct ast_rtp_instance *instance, int stream_num)
Definition rtp_engine.h:740
int(* bundle)(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Definition rtp_engine.h:736
int(* extension_enable)(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Definition rtp_engine.h:750
int(* extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value)
Definition rtp_engine.h:688
int(* allow_vrtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance)
Used to prevent two channels from remotely bridging video rtp if the channel tech has a reason for pr...
Definition rtp_engine.h:805
enum ast_rtp_glue_result(* get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying audio.
Definition rtp_engine.h:787
void(* get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap)
Callback for retrieving codecs that the channel can do. Result returned in result_cap.
Definition rtp_engine.h:819
struct ast_rtp_glue::@294 entry
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)
Definition rtp_engine.h:814
const char * type
Definition rtp_engine.h:780
struct ast_module * mod
Definition rtp_engine.h:782
enum ast_rtp_glue_result(* get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying text.
Definition rtp_engine.h:812
int(* allow_rtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance)
Used to prevent two channels from remotely bridging audio rtp if the channel tech has a reason for pr...
Definition rtp_engine.h:793
enum ast_rtp_glue_result(* get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying video.
Definition rtp_engine.h:799
Options for creating a new RTP instance.
Definition rtp_engine.h:994
unsigned int remote_ssrc
Definition rtp_engine.h:454
unsigned int local_ssrc
Definition rtp_engine.h:452
unsigned int rxoctetcount
Definition rtp_engine.h:460
unsigned int txoctetcount
Definition rtp_engine.h:458
char channel_uniqueid[MAX_CHANNEL_ID]
Definition rtp_engine.h:456
struct ast_rtp_instance * bridged
Definition rtp_engine.c:208
unsigned int sample_rate
Definition rtp_engine.h:318
unsigned int primary_mapping
Definition rtp_engine.h:314
struct ast_format * format
Definition rtp_engine.h:306
struct timeval when_retired
Definition rtp_engine.h:316
A REMB feedback message (see draft-alvestrand-rmcat-remb-03 for details)
Definition rtp_engine.h:380
An object that represents data received in a feedback report.
Definition rtp_engine.h:388
struct ast_rtp_rtcp_feedback_remb remb
Definition rtp_engine.h:391
A report block within a SR/RR report.
Definition rtp_engine.h:346
unsigned int highest_seq_no
Definition rtp_engine.h:352
unsigned short fraction
Definition rtp_engine.h:349
struct ast_rtp_rtcp_report_block::@287 lost_count
An object that represents data sent during a SR/RR RTCP report.
Definition rtp_engine.h:361
struct ast_rtp_rtcp_report::@288 sender_information
unsigned int type
Definition rtp_engine.h:364
unsigned short reception_report_count
Definition rtp_engine.h:362
unsigned int rtp_timestamp
Definition rtp_engine.h:367
struct ast_rtp_rtcp_report_block * report_block[0]
Definition rtp_engine.h:374
struct timeval ntp_timestamp
Definition rtp_engine.h:366
unsigned int octet_count
Definition rtp_engine.h:369
unsigned int ssrc
Definition rtp_engine.h:363
unsigned int packet_count
Definition rtp_engine.h:368
Structure for rwlock and tracking information.
Definition lock.h:164
Socket address structure.
Definition netsock2.h:97
Support for dynamic strings.
Definition strings.h:623
structure to hold extensions
Definition sched.c:76
int value
Definition syslog.c:37
static struct test_options options
Vector container support.
#define AST_VECTOR(name, type)
Define a vector structure.
Definition vector.h:44