Sat Feb 11 06:36:40 2012

Asterisk developer's documentation


rtp_engine.h File Reference

Pluggable RTP Architecture. More...

#include "asterisk/astobj2.h"
#include "asterisk/frame.h"
#include "asterisk/netsock2.h"
#include "asterisk/sched.h"
#include "asterisk/res_srtp.h"

Include dependency graph for rtp_engine.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_rtp_codecs
struct  ast_rtp_engine
struct  ast_rtp_glue
struct  ast_rtp_instance_stats
struct  ast_rtp_payload_type

Defines

#define AST_RED_MAX_GENERATION   5
#define AST_RTP_CISCO_DTMF   (1 << 2)
#define AST_RTP_CN   (1 << 1)
#define AST_RTP_DTMF   (1 << 0)
#define ast_rtp_engine_register(engine)   ast_rtp_engine_register2(engine, ast_module_info->self)
#define ast_rtp_glue_register(glue)   ast_rtp_glue_register2(glue, ast_module_info->self)
#define AST_RTP_MAX   AST_RTP_CISCO_DTMF
#define AST_RTP_MAX_PT   256
#define AST_RTP_STAT_SET(current_stat, combined, placement, value)
#define AST_RTP_STAT_TERMINATOR(combined)

Enumerations

enum  ast_rtp_dtmf_mode { AST_RTP_DTMF_MODE_NONE = 0, AST_RTP_DTMF_MODE_RFC2833, AST_RTP_DTMF_MODE_INBAND }
enum  ast_rtp_glue_result { AST_RTP_GLUE_RESULT_FORBID = 0, AST_RTP_GLUE_RESULT_REMOTE, AST_RTP_GLUE_RESULT_LOCAL }
enum  ast_rtp_instance_stat {
  AST_RTP_INSTANCE_STAT_ALL = 0, AST_RTP_INSTANCE_STAT_TXCOUNT, AST_RTP_INSTANCE_STAT_RXCOUNT, AST_RTP_INSTANCE_STAT_COMBINED_LOSS,
  AST_RTP_INSTANCE_STAT_TXPLOSS, AST_RTP_INSTANCE_STAT_RXPLOSS, AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS, AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS,
  AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS, AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS, AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS, AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS,
  AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS, AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS, AST_RTP_INSTANCE_STAT_COMBINED_JITTER, AST_RTP_INSTANCE_STAT_TXJITTER,
  AST_RTP_INSTANCE_STAT_RXJITTER, AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER, AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER, AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER,
  AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER, AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER, AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER, AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER,
  AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER, AST_RTP_INSTANCE_STAT_COMBINED_RTT, AST_RTP_INSTANCE_STAT_RTT, AST_RTP_INSTANCE_STAT_MAX_RTT,
  AST_RTP_INSTANCE_STAT_MIN_RTT, AST_RTP_INSTANCE_STAT_NORMDEVRTT, AST_RTP_INSTANCE_STAT_STDEVRTT, AST_RTP_INSTANCE_STAT_LOCAL_SSRC,
  AST_RTP_INSTANCE_STAT_REMOTE_SSRC
}
enum  ast_rtp_instance_stat_field { AST_RTP_INSTANCE_STAT_FIELD_QUALITY = 0, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT }
enum  ast_rtp_options { AST_RTP_OPT_G726_NONSTANDARD = (1 << 0) }
enum  ast_rtp_property {
  AST_RTP_PROPERTY_NAT = 0, AST_RTP_PROPERTY_DTMF, AST_RTP_PROPERTY_DTMF_COMPENSATE, AST_RTP_PROPERTY_STUN,
  AST_RTP_PROPERTY_RTCP, AST_RTP_PROPERTY_MAX
}

Functions

struct ast_formatast_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 payload.
void ast_rtp_codecs_packetization_set (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs)
 Set codec packetization preferences.
