Sat Jul 12 2014 17:18:37

Asterisk developer's documentation


rtp_engine.h
Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2009, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  * Joshua Colp <jcolp@digium.com>
00008  *
00009  * See http://www.asterisk.org for more information about
00010  * the Asterisk project. Please do not directly contact
00011  * any of the maintainers of this project for assistance;
00012  * the project provides a web site, mailing lists and IRC
00013  * channels for your use.
00014  *
00015  * This program is free software, distributed under the terms of
00016  * the GNU General Public License Version 2. See the LICENSE file
00017  * at the top of the source tree.
00018  */
00019 
00020 /*! \file
00021  * \brief Pluggable RTP Architecture
00022  * \author Joshua Colp <jcolp@digium.com>
00023  * \ref AstRTPEngine
00024  */
00025 
00026 /*!
00027  * \page AstRTPEngine Asterisk RTP Engine API
00028  *
00029  * The purpose of this API is to provide a way for multiple RTP stacks to be
00030  * used inside of Asterisk without any module that uses RTP knowing any
00031  * different. To the module each RTP stack behaves the same.
00032  *
00033  * An RTP session is called an instance and is made up of a combination of codec
00034  * information, RTP engine, RTP properties, and address information. An engine
00035  * name may be passed in to explicitly choose an RTP stack to be used but a
00036  * default one will be used if none is provided. An address to use for RTP may
00037  * also be provided but the underlying RTP engine may choose a different address
00038  * depending on it's configuration.
00039  *
00040  * An RTP engine is the layer between the RTP engine core and the RTP stack
00041  * itself. The RTP engine core provides a set of callbacks to do various things
00042  * (such as write audio out) that the RTP engine has to have implemented.
00043  *
00044  * Glue is what binds an RTP instance to a channel. It is used to retrieve RTP
00045  * instance information when performing remote or local bridging and is used to
00046  * have the channel driver tell the remote side to change destination of the RTP
00047  * stream.
00048  *
00049  * Statistics from an RTP instance can be retrieved using the
00050  * ast_rtp_instance_get_stats API call. This essentially asks the RTP engine in
00051  * use to fill in a structure with the requested values. It is not required for
00052  * an RTP engine to support all statistic values.
00053  *
00054  * Properties allow behavior of the RTP engine and RTP engine core to be
00055  * changed. For example, there is a property named AST_RTP_PROPERTY_NAT which is
00056  * used to tell the RTP engine to enable symmetric RTP if it supports it. It is
00057  * not required for an RTP engine to support all properties.
00058  *
00059  * Codec information is stored using a separate data structure which has it's
00060  * own set of API calls to add/remove/retrieve information. They are used by the
00061  * module after an RTP instance is created so that payload information is
00062  * available for the RTP engine.
00063  */
00064 
00065 #ifndef _ASTERISK_RTP_ENGINE_H
00066 #define _ASTERISK_RTP_ENGINE_H
00067 
00068 #if defined(__cplusplus) || defined(c_plusplus)
00069 extern "C" {
00070 #endif
00071 
00072 #include "asterisk/astobj2.h"
00073 #include "asterisk/frame.h"
00074 #include "asterisk/netsock2.h"
00075 #include "asterisk/sched.h"
00076 #include "asterisk/res_srtp.h"
00077 
00078 /* Maximum number of payloads supported */
00079 #if defined(LOW_MEMORY)
00080 #define AST_RTP_MAX_PT 128
00081 #else
00082 #define AST_RTP_MAX_PT 196
00083 #endif
00084 
00085 /* Maximum number of generations */
00086 #define AST_RED_MAX_GENERATION 5
00087 
00088 struct ast_rtp_instance;
00089 struct ast_rtp_glue;
00090 
00091 /*! RTP Properties that can be set on an RTP instance */
00092 enum ast_rtp_property {
00093    /*! Enable symmetric RTP support */
00094    AST_RTP_PROPERTY_NAT = 0,
00095    /*! RTP instance will be carrying DTMF (using RFC2833) */
00096    AST_RTP_PROPERTY_DTMF,
00097    /*! Expect unreliable DTMF from remote party */
00098    AST_RTP_PROPERTY_DTMF_COMPENSATE,
00099    /*! Enable STUN support */
00100    AST_RTP_PROPERTY_STUN,
00101    /*! Enable RTCP support */
00102    AST_RTP_PROPERTY_RTCP,
00103 
00104    /*!
00105     * \brief Maximum number of RTP properties supported
00106     *
00107     * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
00108     */
00109    AST_RTP_PROPERTY_MAX,
00110 };
00111 
00112 /*! Additional RTP options */
00113 enum ast_rtp_options {
00114    /*! Remote side is using non-standard G.726 */
00115    AST_RTP_OPT_G726_NONSTANDARD = (1 << 0),
00116 };
00117 
00118 /*! RTP DTMF Modes */
00119 enum ast_rtp_dtmf_mode {
00120    /*! No DTMF is being carried over the RTP stream */
00121    AST_RTP_DTMF_MODE_NONE = 0,
00122    /*! DTMF is being carried out of band using RFC2833 */
00123    AST_RTP_DTMF_MODE_RFC2833,
00124    /*! DTMF is being carried inband over the RTP stream */
00125    AST_RTP_DTMF_MODE_INBAND,
00126 };
00127 
00128 /*! Result codes when RTP glue is queried for information */
00129 enum ast_rtp_glue_result {
00130    /*! No remote or local bridging is permitted */
00131    AST_RTP_GLUE_RESULT_FORBID = 0,
00132    /*! Move RTP stream to be remote between devices directly */
00133    AST_RTP_GLUE_RESULT_REMOTE,
00134    /*! Perform RTP engine level bridging if possible */
00135    AST_RTP_GLUE_RESULT_LOCAL,
00136 };
00137 
00138 /*! Field statistics that can be retrieved from an RTP instance */
00139 enum ast_rtp_instance_stat_field {
00140    /*! Retrieve quality information */
00141    AST_RTP_INSTANCE_STAT_FIELD_QUALITY = 0,
00142    /*! Retrieve quality information about jitter */
00143    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER,
00144    /*! Retrieve quality information about packet loss */
00145    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS,
00146    /*! Retrieve quality information about round trip time */
00147    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT,
00148 };
00149 
00150 /*! Statistics that can be retrieved from an RTP instance */
00151 enum ast_rtp_instance_stat {
00152    /*! Retrieve all statistics */
00153    AST_RTP_INSTANCE_STAT_ALL = 0,
00154    /*! Retrieve number of packets transmitted */
00155    AST_RTP_INSTANCE_STAT_TXCOUNT,
00156    /*! Retrieve number of packets received */
00157    AST_RTP_INSTANCE_STAT_RXCOUNT,
00158    /*! Retrieve ALL statistics relating to packet loss */
00159    AST_RTP_INSTANCE_STAT_COMBINED_LOSS,
00160    /*! Retrieve number of packets lost for transmitting */
00161    AST_RTP_INSTANCE_STAT_TXPLOSS,
00162    /*! Retrieve number of packets lost for receiving */
00163    AST_RTP_INSTANCE_STAT_RXPLOSS,
00164    /*! Retrieve maximum number of packets lost on remote side */
00165    AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS,
00166    /*! Retrieve minimum number of packets lost on remote side */
00167    AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS,
00168    /*! Retrieve average number of packets lost on remote side */
00169    AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS,
00170    /*! Retrieve standard deviation of packets lost on remote side */
00171    AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS,
00172    /*! Retrieve maximum number of packets lost on local side */
00173    AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS,
00174    /*! Retrieve minimum number of packets lost on local side */
00175    AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS,
00176    /*! Retrieve average number of packets lost on local side */
00177    AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS,
00178    /*! Retrieve standard deviation of packets lost on local side */
00179    AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS,
00180    /*! Retrieve ALL statistics relating to jitter */
00181    AST_RTP_INSTANCE_STAT_COMBINED_JITTER,
00182    /*! Retrieve jitter on transmitted packets */
00183    AST_RTP_INSTANCE_STAT_TXJITTER,
00184    /*! Retrieve jitter on received packets */
00185    AST_RTP_INSTANCE_STAT_RXJITTER,
00186    /*! Retrieve maximum jitter on remote side */
00187    AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER,
00188    /*! Retrieve minimum jitter on remote side */
00189    AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER,
00190    /*! Retrieve average jitter on remote side */
00191    AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER,
00192    /*! Retrieve standard deviation jitter on remote side */
00193    AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER,
00194    /*! Retrieve maximum jitter on local side */
00195    AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER,
00196    /*! Retrieve minimum jitter on local side */
00197    AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER,
00198    /*! Retrieve average jitter on local side */
00199    AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER,
00200    /*! Retrieve standard deviation jitter on local side */
00201    AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER,
00202    /*! Retrieve ALL statistics relating to round trip time */
00203    AST_RTP_INSTANCE_STAT_COMBINED_RTT,
00204    /*! Retrieve round trip time */
00205    AST_RTP_INSTANCE_STAT_RTT,
00206    /*! Retrieve maximum round trip time */
00207    AST_RTP_INSTANCE_STAT_MAX_RTT,
00208    /*! Retrieve minimum round trip time */
00209    AST_RTP_INSTANCE_STAT_MIN_RTT,
00210    /*! Retrieve average round trip time */
00211    AST_RTP_INSTANCE_STAT_NORMDEVRTT,
00212    /*! Retrieve standard deviation round trip time */
00213    AST_RTP_INSTANCE_STAT_STDEVRTT,
00214    /*! Retrieve local SSRC */
00215    AST_RTP_INSTANCE_STAT_LOCAL_SSRC,
00216    /*! Retrieve remote SSRC */
00217    AST_RTP_INSTANCE_STAT_REMOTE_SSRC,
00218 };
00219 
00220 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
00221 /*! DTMF (RFC2833) */
00222 #define AST_RTP_DTMF                    (1 << 0)
00223 /*! 'Comfort Noise' (RFC3389) */
00224 #define AST_RTP_CN                      (1 << 1)
00225 /*! DTMF (Cisco Proprietary) */
00226 #define AST_RTP_CISCO_DTMF              (1 << 2)
00227 /*! Maximum RTP-specific code */
00228 #define AST_RTP_MAX                     AST_RTP_CISCO_DTMF
00229 
00230 /*! Structure that represents a payload */
00231 struct ast_rtp_payload_type {
00232    /*! Is this an Asterisk value */
00233    int asterisk_format;
00234    /*! If asterisk_format is set, this is the internal
00235     * asterisk format represented by the payload */
00236    struct ast_format format;
00237    /*! Actual internal RTP specific value of the payload */
00238    int rtp_code;
00239    /*! Actual payload number */
00240    int payload;
00241 };
00242 
00243 /*! Structure that represents statistics from an RTP instance */
00244 struct ast_rtp_instance_stats {
00245    /*! Number of packets transmitted */
00246    unsigned int txcount;
00247    /*! Number of packets received */
00248    unsigned int rxcount;
00249    /*! Jitter on transmitted packets */
00250    double txjitter;
00251    /*! Jitter on received packets */
00252    double rxjitter;
00253    /*! Maximum jitter on remote side */
00254    double remote_maxjitter;
00255    /*! Minimum jitter on remote side */
00256    double remote_minjitter;
00257    /*! Average jitter on remote side */
00258    double remote_normdevjitter;
00259    /*! Standard deviation jitter on remote side */
00260    double remote_stdevjitter;
00261    /*! Maximum jitter on local side */
00262    double local_maxjitter;
00263    /*! Minimum jitter on local side */
00264    double local_minjitter;
00265    /*! Average jitter on local side */
00266    double local_normdevjitter;
00267    /*! Standard deviation jitter on local side */
00268    double local_stdevjitter;
00269    /*! Number of transmitted packets lost */
00270    unsigned int txploss;
00271    /*! Number of received packets lost */
00272    unsigned int rxploss;
00273    /*! Maximum number of packets lost on remote side */
00274    double remote_maxrxploss;
00275    /*! Minimum number of packets lost on remote side */
00276    double remote_minrxploss;
00277    /*! Average number of packets lost on remote side */
00278    double remote_normdevrxploss;
00279    /*! Standard deviation packets lost on remote side */
00280    double remote_stdevrxploss;
00281    /*! Maximum number of packets lost on local side */
00282    double local_maxrxploss;
00283    /*! Minimum number of packets lost on local side */
00284    double local_minrxploss;
00285    /*! Average number of packets lost on local side */
00286    double local_normdevrxploss;
00287    /*! Standard deviation packets lost on local side */
00288    double local_stdevrxploss;
00289    /*! Total round trip time */
00290    double rtt;
00291    /*! Maximum round trip time */
00292    double maxrtt;
00293    /*! Minimum round trip time */
00294    double minrtt;
00295    /*! Average round trip time */
00296    double normdevrtt;
00297    /*! Standard deviation round trip time */
00298    double stdevrtt;
00299    /*! Our SSRC */
00300    unsigned int local_ssrc;
00301    /*! Their SSRC */
00302    unsigned int remote_ssrc;
00303 };
00304 
00305 #define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
00306 if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == current_stat)) { \
00307 placement = value; \
00308 if (stat == current_stat) { \
00309 return 0; \
00310 } \
00311 }
00312 
00313 #define AST_RTP_STAT_TERMINATOR(combined) \
00314 if (stat == combined) { \
00315 return 0; \
00316 }
00317 
00318 /*! \brief ICE candidate types */
00319 enum ast_rtp_ice_candidate_type {
00320    AST_RTP_ICE_CANDIDATE_TYPE_HOST,    /*!< ICE host candidate. A host candidate represents the actual local transport address in the host. */
00321    AST_RTP_ICE_CANDIDATE_TYPE_SRFLX,   /*!< ICE server reflexive candidate, which represents the public mapped address of the local address. */
00322    AST_RTP_ICE_CANDIDATE_TYPE_RELAYED, /*!< ICE relayed candidate, which represents the address allocated in TURN server. */
00323 };
00324 
00325 /*! \brief ICE component types */
00326 enum ast_rtp_ice_component_type {
00327    AST_RTP_ICE_COMPONENT_RTP = 1,
00328    AST_RTP_ICE_COMPONENT_RTCP = 2,
00329 };
00330 
00331 /*! \brief ICE role during negotiation */
00332 enum ast_rtp_ice_role {
00333    AST_RTP_ICE_ROLE_CONTROLLED,
00334    AST_RTP_ICE_ROLE_CONTROLLING,
00335 };
00336 
00337 /*! \brief Structure for an ICE candidate */
00338 struct ast_rtp_engine_ice_candidate {
00339    char *foundation;                     /*!< Foundation identifier */
00340    enum ast_rtp_ice_component_type id;   /*!< Component identifier */
00341    char *transport;                      /*!< Transport for the media */
00342    int priority;                         /*!< Priority which is used if multiple candidates can be used */
00343    struct ast_sockaddr address;          /*!< Address of the candidate */
00344    struct ast_sockaddr relay_address;    /*!< Relay address for the candidate */
00345    enum ast_rtp_ice_candidate_type type; /*!< Type of candidate */
00346 };
00347 
00348 /*! \brief Structure that represents the optional ICE support within an RTP engine */
00349 struct ast_rtp_engine_ice {
00350    /*! Callback for setting received authentication information */
00351    void (*set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password);
00352    /*! Callback for adding a remote candidate */
00353    void (*add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate);
00354    /*! Callback for starting ICE negotiation */
00355    void (*start)(struct ast_rtp_instance *instance);
00356    /*! Callback for stopping ICE support */
00357    void (*stop)(struct ast_rtp_instance *instance);
00358    /*! Callback for getting local username */
00359    const char *(*get_ufrag)(struct ast_rtp_instance *instance);
00360    /*! Callback for getting local password */
00361    const char *(*get_password)(struct ast_rtp_instance *instance);
00362    /*! Callback for getting local candidates */
00363    struct ao2_container *(*get_local_candidates)(struct ast_rtp_instance *instance);
00364    /*! Callback for telling the ICE support that it is talking to an ice-lite implementation */
00365    void (*ice_lite)(struct ast_rtp_instance *instance);
00366    /*! Callback for changing our role in negotiation */
00367    void (*set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role);
00368 };
00369 
00370 /*! \brief DTLS setup types */
00371 enum ast_rtp_dtls_setup {
00372    AST_RTP_DTLS_SETUP_ACTIVE,   /*!< Endpoint is willing to inititate connections */
00373    AST_RTP_DTLS_SETUP_PASSIVE,  /*!< Endpoint is willing to accept connections */
00374    AST_RTP_DTLS_SETUP_ACTPASS,  /*!< Endpoint is willing to both accept and initiate connections */
00375    AST_RTP_DTLS_SETUP_HOLDCONN, /*!< Endpoint does not want the connection to be established right now */
00376 };
00377 
00378 /*! \brief DTLS connection states */
00379 enum ast_rtp_dtls_connection {
00380    AST_RTP_DTLS_CONNECTION_NEW,      /*!< Endpoint wants to use a new connection */
00381    AST_RTP_DTLS_CONNECTION_EXISTING, /*!< Endpoint wishes to use existing connection */
00382 };
00383 
00384 /*! \brief DTLS fingerprint hashes */
00385 enum ast_rtp_dtls_hash {
00386    AST_RTP_DTLS_HASH_SHA256, /*!< SHA-256 fingerprint hash */
00387    AST_RTP_DTLS_HASH_SHA1,   /*!< SHA-1 fingerprint hash */
00388 };
00389 
00390 /*! \brief DTLS verification settings */
00391 enum ast_rtp_dtls_verify {
00392    AST_RTP_DTLS_VERIFY_NONE = 0,               /*!< Don't verify anything */
00393    AST_RTP_DTLS_VERIFY_FINGERPRINT = (1 << 0), /*!< Verify the fingerprint */
00394    AST_RTP_DTLS_VERIFY_CERTIFICATE = (1 << 1), /*!< Verify the certificate */
00395 };
00396 
00397 /*! \brief DTLS configuration structure */
00398 struct ast_rtp_dtls_cfg {
00399    unsigned int enabled:1;                /*!< Whether DTLS support is enabled or not */
00400    unsigned int rekey;                    /*!< Interval at which to renegotiate and rekey - defaults to 0 (off) */
00401    enum ast_rtp_dtls_setup default_setup; /*!< Default setup type to use for outgoing */
00402    enum ast_srtp_suite suite;             /*!< Crypto suite in use */
00403    enum ast_rtp_dtls_hash hash;        /*!< Hash to use for fingerprint */
00404    enum ast_rtp_dtls_verify verify;    /*!< What should be verified */
00405    char *certfile;                        /*!< Certificate file */
00406    char *pvtfile;                         /*!< Private key file */
00407    char *cipher;                          /*!< Cipher to use */
00408    char *cafile;                          /*!< Certificate authority file */
00409    char *capath;                          /*!< Path to certificate authority */
00410 };
00411 
00412 /*! \brief Structure that represents the optional DTLS SRTP support within an RTP engine */
00413 struct ast_rtp_engine_dtls {
00414    /*! Set the configuration of the DTLS support on the instance */
00415    int (*set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg);
00416    /*! Get if the DTLS SRTP support is active or not */
00417    int (*active)(struct ast_rtp_instance *instance);
00418    /*! Stop and terminate DTLS SRTP support */
00419    void (*stop)(struct ast_rtp_instance *instance);
00420    /*! Reset the connection and start fresh */
00421    void (*reset)(struct ast_rtp_instance *instance);
00422    /*! Get the current connection state */
00423    enum ast_rtp_dtls_connection (*get_connection)(struct ast_rtp_instance *instance);
00424    /*! Get the current setup state */
00425    enum ast_rtp_dtls_setup (*get_setup)(struct ast_rtp_instance *instance);
00426    /*! Set the remote setup state */
00427    void (*set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup);
00428    /*! Set the remote fingerprint */
00429    void (*set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint);
00430    /*! Get the local fingerprint hash type */
00431    enum ast_rtp_dtls_hash (*get_fingerprint_hash)(struct ast_rtp_instance *instance);
00432    /*! Get the local fingerprint */
00433    const char *(*get_fingerprint)(struct ast_rtp_instance *instance);
00434 };
00435 
00436 /*! Structure that represents an RTP stack (engine) */
00437 struct ast_rtp_engine {
00438    /*! Name of the RTP engine, used when explicitly requested */
00439    const char *name;
00440    /*! Module this RTP engine came from, used for reference counting */
00441    struct ast_module *mod;
00442    /*! Callback for setting up a new RTP instance */
00443    int (*new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data);
00444    /*! Callback for destroying an RTP instance */
00445    int (*destroy)(struct ast_rtp_instance *instance);
00446    /*! Callback for writing out a frame */
00447    int (*write)(struct ast_rtp_instance *instance, struct ast_frame *frame);
00448    /*! Callback for stopping the RTP instance */
00449    void (*stop)(struct ast_rtp_instance *instance);
00450    /*! Callback for starting RFC2833 DTMF transmission */
00451    int (*dtmf_begin)(struct ast_rtp_instance *instance, char digit);
00452    /*! Callback for stopping RFC2833 DTMF transmission */
00453    int (*dtmf_end)(struct ast_rtp_instance *instance, char digit);
00454    int (*dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration);
00455    /*! Callback to indicate that we should update the marker bit */
00456    void (*update_source)(struct ast_rtp_instance *instance);
00457    /*! Callback to indicate that we should update the marker bit and ssrc */
00458    void (*change_source)(struct ast_rtp_instance *instance);
00459    /*! Callback for setting an extended RTP property */
00460    int (*extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value);
00461    /*! Callback for getting an extended RTP property */
00462    void *(*extended_prop_get)(struct ast_rtp_instance *instance, int property);
00463    /*! Callback for setting an RTP property */
00464    void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
00465    /*! Callback for setting a payload.  If asterisk  is to be used, asterisk_format will be set, otherwise value in code is used. */
00466    void (*payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code);
00467    /*! Callback for setting packetization preferences */
00468    void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
00469    /*! Callback for setting the remote address that RTP is to be sent to */
00470    void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
00471    /*! Callback for setting an alternate remote address */
00472    void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
00473    /*! Callback for changing DTMF mode */
00474    int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
00475    /*! Callback for getting DTMF mode */
00476    enum ast_rtp_dtmf_mode (*dtmf_mode_get)(struct ast_rtp_instance *instance);
00477    /*! Callback for retrieving statistics */
00478    int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
00479    /*! Callback for setting QoS values */
00480    int (*qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
00481    /*! Callback for retrieving a file descriptor to poll on, not always required */
00482    int (*fd)(struct ast_rtp_instance *instance, int rtcp);
00483    /*! Callback for initializing RED support */
00484    int (*red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
00485    /*! Callback for buffering a frame using RED */
00486    int (*red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame);
00487    /*! Callback for reading a frame from the RTP engine */
00488    struct ast_frame *(*read)(struct ast_rtp_instance *instance, int rtcp);
00489    /*! Callback to locally bridge two RTP instances */
00490    int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
00491    /*! Callback to set the read format */
00492    int (*set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format);
00493    /*! Callback to set the write format */
00494    int (*set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format);
00495    /*! Callback to make two instances compatible */
00496    int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
00497    /*! Callback to see if two instances are compatible with DTMF */
00498    int (*dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
00499    /*! Callback to indicate that packets will now flow */
00500    int (*activate)(struct ast_rtp_instance *instance);
00501    /*! Callback to request that the RTP engine send a STUN BIND request */
00502    void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
00503    /*! Callback to get the transcodeable formats supported. result returned in ast_format_cap *result */
00504    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);
00505    /*! Callback to send CNG */
00506    int (*sendcng)(struct ast_rtp_instance *instance, int level);
00507    /*! Callback to pointer for optional ICE support */
00508    struct ast_rtp_engine_ice *ice;
00509    /*! Callback to pointer for optional DTLS SRTP support */
00510    struct ast_rtp_engine_dtls *dtls;
00511    /*! Linked list information */
00512    AST_RWLIST_ENTRY(ast_rtp_engine) entry;
00513 };
00514 
00515 /*! Structure that represents codec and packetization information */
00516 struct ast_rtp_codecs {
00517    /*! Payloads present */
00518    struct ao2_container *payloads;
00519    /*! Codec packetization preferences */
00520    struct ast_codec_pref pref;
00521 };
00522 
00523 /*! Structure that represents the glue that binds an RTP instance to a channel */
00524 struct ast_rtp_glue {
00525    /*! Name of the channel driver that this glue is responsible for */
00526    const char *type;
00527    /*! Module that the RTP glue came from */
00528    struct ast_module *mod;
00529    /*!
00530     * \brief Callback for retrieving the RTP instance carrying audio
00531     * \note This function increases the reference count on the returned RTP instance.
00532     */
00533    enum ast_rtp_glue_result (*get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
00534    /*!
00535     * \brief Used to prevent two channels from remotely bridging audio rtp if the channel tech has a
00536     *        reason for prohibiting it based on qualities that need to be compared from both channels.
00537     * \note This function should only be called with two channels of the same technology
00538     * \note This function may be NULL for a given channel driver. This should be accounted for and if that is the case, function this is not used.
00539     */
00540    int (*allow_rtp_remote)(struct ast_channel *chan1, struct ast_channel *chan2);
00541    /*!
00542     * \brief Callback for retrieving the RTP instance carrying video
00543     * \note This function increases the reference count on the returned RTP instance.
00544     */
00545    enum ast_rtp_glue_result (*get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
00546    /*!
00547     * \brief Used to prevent two channels from remotely bridging video rtp if the channel tech has a
00548     *        reason for prohibiting it based on qualities that need to be compared from both channels.
00549     * \note This function should only be called with two channels of the same technology
00550     * \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.
00551     */
00552    int (*allow_vrtp_remote)(struct ast_channel *chan1, struct ast_channel *chan2);
00553 
00554    /*!
00555     * \brief Callback for retrieving the RTP instance carrying text
00556     * \note This function increases the reference count on the returned RTP instance.
00557     */
00558    enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
00559    /*! Callback for updating the destination that the remote side should send RTP to */
00560    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);
00561    /*! Callback for retrieving codecs that the channel can do.  Result returned in result_cap.
00562     * \note The channel chan will be locked during this call.
00563     */
00564    void (*get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap);
00565    /*! Linked list information */
00566    AST_RWLIST_ENTRY(ast_rtp_glue) entry;
00567 };
00568 
00569 #define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self)
00570 
00571 /*!
00572  * \brief Register an RTP engine
00573  *
00574  * \param engine Structure of the RTP engine to register
00575  * \param module Module that the RTP engine is part of
00576  *
00577  * \retval 0 success
00578  * \retval -1 failure
00579  *
00580  * Example usage:
00581  *
00582  * \code
00583  * ast_rtp_engine_register2(&example_rtp_engine, NULL);
00584  * \endcode
00585  *
00586  * This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not
00587  * associate a module with it.
00588  *
00589  * \note It is recommended that you use the ast_rtp_engine_register macro so that the module is
00590  *       associated with the RTP engine and use counting is performed.
00591  *
00592  * \since 1.8
00593  */
00594 int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module);
00595 
00596 /*!
00597  * \brief Unregister an RTP engine
00598  *
00599  * \param engine Structure of the RTP engine to unregister
00600  *
00601  * \retval 0 success
00602  * \retval -1 failure
00603  *
00604  * Example usage:
00605  *
00606  * \code
00607  * ast_rtp_engine_unregister(&example_rtp_engine);
00608  * \endcode
00609  *
00610  * This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module
00611  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
00612  *
00613  * \since 1.8
00614  */
00615 int ast_rtp_engine_unregister(struct ast_rtp_engine *engine);
00616 
00617 int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res);
00618 
00619 void ast_rtp_engine_unregister_srtp(void);
00620 int ast_rtp_engine_srtp_is_registered(void);
00621 
00622 #define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self)
00623 
00624 /*!
00625  * \brief Register RTP glue
00626  *
00627  * \param glue The glue to register
00628  * \param module Module that the RTP glue is part of
00629  *
00630  * \retval 0 success
00631  * \retval -1 failure
00632  *
00633  * Example usage:
00634  *
00635  * \code
00636  * ast_rtp_glue_register2(&example_rtp_glue, NULL);
00637  * \endcode
00638  *
00639  * This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not
00640  * associate a module with it.
00641  *
00642  * \note It is recommended that you use the ast_rtp_glue_register macro so that the module is
00643  *       associated with the RTP glue and use counting is performed.
00644  *
00645  * \since 1.8
00646  */
00647 int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module);
00648 
00649 /*!
00650  * \brief Unregister RTP glue
00651  *
00652  * \param glue The glue to unregister
00653  *
00654  * \retval 0 success
00655  * \retval -1 failure
00656  *
00657  * Example usage:
00658  *
00659  * \code
00660  * ast_rtp_glue_unregister(&example_rtp_glue);
00661  * \endcode
00662  *
00663  * This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module
00664  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
00665  *
00666  * \since 1.8
00667  */
00668 int ast_rtp_glue_unregister(struct ast_rtp_glue *glue);
00669 
00670 /*!
00671  * \brief Create a new RTP instance
00672  *
00673  * \param engine_name Name of the engine to use for the RTP instance
00674  * \param sched Scheduler context that the RTP engine may want to use
00675  * \param sa Address we want to bind to
00676  * \param data Unique data for the engine
00677  *
00678  * \retval non-NULL success
00679  * \retval NULL failure
00680  *
00681  * Example usage:
00682  *
00683  * \code
00684  * struct ast_rtp_instance *instance = NULL;
00685  * instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);
00686  * \endcode
00687  *
00688  * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given
00689  * in the address structure.
00690  *
00691  * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use
00692  *       another depending on it's own configuration.
00693  *
00694  * \since 1.8
00695  */
00696 struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
00697                 struct ast_sched_context *sched, const struct ast_sockaddr *sa,
00698                 void *data);
00699 
00700 /*!
00701  * \brief Destroy an RTP instance
00702  *
00703  * \param instance The RTP instance to destroy
00704  *
00705  * \retval 0 success
00706  * \retval -1 failure
00707  *
00708  * Example usage:
00709  *
00710  * \code
00711  * ast_rtp_instance_destroy(instance);
00712  * \endcode
00713  *
00714  * This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid
00715  * memory and may not be used again.
00716  *
00717  * \since 1.8
00718  */
00719 int ast_rtp_instance_destroy(struct ast_rtp_instance *instance);
00720 
00721 /*!
00722  * \brief Set the data portion of an RTP instance
00723  *
00724  * \param instance The RTP instance to manipulate
00725  * \param data Pointer to data
00726  *
00727  * Example usage:
00728  *
00729  * \code
00730  * ast_rtp_instance_set_data(instance, blob);
00731  * \endcode
00732  *
00733  * This sets the data pointer on the RTP instance pointed to by 'instance' to
00734  * blob.
00735  *
00736  * \since 1.8
00737  */
00738 void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data);
00739 
00740 /*!
00741  * \brief Get the data portion of an RTP instance
00742  *
00743  * \param instance The RTP instance we want the data portion from
00744  *
00745  * Example usage:
00746  *
00747  * \code
00748  * struct *blob = ast_rtp_instance_get_data(instance);
00749  ( \endcode
00750  *
00751  * This gets the data pointer on the RTP instance pointed to by 'instance'.
00752  *
00753  * \since 1.8
00754  */
00755 void *ast_rtp_instance_get_data(struct ast_rtp_instance *instance);
00756 
00757 /*!
00758  * \brief Send a frame out over RTP
00759  *
00760  * \param instance The RTP instance to send frame out on
00761  * \param frame the frame to send out
00762  *
00763  * \retval 0 success
00764  * \retval -1 failure
00765  *
00766  * Example usage:
00767  *
00768  * \code
00769  * ast_rtp_instance_write(instance, frame);
00770  * \endcode
00771  *
00772  * This gives the frame pointed to by frame to the RTP engine being used for the instance
00773  * and asks that it be transmitted to the current remote address set on the RTP instance.
00774  *
00775  * \since 1.8
00776  */
00777 int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
00778 
00779 /*!
00780  * \brief Receive a frame over RTP
00781  *
00782  * \param instance The RTP instance to receive frame on
00783  * \param rtcp Whether to read in RTCP or not
00784  *
00785  * \retval non-NULL success
00786  * \retval NULL failure
00787  *
00788  * Example usage:
00789  *
00790  * \code
00791  * struct ast_frame *frame;
00792  * frame = ast_rtp_instance_read(instance, 0);
00793  * \endcode
00794  *
00795  * This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.
00796  *
00797  * \since 1.8
00798  */
00799 struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp);
00800 
00801 /*!
00802  * \brief Set the address of the remote endpoint that we are sending RTP to
00803  *
00804  * \param instance The RTP instance to change the address on
00805  * \param address Address to set it to
00806  *
00807  * \retval 0 success
00808  * \retval -1 failure
00809  *
00810  * Example usage:
00811  *
00812  * \code
00813  * ast_rtp_instance_set_remote_address(instance, &sin);
00814  * \endcode
00815  *
00816  * This changes the remote address that RTP will be sent to on instance to the address given in the sin
00817  * structure.
00818  *
00819  * \since 1.8
00820  */
00821 int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
00822 
00823 
00824 /*!
00825  * \brief Set the address of an an alternate RTP address to receive from
00826  *
00827  * \param instance The RTP instance to change the address on
00828  * \param address Address to set it to
00829  *
00830  * \retval 0 success
00831  * \retval -1 failure
00832  *
00833  * Example usage:
00834  *
00835  * \code
00836  * ast_rtp_instance_set_alt_remote_address(instance, &address);
00837  * \endcode
00838  *
00839  * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin
00840  * structure.
00841  *
00842  * \since 1.8
00843  */
00844 int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
00845 
00846 /*!
00847  * \brief Set the address that we are expecting to receive RTP on
00848  *
00849  * \param instance The RTP instance to change the address on
00850  * \param address Address to set it to
00851  *
00852  * \retval 0 success
00853  * \retval -1 failure
00854  *
00855  * Example usage:
00856  *
00857  * \code
00858  * ast_rtp_instance_set_local_address(instance, &sin);
00859  * \endcode
00860  *
00861  * This changes the local address that RTP is expected on to the address given in the sin
00862  * structure.
00863  *
00864  * \since 1.8
00865  */
00866 int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance,
00867                 const struct ast_sockaddr *address);
00868 
00869 /*!
00870  * \brief Get the local address that we are expecting RTP on
00871  *
00872  * \param instance The RTP instance to get the address from
00873  * \param address The variable to store the address in
00874  *
00875  * Example usage:
00876  *
00877  * \code
00878  * struct ast_sockaddr address;
00879  * ast_rtp_instance_get_local_address(instance, &address);
00880  * \endcode
00881  *
00882  * This gets the local address that we are expecting RTP on and stores it in the 'address' structure.
00883  *
00884  * \since 1.8
00885  */
00886 void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
00887 
00888 /*!
00889  * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
00890  *
00891  * \param instance The instance that we want to get the local address for
00892  * \param address An initialized address that may be overwritten if the local address is different
00893  *
00894  * \retval 0 address was not changed
00895  * \retval 1 address was changed
00896  * Example usage:
00897  *
00898  * \code
00899  * struct ast_sockaddr address;
00900  * int ret;
00901  * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
00902  * \endcode
00903  *
00904  * This retrieves the current local address set on the instance pointed to by instance and puts the value
00905  * into the address structure.
00906  *
00907  * \since 1.8
00908  */
00909 int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
00910 
00911 /*!
00912  * \brief Get the address of the remote endpoint that we are sending RTP to
00913  *
00914  * \param instance The instance that we want to get the remote address for
00915  * \param address A structure to put the address into
00916  *
00917  * Example usage:
00918  *
00919  * \code
00920  * struct ast_sockaddr address;
00921  * ast_rtp_instance_get_remote_address(instance, &address);
00922  * \endcode
00923  *
00924  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
00925  * into the address structure.
00926  *
00927  * \since 1.8
00928  */
00929 void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
00930 
00931 /*!
00932  * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
00933  *
00934  * \param instance The instance that we want to get the remote address for
00935  * \param address An initialized address that may be overwritten if the remote address is different
00936  *
00937  * \retval 0 address was not changed
00938  * \retval 1 address was changed
00939  * Example usage:
00940  *
00941  * \code
00942  * struct ast_sockaddr address;
00943  * int ret;
00944  * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
00945  * \endcode
00946  *
00947  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
00948  * into the address structure.
00949  *
00950  * \since 1.8
00951  */
00952 
00953 int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
00954 
00955 /*!
00956  * \brief Set the value of an RTP instance extended property
00957  *
00958  * \param instance The RTP instance to set the extended property on
00959  * \param property The extended property to set
00960  * \param value The value to set the extended property to
00961  *
00962  * \since 1.8
00963  */
00964 void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value);
00965 
00966 /*!
00967  * \brief Get the value of an RTP instance extended property
00968  *
00969  * \param instance The RTP instance to get the extended property on
00970  * \param property The extended property to get
00971  *
00972  * \since 1.8
00973  */
00974 void *ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property);
00975 
00976 /*!
00977  * \brief Set the value of an RTP instance property
00978  *
00979  * \param instance The RTP instance to set the property on
00980  * \param property The property to modify
00981  * \param value The value to set the property to
00982  *
00983  * Example usage:
00984  *
00985  * \code
00986  * ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1);
00987  * \endcode
00988  *
00989  * This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.
00990  *
00991  * \since 1.8
00992  */
00993 void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
00994 
00995 /*!
00996  * \brief Get the value of an RTP instance property
00997  *
00998  * \param instance The RTP instance to get the property from
00999  * \param property The property to get
01000  *
01001  * \retval Current value of the property
01002  *
01003  * Example usage:
01004  *
01005  * \code
01006  * ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT);
01007  * \endcode
01008  *
01009  * This returns the current value of the NAT property on the instance pointed to by instance.
01010  *
01011  * \since 1.8
01012  */
01013 int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property);
01014 
01015 /*!
01016  * \brief Get the codecs structure of an RTP instance
01017  *
01018  * \param instance The RTP instance to get the codecs structure from
01019  *
01020  * Example usage:
01021  *
01022  * \code
01023  * struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance);
01024  * \endcode
01025  *
01026  * This gets the codecs structure on the RTP instance pointed to by 'instance'.
01027  *
01028  * \since 1.8
01029  */
01030 struct ast_rtp_codecs *ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance);
01031 
01032 /*!
01033  * \brief Initialize an RTP codecs structure
01034  *
01035  * \param codecs The codecs structure to initialize
01036  *
01037  * \retval 0 success
01038  * \retval -1 failure
01039  *
01040  * Example usage:
01041  *
01042  * \code
01043  * struct ast_rtp_codecs codecs;
01044  * ast_rtp_codecs_payloads_initialize(&codecs);
01045  * \endcode
01046  *
01047  * \since 11
01048  */
01049 int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs);
01050 
01051 /*!
01052  * \brief Destroy the contents of an RTP codecs structure (but not the structure itself)
01053  *
01054  * \param codecs The codecs structure to destroy the contents of
01055  *
01056  * Example usage:
01057  *
01058  * \code
01059  * struct ast_rtp_codecs codecs;
01060  * ast_rtp_codecs_payloads_destroy(&codecs);
01061  * \endcode
01062  *
01063  * \since 11
01064  */
01065 void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs);
01066 
01067 /*!
01068  * \brief Clear payload information from an RTP instance
01069  *
01070  * \param codecs The codecs structure that payloads will be cleared from
01071  * \param instance Optionally the instance that the codecs structure belongs to
01072  *
01073  * Example usage:
01074  *
01075  * \code
01076  * struct ast_rtp_codecs codecs;
01077  * ast_rtp_codecs_payloads_clear(&codecs, NULL);
01078  * \endcode
01079  *
01080  * This clears the codecs structure and puts it into a pristine state.
01081  *
01082  * \since 1.8
01083  */
01084 void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance);
01085 
01086 /*!
01087  * \brief Set payload information on an RTP instance to the default
01088  *
01089  * \param codecs The codecs structure to set defaults on
01090  * \param instance Optionally the instance that the codecs structure belongs to
01091  *
01092  * Example usage:
01093  *
01094  * \code
01095  * struct ast_rtp_codecs codecs;
01096  * ast_rtp_codecs_payloads_default(&codecs, NULL);
01097  * \endcode
01098  *
01099  * This sets the default payloads on the codecs structure.
01100  *
01101  * \since 1.8
01102  */
01103 void ast_rtp_codecs_payloads_default(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance);
01104 
01105 /*!
01106  * \brief Copy payload information from one RTP instance to another
01107  *
01108  * \param src The source codecs structure
01109  * \param dest The destination codecs structure that the values from src will be copied to
01110  * \param instance Optionally the instance that the dst codecs structure belongs to
01111  *
01112  * Example usage:
01113  *
01114  * \code
01115  * ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);
01116  * \endcode
01117  *
01118  * This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.
01119  *
01120  * \since 1.8
01121  */
01122 void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
01123 
01124 /*!
01125  * \brief Record payload information that was seen in an m= SDP line
01126  *
01127  * \param codecs The codecs structure to muck with
01128  * \param instance Optionally the instance that the codecs structure belongs to
01129  * \param payload Numerical payload that was seen in the m= SDP line
01130  *
01131  * Example usage:
01132  *
01133  * \code
01134  * ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0);
01135  * \endcode
01136  *
01137  * This records that the numerical payload '0' was seen in the codecs structure.
01138  *
01139  * \since 1.8
01140  */
01141 void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
01142 
01143 /*!
01144  * \brief Record payload information that was seen in an a=rtpmap: SDP line
01145  *
01146  * \param codecs The codecs structure to muck with
01147  * \param instance Optionally the instance that the codecs structure belongs to
01148  * \param payload Numerical payload that was seen in the a=rtpmap: SDP line
01149  * \param mimetype The string mime type that was seen
01150  * \param mimesubtype The strin mime sub type that was seen
01151  * \param options Optional options that may change the behavior of this specific payload
01152  *
01153  * \retval 0 success
01154  * \retval -1 failure, invalid payload numbe
01155  * \retval -2 failure, unknown mimetype
01156  *
01157  * Example usage:
01158  *
01159  * \code
01160  * ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);
01161  * \endcode
01162  *
01163  * This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.
01164  *
01165  * \since 1.8
01166  */
01167 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);
01168 
01169 /*!
01170  * \brief Set payload type to a known MIME media type for a codec with a specific sample rate
01171  *
01172  * \param codecs RTP structure to modify
01173  * \param instance Optionally the instance that the codecs structure belongs to
01174  * \param pt Payload type entry to modify
01175  * \param mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.)
01176  * \param mimesubtype MIME subtype of media stream (typically a codec name)
01177  * \param options Zero or more flags from the ast_rtp_options enum
01178  * \param sample_rate The sample rate of the media stream
01179  *
01180  * This function 'fills in' an entry in the list of possible formats for
01181  * a media stream associated with an RTP structure.
01182  *
01183  * \retval 0 on success
01184  * \retval -1 if the payload type is out of range
01185  * \retval -2 if the mimeType/mimeSubtype combination was not found
01186  *
01187  * \since 1.8
01188  */
01189 int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt,
01190               char *mimetype, char *mimesubtype,
01191               enum ast_rtp_options options,
01192               unsigned int sample_rate);
01193 
01194 /*!
01195  * \brief Remove payload information
01196  *
01197  * \param codecs The codecs structure to muck with
01198  * \param instance Optionally the instance that the codecs structure belongs to
01199  * \param payload Numerical payload to unset
01200  *
01201  * Example usage:
01202  *
01203  * \code
01204  * ast_rtp_codecs_payloads_unset(&codecs, NULL, 0);
01205  * \endcode
01206  *
01207  * This clears the payload '0' from the codecs structure. It will be as if it was never set.
01208  *
01209  * \since 1.8
01210  */
01211 void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
01212 
01213 /*!
01214  * \brief Retrieve payload information by payload
01215  *
01216  * \param codecs Codecs structure to look in
01217  * \param payload Numerical payload to look up
01218  *
01219  * \retval Payload information
01220  *
01221  * Example usage:
01222  *
01223  * \code
01224  * struct ast_rtp_payload_type payload_type;
01225  * payload_type = ast_rtp_codecs_payload_lookup(&codecs, 0);
01226  * \endcode
01227  *
01228  * This looks up the information for payload '0' from the codecs structure.
01229  *
01230  * \since 1.8
01231  */
01232 struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload);
01233 
01234 /*!
01235  * \brief Retrieve the actual ast_format stored on the codecs structure for a specific payload
01236  *
01237  * \param codecs Codecs structure to look in
01238  * \param payload Numerical payload to look up
01239  *
01240  * \retval pointer to format structure on success
01241  * \retval NULL on failure
01242  *
01243  * \since 10.0
01244  */
01245 struct ast_format *ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload);
01246 
01247 /*!
01248  * \brief Get the sample rate associated with known RTP payload types
01249  *
01250  * \param asterisk_format True if the value in format is to be used.
01251  * \param An asterisk format
01252  * \param code from AST_RTP list
01253  *
01254  * \return the sample rate if the format was found, zero if it was not found
01255  *
01256  * \since 1.8
01257  */
01258 unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, struct ast_format *format, int code);
01259 
01260 /*!
01261  * \brief Retrieve all formats that were found
01262  *
01263  * \param codecs Codecs structure to look in
01264  * \param astformats A capabilities structure to put the Asterisk formats in.
01265  * \param nonastformats An integer to put the non-Asterisk formats in
01266  *
01267  * Example usage:
01268  *
01269  * \code
01270  * struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
01271  * int nonastformats;
01272  * ast_rtp_codecs_payload_formats(&codecs, &astformats, &nonastformats);
01273  * \endcode
01274  *
01275  * This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer
01276  * pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.
01277  *
01278  * \since 1.8
01279  */
01280 void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats);
01281 
01282 /*!
01283  * \brief Retrieve a payload based on whether it is an Asterisk format and the code
01284  *
01285  * \param codecs Codecs structure to look in
01286  * \param asterisk_format Non-zero if the given Asterisk format is present
01287  * \param format Asterisk format to look for
01288  * \param code The format to look for
01289  *
01290  * \retval Numerical payload
01291  *
01292  * Example usage:
01293  *
01294  * \code
01295  * int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0);
01296  * \endcode
01297  *
01298  * This looks for the numerical payload for ULAW in the codecs structure.
01299  *
01300  * \since 1.8
01301  */
01302 int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code);
01303 /*!
01304  * \brief Search for a payload code in the ast_rtp_codecs structure
01305  *
01306  * \param codecs Codecs structure to look in
01307  * \param code The format to look for
01308  *
01309  * \retval Numerical payload or -1 if unable to find payload in codecs
01310  *
01311  * Example usage:
01312  *
01313  * \code
01314  * int payload = ast_rtp_codecs_payload_code(&codecs, 0);
01315  * \endcode
01316  *
01317  * This looks for the numerical payload for ULAW in the codecs structure.
01318  *
01319  */
01320 int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int code);
01321 
01322 /*!
01323  * \brief Retrieve mime subtype information on a payload
01324  *
01325  * \param asterisk_format Non-zero to look up using Asterisk format
01326  * \param format Asterisk format to look up
01327  * \param code RTP code to look up
01328  * \param options Additional options that may change the result
01329  *
01330  * \retval Mime subtype success
01331  * \retval NULL failure
01332  *
01333  * Example usage:
01334  *
01335  * \code
01336  * const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0);
01337  * \endcode
01338  *
01339  * This looks up the mime subtype for the ULAW format.
01340  *
01341  * \since 1.8
01342  */
01343 const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options);
01344 
01345 /*!
01346  * \brief Convert formats into a string and put them into a buffer
01347  *
01348  * \param buf Buffer to put the mime output into
01349  * \param ast_format_capability Asterisk Formats we are looking up.
01350  * \param rtp_capability RTP codes that we are looking up
01351  * \param asterisk_format Non-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used
01352  * \param options Additional options that may change the result
01353  *
01354  * \retval non-NULL success
01355  * \retval NULL failure
01356  *
01357  * Example usage:
01358  *
01359  * \code
01360  * char buf[256] = "";
01361  * struct ast_format tmp_fmt;
01362  * struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
01363  * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
01364  * ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
01365  * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
01366  * ast_format_cap_destroy(cap);
01367  * \endcode
01368  *
01369  * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
01370  *
01371  * \since 1.8
01372  */
01373 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);
01374 
01375 /*!
01376  * \brief Set codec packetization preferences
01377  *
01378  * \param codecs Codecs structure to muck with
01379  * \param instance Optionally the instance that the codecs structure belongs to
01380  * \param prefs Codec packetization preferences
01381  *
01382  * Example usage:
01383  *
01384  * \code
01385  * ast_rtp_codecs_packetization_set(&codecs, NULL, &prefs);
01386  * \endcode
01387  *
01388  * This sets the packetization preferences pointed to by prefs on the codecs structure pointed to by codecs.
01389  *
01390  * \since 1.8
01391  */
01392 void ast_rtp_codecs_packetization_set(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs);
01393 
01394 /*!
01395  * \brief Begin sending a DTMF digit
01396  *
01397  * \param instance The RTP instance to send the DTMF on
01398  * \param digit What DTMF digit to send
01399  *
01400  * \retval 0 success
01401  * \retval -1 failure
01402  *
01403  * Example usage:
01404  *
01405  * \code
01406  * ast_rtp_instance_dtmf_begin(instance, '1');
01407  * \endcode
01408  *
01409  * This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will
01410  * continue being sent until it is ended.
01411  *
01412  * \since 1.8
01413  */
01414 int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit);
01415 
01416 /*!
01417  * \brief Stop sending a DTMF digit
01418  *
01419  * \param instance The RTP instance to stop the DTMF on
01420  * \param digit What DTMF digit to stop
01421  *
01422  * \retval 0 success
01423  * \retval -1 failure
01424  *
01425  * Example usage:
01426  *
01427  * \code
01428  * ast_rtp_instance_dtmf_end(instance, '1');
01429  * \endcode
01430  *
01431  * This stops sending the DTMF '1' on the RTP instance pointed to by instance.
01432  *
01433  * \since 1.8
01434  */
01435 int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit);
01436 int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration);
01437 
01438 /*!
01439  * \brief Set the DTMF mode that should be used
01440  *
01441  * \param instance the RTP instance to set DTMF mode on
01442  * \param dtmf_mode The DTMF mode that is in use
01443  *
01444  * \retval 0 success
01445  * \retval -1 failure
01446  *
01447  * Example usage:
01448  *
01449  * \code
01450  * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833);
01451  * \endcode
01452  *
01453  * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
01454  *
01455  * \since 1.8
01456  */
01457 int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
01458 
01459 /*!
01460  * \brief Get the DTMF mode of an RTP instance
01461  *
01462  * \param instance The RTP instance to get the DTMF mode of
01463  *
01464  * \retval DTMF mode
01465  *
01466  * Example usage:
01467  *
01468  * \code
01469  * enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance);
01470  * \endcode
01471  *
01472  * This gets the DTMF mode set on the RTP instance pointed to by 'instance'.
01473  *
01474  * \since 1.8
01475  */
01476 enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance);
01477 
01478 /*!
01479  * \brief Indicate that the RTP marker bit should be set on an RTP stream
01480  *
01481  * \param instance Instance that the new media source is feeding into
01482  *
01483  * Example usage:
01484  *
01485  * \code
01486  * ast_rtp_instance_update_source(instance);
01487  * \endcode
01488  *
01489  * This indicates that the source of media that is feeding the instance pointed to by
01490  * instance has been updated and that the marker bit should be set.
01491  *
01492  * \since 1.8
01493  */
01494 void ast_rtp_instance_update_source(struct ast_rtp_instance *instance);
01495 
01496 /*!
01497  * \brief Indicate a new source of audio has dropped in and the ssrc should change
01498  *
01499  * \param instance Instance that the new media source is feeding into
01500  *
01501  * Example usage:
01502  *
01503  * \code
01504  * ast_rtp_instance_change_source(instance);
01505  * \endcode
01506  *
01507  * This indicates that the source of media that is feeding the instance pointed to by
01508  * instance has changed and that the marker bit should be set and the SSRC updated.
01509  *
01510  * \since 1.8
01511  */
01512 void ast_rtp_instance_change_source(struct ast_rtp_instance *instance);
01513 
01514 /*!
01515  * \brief Set QoS parameters on an RTP session
01516  *
01517  * \param instance Instance to set the QoS parameters on
01518  * \param tos Terms of service value
01519  * \param cos Class of service value
01520  * \param desc What is setting the QoS values
01521  *
01522  * \retval 0 success
01523  * \retval -1 failure
01524  *
01525  * Example usage:
01526  *
01527  * \code
01528  * ast_rtp_instance_set_qos(instance, 0, 0, "Example");
01529  * \endcode
01530  *
01531  * This sets the TOS and COS values to 0 on the instance pointed to by instance.
01532  *
01533  * \since 1.8
01534  */
01535 int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
01536 
01537 /*!
01538  * \brief Stop an RTP instance
01539  *
01540  * \param instance Instance that media is no longer going to at this time
01541  *
01542  * Example usage:
01543  *
01544  * \code
01545  * ast_rtp_instance_stop(instance);
01546  * \endcode
01547  *
01548  * This tells the RTP engine being used for the instance pointed to by instance
01549  * that media is no longer going to it at this time, but may in the future.
01550  *
01551  * \since 1.8
01552  */
01553 void ast_rtp_instance_stop(struct ast_rtp_instance *instance);
01554 
01555 /*!
01556  * \brief Get the file descriptor for an RTP session (or RTCP)
01557  *
01558  * \param instance Instance to get the file descriptor for
01559  * \param rtcp Whether to retrieve the file descriptor for RTCP or not
01560  *
01561  * \retval fd success
01562  * \retval -1 failure
01563  *
01564  * Example usage:
01565  *
01566  * \code
01567  * int rtp_fd = ast_rtp_instance_fd(instance, 0);
01568  * \endcode
01569  *
01570  * This retrieves the file descriptor for the socket carrying media on the instance
01571  * pointed to by instance.
01572  *
01573  * \since 1.8
01574  */
01575 int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp);
01576 
01577 /*!
01578  * \brief Get the RTP glue that binds a channel to the RTP engine
01579  *
01580  * \param type Name of the glue we want
01581  *
01582  * \retval non-NULL success
01583  * \retval NULL failure
01584  *
01585  * Example usage:
01586  *
01587  * \code
01588  * struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");
01589  * \endcode
01590  *
01591  * This retrieves the RTP glue that has the name 'Example'.
01592  *
01593  * \since 1.8
01594  */
01595 struct ast_rtp_glue *ast_rtp_instance_get_glue(const char *type);
01596 
01597 /*!
01598  * \brief Bridge two channels that use RTP instances
01599  *
01600  * \param c0 First channel part of the bridge
01601  * \param c1 Second channel part of the bridge
01602  * \param flags Bridging flags
01603  * \param fo If a frame needs to be passed up it is stored here
01604  * \param rc Channel that passed the above frame up
01605  * \param timeoutms How long the channels should be bridged for
01606  *
01607  * \retval Bridge result
01608  *
01609  * \note This should only be used by channel drivers in their technology declaration.
01610  *
01611  * \since 1.8
01612  */
01613 enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
01614 
01615 /*!
01616  * \brief Get the other RTP instance that an instance is bridged to
01617  *
01618  * \param instance The RTP instance that we want
01619  *
01620  * \retval non-NULL success
01621  * \retval NULL failure
01622  *
01623  * Example usage:
01624  *
01625  * \code
01626  * struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0);
01627  * \endcode
01628  *
01629  * This gets the RTP instance that instance0 is bridged to.
01630  *
01631  * \since 1.8
01632  */
01633 struct ast_rtp_instance *ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance);
01634 
01635 /*!
01636  * \brief Make two channels compatible for early bridging
01637  *
01638  * \param c_dst Destination channel to copy to
01639  * \param c_src Source channel to copy from
01640  *
01641  * \since 1.8
01642  */
01643 void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src);
01644 
01645 /*!
01646  * \brief Early bridge two channels that use RTP instances
01647  *
01648  * \param c0 First channel part of the bridge
01649  * \param c1 Second channel part of the bridge
01650  *
01651  * \retval 0 success
01652  * \retval -1 failure
01653  *
01654  * \note This should only be used by channel drivers in their technology declaration.
01655  *
01656  * \since 1.8
01657  */
01658 int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
01659 
01660 /*!
01661  * \brief Initialize RED support on an RTP instance
01662  *
01663  * \param instance The instance to initialize RED support on
01664  * \param buffer_time How long to buffer before sending
01665  * \param payloads Payload values
01666  * \param generations Number of generations
01667  *
01668  * \retval 0 success
01669  * \retval -1 failure
01670  *
01671  * \since 1.8
01672  */
01673 int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
01674 
01675 /*!
01676  * \brief Buffer a frame in an RTP instance for RED
01677  *
01678  * \param instance The instance to buffer the frame on
01679  * \param frame Frame that we want to buffer
01680  *
01681  * \retval 0 success
01682  * \retval -1 failure
01683  *
01684  * \since 1.8
01685  */
01686 int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
01687 
01688 /*!
01689  * \brief Retrieve statistics about an RTP instance
01690  *
01691  * \param instance Instance to get statistics on
01692  * \param stats Structure to put results into
01693  * \param stat What statistic(s) to retrieve
01694  *
01695  * \retval 0 success
01696  * \retval -1 failure
01697  *
01698  * Example usage:
01699  *
01700  * \code
01701  * struct ast_rtp_instance_stats stats;
01702  * ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL);
01703  * \endcode
01704  *
01705  * This retrieves all statistics the underlying RTP engine supports and puts the values into the
01706  * stats structure.
01707  *
01708  * \since 1.8
01709  */
01710 int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
01711 
01712 /*!
01713  * \brief Set standard statistics from an RTP instance on a channel
01714  *
01715  * \param chan Channel to set the statistics on
01716  * \param instance The RTP instance that statistics will be retrieved from
01717  *
01718  * Example usage:
01719  *
01720  * \code
01721  * ast_rtp_instance_set_stats_vars(chan, rtp);
01722  * \endcode
01723  *
01724  * This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to
01725  * by chan.
01726  *
01727  * \since 1.8
01728  */
01729 void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance);
01730 
01731 /*!
01732  * \brief Retrieve quality statistics about an RTP instance
01733  *
01734  * \param instance Instance to get statistics on
01735  * \param field What quality statistic to retrieve
01736  * \param buf What buffer to put the result into
01737  * \param size Size of the above buffer
01738  *
01739  * \retval non-NULL success
01740  * \retval NULL failure
01741  *
01742  * Example usage:
01743  *
01744  * \code
01745  * char quality[AST_MAX_USER_FIELD];
01746  * ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf));
01747  * \endcode
01748  *
01749  * This retrieves general quality statistics and places a text representation into the buf pointed to by buf.
01750  *
01751  * \since 1.8
01752  */
01753 char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size);
01754 
01755 /*!
01756  * \brief Request that the underlying RTP engine provide audio frames in a specific format
01757  *
01758  * \param instance The RTP instance to change read format on
01759  * \param format Format that frames are wanted in
01760  *
01761  * \retval 0 success
01762  * \retval -1 failure
01763  *
01764  * Example usage:
01765  *
01766  * \code
01767  * struct ast_format tmp_fmt;
01768  * ast_rtp_instance_set_read_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
01769  * \endcode
01770  *
01771  * This requests that the RTP engine provide audio frames in the ULAW format.
01772  *
01773  * \since 1.8
01774  */
01775 int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format);
01776 
01777 /*!
01778  * \brief Tell underlying RTP engine that audio frames will be provided in a specific format
01779  *
01780  * \param instance The RTP instance to change write format on
01781  * \param format Format that frames will be provided in
01782  *
01783  * \retval 0 success
01784  * \retval -1 failure
01785  *
01786  * Example usage:
01787  *
01788  * \code
01789  * struct ast_format tmp_fmt;
01790  * ast_rtp_instance_set_write_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
01791  * \endcode
01792  *
01793  * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
01794  *
01795  * \since 1.8
01796  */
01797 int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format);
01798 
01799 /*!
01800  * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
01801  *
01802  * \param chan Our own Asterisk channel
01803  * \param instance The first RTP instance
01804  * \param peer The peer Asterisk channel
01805  *
01806  * \retval 0 success
01807  * \retval -1 failure
01808  *
01809  * Example usage:
01810  *
01811  * \code
01812  * ast_rtp_instance_make_compatible(instance, peer);
01813  * \endcode
01814  *
01815  * This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.
01816  *
01817  * \since 1.8
01818  */
01819 int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer);
01820 
01821 /*! \brief Request the formats that can be transcoded
01822  *
01823  * \param instance The RTP instance
01824  * \param to_endpoint Formats being sent/received towards the endpoint
01825  * \param to_asterisk Formats being sent/received towards Asterisk
01826  * \param result capabilities structure to store and return supported formats in.
01827  *
01828  * Example usage:
01829  *
01830  * \code
01831  * ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);
01832  * \endcode
01833  *
01834  * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
01835  *
01836  * \since 1.8
01837  */
01838 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);
01839 
01840 /*!
01841  * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
01842  *
01843  * \param instance The RTP instance
01844  *
01845  * \retval 0 success
01846  * \retval -1 failure
01847  *
01848  * Example usage:
01849  *
01850  * \code
01851  * ast_rtp_instance_activate(instance);
01852  * \endcode
01853  *
01854  * This tells the underlying RTP engine of instance that packets will now flow.
01855  *
01856  * \since 1.8
01857  */
01858 int ast_rtp_instance_activate(struct ast_rtp_instance *instance);
01859 
01860 /*!
01861  * \brief Request that the underlying RTP engine send a STUN BIND request
01862  *
01863  * \param instance The RTP instance
01864  * \param suggestion The suggested destination
01865  * \param username Optionally a username for the request
01866  *
01867  * Example usage:
01868  *
01869  * \code
01870  * ast_rtp_instance_stun_request(instance, NULL, NULL);
01871  * \endcode
01872  *
01873  * This requests that the RTP engine send a STUN BIND request on the session pointed to by
01874  * 'instance'.
01875  *
01876  * \since 1.8
01877  */
01878 void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
01879 
01880 /*!
01881  * \brief Set the RTP timeout value
01882  *
01883  * \param instance The RTP instance
01884  * \param timeout Value to set the timeout to
01885  *
01886  * Example usage:
01887  *
01888  * \code
01889  * ast_rtp_instance_set_timeout(instance, 5000);
01890  * \endcode
01891  *
01892  * This sets the RTP timeout value on 'instance' to be 5000.
01893  *
01894  * \since 1.8
01895  */
01896 void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout);
01897 
01898 /*!
01899  * \brief Set the RTP timeout value for when the instance is on hold
01900  *
01901  * \param instance The RTP instance
01902  * \param timeout Value to set the timeout to
01903  *
01904  * Example usage:
01905  *
01906  * \code
01907  * ast_rtp_instance_set_hold_timeout(instance, 5000);
01908  * \endcode
01909  *
01910  * This sets the RTP hold timeout value on 'instance' to be 5000.
01911  *
01912  * \since 1.8
01913  */
01914 void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout);
01915 
01916 /*!
01917  * \brief Set the RTP keepalive interval
01918  *
01919  * \param instance The RTP instance
01920  * \param period Value to set the keepalive interval to
01921  *
01922  * Example usage:
01923  *
01924  * \code
01925  * ast_rtp_instance_set_keepalive(instance, 5000);
01926  * \endcode
01927  *
01928  * This sets the RTP keepalive interval on 'instance' to be 5000.
01929  *
01930  * \since 1.8
01931  */
01932 void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout);
01933 
01934 /*!
01935  * \brief Get the RTP timeout value
01936  *
01937  * \param instance The RTP instance
01938  *
01939  * \retval timeout value
01940  *
01941  * Example usage:
01942  *
01943  * \code
01944  * int timeout = ast_rtp_instance_get_timeout(instance);
01945  * \endcode
01946  *
01947  * This gets the RTP timeout value for the RTP instance pointed to by 'instance'.
01948  *
01949  * \since 1.8
01950  */
01951 int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance);
01952 
01953 /*!
01954  * \brief Get the RTP timeout value for when an RTP instance is on hold
01955  *
01956  * \param instance The RTP instance
01957  *
01958  * \retval timeout value
01959  *
01960  * Example usage:
01961  *
01962  * \code
01963  * int timeout = ast_rtp_instance_get_hold_timeout(instance);
01964  * \endcode
01965  *
01966  * This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.
01967  *
01968  * \since 1.8
01969  */
01970 int ast_rtp_instance_get_hold_timeout(struct ast_rtp_instance *instance);
01971 
01972 /*!
01973  * \brief Get the RTP keepalive interval
01974  *
01975  * \param instance The RTP instance
01976  *
01977  * \retval period Keepalive interval value
01978  *
01979  * Example usage:
01980  *
01981  * \code
01982  * int interval = ast_rtp_instance_get_keepalive(instance);
01983  * \endcode
01984  *
01985  * This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.
01986  *
01987  * \since 1.8
01988  */
01989 int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance);
01990 
01991 /*!
01992  * \brief Get the RTP engine in use on an RTP instance
01993  *
01994  * \param instance The RTP instance
01995  *
01996  * \retval pointer to the engine
01997  *
01998  * Example usage:
01999  *
02000  * \code
02001  * struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);
02002  * \endcode
02003  *
02004  * This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.
02005  *
02006  * \since 1.8
02007  */
02008 struct ast_rtp_engine *ast_rtp_instance_get_engine(struct ast_rtp_instance *instance);
02009 
02010 /*!
02011  * \brief Get the RTP glue in use on an RTP instance
02012  *
02013  * \param instance The RTP instance
02014  *
02015  * \retval pointer to the glue
02016  *
02017  * Example:
02018  *
02019  * \code
02020  * struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance);
02021  * \endcode
02022  *
02023  * This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.
02024  *
02025  * \since 1.8
02026  */
02027 struct ast_rtp_glue *ast_rtp_instance_get_active_glue(struct ast_rtp_instance *instance);
02028 
02029 /*!
02030  * \brief Get the channel that is associated with an RTP instance while in a bridge
02031  *
02032  * \param instance The RTP instance
02033  *
02034  * \retval pointer to the channel
02035  *
02036  * Example:
02037  *
02038  * \code
02039  * struct ast_channel *chan = ast_rtp_instance_get_chan(instance);
02040  * \endcode
02041  *
02042  * This gets the channel associated with the RTP instance pointed to by 'instance'.
02043  *
02044  * \note This will only return a channel while in a local or remote bridge.
02045  *
02046  * \since 1.8
02047  */
02048 struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance);
02049 
02050 /*!
02051  * \brief Send a comfort noise packet to the RTP instance
02052  *
02053  * \param instance The RTP instance
02054  * \param level Magnitude of the noise level
02055  *
02056  * \retval 0 Success
02057  * \retval non-zero Failure
02058  */
02059 int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level);
02060 
02061 /*!
02062  * \brief Add or replace the SRTP policies for the given RTP instance
02063  *
02064  * \param instance the RTP instance
02065  * \param remote_policy the remote endpoint's policy
02066  * \param local_policy our policy for this RTP instance's remote endpoint
02067  *
02068  * \retval 0 Success
02069  * \retval non-zero Failure
02070  */
02071 int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy* remote_policy, struct ast_srtp_policy *local_policy);
02072 
02073 /*!
02074  * \brief Obtain the SRTP instance associated with an RTP instance
02075  *
02076  * \param instance the RTP instance
02077  * \retval the SRTP instance on success
02078  * \retval NULL if no SRTP instance exists
02079  */
02080 struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
02081 
02082 /*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine
02083  * so their mime type can payload number can be initialized. */
02084 int ast_rtp_engine_load_format(const struct ast_format *format);
02085 
02086 /*! \brief Formats requiring the use of a format attribute interface must have that
02087  * interface registered in order for the rtp engine to handle it correctly.  If an
02088  * attribute interface is unloaded, this function must be called to notify the rtp_engine. */
02089 int ast_rtp_engine_unload_format(const struct ast_format *format);
02090 
02091 /*!
02092  * \brief Obtain a pointer to the ICE support present on an RTP instance
02093  *
02094  * \param instance the RTP instance
02095  *
02096  * \retval ICE support if present
02097  * \retval NULL if no ICE support available
02098  */
02099 struct ast_rtp_engine_ice *ast_rtp_instance_get_ice(struct ast_rtp_instance *instance);
02100 
02101 /*!
02102  * \brief Obtain a pointer to the DTLS support present on an RTP instance
02103  *
02104  * \param instance the RTP instance
02105  *
02106  * \retval DTLS support if present
02107  * \retval NULL if no DTLS support available
02108  */
02109 struct ast_rtp_engine_dtls *ast_rtp_instance_get_dtls(struct ast_rtp_instance *instance);
02110 
02111 /*!
02112  * \brief Parse DTLS related configuration options
02113  *
02114  * \param dtls_cfg a DTLS configuration structure
02115  * \param name name of the configuration option
02116  * \param value value of the configuration option
02117  *
02118  * \retval 0 if handled
02119  * \retval -1 if not handled
02120  */
02121 int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value);
02122 
02123 /*!
02124  * \brief Copy contents of a DTLS configuration structure
02125  *
02126  * \param src_cfg source DTLS configuration structure
02127  * \param dst_cfg destination DTLS configuration structure
02128  */
02129 void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg);
02130 
02131 /*!
02132  * \brief Free contents of a DTLS configuration structure
02133  *
02134  * \param dtls_cfg a DTLS configuration structure
02135  */
02136 void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg);
02137 
02138 #if defined(__cplusplus) || defined(c_plusplus)
02139 }
02140 #endif
02141 
02142 #endif /* _ASTERISK_RTP_ENGINE_H */