int ast_rtp_codecs_payload_code (struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
 Retrieve a payload based on whether it is an Asterisk format and the code.
void ast_rtp_codecs_payload_formats (struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
 Retrieve all formats that were found.
struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup (struct ast_rtp_codecs *codecs, int payload)
 Retrieve payload information by payload.
void ast_rtp_codecs_payloads_clear (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
 Clear payload information from an RTP instance.
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_codecs_payloads_default (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
 Set payload information on an RTP instance to the default.
void ast_rtp_codecs_payloads_set_m_type (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
 Record payload information that was seen in an m= SDP line.
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 payload information that was seen in an a=rtpmap: SDP line.
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 payload type to a known MIME media type for a codec with a specific sample rate.
void ast_rtp_codecs_payloads_unset (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
 Remove payload information.
int ast_rtp_engine_load_format (const struct ast_format *format)
 Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine so their mime type can payload number can be initialized.
int ast_rtp_engine_register2 (struct ast_rtp_engine *engine, struct ast_module *module)
 Register an RTP engine.
int ast_rtp_engine_register_srtp (struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
int ast_rtp_engine_srtp_is_registered (void)
int ast_rtp_engine_unload_format (const struct ast_format *format)
 Formats requiring the use of a format attribute interface must have that interface registered in order for the rtp engine to handle it correctly. If an attribute interface is unloaded, this function must be called to notify the rtp_engine.
int ast_rtp_engine_unregister (struct ast_rtp_engine *engine)
 Unregister an RTP engine.
void ast_rtp_engine_unregister_srtp (void)
int ast_rtp_glue_register2 (struct ast_rtp_glue *glue, struct ast_module *module)
 Register RTP glue.
int ast_rtp_glue_unregister (struct ast_rtp_glue *glue)
 Unregister RTP glue.
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.
int ast_rtp_instance_add_srtp_policy (struct ast_rtp_instance *instance, struct ast_srtp_policy *policy)
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.
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)
 Bridge two channels that use RTP instances.
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_instance_destroy (struct ast_rtp_instance *instance)
 Destroy an RTP instance.
int ast_rtp_instance_dtmf_begin (struct ast_rtp_instance *instance, char digit)
 Begin sending a DTMF digit.
int ast_rtp_instance_dtmf_end (struct ast_rtp_instance *instance, char digit)
 Stop sending a DTMF digit.
int ast_rtp_instance_dtmf_end_with_duration (struct ast_rtp_instance *instance, char digit, unsigned int duration)
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_instance_dtmf_mode_set (struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
 Set the DTMF mode that should be used.
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_early_bridge_make_compatible (struct ast_channel *c0, struct ast_channel *c1)
 Make two channels compatible for early bridging.
int ast_rtp_instance_fd (struct ast_rtp_instance *instance, int rtcp)
 Get the file descriptor for an RTP session (or RTCP).
struct ast_rtp_glueast_rtp_instance_get_active_glue (struct ast_rtp_instance *instance)
 Get the RTP glue in use on an RTP instance.
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.
int ast_rtp_instance_get_and_cmp_remote_address (struct ast_rtp_instance *instance, struct ast_sockaddr *address)
 Get the address of the remote endpoint that we are sending RTP to, comparing its address to another.
struct ast_rtp_instanceast_rtp_instance_get_bridged (struct ast_rtp_instance *instance)
 Get the other RTP instance that an instance is bridged to.
struct ast_channelast_rtp_instance_get_chan (struct ast_rtp_instance *instance)
 Get the channel that is associated with an RTP instance while in a bridge.
struct ast_rtp_codecsast_rtp_instance_get_codecs (struct ast_rtp_instance *instance)
 Get the codecs structure of an RTP instance.
void * ast_rtp_instance_get_data (struct ast_rtp_instance *instance)
 Get the data portion of an RTP instance.
struct ast_rtp_engineast_rtp_instance_get_engine (struct ast_rtp_instance *instance)
 Get the RTP engine in use on an RTP instance.
void * ast_rtp_instance_get_extended_prop (struct ast_rtp_instance *instance, int property)
 Get the value of an RTP instance extended property.
struct ast_rtp_glueast_rtp_instance_get_glue (const char *type)
 Get the RTP glue that binds a channel to the RTP engine.
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.
int ast_rtp_instance_get_keepalive (struct ast_rtp_instance *instance)
 Get the RTP keepalive interval.
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.
int ast_rtp_instance_get_prop (struct ast_rtp_instance *instance, enum ast_rtp_property property)
 Get the value of an RTP instance property.
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.
void ast_rtp_instance_get_remote_address (struct ast_rtp_instance *instance, struct ast_sockaddr *address)
 Get the address of the remote endpoint that we are sending RTP to.
struct ast_srtpast_rtp_instance_get_srtp (struct ast_rtp_instance *instance)
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.
int ast_rtp_instance_get_timeout (struct ast_rtp_instance *instance)
 Get the RTP timeout value.
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.
struct ast_rtp_instanceast_rtp_instance_new (const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
 Create a new RTP instance.
struct ast_frameast_rtp_instance_read (struct ast_rtp_instance *instance, int rtcp)
 Receive a frame over RTP.
int ast_rtp_instance_sendcng (struct ast_rtp_instance *instance, int level)
 Send a comfort noise packet to the RTP instance.
int ast_rtp_instance_set_alt_remote_address (struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
 Set the address of an an alternate RTP address to receive from.
void ast_rtp_instance_set_data (struct ast_rtp_instance *instance, void *data)
 Set the data portion of an RTP instance.
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.
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.
void ast_rtp_instance_set_keepalive (struct ast_rtp_instance *instance, int timeout)
 Set the RTP keepalive interval.
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.
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.
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.
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.
int ast_rtp_instance_set_remote_address (struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
 Set the address of the remote endpoint that we are sending RTP to.
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.
void ast_rtp_instance_set_timeout (struct ast_rtp_instance *instance, int timeout)
 Set the RTP timeout value.
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.
void ast_rtp_instance_stop (struct ast_rtp_instance *instance)
 Stop an RTP instance.
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.
void ast_rtp_instance_update_source (struct ast_rtp_instance *instance)
 Indicate that the RTP marker bit should be set on an RTP stream.
int ast_rtp_instance_write (struct ast_rtp_instance *instance, struct ast_frame *frame)
 Send a frame out over RTP.
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.
const char * ast_rtp_lookup_mime_subtype2 (const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options)
 Retrieve mime subtype information on a payload.
unsigned int ast_rtp_lookup_sample_rate2 (int asterisk_format, struct ast_format *format, int code)
 Get the sample rate associated with known RTP payload types.
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_red_init (struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
 Initialize RED support on an RTP instance.


Detailed Description

Pluggable RTP Architecture.

Author:
Joshua Colp <jcolp@digium.com> Asterisk RTP Engine API

Definition in file rtp_engine.h.


Define Documentation

#define AST_RED_MAX_GENERATION   5

Definition at line 82 of file rtp_engine.h.

Referenced by process_sdp_a_text().

#define AST_RTP_CISCO_DTMF   (1 << 2)

DTMF (Cisco Proprietary)

Definition at line 222 of file rtp_engine.h.

Referenced by ast_rtp_engine_init(), and ast_rtp_read().

#define AST_RTP_CN   (1 << 1)

'Comfort Noise' (RFC3389)

Definition at line 220 of file rtp_engine.h.

Referenced by ast_rtp_engine_init(), ast_rtp_read(), and ast_rtp_sendcng().

#define AST_RTP_DTMF   (1 << 0)

#define ast_rtp_engine_register ( engine   )     ast_rtp_engine_register2(engine, ast_module_info->self)

Definition at line 425 of file rtp_engine.h.

Referenced by load_module().

#define ast_rtp_glue_register ( glue   )     ast_rtp_glue_register2(glue, ast_module_info->self)

Definition at line 478 of file rtp_engine.h.

Referenced by load_module().

#define AST_RTP_MAX   AST_RTP_CISCO_DTMF

Maximum RTP-specific code

Definition at line 224 of file rtp_engine.h.

Referenced by add_sdp(), and ast_rtp_lookup_mime_multiple2().

#define AST_RTP_MAX_PT   256

#define AST_RTP_STAT_SET ( current_stat,
combined,
placement,
value   ) 

Definition at line 300 of file rtp_engine.h.

Referenced by ast_rtp_get_stat().

#define AST_RTP_STAT_TERMINATOR ( combined   ) 

Value:

if (stat == combined) { \
return 0; \
}

Definition at line 308 of file rtp_engine.h.

Referenced by ast_rtp_get_stat().


Enumeration Type Documentation

RTP DTMF Modes

Enumerator:
AST_RTP_DTMF_MODE_NONE  No DTMF is being carried over the RTP stream
AST_RTP_DTMF_MODE_RFC2833  DTMF is being carried out of band using RFC2833
AST_RTP_DTMF_MODE_INBAND  DTMF is being carried inband over the RTP stream

Definition at line 115 of file rtp_engine.h.

00115                        {
00116    /*! No DTMF is being carried over the RTP stream */
00117    AST_RTP_DTMF_MODE_NONE = 0,
00118    /*! DTMF is being carried out of band using RFC2833 */
00119    AST_RTP_DTMF_MODE_RFC2833,
00120    /*! DTMF is being carried inband over the RTP stream */
00121    AST_RTP_DTMF_MODE_INBAND,
00122 };

Result codes when RTP glue is queried for information

Enumerator:
AST_RTP_GLUE_RESULT_FORBID  No remote or local bridging is permitted
AST_RTP_GLUE_RESULT_REMOTE  Move RTP stream to be remote between devices directly
AST_RTP_GLUE_RESULT_LOCAL  Perform RTP engine level bridging if possible

Definition at line 125 of file rtp_engine.h.

00125                          {
00126    /*! No remote or local bridging is permitted */
00127    AST_RTP_GLUE_RESULT_FORBID = 0,
00128    /*! Move RTP stream to be remote between devices directly */
00129    AST_RTP_GLUE_RESULT_REMOTE,
00130    /*! Perform RTP engine level bridging if possible */
00131    AST_RTP_GLUE_RESULT_LOCAL,
00132 };

Statistics that can be retrieved from an RTP instance

Enumerator:
AST_RTP_INSTANCE_STAT_ALL  Retrieve all statistics
AST_RTP_INSTANCE_STAT_TXCOUNT  Retrieve number of packets transmitted
AST_RTP_INSTANCE_STAT_RXCOUNT  Retrieve number of packets received
AST_RTP_INSTANCE_STAT_COMBINED_LOSS  Retrieve ALL statistics relating to packet loss
AST_RTP_INSTANCE_STAT_TXPLOSS  Retrieve number of packets lost for transmitting
AST_RTP_INSTANCE_STAT_RXPLOSS  Retrieve number of packets lost for receiving
AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS  Retrieve maximum number of packets lost on remote side
AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS  Retrieve minimum number of packets lost on remote side
AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS  Retrieve average number of packets lost on remote side
AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS  Retrieve standard deviation of packets lost on remote side
AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS  Retrieve maximum number of packets lost on local side
AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS  Retrieve minimum number of packets lost on local side
AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS  Retrieve average number of packets lost on local side
AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS  Retrieve standard deviation of packets lost on local side
AST_RTP_INSTANCE_STAT_COMBINED_JITTER  Retrieve ALL statistics relating to jitter
AST_RTP_INSTANCE_STAT_TXJITTER  Retrieve jitter on transmitted packets
AST_RTP_INSTANCE_STAT_RXJITTER  Retrieve jitter on received packets
AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER  Retrieve maximum jitter on remote side
AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER  Retrieve minimum jitter on remote side
AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER  Retrieve average jitter on remote side
AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER  Retrieve standard deviation jitter on remote side
AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER  Retrieve maximum jitter on local side
AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER  Retrieve minimum jitter on local side
AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER  Retrieve average jitter on local side
AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER  Retrieve standard deviation jitter on local side
AST_RTP_INSTANCE_STAT_COMBINED_RTT  Retrieve ALL statistics relating to round trip time
AST_RTP_INSTANCE_STAT_RTT  Retrieve round trip time
AST_RTP_INSTANCE_STAT_MAX_RTT  Retrieve maximum round trip time
AST_RTP_INSTANCE_STAT_MIN_RTT  Retrieve minimum round trip time
AST_RTP_INSTANCE_STAT_NORMDEVRTT  Retrieve average round trip time
AST_RTP_INSTANCE_STAT_STDEVRTT  Retrieve standard deviation round trip time
AST_RTP_INSTANCE_STAT_LOCAL_SSRC  Retrieve local SSRC
AST_RTP_INSTANCE_STAT_REMOTE_SSRC  Retrieve remote SSRC

Definition at line 147 of file rtp_engine.h.

00147                            {
00148    /*! Retrieve all statistics */
00149    AST_RTP_INSTANCE_STAT_ALL = 0,
00150    /*! Retrieve number of packets transmitted */
00151    AST_RTP_INSTANCE_STAT_TXCOUNT,
00152    /*! Retrieve number of packets received */
00153    AST_RTP_INSTANCE_STAT_RXCOUNT,
00154    /*! Retrieve ALL statistics relating to packet loss */
00155    AST_RTP_INSTANCE_STAT_COMBINED_LOSS,
00156    /*! Retrieve number of packets lost for transmitting */
00157    AST_RTP_INSTANCE_STAT_TXPLOSS,
00158    /*! Retrieve number of packets lost for receiving */
00159    AST_RTP_INSTANCE_STAT_RXPLOSS,
00160    /*! Retrieve maximum number of packets lost on remote side */
00161    AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS,
00162    /*! Retrieve minimum number of packets lost on remote side */
00163    AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS,
00164    /*! Retrieve average number of packets lost on remote side */
00165    AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS,
00166    /*! Retrieve standard deviation of packets lost on remote side */
00167    AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS,
00168    /*! Retrieve maximum number of packets lost on local side */
00169    AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS,
00170    /*! Retrieve minimum number of packets lost on local side */
00171    AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS,
00172    /*! Retrieve average number of packets lost on local side */
00173    AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS,
00174    /*! Retrieve standard deviation of packets lost on local side */
00175    AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS,
00176    /*! Retrieve ALL statistics relating to jitter */
00177    AST_RTP_INSTANCE_STAT_COMBINED_JITTER,
00178    /*! Retrieve jitter on transmitted packets */
00179    AST_RTP_INSTANCE_STAT_TXJITTER,
00180    /*! Retrieve jitter on received packets */
00181    AST_RTP_INSTANCE_STAT_RXJITTER,
00182    /*! Retrieve maximum jitter on remote side */
00183    AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER,
00184    /*! Retrieve minimum jitter on remote side */
00185    AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER,
00186    /*! Retrieve average jitter on remote side */
00187    AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER,
00188    /*! Retrieve standard deviation jitter on remote side */
00189    AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER,
00190    /*! Retrieve maximum jitter on local side */
00191    AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER,
00192    /*! Retrieve minimum jitter on local side */
00193    AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER,
00194    /*! Retrieve average jitter on local side */
00195    AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER,
00196    /*! Retrieve standard deviation jitter on local side */
00197    AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER,
00198    /*! Retrieve ALL statistics relating to round trip time */
00199    AST_RTP_INSTANCE_STAT_COMBINED_RTT,
00200    /*! Retrieve round trip time */
00201    AST_RTP_INSTANCE_STAT_RTT,
00202    /*! Retrieve maximum round trip time */
00203    AST_RTP_INSTANCE_STAT_MAX_RTT,
00204    /*! Retrieve minimum round trip time */
00205    AST_RTP_INSTANCE_STAT_MIN_RTT,
00206    /*! Retrieve average round trip time */
00207    AST_RTP_INSTANCE_STAT_NORMDEVRTT,
00208    /*! Retrieve standard deviation round trip time */
00209    AST_RTP_INSTANCE_STAT_STDEVRTT,
00210    /*! Retrieve local SSRC */
00211    AST_RTP_INSTANCE_STAT_LOCAL_SSRC,
00212    /*! Retrieve remote SSRC */
00213    AST_RTP_INSTANCE_STAT_REMOTE_SSRC,
00214 };

Field statistics that can be retrieved from an RTP instance

Enumerator:
AST_RTP_INSTANCE_STAT_FIELD_QUALITY  Retrieve quality information
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER  Retrieve quality information about jitter
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS  Retrieve quality information about packet loss
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT  Retrieve quality information about round trip time

Definition at line 135 of file rtp_engine.h.

00135                                  {
00136    /*! Retrieve quality information */
00137    AST_RTP_INSTANCE_STAT_FIELD_QUALITY = 0,
00138    /*! Retrieve quality information about jitter */
00139    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER,
00140    /*! Retrieve quality information about packet loss */
00141    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS,
00142    /*! Retrieve quality information about round trip time */
00143    AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT,
00144 };

Additional RTP options

Enumerator:
AST_RTP_OPT_G726_NONSTANDARD  Remote side is using non-standard G.726

Definition at line 109 of file rtp_engine.h.

00109                      {
00110    /*! Remote side is using non-standard G.726 */
00111    AST_RTP_OPT_G726_NONSTANDARD = (1 << 0),
00112 };

RTP Properties that can be set on an RTP instance

Enumerator:
AST_RTP_PROPERTY_NAT  Enable symmetric RTP support
AST_RTP_PROPERTY_DTMF  RTP instance will be carrying DTMF (using RFC2833)
AST_RTP_PROPERTY_DTMF_COMPENSATE  Expect unreliable DTMF from remote party
AST_RTP_PROPERTY_STUN  Enable STUN support
AST_RTP_PROPERTY_RTCP  Enable RTCP support
AST_RTP_PROPERTY_MAX  Maximum number of RTP properties supported.

Note:
THIS MUST BE THE LAST ENTRY IN THIS ENUM.

Definition at line 88 of file rtp_engine.h.

00088                       {
00089    /*! Enable symmetric RTP support */
00090    AST_RTP_PROPERTY_NAT = 0,
00091    /*! RTP instance will be carrying DTMF (using RFC2833) */
00092    AST_RTP_PROPERTY_DTMF,
00093    /*! Expect unreliable DTMF from remote party */
00094    AST_RTP_PROPERTY_DTMF_COMPENSATE,
00095    /*! Enable STUN support */
00096    AST_RTP_PROPERTY_STUN,
00097    /*! Enable RTCP support */
00098    AST_RTP_PROPERTY_RTCP,
00099 
00100    /*!
00101     * \brief Maximum number of RTP properties supported
00102     *
00103     * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
00104     */
00105    AST_RTP_PROPERTY_MAX,
00106 };


Function Documentation

struct ast_format* ast_rtp_codecs_get_payload_format ( struct ast_rtp_codecs codecs,
int  payload 
) [read]

Retrieve the actual ast_format stored on the codecs structure for a specific payload.

Parameters:
codecs Codecs structure to look in
payload Numerical payload to look up
Return values:
pointer to format structure on success
NULL on failure
Since:
10.0

Definition at line 574 of file rtp_engine.c.

References AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, and ast_rtp_codecs::payloads.

Referenced by process_sdp_a_audio().

00575 {
00576    if (payload < 0 || payload >= AST_RTP_MAX_PT) {
00577       return NULL;
00578    }
00579    if (!codecs->payloads[payload].asterisk_format) {
00580       return NULL;
00581    }
00582    return &codecs->payloads[payload].format;
00583 }

void ast_rtp_codecs_packetization_set ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance,
struct ast_codec_pref prefs 
)

Set codec packetization preferences.

Parameters:
codecs Codecs structure to muck with
instance Optionally the instance that the codecs structure belongs to
prefs Codec packetization preferences
Example usage:

This sets the packetization preferences pointed to by prefs on the codecs structure pointed to by codecs.

Since:
1.8

Definition at line 721 of file rtp_engine.c.

References ast_rtp_instance::codecs, ast_rtp_instance::engine, ast_rtp_engine::packetization_set, and ast_rtp_codecs::pref.

Referenced by __oh323_rtp_create(), check_peer_ok(), create_addr_from_peer(), gtalk_new(), jingle_new(), process_sdp_a_audio(), set_peer_capabilities(), start_rtp(), and transmit_response_with_sdp().

00722 {
00723    codecs->pref = *prefs;
00724 
00725    if (instance && instance->engine->packetization_set) {
00726       instance->engine->packetization_set(instance, &instance->codecs.pref);
00727    }
00728 }

int ast_rtp_codecs_payload_code ( struct ast_rtp_codecs codecs,
int  asterisk_format,
const struct ast_format format,
int  code 
)

Retrieve a payload based on whether it is an Asterisk format and the code.

Parameters:
codecs Codecs structure to look in
asterisk_format Non-zero if the given Asterisk format is present
format Asterisk format to look for
code The format to look for
Return values:
Numerical payload
Example usage:

 int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0);

This looks for the numerical payload for ULAW in the codecs structure.

Since:
1.8

Definition at line 604 of file rtp_engine.c.

References ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, ast_rtp_codecs::payloads, ast_rtp_payload_type::rtp_code, and static_RTP_PT.

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), ast_rtp_dtmf_begin(), ast_rtp_sendcng(), ast_rtp_write(), bridge_p2p_rtp_write(), multicast_rtp_write(), and start_rtp().

00605 {
00606    int i;
00607    int res = -1;
00608    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00609       if (codecs->payloads[i].asterisk_format && asterisk_format && format &&
00610          (ast_format_cmp(format, &codecs->payloads[i].format) != AST_FORMAT_CMP_NOT_EQUAL)) {
00611          return i;
00612       } else if (!codecs->payloads[i].asterisk_format && !asterisk_format &&
00613          (codecs->payloads[i].rtp_code == code)) {
00614          return i;
00615       }
00616    }
00617 
00618    ast_rwlock_rdlock(&static_RTP_PT_lock);
00619    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00620       if (static_RTP_PT[i].asterisk_format && asterisk_format && format &&
00621          (ast_format_cmp(format, &static_RTP_PT[i].format) != AST_FORMAT_CMP_NOT_EQUAL)) {
00622          res = i;
00623          break;
00624       } else if (!static_RTP_PT[i].asterisk_format && !asterisk_format &&
00625          (static_RTP_PT[i].rtp_code == code)) {
00626          res = i;
00627          break;
00628       }
00629    }
00630    ast_rwlock_unlock(&static_RTP_PT_lock);
00631 
00632    return res;
00633 }

void ast_rtp_codecs_payload_formats ( struct ast_rtp_codecs codecs,
struct ast_format_cap astformats,
int *  nonastformats 
)

Retrieve all formats that were found.

Parameters:
codecs Codecs structure to look in
astformats A capabilities structure to put the Asterisk formats in.
nonastformats An integer to put the non-Asterisk formats in
Example usage:

 struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
 int nonastformats;
 ast_rtp_codecs_payload_formats(&codecs, &astformats, &nonastformats);

This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.

Since:
1.8

Definition at line 585 of file rtp_engine.c.

References ast_debug, ast_format_cap_add(), ast_format_cap_remove_all(), AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, ast_rtp_codecs::payloads, and ast_rtp_payload_type::rtp_code.

Referenced by gtalk_is_answered(), gtalk_newcall(), and process_sdp().

00586 {
00587    int i;
00588 
00589    ast_format_cap_remove_all(astformats);
00590    *nonastformats = 0;
00591 
00592    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00593       if (codecs->payloads[i].rtp_code || codecs->payloads[i].asterisk_format) {
00594          ast_debug(1, "Incorporating payload %d on %p\n", i, codecs);
00595       }
00596       if (codecs->payloads[i].asterisk_format) {
00597          ast_format_cap_add(astformats, &codecs->payloads[i].format);
00598       } else {
00599          *nonastformats |= codecs->payloads[i].rtp_code;
00600       }
00601    }
00602 }

struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup ( struct ast_rtp_codecs codecs,
int  payload 
) [read]

Retrieve payload information by payload.

Parameters:
codecs Codecs structure to look in
payload Numerical payload to look up
Return values:
Payload information
Example usage:

 struct ast_rtp_payload_type payload_type;
 payload_type = ast_rtp_codecs_payload_lookup(&codecs, 0);

This looks up the information for payload '0' from the codecs structure.

Since:
1.8

Definition at line 552 of file rtp_engine.c.

References ast_format_copy(), AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, ast_rtp_payload_type::rtp_code, and static_RTP_PT.

Referenced by ast_rtp_read(), bridge_p2p_rtp_write(), process_sdp_a_audio(), and setup_rtp_connection().

00553 {
00554    struct ast_rtp_payload_type result = { .asterisk_format = 0, };
00555 
00556    if (payload < 0 || payload >= AST_RTP_MAX_PT) {
00557       return result;
00558    }
00559 
00560    result.asterisk_format = codecs->payloads[payload].asterisk_format;
00561    result.rtp_code = codecs->payloads[payload].rtp_code;
00562    ast_format_copy(&result.format, &codecs->payloads[payload].format);
00563 
00564    if (!result.rtp_code && !result.asterisk_format) {
00565       ast_rwlock_rdlock(&static_RTP_PT_lock);
00566       result = static_RTP_PT[payload];
00567       ast_rwlock_unlock(&static_RTP_PT_lock);
00568    }
00569 
00570    return result;
00571 }

void ast_rtp_codecs_payloads_clear ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance 
)

Clear payload information from an RTP instance.

Parameters:
codecs The codecs structure that payloads will be cleared from
instance Optionally the instance that the codecs structure belongs to
Example usage:

 struct ast_rtp_codecs codecs;
 ast_rtp_codecs_payloads_clear(&codecs, NULL);

This clears the codecs structure and puts it into a pristine state.

Since:
1.8

Definition at line 410 of file rtp_engine.c.

References ast_format_clear(), AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_engine::payload_set, ast_rtp_codecs::payloads, and ast_rtp_payload_type::rtp_code.

Referenced by gtalk_alloc(), and process_sdp().

00411 {
00412    int i;
00413 
00414    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00415       codecs->payloads[i].asterisk_format = 0;
00416       codecs->payloads[i].rtp_code = 0;
00417       ast_format_clear(&codecs->payloads[i].format);
00418       if (instance && instance->engine && instance->engine->payload_set) {
00419          instance->engine->payload_set(instance, i, 0, NULL, 0);
00420       }
00421    }
00422 }

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.

Parameters:
src The source codecs structure
dest The destination codecs structure that the values from src will be copied to
instance Optionally the instance that the dst codecs structure belongs to
Example usage:

 ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);

This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.

Since:
1.8

Definition at line 443 of file rtp_engine.c.

References ast_debug, ast_format_copy(), AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_engine::payload_set, ast_rtp_codecs::payloads, and ast_rtp_payload_type::rtp_code.

Referenced by ast_rtp_instance_early_bridge_make_compatible(), and process_sdp().

00444 {
00445    int i;
00446 
00447    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00448       if (src->payloads[i].rtp_code || src->payloads[i].asterisk_format) {
00449          ast_debug(2, "Copying payload %d from %p to %p\n", i, src, dest);
00450          dest->payloads[i].asterisk_format = src->payloads[i].asterisk_format;
00451          dest->payloads[i].rtp_code = src->payloads[i].rtp_code;
00452          ast_format_copy(&dest->payloads[i].format, &src->payloads[i].format);
00453          if (instance && instance->engine && instance->engine->payload_set) {
00454             instance->engine->payload_set(instance, i, dest->payloads[i].asterisk_format, &dest->payloads[i].format, dest->payloads[i].rtp_code);
00455          }
00456       }
00457    }
00458 }

void ast_rtp_codecs_payloads_default ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance 
)

Set payload information on an RTP instance to the default.

Parameters:
codecs The codecs structure to set defaults on
instance Optionally the instance that the codecs structure belongs to
Example usage:

 struct ast_rtp_codecs codecs;
 ast_rtp_codecs_payloads_default(&codecs, NULL);

This sets the default payloads on the codecs structure.

Since:
1.8

Definition at line 424 of file rtp_engine.c.

References ast_format_copy(), AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_engine::payload_set, ast_rtp_codecs::payloads, ast_rtp_payload_type::rtp_code, and static_RTP_PT.

00425 {
00426    int i;
00427 
00428    ast_rwlock_rdlock(&static_RTP_PT_lock);
00429    for (i = 0; i < AST_RTP_MAX_PT; i++) {
00430       if (static_RTP_PT[i].rtp_code || static_RTP_PT[i].asterisk_format) {
00431 
00432          codecs->payloads[i].asterisk_format = static_RTP_PT[i].asterisk_format;
00433          codecs->payloads[i].rtp_code = static_RTP_PT[i].rtp_code;
00434          ast_format_copy(&codecs->payloads[i].format, &static_RTP_PT[i].format);
00435          if (instance && instance->engine && instance->engine->payload_set) {
00436             instance->engine->payload_set(instance, i, codecs->payloads[i].asterisk_format, &codecs->payloads[i].format, codecs->payloads[i].rtp_code);
00437          }
00438       }
00439    }
00440    ast_rwlock_unlock(&static_RTP_PT_lock);
00441 }

void ast_rtp_codecs_payloads_set_m_type ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance,
int  payload 
)

Record payload information that was seen in an m= SDP line.

Parameters:
codecs The codecs structure to muck with
instance Optionally the instance that the codecs structure belongs to
payload Numerical payload that was seen in the m= SDP line
Example usage:

This records that the numerical payload '0' was seen in the codecs structure.

Since:
1.8

Definition at line 460 of file rtp_engine.c.

References ast_debug, ast_format_copy(), AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_engine::payload_set, ast_rtp_codecs::payloads, ast_rtp_payload_type::rtp_code, and static_RTP_PT.

Referenced by gtalk_is_answered(), gtalk_newcall(), jingle_newcall(), and process_sdp().

00461 {
00462 
00463    ast_rwlock_rdlock(&static_RTP_PT_lock);
00464    if (payload < 0 || payload >= AST_RTP_MAX_PT || (!static_RTP_PT[payload].rtp_code && !static_RTP_PT[payload].asterisk_format)) {
00465       ast_rwlock_unlock(&static_RTP_PT_lock);
00466       return;
00467    }
00468 
00469    codecs->payloads[payload].asterisk_format = static_RTP_PT[payload].asterisk_format;
00470    codecs->payloads[payload].rtp_code = static_RTP_PT[payload].rtp_code;
00471    ast_format_copy(&codecs->payloads[payload].format, &static_RTP_PT[payload].format);
00472 
00473    ast_debug(1, "Setting payload %d based on m type on %p\n", payload, codecs);
00474 
00475    if (instance && instance->engine && instance->engine->payload_set) {
00476       instance->engine->payload_set(instance, payload, codecs->payloads[payload].asterisk_format, &codecs->payloads[payload].format, codecs->payloads[payload].rtp_code);
00477    }
00478    ast_rwlock_unlock(&static_RTP_PT_lock);
00479 }

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 payload information that was seen in an a=rtpmap: SDP line.

Parameters:
codecs The codecs structure to muck with
instance Optionally the instance that the codecs structure belongs to
payload Numerical payload that was seen in the a=rtpmap: SDP line
mimetype The string mime type that was seen
mimesubtype The strin mime sub type that was seen
options Optional options that may change the behavior of this specific payload
Return values:
0 success
-1 failure, invalid payload numbe
-2 failure, unknown mimetype
Example usage:

 ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);

This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.

Since:
1.8

Definition at line 530 of file rtp_engine.c.

References ast_rtp_codecs_payloads_set_rtpmap_type_rate().

Referenced by __oh323_rtp_create(), gtalk_is_answered(), gtalk_newcall(), jingle_newcall(), process_sdp(), set_dtmf_payload(), and setup_rtp_connection().

00531 {
00532    return ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, instance, payload, mimetype, mimesubtype, options, 0);
00533 }

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 payload type to a known MIME media type for a codec with a specific sample rate.

Parameters:
codecs RTP structure to modify
instance Optionally the instance that the codecs structure belongs to
pt Payload type entry to modify
mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.)
mimesubtype MIME subtype of media stream (typically a codec name)
options Zero or more flags from the ast_rtp_options enum
sample_rate The sample rate of the media stream
This function 'fills in' an entry in the list of possible formats for a media stream associated with an RTP structure.

Return values:
0 on success
-1 if the payload type is out of range
-2 if the mimeType/mimeSubtype combination was not found
Since:
1.8

Definition at line 481 of file rtp_engine.c.

References AST_FORMAT_G726, AST_FORMAT_G726_AAL2, ast_format_set(), AST_RTP_MAX_PT, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_format::id, ast_rtp_engine::payload_set, ast_rtp_mime_type::payload_type, ast_rtp_codecs::payloads, ast_rtp_payload_type::rtp_code, ast_rtp_mime_type::sample_rate, ast_rtp_mime_type::subtype, and ast_rtp_mime_type::type.

Referenced by ast_rtp_codecs_payloads_set_rtpmap_type(), process_sdp_a_audio(), process_sdp_a_text(), and process_sdp_a_video().

00485 {
00486    unsigned int i;
00487    int found = 0;
00488 
00489    if (pt < 0 || pt >= AST_RTP_MAX_PT)
00490       return -1; /* bogus payload type */
00491 
00492    ast_rwlock_rdlock(&mime_types_lock);
00493    for (i = 0; i < mime_types_len; ++i) {
00494       const struct ast_rtp_mime_type *t = &ast_rtp_mime_types[i];
00495 
00496       if (strcasecmp(mimesubtype, t->subtype)) {
00497          continue;
00498       }
00499 
00500       if (strcasecmp(mimetype, t->type)) {
00501          continue;
00502       }
00503 
00504       /* if both sample rates have been supplied, and they don't match,
00505        * then this not a match; if one has not been supplied, then the
00506        * rates are not compared */
00507       if (sample_rate && t->sample_rate &&
00508           (sample_rate != t->sample_rate)) {
00509          continue;
00510       }
00511 
00512       found = 1;
00513       codecs->payloads[pt] = t->payload_type;
00514 
00515       if ((t->payload_type.format.id == AST_FORMAT_G726) && t->payload_type.asterisk_format && (options & AST_RTP_OPT_G726_NONSTANDARD)) {
00516          ast_format_set(&codecs->payloads[pt].format, AST_FORMAT_G726_AAL2, 0);
00517       }
00518 
00519       if (instance && instance->engine && instance->engine->payload_set) {
00520          instance->engine->payload_set(instance, pt, codecs->payloads[i].asterisk_format, &codecs->payloads[i].format, codecs->payloads[i].rtp_code);
00521       }
00522 
00523       break;
00524    }
00525    ast_rwlock_unlock(&mime_types_lock);
00526 
00527    return (found ? 0 : -2);
00528 }

void ast_rtp_codecs_payloads_unset ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance,
int  payload 
)

Remove payload information.

Parameters:
codecs The codecs structure to muck with
instance Optionally the instance that the codecs structure belongs to
payload Numerical payload to unset
Example usage:

 ast_rtp_codecs_payloads_unset(&codecs, NULL, 0);

This clears the payload '0' from the codecs structure. It will be as if it was never set.

Since:
1.8

Definition at line 535 of file rtp_engine.c.

References ast_debug, ast_format_clear(), AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_engine::payload_set, ast_rtp_codecs::payloads, and ast_rtp_payload_type::rtp_code.

Referenced by process_sdp_a_audio(), and process_sdp_a_video().

00536 {
00537    if (payload < 0 || payload >= AST_RTP_MAX_PT) {
00538       return;
00539    }
00540 
00541    ast_debug(2, "Unsetting payload %d on %p\n", payload, codecs);
00542 
00543    codecs->payloads[payload].asterisk_format = 0;
00544    codecs->payloads[payload].rtp_code = 0;
00545    ast_format_clear(&codecs->payloads[payload].format);
00546 
00547    if (instance && instance->engine && instance->engine->payload_set) {
00548       instance->engine->payload_set(instance, payload, 0, NULL, 0);
00549    }
00550 }

int ast_rtp_engine_load_format ( const struct ast_format format  ) 

Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine so their mime type can payload number can be initialized.

Definition at line 1936 of file rtp_engine.c.

References add_static_payload(), AST_FORMAT_CELT, ast_format_rate(), AST_FORMAT_SILK, ast_format::id, and set_next_mime_type().

Referenced by ast_format_attr_reg_interface().

01937 {
01938    switch (format->id) {
01939    case AST_FORMAT_SILK:
01940       set_next_mime_type(format, 0, "audio", "SILK", ast_format_rate(format));
01941       add_static_payload(-1, format, 0);
01942       break;
01943    case AST_FORMAT_CELT:
01944       set_next_mime_type(format, 0, "audio", "CELT", ast_format_rate(format));
01945       add_static_payload(-1, format, 0);
01946       break;
01947    default:
01948       break;
01949    }
01950 
01951    return 0;
01952 }

int ast_rtp_engine_register2 ( struct ast_rtp_engine engine,
struct ast_module module 
)

Register an RTP engine.

Parameters:
engine Structure of the RTP engine to register
module Module that the RTP engine is part of
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_engine_register2(&example_rtp_engine, NULL);

This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not associate a module with it.

Note:
It is recommended that you use the ast_rtp_engine_register macro so that the module is associated with the RTP engine and use counting is performed.
Since:
1.8

Definition at line 110 of file rtp_engine.c.

References ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verb, ast_rtp_engine::destroy, ast_rtp_engine::entry, LOG_WARNING, ast_rtp_engine::mod, ast_rtp_engine::name, ast_rtp_engine::new, ast_rtp_engine::read, and ast_rtp_engine::write.

00111 {
00112    struct ast_rtp_engine *current_engine;
00113 
00114    /* Perform a sanity check on the engine structure to make sure it has the basics */
00115    if (ast_strlen_zero(engine->name) || !engine->new || !engine->destroy || !engine->write || !engine->read) {
00116       ast_log(LOG_WARNING, "RTP Engine '%s' failed sanity check so it was not registered.\n", !ast_strlen_zero(engine->name) ? engine->name : "Unknown");
00117       return -1;
00118    }
00119 
00120    /* Link owner module to the RTP engine for reference counting purposes */
00121    engine->mod = module;
00122 
00123    AST_RWLIST_WRLOCK(&engines);
00124 
00125    /* Ensure that no two modules with the same name are registered at the same time */
00126    AST_RWLIST_TRAVERSE(&engines, current_engine, entry) {
00127       if (!strcmp(current_engine->name, engine->name)) {
00128          ast_log(LOG_WARNING, "An RTP engine with the name '%s' has already been registered.\n", engine->name);
00129          AST_RWLIST_UNLOCK(&engines);
00130          return -1;
00131       }
00132    }
00133 
00134    /* The engine survived our critique. Off to the list it goes to be used */
00135    AST_RWLIST_INSERT_TAIL(&engines, engine, entry);
00136 
00137    AST_RWLIST_UNLOCK(&engines);
00138 
00139    ast_verb(2, "Registered RTP engine '%s'\n", engine->name);
00140 
00141    return 0;
00142 }

int ast_rtp_engine_register_srtp ( struct ast_srtp_res srtp_res,
struct ast_srtp_policy_res policy_res 
)

Definition at line 1833 of file rtp_engine.c.

Referenced by res_srtp_init().

01834 {
01835    if (res_srtp || res_srtp_policy) {
01836       return -1;
01837    }
01838    if (!srtp_res || !policy_res) {
01839       return -1;
01840    }
01841 
01842    res_srtp = srtp_res;
01843    res_srtp_policy = policy_res;
01844 
01845    return 0;
01846 }

int ast_rtp_engine_srtp_is_registered ( void   ) 

Definition at line 1854 of file rtp_engine.c.

Referenced by sdp_crypto_activate(), sdp_crypto_process(), sdp_crypto_setup(), set_crypto_policy(), and setup_srtp().

01855 {
01856    return res_srtp && res_srtp_policy;
01857 }

int ast_rtp_engine_unload_format ( const struct ast_format format  ) 

Formats requiring the use of a format attribute interface must have that interface registered in order for the rtp engine to handle it correctly. If an attribute interface is unloaded, this function must be called to notify the rtp_engine.

Definition at line 1954 of file rtp_engine.c.

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_RTP_MAX_PT, ast_rtp_mime_types, ast_rwlock_unlock, ast_rwlock_wrlock, and static_RTP_PT.

Referenced by ast_format_attr_unreg_interface().

01955 {
01956    int x;
01957    int y = 0;
01958 
01959    ast_rwlock_wrlock(&static_RTP_PT_lock);
01960    /* remove everything pertaining to this format id from the lists */
01961    for (x = 0; x < AST_RTP_MAX_PT; x++) {
01962       if (ast_format_cmp(&static_RTP_PT[x].format, format) == AST_FORMAT_CMP_EQUAL) {
01963          memset(&static_RTP_PT[x], 0, sizeof(struct ast_rtp_payload_type));
01964       }
01965    }
01966    ast_rwlock_unlock(&static_RTP_PT_lock);
01967 
01968 
01969    ast_rwlock_wrlock(&mime_types_lock);
01970    /* rebuild the list skipping the items matching this id */
01971    for (x = 0; x < mime_types_len; x++) {
01972       if (ast_format_cmp(&ast_rtp_mime_types[x].payload_type.format, format) == AST_FORMAT_CMP_EQUAL) {
01973          continue;
01974       }
01975       ast_rtp_mime_types[y] = ast_rtp_mime_types[x];
01976       y++;
01977    }
01978    mime_types_len = y;
01979    ast_rwlock_unlock(&mime_types_lock);
01980    return 0;
01981 }

int ast_rtp_engine_unregister ( struct ast_rtp_engine engine  ) 

Unregister an RTP engine.

Parameters:
engine Structure of the RTP engine to unregister
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_engine_unregister(&example_rtp_engine);

This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.

Since:
1.8

Definition at line 144 of file rtp_engine.c.

References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_rtp_engine::entry, and ast_rtp_engine::name.

Referenced by load_module(), and unload_module().

00145 {
00146    struct ast_rtp_engine *current_engine = NULL;
00147 
00148    AST_RWLIST_WRLOCK(&engines);
00149 
00150    if ((current_engine = AST_RWLIST_REMOVE(&engines, engine, entry))) {
00151       ast_verb(2, "Unregistered RTP engine '%s'\n", engine->name);
00152    }
00153 
00154    AST_RWLIST_UNLOCK(&engines);
00155 
00156    return current_engine ? 0 : -1;
00157 }

void ast_rtp_engine_unregister_srtp ( void   ) 

Definition at line 1848 of file rtp_engine.c.

Referenced by unload_module().

01849 {
01850    res_srtp = NULL;
01851    res_srtp_policy = NULL;
01852 }

int ast_rtp_glue_register2 ( struct ast_rtp_glue glue,
struct ast_module module 
)

Register RTP glue.

Parameters:
glue The glue to register
module Module that the RTP glue is part of
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_glue_register2(&example_rtp_glue, NULL);

This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not associate a module with it.

Note:
It is recommended that you use the ast_rtp_glue_register macro so that the module is associated with the RTP glue and use counting is performed.
Since:
1.8

Definition at line 159 of file rtp_engine.c.

References ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verb, ast_rtp_glue::entry, LOG_WARNING, ast_rtp_glue::mod, and ast_rtp_glue::type.

00160 {
00161    struct ast_rtp_glue *current_glue = NULL;
00162 
00163    if (ast_strlen_zero(glue->type)) {
00164       return -1;
00165    }
00166 
00167    glue->mod = module;
00168 
00169    AST_RWLIST_WRLOCK(&glues);
00170 
00171    AST_RWLIST_TRAVERSE(&glues, current_glue, entry) {
00172       if (!strcasecmp(current_glue->type, glue->type)) {
00173          ast_log(LOG_WARNING, "RTP glue with the name '%s' has already been registered.\n", glue->type);
00174          AST_RWLIST_UNLOCK(&glues);
00175          return -1;
00176       }
00177    }
00178 
00179    AST_RWLIST_INSERT_TAIL(&glues, glue, entry);
00180 
00181    AST_RWLIST_UNLOCK(&glues);
00182 
00183    ast_verb(2, "Registered RTP glue '%s'\n", glue->type);
00184 
00185    return 0;
00186 }

int ast_rtp_glue_unregister ( struct ast_rtp_glue glue  ) 

Unregister RTP glue.

Parameters:
glue The glue to unregister
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_glue_unregister(&example_rtp_glue);

This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.

Since:
1.8

Definition at line 188 of file rtp_engine.c.

References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_rtp_glue::entry, and ast_rtp_glue::type.

Referenced by load_module(), and unload_module().

00189 {
00190    struct ast_rtp_glue *current_glue = NULL;
00191 
00192    AST_RWLIST_WRLOCK(&glues);
00193 
00194    if ((current_glue = AST_RWLIST_REMOVE(&glues, glue, entry))) {
00195       ast_verb(2, "Unregistered RTP glue '%s'\n", glue->type);
00196    }
00197 
00198    AST_RWLIST_UNLOCK(&glues);
00199 
00200    return current_glue ? 0 : -1;
00201 }

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.

Parameters:
instance The RTP instance
Return values:
0 success
-1 failure
Example usage:

This tells the underlying RTP engine of instance that packets will now flow.

Since:
1.8

Definition at line 1774 of file rtp_engine.c.

References ast_rtp_engine::activate, and ast_rtp_instance::engine.

Referenced by handle_response_invite(), multicast_rtp_call(), and transmit_response_with_sdp().

01775 {
01776    return instance->engine->activate ? instance->engine->activate(instance) : 0;
01777 }

int ast_rtp_instance_add_srtp_policy ( struct ast_rtp_instance instance,
struct ast_srtp_policy policy 
)

Definition at line 1859 of file rtp_engine.c.

References ast_srtp_res::add_stream, ast_srtp_res::create, and ast_rtp_instance::srtp.

Referenced by sdp_crypto_activate().

01860 {
01861    if (!res_srtp) {
01862       return -1;
01863    }
01864 
01865    if (!instance->srtp) {
01866       return res_srtp->create(&instance->srtp, instance, policy);
01867    } else {
01868       return res_srtp->add_stream(instance->srtp, policy);
01869    }
01870 }

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.

Parameters:
instance The RTP instance
to_endpoint Formats being sent/received towards the endpoint
to_asterisk Formats being sent/received towards Asterisk
result capabilities structure to store and return supported formats in.
Example usage:

 ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);

This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.

Since:
1.8

Definition at line 1762 of file rtp_engine.c.

References ast_format_cap_is_empty(), ast_translate_available_formats(), ast_rtp_engine::available_formats, and ast_rtp_instance::engine.

Referenced by sip_call().

01763 {
01764    if (instance->engine->available_formats) {
01765       instance->engine->available_formats(instance, to_endpoint, to_asterisk, result);
01766       if (!ast_format_cap_is_empty(result)) {
01767          return;
01768       }
01769    }
01770 
01771    ast_translate_available_formats(to_endpoint, to_asterisk, result);
01772 }

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 
)

Bridge two channels that use RTP instances.

Parameters:
c0 First channel part of the bridge
c1 Second channel part of the bridge
flags Bridging flags
fo If a frame needs to be passed up it is stored here
rc Channel that passed the above frame up
timeoutms How long the channels should be bridged for
Return values:
Bridge result
Note:
This should only be used by channel drivers in their technology declaration.
Since:
1.8

Definition at line 1286 of file rtp_engine.c.

References AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, ast_channel_lock, ast_channel_name(), ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_debug, ast_format_cap_alloc_nolock(), ast_format_cap_destroy(), ast_format_cap_has_joint(), ast_format_cap_is_empty(), ast_getformatname_multiple(), ast_log(), AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_LOCAL, AST_RTP_GLUE_RESULT_REMOTE, ast_rtp_instance_dtmf_mode_get(), ast_rtp_instance_get_glue(), ast_rtp_instance_get_remote_address(), ast_sockaddr_is_ipv4_mapped(), ast_verb, ast_rtp_instance::chan, ast_rtp_engine::dtmf_compatible, ast_rtp_instance::engine, ast_rtp_glue::get_codec, ast_rtp_glue::get_rtp_info, ast_rtp_glue::get_vrtp_info, ast_rtp_instance::glue, ast_rtp_engine::local_bridge, local_bridge_loop(), LOG_WARNING, remote_bridge_loop(), ast_sockaddr::ss, ast_channel::tech, ast_channel::tech_pvt, ast_channel_tech::type, and unref_instance_cond().

01287 {
01288    struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,
01289          *vinstance0 = NULL, *vinstance1 = NULL,
01290          *tinstance0 = NULL, *tinstance1 = NULL;
01291    struct ast_rtp_glue *glue0, *glue1;
01292    struct ast_sockaddr addr1 = { {0, }, }, addr2 = { {0, }, };
01293    enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01294    enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01295    enum ast_bridge_result res = AST_BRIDGE_FAILED;
01296    enum ast_rtp_dtmf_mode dmode;
01297    struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
01298    struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
01299    int unlock_chans = 1;
01300 
01301    if (!cap0 || !cap1) {
01302       unlock_chans = 0;
01303       goto done;
01304    }
01305 
01306    /* Lock both channels so we can look for the glue that binds them together */
01307    ast_channel_lock(c0);
01308    while (ast_channel_trylock(c1)) {
01309       ast_channel_unlock(c0);
01310       usleep(1);
01311       ast_channel_lock(c0);
01312    }
01313 
01314    /* Ensure neither channel got hungup during lock avoidance */
01315    if (ast_check_hangup(c0) || ast_check_hangup(c1)) {
01316       ast_log(LOG_WARNING, "Got hangup while attempting to bridge '%s' and '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
01317       goto done;
01318    }
01319 
01320    /* Grab glue that binds each channel to something using the RTP engine */
01321    if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
01322       ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
01323       goto done;
01324    }
01325 
01326    audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
01327    video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
01328 
01329    audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
01330    video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
01331 
01332    /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
01333    if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01334       audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01335    }
01336    if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01337       audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01338    }
01339 
01340    /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
01341    if (audio_glue0_res == AST_RTP_GLUE_RESULT_FORBID || audio_glue1_res == AST_RTP_GLUE_RESULT_FORBID) {
01342       res = AST_BRIDGE_FAILED_NOWARN;
01343       goto done;
01344    }
01345 
01346 
01347    /* If address families differ, force a local bridge */
01348    ast_rtp_instance_get_remote_address(instance0, &addr1);
01349    ast_rtp_instance_get_remote_address(instance1, &addr2);
01350 
01351    if (addr1.ss.ss_family != addr2.ss.ss_family ||
01352       (ast_sockaddr_is_ipv4_mapped(&addr1) != ast_sockaddr_is_ipv4_mapped(&addr2))) {
01353       audio_glue0_res = AST_RTP_GLUE_RESULT_LOCAL;
01354       audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
01355    }
01356 
01357    /* If we need to get DTMF see if we can do it outside of the RTP stream itself */
01358    dmode = ast_rtp_instance_dtmf_mode_get(instance0);
01359    if ((flags & AST_BRIDGE_DTMF_CHANNEL_0) && dmode) {
01360       res = AST_BRIDGE_FAILED_NOWARN;
01361       goto done;
01362    }
01363    dmode = ast_rtp_instance_dtmf_mode_get(instance1);
01364    if ((flags & AST_BRIDGE_DTMF_CHANNEL_1) && dmode) {
01365       res = AST_BRIDGE_FAILED_NOWARN;
01366       goto done;
01367    }
01368 
01369    /* If we have gotten to a local bridge make sure that both sides have the same local bridge callback and that they are DTMF compatible */
01370    if ((audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) && ((instance0->engine->local_bridge != instance1->engine->local_bridge) || (instance0->engine->dtmf_compatible && !instance0->engine->dtmf_compatible(c0, instance0, c1, instance1)))) {
01371       res = AST_BRIDGE_FAILED_NOWARN;
01372       goto done;
01373    }
01374 
01375    /* Make sure that codecs match */
01376    if (glue0->get_codec){
01377       glue0->get_codec(c0, cap0);
01378    }
01379    if (glue1->get_codec) {
01380       glue1->get_codec(c1, cap1);
01381    }
01382    if (!ast_format_cap_is_empty(cap0) && !ast_format_cap_is_empty(cap1) && !ast_format_cap_has_joint(cap0, cap1)) {
01383       char tmp0[256] = { 0, };
01384       char tmp1[256] = { 0, };
01385       ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n",
01386          ast_getformatname_multiple(tmp0, sizeof(tmp0), cap0),
01387          ast_getformatname_multiple(tmp1, sizeof(tmp1), cap1));
01388       res = AST_BRIDGE_FAILED_NOWARN;
01389       goto done;
01390    }
01391 
01392    instance0->glue = glue0;
01393    instance1->glue = glue1;
01394    instance0->chan = c0;
01395    instance1->chan = c1;
01396 
01397    /* Depending on the end result for bridging either do a local bridge or remote bridge */
01398    if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) {
01399       ast_verb(3, "Locally bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
01400       res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, c0->tech_pvt, c1->tech_pvt);
01401    } else {
01402       ast_verb(3, "Remotely bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
01403       res = remote_bridge_loop(c0, c1, instance0, instance1, vinstance0, vinstance1,
01404             tinstance0, tinstance1, glue0, glue1, cap0, cap1, timeoutms, flags,
01405             fo, rc, c0->tech_pvt, c1->tech_pvt);
01406    }
01407 
01408    instance0->glue = NULL;
01409    instance1->glue = NULL;
01410    instance0->chan = NULL;
01411    instance1->chan = NULL;
01412 
01413    unlock_chans = 0;
01414 
01415 done:
01416    if (unlock_chans) {
01417       ast_channel_unlock(c0);
01418       ast_channel_unlock(c1);
01419    }
01420    ast_format_cap_destroy(cap1);
01421    ast_format_cap_destroy(cap0);
01422 
01423    unref_instance_cond(&instance0);
01424    unref_instance_cond(&instance1);
01425    unref_instance_cond(&vinstance0);
01426    unref_instance_cond(&vinstance1);
01427    unref_instance_cond(&tinstance0);
01428    unref_instance_cond(&tinstance1);
01429 
01430    return res;
01431 }

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.

Parameters:
instance Instance that the new media source is feeding into
Example usage:

This indicates that the source of media that is feeding the instance pointed to by instance has changed and that the marker bit should be set and the SSRC updated.

Since:
1.8

Definition at line 761 of file rtp_engine.c.

References ast_rtp_engine::change_source, and ast_rtp_instance::engine.

Referenced by mgcp_indicate(), oh323_indicate(), sip_indicate(), and skinny_indicate().

00762 {
00763    if (instance->engine->change_source) {
00764       instance->engine->change_source(instance);
00765    }
00766 }

int ast_rtp_instance_destroy ( struct ast_rtp_instance instance  ) 

Destroy an RTP instance.

Parameters:
instance The RTP instance to destroy
Return values:
0 success
-1 failure
Example usage:

This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid memory and may not be used again.

Since:
1.8

Definition at line 223 of file rtp_engine.c.

References ao2_ref.

Referenced by __oh323_destroy(), __sip_destroy(), cleanup_connection(), destroy_endpoint(), gtalk_free_pvt(), jingle_free_pvt(), mgcp_hangup(), multicast_rtp_hangup(), multicast_rtp_request(), oh323_alloc(), setsubstate(), skinny_hangup(), start_rtp(), unalloc_sub(), and unistim_hangup().

00224 {
00225    ao2_ref(instance, -1);
00226 
00227    return 0;
00228 }

int ast_rtp_instance_dtmf_begin ( struct ast_rtp_instance instance,
char  digit 
)

Begin sending a DTMF digit.

Parameters:
instance The RTP instance to send the DTMF on
digit What DTMF digit to send
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_instance_dtmf_begin(instance, '1');

This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will continue being sent until it is ended.

Since:
1.8

Definition at line 730 of file rtp_engine.c.

References ast_rtp_engine::dtmf_begin, and ast_rtp_instance::engine.

Referenced by gtalk_digit_begin(), mgcp_senddigit_begin(), oh323_digit_begin(), and sip_senddigit_begin().

00731 {
00732    return instance->engine->dtmf_begin ? instance->engine->dtmf_begin(instance, digit) : -1;
00733 }

int ast_rtp_instance_dtmf_end ( struct ast_rtp_instance instance,
char  digit 
)

Stop sending a DTMF digit.

Parameters:
instance The RTP instance to stop the DTMF on
digit What DTMF digit to stop
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_instance_dtmf_end(instance, '1');

This stops sending the DTMF '1' on the RTP instance pointed to by instance.

Since:
1.8

Definition at line 735 of file rtp_engine.c.

References ast_rtp_engine::dtmf_end, and ast_rtp_instance::engine.

Referenced by mgcp_senddigit_end(), and oh323_digit_end().

00736 {
00737    return instance->engine->dtmf_end ? instance->engine->dtmf_end(instance, digit) : -1;
00738 }

int ast_rtp_instance_dtmf_end_with_duration ( struct ast_rtp_instance instance,
char  digit,
unsigned int  duration 
)

Definition at line 739 of file rtp_engine.c.

References ast_rtp_engine::dtmf_end_with_duration, and ast_rtp_instance::engine.

Referenced by gtalk_digit_end(), and sip_senddigit_end().

00740 {
00741    return instance->engine->dtmf_end_with_duration ? instance->engine->dtmf_end_with_duration(instance, digit, duration) : -1;
00742 }

enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get ( struct ast_rtp_instance instance  ) 

Get the DTMF mode of an RTP instance.

Parameters:
instance The RTP instance to get the DTMF mode of
Return values:
DTMF mode
Example usage:

This gets the DTMF mode set on the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 749 of file rtp_engine.c.

References ast_rtp_engine::dtmf_mode_get, and ast_rtp_instance::engine.

Referenced by ast_rtp_instance_bridge().

00750 {
00751    return instance->engine->dtmf_mode_get ? instance->engine->dtmf_mode_get(instance) : 0;
00752 }

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.

Parameters:
instance the RTP instance to set DTMF mode on
dtmf_mode The DTMF mode that is in use
Return values:
0 success
-1 failure
Example usage:

This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.

Since:
1.8

Definition at line 744 of file rtp_engine.c.

References ast_rtp_engine::dtmf_mode_set, and ast_rtp_instance::engine.

Referenced by enable_dsp_detect(), gtalk_alloc(), and sip_new().

00745 {
00746    return (!instance->engine->dtmf_mode_set || instance->engine->dtmf_mode_set(instance, dtmf_mode)) ? -1 : 0;
00747 }

int ast_rtp_instance_early_bridge ( struct ast_channel c0,
struct ast_channel c1 
)

Early bridge two channels that use RTP instances.

Parameters:
c0 First channel part of the bridge
c1 Second channel part of the bridge
Return values:
0 success
-1 failure
Note:
This should only be used by channel drivers in their technology declaration.
Since:
1.8

Definition at line 1532 of file rtp_engine.c.

References ast_channel_lock, ast_channel_name(), ast_channel_trylock, ast_channel_unlock, ast_debug, ast_format_cap_alloc_nolock(), ast_format_cap_destroy(), ast_format_cap_has_joint(), ast_log(), AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_REMOTE, ast_rtp_instance_get_glue(), ast_rtp_glue::get_codec, ast_rtp_glue::get_rtp_info, ast_rtp_glue::get_vrtp_info, LOG_WARNING, ast_channel::tech, ast_channel_tech::type, unref_instance_cond(), and ast_rtp_glue::update_peer.

01533 {
01534    struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,
01535          *vinstance0 = NULL, *vinstance1 = NULL,
01536          *tinstance0 = NULL, *tinstance1 = NULL;
01537    struct ast_rtp_glue *glue0, *glue1;
01538    enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01539    enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01540    struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
01541    struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
01542    int res = 0;
01543 
01544    /* If there is no second channel just immediately bail out, we are of no use in that scenario */
01545    if (!c1) {
01546       ast_format_cap_destroy(cap0);
01547       ast_format_cap_destroy(cap1);
01548       return -1;
01549    }
01550 
01551    /* Lock both channels so we can look for the glue that binds them together */
01552    ast_channel_lock(c0);
01553    while (ast_channel_trylock(c1)) {
01554       ast_channel_unlock(c0);
01555       usleep(1);
01556       ast_channel_lock(c0);
01557    }
01558 
01559    if (!cap1 || !cap0) {
01560       goto done;
01561    }
01562 
01563    /* Grab glue that binds each channel to something using the RTP engine */
01564    if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
01565       ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
01566       goto done;
01567    }
01568 
01569    audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
01570    video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
01571 
01572    audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
01573    video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
01574 
01575    /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
01576    if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01577       audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01578    }
01579    if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01580       audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01581    }
01582    if (audio_glue0_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue0_res == AST_RTP_GLUE_RESULT_FORBID || video_glue0_res == AST_RTP_GLUE_RESULT_REMOTE) && glue0->get_codec) {
01583       glue0->get_codec(c0, cap0);
01584    }
01585    if (audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue1_res == AST_RTP_GLUE_RESULT_FORBID || video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) && glue1->get_codec) {
01586       glue1->get_codec(c1, cap1);
01587    }
01588 
01589    /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
01590    if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
01591       goto done;
01592    }
01593 
01594    /* Make sure we have matching codecs */
01595    if (!ast_format_cap_has_joint(cap0, cap1)) {
01596       goto done;
01597    }
01598 
01599    /* Bridge media early */
01600    if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
01601       ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
01602    }
01603 
01604    res = 0;
01605 
01606 done:
01607    ast_channel_unlock(c0);
01608    ast_channel_unlock(c1);
01609 
01610    ast_format_cap_destroy(cap0);
01611    ast_format_cap_destroy(cap1);
01612 
01613    unref_instance_cond(&instance0);
01614    unref_instance_cond(&instance1);
01615    unref_instance_cond(&vinstance0);
01616    unref_instance_cond(&vinstance1);
01617    unref_instance_cond(&tinstance0);
01618    unref_instance_cond(&tinstance1);
01619 
01620    if (!res) {
01621       ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
01622    }
01623 
01624    return res;
01625 }

void ast_rtp_instance_early_bridge_make_compatible ( struct ast_channel c0,
struct ast_channel c1 
)

Make two channels compatible for early bridging.

Parameters:
c0 First channel part of the bridge
c1 Second channel part of the bridge
Since:
1.8

Definition at line 1438 of file rtp_engine.c.

References ast_channel_lock, ast_channel_name(), ast_channel_trylock, ast_channel_unlock, ast_debug, ast_format_cap_alloc_nolock(), ast_format_cap_destroy(), ast_format_cap_has_joint(), ast_log(), ast_rtp_codecs_payloads_copy(), AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_REMOTE, ast_rtp_instance_get_glue(), ast_rtp_instance::codecs, ast_rtp_glue::get_codec, ast_rtp_glue::get_rtp_info, ast_rtp_glue::get_vrtp_info, LOG_WARNING, ast_channel::tech, ast_channel_tech::type, unref_instance_cond(), and ast_rtp_glue::update_peer.

Referenced by dial_exec_full(), and do_forward().

01439 {
01440    struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,
01441       *vinstance0 = NULL, *vinstance1 = NULL,
01442       *tinstance0 = NULL, *tinstance1 = NULL;
01443    struct ast_rtp_glue *glue0, *glue1;
01444    enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01445    enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01446    struct ast_format_cap *cap0 = ast_format_cap_alloc_nolock();
01447    struct ast_format_cap *cap1 = ast_format_cap_alloc_nolock();
01448    int res = 0;
01449 
01450    /* Lock both channels so we can look for the glue that binds them together */
01451    ast_channel_lock(c0);
01452    while (ast_channel_trylock(c1)) {
01453       ast_channel_unlock(c0);
01454       usleep(1);
01455       ast_channel_lock(c0);
01456    }
01457 
01458    if (!cap1 || !cap0) {
01459       goto done;
01460    }
01461 
01462    /* Grab glue that binds each channel to something using the RTP engine */
01463    if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
01464       ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
01465       goto done;
01466    }
01467 
01468    audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
01469    video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
01470 
01471    audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
01472    video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
01473 
01474    /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
01475    if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01476       audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
01477    }
01478    if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
01479       audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
01480    }
01481    if (audio_glue0_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue0_res == AST_RTP_GLUE_RESULT_FORBID || video_glue0_res == AST_RTP_GLUE_RESULT_REMOTE) && glue0->get_codec) {
01482       glue0->get_codec(c0, cap0);
01483    }
01484    if (audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue1_res == AST_RTP_GLUE_RESULT_FORBID || video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) && glue1->get_codec) {
01485       glue1->get_codec(c1, cap1);
01486    }
01487 
01488    /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
01489    if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
01490       goto done;
01491    }
01492 
01493    /* Make sure we have matching codecs */
01494    if (!ast_format_cap_has_joint(cap0, cap1)) {
01495       goto done;
01496    }
01497 
01498    ast_rtp_codecs_payloads_copy(&instance0->codecs, &instance1->codecs, instance1);
01499 
01500    if (vinstance0 && vinstance1) {
01501       ast_rtp_codecs_payloads_copy(&vinstance0->codecs, &vinstance1->codecs, vinstance1);
01502    }
01503    if (tinstance0 && tinstance1) {
01504       ast_rtp_codecs_payloads_copy(&tinstance0->codecs, &tinstance1->codecs, tinstance1);
01505    }
01506 
01507         if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
01508                 ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
01509         }
01510 
01511    res = 0;
01512 
01513 done:
01514    ast_channel_unlock(c0);
01515    ast_channel_unlock(c1);
01516 
01517    ast_format_cap_destroy(cap0);
01518    ast_format_cap_destroy(cap1);
01519 
01520    unref_instance_cond(&instance0);
01521    unref_instance_cond(&instance1);
01522    unref_instance_cond(&vinstance0);
01523    unref_instance_cond(&vinstance1);
01524    unref_instance_cond(&tinstance0);
01525    unref_instance_cond(&tinstance1);
01526 
01527    if (!res) {
01528       ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
01529    }
01530 }

int ast_rtp_instance_fd ( struct ast_rtp_instance instance,
int  rtcp 
)

Get the file descriptor for an RTP session (or RTCP).

Parameters:
instance Instance to get the file descriptor for
rtcp Whether to retrieve the file descriptor for RTCP or not
Return values:
fd success
-1 failure
Example usage:

 int rtp_fd = ast_rtp_instance_fd(instance, 0);

This retrieves the file descriptor for the socket carrying media on the instance pointed to by instance.

Since:
1.8

Definition at line 780 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::fd.

Referenced by __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), gtalk_new(), jingle_new(), mgcp_new(), process_sdp(), sip_new(), skinny_new(), start_rtp(), and unistim_new().

00781 {
00782    return instance->engine->fd ? instance->engine->fd(instance, rtcp) : -1;
00783 }

struct ast_rtp_glue* ast_rtp_instance_get_active_glue ( struct ast_rtp_instance instance  )  [read]

Get the RTP glue in use on an RTP instance.

Parameters:
instance The RTP instance
Return values:
pointer to the glue
Example:

This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 1823 of file rtp_engine.c.

References ast_rtp_instance::glue.

01824 {
01825    return instance->glue;
01826 }

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.

Parameters:
instance The instance that we want to get the local address for
address An initialized address that may be overwritten if the local address is different
Return values:
0 address was not changed
1 address was changed Example usage:
 struct ast_sockaddr address;
 int ret;
 ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);

This retrieves the current local address set on the instance pointed to by instance and puts the value into the address structure.

Since:
1.8

Definition at line 341 of file rtp_engine.c.

References ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::local_address.

00343 {
00344    if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
00345       ast_sockaddr_copy(address, &instance->local_address);
00346       return 1;
00347    }
00348 
00349    return 0;
00350 }

int ast_rtp_instance_get_and_cmp_remote_address ( struct ast_rtp_instance instance,
struct ast_sockaddr address 
)

Get the address of the remote endpoint that we are sending RTP to, comparing its address to another.

Parameters:
instance The instance that we want to get the remote address for
address An initialized address that may be overwritten if the remote address is different
Return values:
0 address was not changed
1 address was changed Example usage:
 struct ast_sockaddr address;
 int ret;
 ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);

This retrieves the current remote address set on the instance pointed to by instance and puts the value into the address structure.

Since:
1.8

Definition at line 358 of file rtp_engine.c.

References ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::remote_address.

Referenced by sip_set_rtp_peer().

00360 {
00361    if (ast_sockaddr_cmp(address, &instance->remote_address) != 0) {
00362       ast_sockaddr_copy(address, &instance->remote_address);
00363       return 1;
00364    }
00365 
00366    return 0;
00367 }

struct ast_rtp_instance* ast_rtp_instance_get_bridged ( struct ast_rtp_instance instance  )  [read]

Get the other RTP instance that an instance is bridged to.

Parameters:
instance The RTP instance that we want
Return values:
non-NULL success
NULL failure
Example usage:

This gets the RTP instance that instance0 is bridged to.

Since:
1.8

Definition at line 1433 of file rtp_engine.c.

References ast_rtp_instance::bridged.

Referenced by ast_rtp_read(), bridge_p2p_rtp_write(), and dialog_needdestroy().

01434 {
01435    return instance->bridged;
01436 }

struct ast_channel* ast_rtp_instance_get_chan ( struct ast_rtp_instance instance  )  [read]

Get the channel that is associated with an RTP instance while in a bridge.

Parameters:
instance The RTP instance
Return values:
pointer to the channel
Example:

 struct ast_channel *chan = ast_rtp_instance_get_chan(instance);

This gets the channel associated with the RTP instance pointed to by 'instance'.

Note:
This will only return a channel while in a local or remote bridge.
Since:
1.8

Definition at line 1828 of file rtp_engine.c.

References ast_rtp_instance::chan.

01829 {
01830    return instance->chan;
01831 }

struct ast_rtp_codecs* ast_rtp_instance_get_codecs ( struct ast_rtp_instance instance  )  [read]

Get the codecs structure of an RTP instance.

Parameters:
instance The RTP instance to get the codecs structure from
Example usage:

 struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance);

This gets the codecs structure on the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 405 of file rtp_engine.c.

References ast_rtp_instance::codecs.

Referenced by __oh323_rtp_create(), add_codec_to_sdp(), add_noncodec_to_sdp(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), ast_rtp_dtmf_begin(), ast_rtp_read(), ast_rtp_sendcng(), ast_rtp_write(), bridge_p2p_rtp_write(), check_peer_ok(), create_addr_from_peer(), gtalk_alloc(), gtalk_is_answered(), gtalk_new(), gtalk_newcall(), jingle_new(), jingle_newcall(), multicast_rtp_write(), process_sdp(), process_sdp_a_audio(), set_dtmf_payload(), set_peer_capabilities(), setup_rtp_connection(), start_rtp(), and transmit_response_with_sdp().

00406 {
00407    return &instance->codecs;
00408 }

void* ast_rtp_instance_get_data ( struct ast_rtp_instance instance  ) 

struct ast_rtp_engine* ast_rtp_instance_get_engine ( struct ast_rtp_instance instance  )  [read]

Get the RTP engine in use on an RTP instance.

Parameters:
instance The RTP instance
Return values:
pointer to the engine
Example usage:

 struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);

This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 1818 of file rtp_engine.c.

References ast_rtp_instance::engine.

01819 {
01820    return instance->engine;
01821 }

void* ast_rtp_instance_get_extended_prop ( struct ast_rtp_instance instance,
int  property 
)

Get the value of an RTP instance extended property.

Parameters:
instance The RTP instance to get the extended property on
property The extended property to get
Since:
1.8

Definition at line 382 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::extended_prop_get.

00383 {
00384    if (instance->engine->extended_prop_get) {
00385       return instance->engine->extended_prop_get(instance, property);
00386    }
00387 
00388    return NULL;
00389 }

struct ast_rtp_glue* ast_rtp_instance_get_glue ( const char *  type  )  [read]

Get the RTP glue that binds a channel to the RTP engine.

Parameters:
type Name of the glue we want
Return values:
non-NULL success
NULL failure
Example usage:

 struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");

This retrieves the RTP glue that has the name 'Example'.

Since:
1.8

Definition at line 785 of file rtp_engine.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_rtp_glue::entry, and ast_rtp_glue::type.

Referenced by ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), and remote_bridge_loop().

00786 {
00787    struct ast_rtp_glue *glue = NULL;
00788 
00789    AST_RWLIST_RDLOCK(&glues);
00790 
00791    AST_RWLIST_TRAVERSE(&glues, glue, entry) {
00792       if (!strcasecmp(glue->type, type)) {
00793          break;
00794       }
00795    }
00796 
00797    AST_RWLIST_UNLOCK(&glues);
00798 
00799    return glue;
00800 }

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.

Parameters:
instance The RTP instance
Return values:
timeout value
Example usage:

 int timeout = ast_rtp_instance_get_hold_timeout(instance);

This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 1808 of file rtp_engine.c.

References ast_rtp_instance::holdtimeout.

Referenced by check_rtp_timeout().

01809 {
01810    return instance->holdtimeout;
01811 }

int ast_rtp_instance_get_keepalive ( struct ast_rtp_instance instance  ) 

Get the RTP keepalive interval.

Parameters:
instance The RTP instance
Return values:
period Keepalive interval value
Example usage:

 int interval = ast_rtp_instance_get_keepalive(instance);

This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 1813 of file rtp_engine.c.

References ast_rtp_instance::keepalive.

Referenced by check_rtp_timeout().

01814 {
01815    return instance->keepalive;
01816 }

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.

Parameters:
instance The RTP instance to get the address from
address The variable to store the address in
Example usage:

 struct ast_sockaddr address;
 ast_rtp_instance_get_local_address(instance, &address);

This gets the local address that we are expecting RTP on and stores it in the 'address' structure.

Since:
1.8

Definition at line 352 of file rtp_engine.c.

References ast_sockaddr_copy(), and ast_rtp_instance::local_address.

Referenced by add_sdp(), apply_directmedia_ha(), ast_rtp_prop_set(), external_rtp_create(), get_our_media_address(), gtalk_create_candidates(), handle_open_receive_channel_ack_message(), jingle_create_candidates(), multicast_send_control_packet(), oh323_set_rtp_peer(), sip_acf_channel_read(), skinny_set_rtp_peer(), and start_rtp().

00354 {
00355    ast_sockaddr_copy(address, &instance->local_address);
00356 }

int ast_rtp_instance_get_prop ( struct ast_rtp_instance instance,
enum ast_rtp_property  property 
)

Get the value of an RTP instance property.

Parameters:
instance The RTP instance to get the property from
property The property to get
Return values:
Current value of the property
Example usage:

This returns the current value of the NAT property on the instance pointed to by instance.

Since:
1.8

Definition at line 400 of file rtp_engine.c.

References ast_rtp_instance::properties.

Referenced by ast_rtcp_read(), ast_rtp_dtmf_compatible(), ast_rtp_raw_write(), ast_rtp_read(), bridge_p2p_rtp_write(), process_dtmf_cisco(), and process_dtmf_rfc2833().

00401 {
00402    return instance->properties[property];
00403 }

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.

Parameters:
instance Instance to get statistics on
field What quality statistic to retrieve
buf What buffer to put the result into
size Size of the above buffer
Return values:
non-NULL success
NULL failure
Example usage:

This retrieves general quality statistics and places a text representation into the buf pointed to by buf.

Since:
1.8

Definition at line 1642 of file rtp_engine.c.

References ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_ALL, AST_RTP_INSTANCE_STAT_COMBINED_JITTER, AST_RTP_INSTANCE_STAT_COMBINED_LOSS, AST_RTP_INSTANCE_STAT_COMBINED_RTT, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, ast_rtp_instance_stats::local_maxjitter, ast_rtp_instance_stats::local_maxrxploss, ast_rtp_instance_stats::local_minjitter, ast_rtp_instance_stats::local_minrxploss, ast_rtp_instance_stats::local_normdevjitter, ast_rtp_instance_stats::local_normdevrxploss, ast_rtp_instance_stats::local_ssrc, ast_rtp_instance_stats::local_stdevjitter, ast_rtp_instance_stats::local_stdevrxploss, ast_rtp_instance_stats::maxrtt, ast_rtp_instance_stats::minrtt, ast_rtp_instance_stats::normdevrtt, ast_rtp_instance_stats::remote_maxjitter, ast_rtp_instance_stats::remote_maxrxploss, ast_rtp_instance_stats::remote_minjitter, ast_rtp_instance_stats::remote_minrxploss, ast_rtp_instance_stats::remote_normdevjitter, ast_rtp_instance_stats::remote_normdevrxploss, ast_rtp_instance_stats::remote_ssrc, ast_rtp_instance_stats::remote_stdevjitter, ast_rtp_instance_stats::remote_stdevrxploss, ast_rtp_instance_stats::rtt, ast_rtp_instance_stats::rxcount, ast_rtp_instance_stats::rxjitter, ast_rtp_instance_stats::rxploss, ast_rtp_instance_stats::stdevrtt, ast_rtp_instance_stats::txcount, ast_rtp_instance_stats::txjitter, and ast_rtp_instance_stats::txploss.

Referenced by ast_rtp_instance_set_stats_vars(), handle_request_bye(), sip_acf_channel_read(), and sip_hangup().

01643 {
01644    struct ast_rtp_instance_stats stats = { 0, };
01645    enum ast_rtp_instance_stat stat;
01646 
01647    /* Determine what statistics we will need to retrieve based on field passed in */
01648    if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) {
01649       stat = AST_RTP_INSTANCE_STAT_ALL;
01650    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
01651       stat = AST_RTP_INSTANCE_STAT_COMBINED_JITTER;
01652    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
01653       stat = AST_RTP_INSTANCE_STAT_COMBINED_LOSS;
01654    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
01655       stat = AST_RTP_INSTANCE_STAT_COMBINED_RTT;
01656    } else {
01657       return NULL;
01658    }
01659 
01660    /* Attempt to actually retrieve the statistics we need to generate the quality string */
01661    if (ast_rtp_instance_get_stats(instance, &stats, stat)) {
01662       return NULL;
01663    }
01664 
01665    /* Now actually fill the buffer with the good information */
01666    if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) {
01667       snprintf(buf, size, "ssrc=%i;themssrc=%u;lp=%u;rxjitter=%f;rxcount=%u;txjitter=%f;txcount=%u;rlp=%u;rtt=%f",
01668           stats.local_ssrc, stats.remote_ssrc, stats.rxploss, stats.txjitter, stats.rxcount, stats.rxjitter, stats.txcount, stats.txploss, stats.rtt);
01669    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
01670       snprintf(buf, size, "minrxjitter=%f;maxrxjitter=%f;avgrxjitter=%f;stdevrxjitter=%f;reported_minjitter=%f;reported_maxjitter=%f;reported_avgjitter=%f;reported_stdevjitter=%f;",
01671           stats.local_minjitter, stats.local_maxjitter, stats.local_normdevjitter, sqrt(stats.local_stdevjitter), stats.remote_minjitter, stats.remote_maxjitter, stats.remote_normdevjitter, sqrt(stats.remote_stdevjitter));
01672    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
01673       snprintf(buf, size, "minrxlost=%f;maxrxlost=%f;avgrxlost=%f;stdevrxlost=%f;reported_minlost=%f;reported_maxlost=%f;reported_avglost=%f;reported_stdevlost=%f;",
01674           stats.local_minrxploss, stats.local_maxrxploss, stats.local_normdevrxploss, sqrt(stats.local_stdevrxploss), stats.remote_minrxploss, stats.remote_maxrxploss, stats.remote_normdevrxploss, sqrt(stats.remote_stdevrxploss));
01675    } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
01676       snprintf(buf, size, "minrtt=%f;maxrtt=%f;avgrtt=%f;stdevrtt=%f;", stats.minrtt, stats.maxrtt, stats.normdevrtt, stats.stdevrtt);
01677    }
01678 
01679    return buf;
01680 }

void ast_rtp_instance_get_remote_address ( struct ast_rtp_instance instance,
struct ast_sockaddr address 
)

Get the address of the remote endpoint that we are sending RTP to.

Parameters:
instance The instance that we want to get the remote address for
address A structure to put the address into
Example usage:

 struct ast_sockaddr address;
 ast_rtp_instance_get_remote_address(instance, &address);

This retrieves the current remote address set on the instance pointed to by instance and puts the value into the address structure.

Since:
1.8

Definition at line 369 of file rtp_engine.c.

References ast_sockaddr_copy(), and ast_rtp_instance::remote_address.

Referenced by add_sdp(), apply_directmedia_ha(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_instance_bridge(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_sendcng(), ast_rtp_write(), bridge_p2p_rtp_write(), create_dtmf_frame(), gtalk_update_stun(), multicast_rtp_write(), multicast_send_control_packet(), oh323_set_rtp_peer(), process_cn_rfc3389(), process_dtmf_rfc2833(), process_sdp(), remote_bridge_loop(), sip_acf_channel_read(), skinny_set_rtp_peer(), and transmit_modify_with_sdp().

00371 {
00372    ast_sockaddr_copy(address, &instance->remote_address);
00373 }

struct ast_srtp* ast_rtp_instance_get_srtp ( struct ast_rtp_instance instance  )  [read]

Definition at line 1872 of file rtp_engine.c.

References ast_rtp_instance::srtp.

Referenced by __rtp_recvfrom(), __rtp_sendto(), and ast_rtp_change_source().

01873 {
01874    return instance->srtp;
01875 }

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.

Parameters:
instance Instance to get statistics on
stats Structure to put results into
stat What statistic(s) to retrieve
Return values:
0 success
-1 failure
Example usage:

This retrieves all statistics the underlying RTP engine supports and puts the values into the stats structure.

Since:
1.8

Definition at line 1637 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::get_stat.

Referenced by ast_rtp_instance_get_quality(), ast_srtp_unprotect(), sdp_crypto_activate(), show_chanstats_cb(), and sip_acf_channel_read().

01638 {
01639    return instance->engine->get_stat ? instance->engine->get_stat(instance, stats, stat) : -1;
01640 }

int ast_rtp_instance_get_timeout ( struct ast_rtp_instance instance  ) 

Get the RTP timeout value.

Parameters:
instance The RTP instance
Return values:
timeout value
Example usage:

 int timeout = ast_rtp_instance_get_timeout(instance);

This gets the RTP timeout value for the RTP instance pointed to by 'instance'.

Since:
1.8

Definition at line 1803 of file rtp_engine.c.

References ast_rtp_instance::timeout.

Referenced by check_rtp_timeout().

01804 {
01805    return instance->timeout;
01806 }

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.

Parameters:
chan Our own Asterisk channel
instance The first RTP instance
peer The peer Asterisk channel
Return values:
0 success
-1 failure
Example usage:

This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.

Since:
1.8

Definition at line 1726 of file rtp_engine.c.

References ao2_ref, ast_channel_lock, ast_channel_unlock, ast_rtp_instance_get_glue(), ast_rtp_instance::engine, ast_rtp_glue::get_rtp_info, ast_rtp_engine::make_compatible, ast_channel::tech, and ast_channel_tech::type.

Referenced by sip_setoption().

01727 {
01728    struct ast_rtp_glue *glue;
01729    struct ast_rtp_instance *peer_instance = NULL;
01730    int res = -1;
01731 
01732    if (!instance->engine->make_compatible) {
01733       return -1;
01734    }
01735 
01736    ast_channel_lock(peer);
01737 
01738    if (!(glue = ast_rtp_instance_get_glue(peer->tech->type))) {
01739       ast_channel_unlock(peer);
01740       return -1;
01741    }
01742 
01743    glue->get_rtp_info(peer, &peer_instance);
01744 
01745    if (!peer_instance || peer_instance->engine != instance->engine) {
01746       ast_channel_unlock(peer);
01747       ao2_ref(peer_instance, -1);
01748       peer_instance = NULL;
01749       return -1;
01750    }
01751 
01752    res = instance->engine->make_compatible(chan, instance, peer, peer_instance);
01753 
01754    ast_channel_unlock(peer);
01755 
01756    ao2_ref(peer_instance, -1);
01757    peer_instance = NULL;
01758 
01759    return res;
01760 }

struct ast_rtp_instance* ast_rtp_instance_new ( const char *  engine_name,
struct ast_sched_context sched,
const struct ast_sockaddr sa,
void *  data 
) [read]

Create a new RTP instance.

Parameters:
engine_name Name of the engine to use for the RTP instance
sched Scheduler context that the RTP engine may want to use
sa Address we want to bind to
data Unique data for the engine
Return values:
non-NULL success
NULL failure
Example usage:

 struct ast_rtp_instance *instance = NULL;
 instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);

This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given in the address structure.

Note:
The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use another depending on it's own configuration.
Since:
1.8

Definition at line 230 of file rtp_engine.c.

References ao2_alloc, ao2_ref, ast_debug, ast_log(), ast_module_ref(), ast_module_unref(), AST_RWLIST_FIRST, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sockaddr_copy(), ast_strlen_zero(), ast_rtp_instance::engine, ast_rtp_engine::entry, instance_destructor(), ast_rtp_instance::local_address, LOG_ERROR, ast_rtp_engine::mod, ast_rtp_engine::name, and ast_rtp_engine::new.

Referenced by __oh323_rtp_create(), dialog_initialize_rtp(), gtalk_alloc(), jingle_alloc(), multicast_rtp_request(), and start_rtp().

00233 {
00234    struct ast_sockaddr address = {{0,}};
00235    struct ast_rtp_instance *instance = NULL;
00236    struct ast_rtp_engine *engine = NULL;
00237 
00238    AST_RWLIST_RDLOCK(&engines);
00239 
00240    /* If an engine name was specified try to use it or otherwise use the first one registered */
00241    if (!ast_strlen_zero(engine_name)) {
00242       AST_RWLIST_TRAVERSE(&engines, engine, entry) {
00243          if (!strcmp(engine->name, engine_name)) {
00244             break;
00245          }
00246       }
00247    } else {
00248       engine = AST_RWLIST_FIRST(&engines);
00249    }
00250 
00251    /* If no engine was actually found bail out now */
00252    if (!engine) {
00253       ast_log(LOG_ERROR, "No RTP engine was found. Do you have one loaded?\n");
00254       AST_RWLIST_UNLOCK(&engines);
00255       return NULL;
00256    }
00257 
00258    /* Bump up the reference count before we return so the module can not be unloaded */
00259    ast_module_ref(engine->mod);
00260 
00261    AST_RWLIST_UNLOCK(&engines);
00262 
00263    /* Allocate a new RTP instance */
00264    if (!(instance = ao2_alloc(sizeof(*instance), instance_destructor))) {
00265       ast_module_unref(engine->mod);
00266       return NULL;
00267    }
00268    instance->engine = engine;
00269    ast_sockaddr_copy(&instance->local_address, sa);
00270    ast_sockaddr_copy(&address, sa);
00271 
00272    ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance);
00273 
00274    /* And pass it off to the engine to setup */
00275    if (instance->engine->new(instance, sched, &address, data)) {
00276       ast_debug(1, "Engine '%s' failed to setup RTP instance '%p'\n", engine->name, instance);
00277       ao2_ref(instance, -1);
00278       return NULL;
00279    }
00280 
00281    ast_debug(1, "RTP instance '%p' is setup and ready to go\n", instance);
00282 
00283    return instance;
00284 }

struct ast_frame* ast_rtp_instance_read ( struct ast_rtp_instance instance,
int  rtcp 
) [read]

Receive a frame over RTP.

Parameters:
instance The RTP instance to receive frame on
rtcp Whether to read in RTCP or not
Return values:
non-NULL success
NULL failure
Example usage:

 struct ast_frame *frame;
 frame = ast_rtp_instance_read(instance, 0);

This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.

Since:
1.8

Definition at line 301 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::read.

Referenced by gtalk_rtp_read(), jingle_rtp_read(), mgcp_rtp_read(), oh323_read(), oh323_rtp_read(), sip_rtp_read(), skinny_rtp_read(), and unistim_rtp_read().

00302 {
00303    return instance->engine->read(instance, rtcp);
00304 }

int ast_rtp_instance_sendcng ( struct ast_rtp_instance instance,
int  level 
)

Send a comfort noise packet to the RTP instance.

Parameters:
instance The RTP instance
level Magnitude of the noise level
Return values:
0 Success
non-zero Failure

Definition at line 1877 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::sendcng.

Referenced by check_rtp_timeout().

01878 {
01879    if (instance->engine->sendcng) {
01880       return instance->engine->sendcng(instance, level);
01881    }
01882 
01883    return -1;
01884 }

int ast_rtp_instance_set_alt_remote_address ( struct ast_rtp_instance instance,
const struct ast_sockaddr address 
)

Set the address of an an alternate RTP address to receive from.

Parameters:
instance The RTP instance to change the address on
address Address to set it to
Return values:
0 success
-1 failure
Example usage:

This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin structure.

Since:
1.8

Definition at line 327 of file rtp_engine.c.

References ast_rtp_instance::alt_remote_address, ast_rtp_engine::alt_remote_address_set, ast_sockaddr_copy(), and ast_rtp_instance::engine.

Referenced by handle_request_invite().

00329 {
00330    ast_sockaddr_copy(&instance->alt_remote_address, address);
00331 
00332    /* oink */
00333 
00334    if (instance->engine->alt_remote_address_set) {
00335       instance->engine->alt_remote_address_set(instance, &instance->alt_remote_address);
00336    }
00337 
00338    return 0;
00339 }

void ast_rtp_instance_set_data ( struct ast_rtp_instance instance,
void *  data 
)

Set the data portion of an RTP instance.

Parameters:
instance The RTP instance to manipulate
data Pointer to data
Example usage:

 ast_rtp_instance_set_data(instance, blob);

This sets the data pointer on the RTP instance pointed to by 'instance' to blob.

Since:
1.8

Definition at line 286 of file rtp_engine.c.

References ast_rtp_instance::data.

Referenced by ast_rtp_new(), and multicast_rtp_new().

00287 {
00288    instance->data = data;
00289 }

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.

Parameters:
instance The RTP instance to set the extended property on
property The extended property to set
value The value to set the extended property to
Since:
1.8

Definition at line 375 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::extended_prop_set.

00376 {
00377    if (instance->engine->extended_prop_set) {
00378       instance->engine->extended_prop_set(instance, property, value);
00379    }
00380 }

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.

Parameters:
instance The RTP instance
timeout Value to set the timeout to
Example usage:

This sets the RTP hold timeout value on 'instance' to be 5000.

Since:
1.8

Definition at line 1793 of file rtp_engine.c.

References ast_rtp_instance::holdtimeout.

Referenced by check_rtp_timeout(), and dialog_initialize_rtp().

01794 {
01795    instance->holdtimeout = timeout;
01796 }

void ast_rtp_instance_set_keepalive ( struct ast_rtp_instance instance,
int  timeout 
)

Set the RTP keepalive interval.

Parameters:
instance The RTP instance
period Value to set the keepalive interval to
Example usage:

This sets the RTP keepalive interval on 'instance' to be 5000.

Since:
1.8

Definition at line 1798 of file rtp_engine.c.

References ast_rtp_instance::keepalive.

Referenced by dialog_initialize_rtp().

01799 {
01800    instance->keepalive = interval;
01801 }

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.

Parameters:
instance The RTP instance to change the address on
address Address to set it to
Return values:
0 success
-1 failure
Example usage:

This changes the local address that RTP is expected on to the address given in the sin structure.

Since:
1.8

Definition at line 306 of file rtp_engine.c.

References ast_sockaddr_copy(), and ast_rtp_instance::local_address.

Referenced by ast_rtp_new().

00308 {
00309    ast_sockaddr_copy(&instance->local_address, address);
00310    return 0;
00311 }

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.

Parameters:
instance The RTP instance to set the property on
property The property to modify
value The value to set the property to
Example usage:

This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.

Since:
1.8

Definition at line 391 of file rtp_engine.c.

References ast_rtp_instance::engine, ast_rtp_engine::prop_set, and ast_rtp_instance::properties.

Referenced by __oh323_rtp_create(), create_addr_from_peer(), dialog_initialize_rtp(), do_setnat(), gtalk_alloc(), handle_request_invite(), oh323_rtp_read(), process_sdp(), sip_dtmfmode(), and start_rtp().

00392 {
00393    instance->properties[property] = value;
00394 
00395    if (instance->engine->prop_set) {
00396       instance->engine->prop_set(instance, property, value);
00397    }
00398 }

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.

Parameters:
instance Instance to set the QoS parameters on
tos Terms of service value
cos Class of service value
desc What is setting the QoS values
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_instance_set_qos(instance, 0, 0, "Example");

This sets the TOS and COS values to 0 on the instance pointed to by instance.

Since:
1.8

Definition at line 768 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::qos.

Referenced by __oh323_rtp_create(), dialog_initialize_rtp(), and start_rtp().

00769 {
00770    return instance->engine->qos ? instance->engine->qos(instance, tos, cos, desc) : -1;
00771 }

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.

Parameters:
instance The RTP instance to change read format on
format Format that frames are wanted in
Return values:
0 success
-1 failure
Example usage:

This requests that the RTP engine provide audio frames in the ULAW format.

Since:
1.8

Definition at line 1716 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::set_read_format.

Referenced by sip_new(), and sip_setoption().

01717 {
01718    return instance->engine->set_read_format ? instance->engine->set_read_format(instance, format) : -1;
01719 }

int ast_rtp_instance_set_remote_address ( struct ast_rtp_instance instance,
const struct ast_sockaddr address 
)

Set the address of the remote endpoint that we are sending RTP to.

Parameters:
instance The RTP instance to change the address on
address Address to set it to
Return values:
0 success
-1 failure
Example usage:

This changes the remote address that RTP will be sent to on instance to the address given in the sin structure.

Since:
1.8

Definition at line 313 of file rtp_engine.c.

References ast_sockaddr_copy(), ast_rtp_instance::engine, ast_rtp_instance::remote_address, and ast_rtp_engine::remote_address_set.

Referenced by ast_rtp_read(), ast_rtp_stop(), handle_open_receive_channel_ack_message(), multicast_rtp_request(), process_sdp(), setup_rtp_connection(), and start_rtp().

00315 {
00316    ast_sockaddr_copy(&instance->remote_address, address);
00317 
00318    /* moo */
00319 
00320    if (instance->engine->remote_address_set) {
00321       instance->engine->remote_address_set(instance, &instance->remote_address);
00322    }
00323 
00324    return 0;
00325 }

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.

Parameters:
chan Channel to set the statistics on
instance The RTP instance that statistics will be retrieved from
Example usage:

This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to by chan.

Since:
1.8

Definition at line 1682 of file rtp_engine.c.

References ast_bridged_channel(), AST_MAX_USER_FIELD, ast_rtp_instance_get_quality(), AST_RTP_INSTANCE_STAT_FIELD_QUALITY, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, ast_channel::bridge, pbx_builtin_setvar_helper(), and quality.

Referenced by handle_request_bye(), and sip_hangup().

01683 {
01684    char quality_buf[AST_MAX_USER_FIELD], *quality;
01685    struct ast_channel *bridge = ast_bridged_channel(chan);
01686 
01687    if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
01688       pbx_builtin_setvar_helper(chan, "RTPAUDIOQOS", quality);
01689       if (bridge) {
01690          pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSBRIDGED", quality);
01691       }
01692    }
01693 
01694    if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf)))) {
01695       pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSJITTER", quality);
01696       if (bridge) {
01697          pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSJITTERBRIDGED", quality);
01698       }
01699    }
01700 
01701    if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf)))) {
01702       pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSLOSS", quality);
01703       if (bridge) {
01704          pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSLOSSBRIDGED", quality);
01705       }
01706    }
01707 
01708    if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf)))) {
01709       pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSRTT", quality);
01710       if (bridge) {
01711          pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSRTTBRIDGED", quality);
01712       }
01713    }
01714 }

void ast_rtp_instance_set_timeout ( struct ast_rtp_instance instance,
int  timeout 
)

Set the RTP timeout value.

Parameters:
instance The RTP instance
timeout Value to set the timeout to
Example usage:

 ast_rtp_instance_set_timeout(instance, 5000);

This sets the RTP timeout value on 'instance' to be 5000.

Since:
1.8

Definition at line 1788 of file rtp_engine.c.

References ast_rtp_instance::timeout.

Referenced by check_rtp_timeout(), and dialog_initialize_rtp().

01789 {
01790    instance->timeout = timeout;
01791 }

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.

Parameters:
instance The RTP instance to change write format on
format Format that frames will be provided in
Return values:
0 success
-1 failure
Example usage:

This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.

Since:
1.8

Definition at line 1721 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::set_write_format.

Referenced by sip_new(), and sip_setoption().

01722 {
01723    return instance->engine->set_write_format ? instance->engine->set_write_format(instance, format) : -1;
01724 }

void ast_rtp_instance_stop ( struct ast_rtp_instance instance  ) 

Stop an RTP instance.

Parameters:
instance Instance that media is no longer going to at this time
Example usage:

This tells the RTP engine being used for the instance pointed to by instance that media is no longer going to it at this time, but may in the future.

Since:
1.8

Definition at line 773 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::stop.

Referenced by process_sdp(), setup_rtp_connection(), and stop_media_flows().

00774 {
00775    if (instance->engine->stop) {
00776       instance->engine->stop(instance);
00777    }
00778 }

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.

Parameters:
instance The RTP instance
suggestion The suggested destination
username Optionally a username for the request
Example usage:

 ast_rtp_instance_stun_request(instance, NULL, NULL);

This requests that the RTP engine send a STUN BIND request on the session pointed to by 'instance'.

Since:
1.8

Definition at line 1779 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::stun_request.

Referenced by gtalk_update_stun(), and jingle_update_stun().

01782 {
01783    if (instance->engine->stun_request) {
01784       instance->engine->stun_request(instance, suggestion, username);
01785    }
01786 }

void ast_rtp_instance_update_source ( struct ast_rtp_instance instance  ) 

Indicate that the RTP marker bit should be set on an RTP stream.

Parameters:
instance Instance that the new media source is feeding into
Example usage:

This indicates that the source of media that is feeding the instance pointed to by instance has been updated and that the marker bit should be set.

Since:
1.8

Definition at line 754 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::update_source.

Referenced by mgcp_indicate(), oh323_indicate(), sip_answer(), sip_indicate(), sip_write(), and skinny_indicate().

00755 {
00756    if (instance->engine->update_source) {
00757       instance->engine->update_source(instance);
00758    }
00759 }

int ast_rtp_instance_write ( struct ast_rtp_instance instance,
struct ast_frame frame 
)

Send a frame out over RTP.

Parameters:
instance The RTP instance to send frame out on
frame the frame to send out
Return values:
0 success
-1 failure
Example usage:

 ast_rtp_instance_write(instance, frame);

This gives the frame pointed to by frame to the RTP engine being used for the instance and asks that it be transmitted to the current remote address set on the RTP instance.

Since:
1.8

Definition at line 296 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::write.

Referenced by gtalk_write(), jingle_write(), mgcp_write(), multicast_rtp_write(), oh323_write(), sip_write(), skinny_write(), and unistim_write().

00297 {
00298    return instance->engine->write(instance, frame);
00299 }

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.

Parameters:
buf Buffer to put the mime output into
ast_format_capability Asterisk Formats we are looking up.
rtp_capability RTP codes that we are looking up
asterisk_format Non-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used
options Additional options that may change the result
Return values:
non-NULL success
NULL failure
Example usage:

 char buf[256] = "";
 struct ast_format tmp_fmt;
 struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
 ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
 char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
 ast_format_cap_destroy(cap);

This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.

Since:
1.8

Definition at line 685 of file rtp_engine.c.

References ast_format_cap_iter_end(), ast_format_cap_iter_next(), ast_format_cap_iter_start(), ast_rtp_lookup_mime_subtype2(), AST_RTP_MAX, ast_str_append(), ast_str_buffer(), and name.

Referenced by process_sdp().

00686 {
00687    int found = 0;
00688    const char *name;
00689    if (!buf) {
00690       return NULL;
00691    }
00692 
00693 
00694    if (asterisk_format) {
00695       struct ast_format tmp_fmt;
00696       ast_format_cap_iter_start(ast_format_capability);
00697       while (!ast_format_cap_iter_next(ast_format_capability, &tmp_fmt)) {
00698          name = ast_rtp_lookup_mime_subtype2(asterisk_format, &tmp_fmt, 0, options);
00699          ast_str_append(&buf, 0, "%s|", name);
00700          found = 1;
00701       }
00702       ast_format_cap_iter_end(ast_format_capability);
00703 
00704    } else {
00705       int x;
00706       ast_str_append(&buf, 0, "0x%x (", (unsigned int) rtp_capability);
00707       for (x = 1; x < AST_RTP_MAX; x <<= 1) {
00708          if (rtp_capability & x) {
00709             name = ast_rtp_lookup_mime_subtype2(asterisk_format, NULL, x, options);
00710             ast_str_append(&buf, 0, "%s|", name);
00711             found = 1;
00712          }
00713       }
00714    }
00715 
00716    ast_str_append(&buf, 0, "%s", found ? ")" : "nothing)");
00717 
00718    return ast_str_buffer(buf);
00719 }

const char* ast_rtp_lookup_mime_subtype2 ( const int  asterisk_format,
struct ast_format format,
int  code,
enum ast_rtp_options  options 
)

Retrieve mime subtype information on a payload.

Parameters:
asterisk_format Non-zero to look up using Asterisk format
format Asterisk format to look up
code RTP code to look up
options Additional options that may change the result
Return values:
Mime subtype success
NULL failure
Example usage:

 const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0);

This looks up the mime subtype for the ULAW format.

Since:
1.8

Definition at line 635 of file rtp_engine.c.

References ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, AST_FORMAT_G726_AAL2, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rwlock_rdlock, ast_rwlock_unlock, ast_format::id, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, and ast_rtp_mime_type::subtype.

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), ast_rtp_lookup_mime_multiple2(), transmit_connect(), transmit_connect_with_sdp(), transmit_modify_request(), and transmit_modify_with_sdp().

00636 {
00637    int i;
00638    const char *res = "";
00639 
00640    ast_rwlock_rdlock(&mime_types_lock);
00641    for (i = 0; i < mime_types_len; i++) {
00642       if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
00643          (ast_format_cmp(format, &ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
00644          if ((format->id == AST_FORMAT_G726_AAL2) && (options & AST_RTP_OPT_G726_NONSTANDARD)) {
00645             res = "G726-32";
00646             break;
00647          } else {
00648             res = ast_rtp_mime_types[i].subtype;
00649             break;
00650          }
00651       } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
00652          ast_rtp_mime_types[i].payload_type.rtp_code == code) {
00653 
00654          res = ast_rtp_mime_types[i].subtype;
00655          break;
00656       }
00657    }
00658    ast_rwlock_unlock(&mime_types_lock);
00659 
00660    return res;
00661 }

unsigned int ast_rtp_lookup_sample_rate2 ( int  asterisk_format,
struct ast_format format,
int  code 
)

Get the sample rate associated with known RTP payload types.

Parameters:
asterisk_format True if the value in format is to be used.
An asterisk format
code from AST_RTP list
Returns:
the sample rate if the format was found, zero if it was not found
Since:
1.8

Definition at line 663 of file rtp_engine.c.

References ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_rtp_mime_types, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, and ast_rtp_mime_type::sample_rate.

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_tcodec_to_sdp(), and add_vcodec_to_sdp().

00664 {
00665    unsigned int i;
00666    unsigned int res = 0;
00667 
00668    ast_rwlock_rdlock(&mime_types_lock);
00669    for (i = 0; i < mime_types_len; ++i) {
00670       if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
00671          (ast_format_cmp(format, &ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
00672          res = ast_rtp_mime_types[i].sample_rate;
00673          break;
00674       } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
00675          ast_rtp_mime_types[i].payload_type.rtp_code == code) {
00676          res = ast_rtp_mime_types[i].sample_rate;
00677          break;
00678       }
00679    }
00680    ast_rwlock_unlock(&mime_types_lock);
00681 
00682    return res;
00683 }

int ast_rtp_red_buffer ( struct ast_rtp_instance instance,
struct ast_frame frame 
)

Buffer a frame in an RTP instance for RED.

Parameters:
instance The instance to buffer the frame on
frame Frame that we want to buffer
Return values:
0 success
-1 failure
Since:
1.8

Definition at line 1632 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::red_buffer.

Referenced by sip_write().

01633 {
01634    return instance->engine->red_buffer ? instance->engine->red_buffer(instance, frame) : -1;
01635 }

int ast_rtp_red_init ( struct ast_rtp_instance instance,
int  buffer_time,
int *  payloads,
int  generations 
)

Initialize RED support on an RTP instance.

Parameters:
instance The instance to initialize RED support on
buffer_time How long to buffer before sending
payloads Payload values
generations Number of generations
Return values:
0 success
-1 failure
Since:
1.8

Definition at line 1627 of file rtp_engine.c.

References ast_rtp_instance::engine, and ast_rtp_engine::red_init.

Referenced by process_sdp().

01628 {
01629    return instance->engine->red_init ? instance->engine->red_init(instance, buffer_time, payloads, generations) : -1;
01630 }


Generated on Sat Feb 11 06:36:41 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6