Pluggable RTP Architecture. More...
#include "asterisk.h"
#include <math.h>
#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include "asterisk/module.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/manager.h"
#include "asterisk/options.h"
#include "asterisk/astobj2.h"
#include "asterisk/pbx.h"
#include "asterisk/translate.h"
#include "asterisk/netsock2.h"
#include "asterisk/framehook.h"
Go to the source code of this file.
Data Structures | |
struct | ast_rtp_instance |
struct | ast_rtp_mime_type |
struct | engines |
struct | glues |
Functions | |
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, const int asterisk_format, const format_t 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, format_t *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_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_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 *remote_policy, struct ast_srtp_policy *local_policy) |
Add or replace the SRTP policies for the given RTP instance. | |
format_t | ast_rtp_instance_available_formats (struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk) |
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_glue * | ast_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_instance * | ast_rtp_instance_get_bridged (struct ast_rtp_instance *instance) |
Get the other RTP instance that an instance is bridged to. | |
struct ast_channel * | ast_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_codecs * | ast_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_engine * | ast_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_glue * | ast_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_srtp * | ast_rtp_instance_get_srtp (struct ast_rtp_instance *instance) |
Obtain the SRTP instance associated with an RTP 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_instance * | ast_rtp_instance_new (const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data) |
Create a new RTP instance. | |
struct ast_frame * | ast_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 interval) |
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, format_t 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, format_t 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, const format_t 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, const format_t code, enum ast_rtp_options options) |
Retrieve mime subtype information on a payload. | |
unsigned int | ast_rtp_lookup_sample_rate2 (int asterisk_format, format_t 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. | |
static void | instance_destructor (void *obj) |
static enum ast_bridge_result | local_bridge_loop (struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1, int timeoutms, int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1) |
static enum ast_bridge_result | remote_bridge_loop (struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1, struct ast_rtp_instance *vinstance0, struct ast_rtp_instance *vinstance1, struct ast_rtp_instance *tinstance0, struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, format_t codec0, format_t codec1, int timeoutms, int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1) |
static void | unref_instance_cond (struct ast_rtp_instance **instance) |
Conditionally unref an rtp instance. | |
Variables | |
static struct ast_rtp_mime_type | ast_rtp_mime_types [] |
struct ast_srtp_res * | res_srtp = NULL |
struct ast_srtp_policy_res * | res_srtp_policy = NULL |
static struct ast_rtp_payload_type | static_RTP_PT [AST_RTP_MAX_PT] |
Mapping between Asterisk codecs and rtp payload types. |
Pluggable RTP Architecture.
Definition in file rtp_engine.c.
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.
codecs | Codecs structure to muck with | |
instance | Optionally the instance that the codecs structure belongs to | |
prefs | Codec packetization preferences |
Example usage:
ast_rtp_codecs_packetization_set(&codecs, NULL, &prefs);
This sets the packetization preferences pointed to by prefs on the codecs structure pointed to by codecs.
Definition at line 727 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().
00728 { 00729 codecs->pref = *prefs; 00730 00731 if (instance && instance->engine->packetization_set) { 00732 instance->engine->packetization_set(instance, &instance->codecs.pref); 00733 } 00734 }
int ast_rtp_codecs_payload_code | ( | struct ast_rtp_codecs * | codecs, | |
const int | asterisk_format, | |||
const format_t | code | |||
) |
Retrieve a payload based on whether it is an Asterisk format and the code.
codecs | Codecs structure to look in | |
asterisk_format | Non-zero if the given code is an Asterisk format value | |
code | The format to look for |
Numerical | payload |
Example usage:
int payload = ast_rtp_codecs_payload_code(&codecs, 1, AST_FORMAT_ULAW);
This looks for the numerical payload for ULAW in the codecs structure.
Definition at line 654 of file rtp_engine.c.
References AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, and ast_rtp_codecs::payloads.
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_write(), bridge_p2p_rtp_write(), multicast_rtp_write(), and start_rtp().
00655 { 00656 int i; 00657 00658 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00659 if (codecs->payloads[i].asterisk_format == asterisk_format && codecs->payloads[i].code == code) { 00660 return i; 00661 } 00662 } 00663 00664 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00665 if (static_RTP_PT[i].asterisk_format == asterisk_format && static_RTP_PT[i].code == code) { 00666 return i; 00667 } 00668 } 00669 00670 return -1; 00671 }
void ast_rtp_codecs_payload_formats | ( | struct ast_rtp_codecs * | codecs, | |
format_t * | astformats, | |||
int * | nonastformats | |||
) |
Retrieve all formats that were found.
codecs | Codecs structure to look in | |
astformats | An integer to put the Asterisk formats in | |
nonastformats | An integer to put the non-Asterisk formats in |
Example usage:
int astformats, 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.
Definition at line 636 of file rtp_engine.c.
References ast_debug, AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, and ast_rtp_codecs::payloads.
Referenced by gtalk_is_answered(), gtalk_newcall(), and process_sdp().
00637 { 00638 int i; 00639 00640 *astformats = *nonastformats = 0; 00641 00642 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00643 if (codecs->payloads[i].code) { 00644 ast_debug(1, "Incorporating payload %d on %p\n", i, codecs); 00645 } 00646 if (codecs->payloads[i].asterisk_format) { 00647 *astformats |= codecs->payloads[i].code; 00648 } else { 00649 *nonastformats |= codecs->payloads[i].code; 00650 } 00651 } 00652 }
struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup | ( | struct ast_rtp_codecs * | codecs, | |
int | payload | |||
) | [read] |
Retrieve payload information by payload.
codecs | Codecs structure to look in | |
payload | Numerical payload to look up |
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.
Definition at line 618 of file rtp_engine.c.
References AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, and ast_rtp_payload_type::code.
Referenced by ast_rtp_read(), ast_rtp_sendcng(), bridge_p2p_rtp_write(), process_sdp_a_audio(), and setup_rtp_connection().
00619 { 00620 struct ast_rtp_payload_type result = { .asterisk_format = 0, }; 00621 00622 if (payload < 0 || payload >= AST_RTP_MAX_PT) { 00623 return result; 00624 } 00625 00626 result.asterisk_format = codecs->payloads[payload].asterisk_format; 00627 result.code = codecs->payloads[payload].code; 00628 00629 if (!result.code) { 00630 result = static_RTP_PT[payload]; 00631 } 00632 00633 return result; 00634 }
void ast_rtp_codecs_payloads_clear | ( | struct ast_rtp_codecs * | codecs, | |
struct ast_rtp_instance * | instance | |||
) |
Clear payload information from an RTP instance.
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.
Definition at line 488 of file rtp_engine.c.
References AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, and ast_rtp_codecs::payloads.
Referenced by gtalk_alloc(), and process_sdp().
00489 { 00490 int i; 00491 00492 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00493 codecs->payloads[i].asterisk_format = 0; 00494 codecs->payloads[i].code = 0; 00495 if (instance && instance->engine && instance->engine->payload_set) { 00496 instance->engine->payload_set(instance, i, 0, 0); 00497 } 00498 } 00499 }
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.
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.
Definition at line 516 of file rtp_engine.c.
References ast_debug, AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, and ast_rtp_codecs::payloads.
Referenced by ast_rtp_instance_early_bridge_make_compatible(), and process_sdp().
00517 { 00518 int i; 00519 00520 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00521 if (src->payloads[i].code) { 00522 ast_debug(2, "Copying payload %d from %p to %p\n", i, src, dest); 00523 dest->payloads[i].asterisk_format = src->payloads[i].asterisk_format; 00524 dest->payloads[i].code = src->payloads[i].code; 00525 if (instance && instance->engine && instance->engine->payload_set) { 00526 instance->engine->payload_set(instance, i, dest->payloads[i].asterisk_format, dest->payloads[i].code); 00527 } 00528 } 00529 } 00530 }
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.
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.
Definition at line 501 of file rtp_engine.c.
References AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, and ast_rtp_codecs::payloads.
00502 { 00503 int i; 00504 00505 for (i = 0; i < AST_RTP_MAX_PT; i++) { 00506 if (static_RTP_PT[i].code) { 00507 codecs->payloads[i].asterisk_format = static_RTP_PT[i].asterisk_format; 00508 codecs->payloads[i].code = static_RTP_PT[i].code; 00509 if (instance && instance->engine && instance->engine->payload_set) { 00510 instance->engine->payload_set(instance, i, codecs->payloads[i].asterisk_format, codecs->payloads[i].code); 00511 } 00512 } 00513 } 00514 }
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.
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:
ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0);
This records that the numerical payload '0' was seen in the codecs structure.
Definition at line 532 of file rtp_engine.c.
References ast_debug, AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, and ast_rtp_codecs::payloads.
Referenced by gtalk_is_answered(), gtalk_newcall(), jingle_newcall(), and process_sdp().
00533 { 00534 if (payload < 0 || payload >= AST_RTP_MAX_PT || !static_RTP_PT[payload].code) { 00535 return; 00536 } 00537 00538 codecs->payloads[payload].asterisk_format = static_RTP_PT[payload].asterisk_format; 00539 codecs->payloads[payload].code = static_RTP_PT[payload].code; 00540 00541 ast_debug(1, "Setting payload %d based on m type on %p\n", payload, codecs); 00542 00543 if (instance && instance->engine && instance->engine->payload_set) { 00544 instance->engine->payload_set(instance, payload, codecs->payloads[payload].asterisk_format, codecs->payloads[payload].code); 00545 } 00546 }
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.
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 |
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.
Definition at line 597 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().
00598 { 00599 return ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, instance, payload, mimetype, mimesubtype, options, 0); 00600 }
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.
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.
0 | on success | |
-1 | if the payload type is out of range | |
-2 | if the mimeType/mimeSubtype combination was not found |
Definition at line 548 of file rtp_engine.c.
References ARRAY_LEN, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_RTP_MAX_PT, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, ast_rtp_mime_type::payload_type, ast_rtp_codecs::payloads, 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().
00552 { 00553 unsigned int i; 00554 int found = 0; 00555 00556 if (pt < 0 || pt >= AST_RTP_MAX_PT) 00557 return -1; /* bogus payload type */ 00558 00559 for (i = 0; i < ARRAY_LEN(ast_rtp_mime_types); ++i) { 00560 const struct ast_rtp_mime_type *t = &ast_rtp_mime_types[i]; 00561 00562 if (strcasecmp(mimesubtype, t->subtype)) { 00563 continue; 00564 } 00565 00566 if (strcasecmp(mimetype, t->type)) { 00567 continue; 00568 } 00569 00570 /* if both sample rates have been supplied, and they don't match, 00571 * then this not a match; if one has not been supplied, then the 00572 * rates are not compared */ 00573 if (sample_rate && t->sample_rate && 00574 (sample_rate != t->sample_rate)) { 00575 continue; 00576 } 00577 00578 found = 1; 00579 codecs->payloads[pt] = t->payload_type; 00580 00581 if ((t->payload_type.code == AST_FORMAT_G726) && 00582 t->payload_type.asterisk_format && 00583 (options & AST_RTP_OPT_G726_NONSTANDARD)) { 00584 codecs->payloads[pt].code = AST_FORMAT_G726_AAL2; 00585 } 00586 00587 if (instance && instance->engine && instance->engine->payload_set) { 00588 instance->engine->payload_set(instance, pt, codecs->payloads[i].asterisk_format, codecs->payloads[i].code); 00589 } 00590 00591 break; 00592 } 00593 00594 return (found ? 0 : -2); 00595 }
void ast_rtp_codecs_payloads_unset | ( | struct ast_rtp_codecs * | codecs, | |
struct ast_rtp_instance * | instance, | |||
int | payload | |||
) |
Remove payload information.
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.
Definition at line 602 of file rtp_engine.c.
References ast_debug, AST_RTP_MAX_PT, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::code, ast_rtp_instance::engine, ast_rtp_engine::payload_set, and ast_rtp_codecs::payloads.
Referenced by process_sdp_a_audio(), and process_sdp_a_video().
00603 { 00604 if (payload < 0 || payload >= AST_RTP_MAX_PT) { 00605 return; 00606 } 00607 00608 ast_debug(2, "Unsetting payload %d on %p\n", payload, codecs); 00609 00610 codecs->payloads[payload].asterisk_format = 0; 00611 codecs->payloads[payload].code = 0; 00612 00613 if (instance && instance->engine && instance->engine->payload_set) { 00614 instance->engine->payload_set(instance, payload, 0, 0); 00615 } 00616 }
int ast_rtp_engine_register2 | ( | struct ast_rtp_engine * | engine, | |
struct ast_module * | module | |||
) |
Register an RTP engine.
engine | Structure of the RTP engine to register | |
module | Module that the RTP engine is part of |
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.
Definition at line 188 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.
00189 { 00190 struct ast_rtp_engine *current_engine; 00191 00192 /* Perform a sanity check on the engine structure to make sure it has the basics */ 00193 if (ast_strlen_zero(engine->name) || !engine->new || !engine->destroy || !engine->write || !engine->read) { 00194 ast_log(LOG_WARNING, "RTP Engine '%s' failed sanity check so it was not registered.\n", !ast_strlen_zero(engine->name) ? engine->name : "Unknown"); 00195 return -1; 00196 } 00197 00198 /* Link owner module to the RTP engine for reference counting purposes */ 00199 engine->mod = module; 00200 00201 AST_RWLIST_WRLOCK(&engines); 00202 00203 /* Ensure that no two modules with the same name are registered at the same time */ 00204 AST_RWLIST_TRAVERSE(&engines, current_engine, entry) { 00205 if (!strcmp(current_engine->name, engine->name)) { 00206 ast_log(LOG_WARNING, "An RTP engine with the name '%s' has already been registered.\n", engine->name); 00207 AST_RWLIST_UNLOCK(&engines); 00208 return -1; 00209 } 00210 } 00211 00212 /* The engine survived our critique. Off to the list it goes to be used */ 00213 AST_RWLIST_INSERT_TAIL(&engines, engine, entry); 00214 00215 AST_RWLIST_UNLOCK(&engines); 00216 00217 ast_verb(2, "Registered RTP engine '%s'\n", engine->name); 00218 00219 return 0; 00220 }
int ast_rtp_engine_register_srtp | ( | struct ast_srtp_res * | srtp_res, | |
struct ast_srtp_policy_res * | policy_res | |||
) |
Definition at line 1788 of file rtp_engine.c.
Referenced by res_srtp_init().
01789 { 01790 if (res_srtp || res_srtp_policy) { 01791 return -1; 01792 } 01793 if (!srtp_res || !policy_res) { 01794 return -1; 01795 } 01796 01797 res_srtp = srtp_res; 01798 res_srtp_policy = policy_res; 01799 01800 return 0; 01801 }
int ast_rtp_engine_srtp_is_registered | ( | void | ) |
Definition at line 1809 of file rtp_engine.c.
Referenced by sdp_crypto_activate(), sdp_crypto_process(), sdp_crypto_setup(), set_crypto_policy(), and setup_srtp().
01810 { 01811 return res_srtp && res_srtp_policy; 01812 }
int ast_rtp_engine_unregister | ( | struct ast_rtp_engine * | engine | ) |
Unregister an RTP engine.
engine | Structure of the RTP engine to unregister |
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.
Definition at line 222 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().
00223 { 00224 struct ast_rtp_engine *current_engine = NULL; 00225 00226 AST_RWLIST_WRLOCK(&engines); 00227 00228 if ((current_engine = AST_RWLIST_REMOVE(&engines, engine, entry))) { 00229 ast_verb(2, "Unregistered RTP engine '%s'\n", engine->name); 00230 } 00231 00232 AST_RWLIST_UNLOCK(&engines); 00233 00234 return current_engine ? 0 : -1; 00235 }
void ast_rtp_engine_unregister_srtp | ( | void | ) |
Definition at line 1803 of file rtp_engine.c.
Referenced by res_srtp_shutdown().
01804 { 01805 res_srtp = NULL; 01806 res_srtp_policy = NULL; 01807 }
int ast_rtp_glue_register2 | ( | struct ast_rtp_glue * | glue, | |
struct ast_module * | module | |||
) |
Register RTP glue.
glue | The glue to register | |
module | Module that the RTP glue is part of |
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.
Definition at line 237 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.
00238 { 00239 struct ast_rtp_glue *current_glue = NULL; 00240 00241 if (ast_strlen_zero(glue->type)) { 00242 return -1; 00243 } 00244 00245 glue->mod = module; 00246 00247 AST_RWLIST_WRLOCK(&glues); 00248 00249 AST_RWLIST_TRAVERSE(&glues, current_glue, entry) { 00250 if (!strcasecmp(current_glue->type, glue->type)) { 00251 ast_log(LOG_WARNING, "RTP glue with the name '%s' has already been registered.\n", glue->type); 00252 AST_RWLIST_UNLOCK(&glues); 00253 return -1; 00254 } 00255 } 00256 00257 AST_RWLIST_INSERT_TAIL(&glues, glue, entry); 00258 00259 AST_RWLIST_UNLOCK(&glues); 00260 00261 ast_verb(2, "Registered RTP glue '%s'\n", glue->type); 00262 00263 return 0; 00264 }
int ast_rtp_glue_unregister | ( | struct ast_rtp_glue * | glue | ) |
Unregister RTP glue.
glue | The glue to unregister |
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.
Definition at line 266 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().
00267 { 00268 struct ast_rtp_glue *current_glue = NULL; 00269 00270 AST_RWLIST_WRLOCK(&glues); 00271 00272 if ((current_glue = AST_RWLIST_REMOVE(&glues, glue, entry))) { 00273 ast_verb(2, "Unregistered RTP glue '%s'\n", glue->type); 00274 } 00275 00276 AST_RWLIST_UNLOCK(&glues); 00277 00278 return current_glue ? 0 : -1; 00279 }
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.
instance | The RTP instance |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_activate(instance);
This tells the underlying RTP engine of instance that packets will now flow.
Definition at line 1729 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().
int ast_rtp_instance_add_srtp_policy | ( | struct ast_rtp_instance * | instance, | |
struct ast_srtp_policy * | remote_policy, | |||
struct ast_srtp_policy * | local_policy | |||
) |
Add or replace the SRTP policies for the given RTP instance.
instance | the RTP instance | |
remote_policy | the remote endpoint's policy | |
local_policy | our policy for this RTP instance's remote endpoint |
0 | Success | |
non-zero | Failure |
Definition at line 1814 of file rtp_engine.c.
References ast_srtp_res::add_stream, ast_srtp_res::create, ast_srtp_res::replace, and ast_rtp_instance::srtp.
Referenced by sdp_crypto_activate().
01815 { 01816 int res = 0; 01817 01818 if (!res_srtp) { 01819 return -1; 01820 } 01821 01822 if (!instance->srtp) { 01823 res = res_srtp->create(&instance->srtp, instance, remote_policy); 01824 } else { 01825 res = res_srtp->replace(&instance->srtp, instance, remote_policy); 01826 } 01827 if (!res) { 01828 res = res_srtp->add_stream(instance->srtp, local_policy); 01829 } 01830 01831 return res; 01832 }
format_t ast_rtp_instance_available_formats | ( | struct ast_rtp_instance * | instance, | |
format_t | to_endpoint, | |||
format_t | to_asterisk | |||
) |
Request the formats that can be transcoded.
instance | The RTP instance | |
to_endpoint | Formats being sent/received towards the endpoint | |
to_asterisk | Formats being sent/received towards Asterisk |
supported | formats |
Example usage:
This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
Definition at line 1718 of file rtp_engine.c.
References ast_translate_available_formats(), ast_rtp_engine::available_formats, and ast_rtp_instance::engine.
Referenced by sip_call().
01719 { 01720 format_t formats; 01721 01722 if (instance->engine->available_formats && (formats = instance->engine->available_formats(instance, to_endpoint, to_asterisk))) { 01723 return formats; 01724 } 01725 01726 return ast_translate_available_formats(to_endpoint, to_asterisk); 01727 }
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.
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 |
Bridge | result |
Definition at line 1263 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_trylock, ast_channel_unlock, ast_check_hangup(), ast_codec_pref_getsize(), ast_debug, ast_getformatname(), 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_instance::codecs, 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, ast_rtp_codecs::pref, ast_channel::rawreadformat, ast_channel::rawwriteformat, remote_bridge_loop(), ast_sockaddr::ss, ast_channel::tech, ast_channel::tech_pvt, ast_channel_tech::type, and unref_instance_cond().
01264 { 01265 struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, 01266 *vinstance0 = NULL, *vinstance1 = NULL, 01267 *tinstance0 = NULL, *tinstance1 = NULL; 01268 struct ast_rtp_glue *glue0, *glue1; 01269 struct ast_sockaddr addr1 = { {0, }, }, addr2 = { {0, }, }; 01270 enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01271 enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01272 enum ast_bridge_result res = AST_BRIDGE_FAILED; 01273 enum ast_rtp_dtmf_mode dmode; 01274 format_t codec0 = 0, codec1 = 0; 01275 int unlock_chans = 1; 01276 int read_ptime0, read_ptime1, write_ptime0, write_ptime1; 01277 01278 /* Lock both channels so we can look for the glue that binds them together */ 01279 ast_channel_lock(c0); 01280 while (ast_channel_trylock(c1)) { 01281 ast_channel_unlock(c0); 01282 usleep(1); 01283 ast_channel_lock(c0); 01284 } 01285 01286 /* Ensure neither channel got hungup during lock avoidance */ 01287 if (ast_check_hangup(c0) || ast_check_hangup(c1)) { 01288 ast_log(LOG_WARNING, "Got hangup while attempting to bridge '%s' and '%s'\n", c0->name, c1->name); 01289 goto done; 01290 } 01291 01292 /* Grab glue that binds each channel to something using the RTP engine */ 01293 if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) { 01294 ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name); 01295 goto done; 01296 } 01297 01298 audio_glue0_res = glue0->get_rtp_info(c0, &instance0); 01299 video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID; 01300 01301 audio_glue1_res = glue1->get_rtp_info(c1, &instance1); 01302 video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID; 01303 01304 /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */ 01305 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)) { 01306 audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01307 } 01308 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)) { 01309 audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01310 } 01311 01312 /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */ 01313 if (audio_glue0_res == AST_RTP_GLUE_RESULT_FORBID || audio_glue1_res == AST_RTP_GLUE_RESULT_FORBID) { 01314 res = AST_BRIDGE_FAILED_NOWARN; 01315 goto done; 01316 } 01317 01318 01319 /* If address families differ, force a local bridge */ 01320 ast_rtp_instance_get_remote_address(instance0, &addr1); 01321 ast_rtp_instance_get_remote_address(instance1, &addr2); 01322 01323 if (addr1.ss.ss_family != addr2.ss.ss_family || 01324 (ast_sockaddr_is_ipv4_mapped(&addr1) != ast_sockaddr_is_ipv4_mapped(&addr2))) { 01325 audio_glue0_res = AST_RTP_GLUE_RESULT_LOCAL; 01326 audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL; 01327 } 01328 01329 /* If we need to get DTMF see if we can do it outside of the RTP stream itself */ 01330 dmode = ast_rtp_instance_dtmf_mode_get(instance0); 01331 if ((flags & AST_BRIDGE_DTMF_CHANNEL_0) && dmode) { 01332 res = AST_BRIDGE_FAILED_NOWARN; 01333 goto done; 01334 } 01335 dmode = ast_rtp_instance_dtmf_mode_get(instance1); 01336 if ((flags & AST_BRIDGE_DTMF_CHANNEL_1) && dmode) { 01337 res = AST_BRIDGE_FAILED_NOWARN; 01338 goto done; 01339 } 01340 01341 /* 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 */ 01342 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)))) { 01343 res = AST_BRIDGE_FAILED_NOWARN; 01344 goto done; 01345 } 01346 01347 /* Make sure that codecs match */ 01348 codec0 = glue0->get_codec ? glue0->get_codec(c0) : 0; 01349 codec1 = glue1->get_codec ? glue1->get_codec(c1) : 0; 01350 if (codec0 && codec1 && !(codec0 & codec1)) { 01351 ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n", ast_getformatname(codec0), ast_getformatname(codec1)); 01352 res = AST_BRIDGE_FAILED_NOWARN; 01353 goto done; 01354 } 01355 01356 read_ptime0 = (ast_codec_pref_getsize(&instance0->codecs.pref, c0->rawreadformat)).cur_ms; 01357 read_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, c1->rawreadformat)).cur_ms; 01358 write_ptime0 = (ast_codec_pref_getsize(&instance0->codecs.pref, c0->rawwriteformat)).cur_ms; 01359 write_ptime1 = (ast_codec_pref_getsize(&instance1->codecs.pref, c1->rawwriteformat)).cur_ms; 01360 01361 if (read_ptime0 != write_ptime1 || read_ptime1 != write_ptime0) { 01362 ast_debug(1, "Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n", 01363 read_ptime0, write_ptime1, read_ptime1, write_ptime0); 01364 res = AST_BRIDGE_FAILED_NOWARN; 01365 goto done; 01366 } 01367 01368 instance0->glue = glue0; 01369 instance1->glue = glue1; 01370 instance0->chan = c0; 01371 instance1->chan = c1; 01372 01373 /* Depending on the end result for bridging either do a local bridge or remote bridge */ 01374 if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) { 01375 ast_verb(3, "Locally bridging %s and %s\n", c0->name, c1->name); 01376 res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, c0->tech_pvt, c1->tech_pvt); 01377 } else { 01378 ast_verb(3, "Remotely bridging %s and %s\n", c0->name, c1->name); 01379 res = remote_bridge_loop(c0, c1, instance0, instance1, vinstance0, vinstance1, 01380 tinstance0, tinstance1, glue0, glue1, codec0, codec1, timeoutms, flags, 01381 fo, rc, c0->tech_pvt, c1->tech_pvt); 01382 } 01383 01384 instance0->glue = NULL; 01385 instance1->glue = NULL; 01386 instance0->chan = NULL; 01387 instance1->chan = NULL; 01388 01389 unlock_chans = 0; 01390 01391 done: 01392 if (unlock_chans) { 01393 ast_channel_unlock(c0); 01394 ast_channel_unlock(c1); 01395 } 01396 01397 unref_instance_cond(&instance0); 01398 unref_instance_cond(&instance1); 01399 unref_instance_cond(&vinstance0); 01400 unref_instance_cond(&vinstance1); 01401 unref_instance_cond(&tinstance0); 01402 unref_instance_cond(&tinstance1); 01403 01404 return res; 01405 }
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.
instance | Instance that the new media source is feeding into |
Example usage:
ast_rtp_instance_change_source(instance);
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.
Definition at line 767 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().
00768 { 00769 if (instance->engine->change_source) { 00770 instance->engine->change_source(instance); 00771 } 00772 }
int ast_rtp_instance_destroy | ( | struct ast_rtp_instance * | instance | ) |
Destroy an RTP instance.
instance | The RTP instance to destroy |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_destroy(instance);
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.
Definition at line 301 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(), skinny_hangup(), start_rtp(), unalloc_sub(), and unistim_hangup().
00302 { 00303 ao2_ref(instance, -1); 00304 00305 return 0; 00306 }
int ast_rtp_instance_dtmf_begin | ( | struct ast_rtp_instance * | instance, | |
char | digit | |||
) |
Begin sending a DTMF digit.
instance | The RTP instance to send the DTMF on | |
digit | What DTMF digit to send |
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.
Definition at line 736 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().
00737 { 00738 return instance->engine->dtmf_begin ? instance->engine->dtmf_begin(instance, digit) : -1; 00739 }
int ast_rtp_instance_dtmf_end | ( | struct ast_rtp_instance * | instance, | |
char | digit | |||
) |
Stop sending a DTMF digit.
instance | The RTP instance to stop the DTMF on | |
digit | What DTMF digit to stop |
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.
Definition at line 741 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().
int ast_rtp_instance_dtmf_end_with_duration | ( | struct ast_rtp_instance * | instance, | |
char | digit, | |||
unsigned int | duration | |||
) |
Definition at line 745 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().
00746 { 00747 return instance->engine->dtmf_end_with_duration ? instance->engine->dtmf_end_with_duration(instance, digit, duration) : -1; 00748 }
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get | ( | struct ast_rtp_instance * | instance | ) |
Get the DTMF mode of an RTP instance.
instance | The RTP instance to get the DTMF mode of |
DTMF | mode |
Example usage:
enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance);
This gets the DTMF mode set on the RTP instance pointed to by 'instance'.
Definition at line 755 of file rtp_engine.c.
References ast_rtp_engine::dtmf_mode_get, and ast_rtp_instance::engine.
Referenced by ast_rtp_instance_bridge().
00756 { 00757 return instance->engine->dtmf_mode_get ? instance->engine->dtmf_mode_get(instance) : 0; 00758 }
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.
instance | the RTP instance to set DTMF mode on | |
dtmf_mode | The DTMF mode that is in use |
0 | success | |
-1 | failure |
Example usage:
This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
Definition at line 750 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().
00751 { 00752 return (!instance->engine->dtmf_mode_set || instance->engine->dtmf_mode_set(instance, dtmf_mode)) ? -1 : 0; 00753 }
int ast_rtp_instance_early_bridge | ( | struct ast_channel * | c0, | |
struct ast_channel * | c1 | |||
) |
Early bridge two channels that use RTP instances.
c0 | First channel part of the bridge | |
c1 | Second channel part of the bridge |
0 | success | |
-1 | failure |
Definition at line 1498 of file rtp_engine.c.
References ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_debug, 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.
01499 { 01500 struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, 01501 *vinstance0 = NULL, *vinstance1 = NULL, 01502 *tinstance0 = NULL, *tinstance1 = NULL; 01503 struct ast_rtp_glue *glue0, *glue1; 01504 enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01505 enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01506 format_t codec0 = 0, codec1 = 0; 01507 int res = 0; 01508 01509 /* If there is no second channel just immediately bail out, we are of no use in that scenario */ 01510 if (!c1) { 01511 return -1; 01512 } 01513 01514 /* Lock both channels so we can look for the glue that binds them together */ 01515 ast_channel_lock(c0); 01516 while (ast_channel_trylock(c1)) { 01517 ast_channel_unlock(c0); 01518 usleep(1); 01519 ast_channel_lock(c0); 01520 } 01521 01522 /* Grab glue that binds each channel to something using the RTP engine */ 01523 if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) { 01524 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name); 01525 goto done; 01526 } 01527 01528 audio_glue0_res = glue0->get_rtp_info(c0, &instance0); 01529 video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID; 01530 01531 audio_glue1_res = glue1->get_rtp_info(c1, &instance1); 01532 video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID; 01533 01534 /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */ 01535 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)) { 01536 audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01537 } 01538 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)) { 01539 audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01540 } 01541 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(c0)) { 01542 codec0 = glue0->get_codec(c0); 01543 } 01544 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(c1)) { 01545 codec1 = glue1->get_codec(c1); 01546 } 01547 01548 /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */ 01549 if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) { 01550 goto done; 01551 } 01552 01553 /* Make sure we have matching codecs */ 01554 if (!(codec0 & codec1)) { 01555 goto done; 01556 } 01557 01558 /* Bridge media early */ 01559 if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0)) { 01560 ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", c0->name, c1 ? c1->name : "<unspecified>"); 01561 } 01562 01563 res = 0; 01564 01565 done: 01566 ast_channel_unlock(c0); 01567 ast_channel_unlock(c1); 01568 01569 unref_instance_cond(&instance0); 01570 unref_instance_cond(&instance1); 01571 unref_instance_cond(&vinstance0); 01572 unref_instance_cond(&vinstance1); 01573 unref_instance_cond(&tinstance0); 01574 unref_instance_cond(&tinstance1); 01575 01576 if (!res) { 01577 ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>"); 01578 } 01579 01580 return res; 01581 }
void ast_rtp_instance_early_bridge_make_compatible | ( | struct ast_channel * | c0, | |
struct ast_channel * | c1 | |||
) |
Make two channels compatible for early bridging.
c0 | First channel part of the bridge | |
c1 | Second channel part of the bridge |
Definition at line 1412 of file rtp_engine.c.
References ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_debug, 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().
01413 { 01414 struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, 01415 *vinstance0 = NULL, *vinstance1 = NULL, 01416 *tinstance0 = NULL, *tinstance1 = NULL; 01417 struct ast_rtp_glue *glue0, *glue1; 01418 enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01419 enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01420 format_t codec0 = 0, codec1 = 0; 01421 int res = 0; 01422 01423 /* Lock both channels so we can look for the glue that binds them together */ 01424 ast_channel_lock(c0); 01425 while (ast_channel_trylock(c1)) { 01426 ast_channel_unlock(c0); 01427 usleep(1); 01428 ast_channel_lock(c0); 01429 } 01430 01431 /* Grab glue that binds each channel to something using the RTP engine */ 01432 if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) { 01433 ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name); 01434 goto done; 01435 } 01436 01437 audio_glue0_res = glue0->get_rtp_info(c0, &instance0); 01438 video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID; 01439 01440 audio_glue1_res = glue1->get_rtp_info(c1, &instance1); 01441 video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID; 01442 01443 /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */ 01444 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)) { 01445 audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID; 01446 } 01447 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)) { 01448 audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID; 01449 } 01450 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) { 01451 codec0 = glue0->get_codec(c0); 01452 } 01453 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) { 01454 codec1 = glue1->get_codec(c1); 01455 } 01456 01457 /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */ 01458 if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) { 01459 goto done; 01460 } 01461 01462 /* Make sure we have matching codecs */ 01463 if (!(codec0 & codec1)) { 01464 goto done; 01465 } 01466 01467 ast_rtp_codecs_payloads_copy(&instance0->codecs, &instance1->codecs, instance1); 01468 01469 if (vinstance0 && vinstance1) { 01470 ast_rtp_codecs_payloads_copy(&vinstance0->codecs, &vinstance1->codecs, vinstance1); 01471 } 01472 if (tinstance0 && tinstance1) { 01473 ast_rtp_codecs_payloads_copy(&tinstance0->codecs, &tinstance1->codecs, tinstance1); 01474 } 01475 01476 if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0)) { 01477 ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", c0->name, c1 ? c1->name : "<unspecified>"); 01478 } 01479 01480 res = 0; 01481 01482 done: 01483 ast_channel_unlock(c0); 01484 ast_channel_unlock(c1); 01485 01486 unref_instance_cond(&instance0); 01487 unref_instance_cond(&instance1); 01488 unref_instance_cond(&vinstance0); 01489 unref_instance_cond(&vinstance1); 01490 unref_instance_cond(&tinstance0); 01491 unref_instance_cond(&tinstance1); 01492 01493 if (!res) { 01494 ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>"); 01495 } 01496 }
int ast_rtp_instance_fd | ( | struct ast_rtp_instance * | instance, | |
int | rtcp | |||
) |
Get the file descriptor for an RTP session (or RTCP).
instance | Instance to get the file descriptor for | |
rtcp | Whether to retrieve the file descriptor for RTCP or not |
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.
Definition at line 786 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(), sip_set_rtp_peer(), skinny_new(), start_rtp(), and unistim_new().
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.
instance | The RTP instance |
pointer | to the glue |
Example:
struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance);
This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.
Definition at line 1778 of file rtp_engine.c.
References ast_rtp_instance::glue.
01779 { 01780 return instance->glue; 01781 }
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.
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 |
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.
Definition at line 419 of file rtp_engine.c.
References ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::local_address.
00421 { 00422 if (ast_sockaddr_cmp(address, &instance->local_address) != 0) { 00423 ast_sockaddr_copy(address, &instance->local_address); 00424 return 1; 00425 } 00426 00427 return 0; 00428 }
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.
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 |
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.
Definition at line 436 of file rtp_engine.c.
References ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::remote_address.
Referenced by sip_set_rtp_peer().
00438 { 00439 if (ast_sockaddr_cmp(address, &instance->remote_address) != 0) { 00440 ast_sockaddr_copy(address, &instance->remote_address); 00441 return 1; 00442 } 00443 00444 return 0; 00445 }
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.
instance | The RTP instance that we want |
non-NULL | success | |
NULL | failure |
Example usage:
struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0);
This gets the RTP instance that instance0 is bridged to.
Definition at line 1407 of file rtp_engine.c.
References ast_rtp_instance::bridged.
Referenced by ast_rtp_read(), bridge_p2p_rtp_write(), and dialog_needdestroy().
01408 { 01409 return instance->bridged; 01410 }
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.
instance | The RTP instance |
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'.
Definition at line 1783 of file rtp_engine.c.
References ast_rtp_instance::chan.
01784 { 01785 return instance->chan; 01786 }
struct ast_rtp_codecs* ast_rtp_instance_get_codecs | ( | struct ast_rtp_instance * | instance | ) | [read] |
Get the codecs structure of an RTP instance.
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'.
Definition at line 483 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().
00484 { 00485 return &instance->codecs; 00486 }
void* ast_rtp_instance_get_data | ( | struct ast_rtp_instance * | instance | ) |
Get the data portion of an RTP instance.
instance | The RTP instance we want the data portion from |
Example usage:
struct *blob = ast_rtp_instance_get_data(instance); (
This gets the data pointer on the RTP instance pointed to by 'instance'.
Definition at line 369 of file rtp_engine.c.
References ast_rtp_instance::data.
Referenced by __rtp_recvfrom(), __rtp_sendto(), ast_rtcp_read(), ast_rtcp_write(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_alt_remote_address_set(), ast_rtp_change_source(), ast_rtp_destroy(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_dtmf_mode_get(), ast_rtp_dtmf_mode_set(), ast_rtp_fd(), ast_rtp_get_stat(), ast_rtp_local_bridge(), ast_rtp_prop_set(), ast_rtp_qos_set(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_sendcng(), ast_rtp_stop(), ast_rtp_stun_request(), ast_rtp_update_source(), ast_rtp_write(), bridge_p2p_rtp_write(), create_dtmf_frame(), multicast_rtp_activate(), multicast_rtp_destroy(), multicast_rtp_write(), process_cn_rfc3389(), process_dtmf_cisco(), process_dtmf_rfc2833(), red_write(), rtp_red_buffer(), and rtp_red_init().
00370 { 00371 return instance->data; 00372 }
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.
instance | The RTP instance |
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'.
Definition at line 1773 of file rtp_engine.c.
References ast_rtp_instance::engine.
01774 { 01775 return instance->engine; 01776 }
void* ast_rtp_instance_get_extended_prop | ( | struct ast_rtp_instance * | instance, | |
int | property | |||
) |
Get the value of an RTP instance extended property.
instance | The RTP instance to get the extended property on | |
property | The extended property to get |
Definition at line 460 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::extended_prop_get.
00461 { 00462 if (instance->engine->extended_prop_get) { 00463 return instance->engine->extended_prop_get(instance, property); 00464 } 00465 00466 return NULL; 00467 }
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.
type | Name of the glue we want |
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'.
Definition at line 791 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().
00792 { 00793 struct ast_rtp_glue *glue = NULL; 00794 00795 AST_RWLIST_RDLOCK(&glues); 00796 00797 AST_RWLIST_TRAVERSE(&glues, glue, entry) { 00798 if (!strcasecmp(glue->type, type)) { 00799 break; 00800 } 00801 } 00802 00803 AST_RWLIST_UNLOCK(&glues); 00804 00805 return glue; 00806 }
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.
instance | The RTP instance |
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'.
Definition at line 1763 of file rtp_engine.c.
References ast_rtp_instance::holdtimeout.
Referenced by check_rtp_timeout().
01764 { 01765 return instance->holdtimeout; 01766 }
int ast_rtp_instance_get_keepalive | ( | struct ast_rtp_instance * | instance | ) |
Get the RTP keepalive interval.
instance | The RTP instance |
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'.
Definition at line 1768 of file rtp_engine.c.
References ast_rtp_instance::keepalive.
Referenced by check_rtp_timeout().
01769 { 01770 return instance->keepalive; 01771 }
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.
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.
Definition at line 430 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().
00432 { 00433 ast_sockaddr_copy(address, &instance->local_address); 00434 }
int ast_rtp_instance_get_prop | ( | struct ast_rtp_instance * | instance, | |
enum ast_rtp_property | property | |||
) |
Get the value of an RTP instance property.
instance | The RTP instance to get the property from | |
property | The property to get |
Current | value of the property |
Example usage:
ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT);
This returns the current value of the NAT property on the instance pointed to by instance.
Definition at line 478 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().
00479 { 00480 return instance->properties[property]; 00481 }
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.
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 |
non-NULL | success | |
NULL | failure |
Example usage:
char quality[AST_MAX_USER_FIELD]; ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf));
This retrieves general quality statistics and places a text representation into the buf pointed to by buf.
Definition at line 1598 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().
01599 { 01600 struct ast_rtp_instance_stats stats = { 0, }; 01601 enum ast_rtp_instance_stat stat; 01602 01603 /* Determine what statistics we will need to retrieve based on field passed in */ 01604 if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) { 01605 stat = AST_RTP_INSTANCE_STAT_ALL; 01606 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) { 01607 stat = AST_RTP_INSTANCE_STAT_COMBINED_JITTER; 01608 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) { 01609 stat = AST_RTP_INSTANCE_STAT_COMBINED_LOSS; 01610 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) { 01611 stat = AST_RTP_INSTANCE_STAT_COMBINED_RTT; 01612 } else { 01613 return NULL; 01614 } 01615 01616 /* Attempt to actually retrieve the statistics we need to generate the quality string */ 01617 if (ast_rtp_instance_get_stats(instance, &stats, stat)) { 01618 return NULL; 01619 } 01620 01621 /* Now actually fill the buffer with the good information */ 01622 if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) { 01623 snprintf(buf, size, "ssrc=%i;themssrc=%u;lp=%u;rxjitter=%f;rxcount=%u;txjitter=%f;txcount=%u;rlp=%u;rtt=%f", 01624 stats.local_ssrc, stats.remote_ssrc, stats.rxploss, stats.txjitter, stats.rxcount, stats.rxjitter, stats.txcount, stats.txploss, stats.rtt); 01625 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) { 01626 snprintf(buf, size, "minrxjitter=%f;maxrxjitter=%f;avgrxjitter=%f;stdevrxjitter=%f;reported_minjitter=%f;reported_maxjitter=%f;reported_avgjitter=%f;reported_stdevjitter=%f;", 01627 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)); 01628 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) { 01629 snprintf(buf, size, "minrxlost=%f;maxrxlost=%f;avgrxlost=%f;stdevrxlost=%f;reported_minlost=%f;reported_maxlost=%f;reported_avglost=%f;reported_stdevlost=%f;", 01630 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)); 01631 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) { 01632 snprintf(buf, size, "minrtt=%f;maxrtt=%f;avgrtt=%f;stdevrtt=%f;", stats.minrtt, stats.maxrtt, stats.normdevrtt, stats.stdevrtt); 01633 } 01634 01635 return buf; 01636 }
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.
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.
Definition at line 447 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().
00449 { 00450 ast_sockaddr_copy(address, &instance->remote_address); 00451 }
struct ast_srtp* ast_rtp_instance_get_srtp | ( | struct ast_rtp_instance * | instance | ) | [read] |
Obtain the SRTP instance associated with an RTP instance.
instance | the RTP instance |
the | SRTP instance on success | |
NULL | if no SRTP instance exists |
Definition at line 1834 of file rtp_engine.c.
References ast_rtp_instance::srtp.
Referenced by __rtp_recvfrom(), __rtp_sendto(), and ast_rtp_change_source().
01835 { 01836 return instance->srtp; 01837 }
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.
instance | Instance to get statistics on | |
stats | Structure to put results into | |
stat | What statistic(s) to retrieve |
0 | success | |
-1 | failure |
Example usage:
struct ast_rtp_instance_stats stats; ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL);
This retrieves all statistics the underlying RTP engine supports and puts the values into the stats structure.
Definition at line 1593 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().
int ast_rtp_instance_get_timeout | ( | struct ast_rtp_instance * | instance | ) |
Get the RTP timeout value.
instance | The RTP instance |
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'.
Definition at line 1758 of file rtp_engine.c.
References ast_rtp_instance::timeout.
Referenced by check_rtp_timeout().
01759 { 01760 return instance->timeout; 01761 }
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.
chan | Our own Asterisk channel | |
instance | The first RTP instance | |
peer | The peer Asterisk channel |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_make_compatible(instance, peer);
This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.
Definition at line 1682 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().
01683 { 01684 struct ast_rtp_glue *glue; 01685 struct ast_rtp_instance *peer_instance = NULL; 01686 int res = -1; 01687 01688 if (!instance->engine->make_compatible) { 01689 return -1; 01690 } 01691 01692 ast_channel_lock(peer); 01693 01694 if (!(glue = ast_rtp_instance_get_glue(peer->tech->type))) { 01695 ast_channel_unlock(peer); 01696 return -1; 01697 } 01698 01699 glue->get_rtp_info(peer, &peer_instance); 01700 01701 if (!peer_instance || peer_instance->engine != instance->engine) { 01702 ast_channel_unlock(peer); 01703 ao2_ref(peer_instance, -1); 01704 peer_instance = NULL; 01705 return -1; 01706 } 01707 01708 res = instance->engine->make_compatible(chan, instance, peer, peer_instance); 01709 01710 ast_channel_unlock(peer); 01711 01712 ao2_ref(peer_instance, -1); 01713 peer_instance = NULL; 01714 01715 return res; 01716 }
struct ast_rtp_instance* ast_rtp_instance_new | ( | const char * | engine_name, | |
struct sched_context * | sched, | |||
const struct ast_sockaddr * | sa, | |||
void * | data | |||
) | [read] |
Create a new RTP instance.
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 |
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.
Definition at line 308 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().
00311 { 00312 struct ast_sockaddr address = {{0,}}; 00313 struct ast_rtp_instance *instance = NULL; 00314 struct ast_rtp_engine *engine = NULL; 00315 00316 AST_RWLIST_RDLOCK(&engines); 00317 00318 /* If an engine name was specified try to use it or otherwise use the first one registered */ 00319 if (!ast_strlen_zero(engine_name)) { 00320 AST_RWLIST_TRAVERSE(&engines, engine, entry) { 00321 if (!strcmp(engine->name, engine_name)) { 00322 break; 00323 } 00324 } 00325 } else { 00326 engine = AST_RWLIST_FIRST(&engines); 00327 } 00328 00329 /* If no engine was actually found bail out now */ 00330 if (!engine) { 00331 ast_log(LOG_ERROR, "No RTP engine was found. Do you have one loaded?\n"); 00332 AST_RWLIST_UNLOCK(&engines); 00333 return NULL; 00334 } 00335 00336 /* Bump up the reference count before we return so the module can not be unloaded */ 00337 ast_module_ref(engine->mod); 00338 00339 AST_RWLIST_UNLOCK(&engines); 00340 00341 /* Allocate a new RTP instance */ 00342 if (!(instance = ao2_alloc(sizeof(*instance), instance_destructor))) { 00343 ast_module_unref(engine->mod); 00344 return NULL; 00345 } 00346 instance->engine = engine; 00347 ast_sockaddr_copy(&instance->local_address, sa); 00348 ast_sockaddr_copy(&address, sa); 00349 00350 ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance); 00351 00352 /* And pass it off to the engine to setup */ 00353 if (instance->engine->new(instance, sched, &address, data)) { 00354 ast_debug(1, "Engine '%s' failed to setup RTP instance '%p'\n", engine->name, instance); 00355 ao2_ref(instance, -1); 00356 return NULL; 00357 } 00358 00359 ast_debug(1, "RTP instance '%p' is setup and ready to go\n", instance); 00360 00361 return instance; 00362 }
struct ast_frame* ast_rtp_instance_read | ( | struct ast_rtp_instance * | instance, | |
int | rtcp | |||
) | [read] |
Receive a frame over RTP.
instance | The RTP instance to receive frame on | |
rtcp | Whether to read in RTCP or not |
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.
Definition at line 379 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().
int ast_rtp_instance_sendcng | ( | struct ast_rtp_instance * | instance, | |
int | level | |||
) |
Send a comfort noise packet to the RTP instance.
instance | The RTP instance | |
level | Magnitude of the noise level |
0 | Success | |
non-zero | Failure |
Definition at line 1839 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::sendcng.
Referenced by check_rtp_timeout().
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.
instance | The RTP instance to change the address on | |
address | Address to set it to |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_set_alt_remote_address(instance, &address);
This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin structure.
Definition at line 405 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().
00407 { 00408 ast_sockaddr_copy(&instance->alt_remote_address, address); 00409 00410 /* oink */ 00411 00412 if (instance->engine->alt_remote_address_set) { 00413 instance->engine->alt_remote_address_set(instance, &instance->alt_remote_address); 00414 } 00415 00416 return 0; 00417 }
void ast_rtp_instance_set_data | ( | struct ast_rtp_instance * | instance, | |
void * | data | |||
) |
Set the data portion of an RTP instance.
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.
Definition at line 364 of file rtp_engine.c.
References ast_rtp_instance::data.
Referenced by ast_rtp_new(), and multicast_rtp_new().
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.
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 |
Definition at line 453 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::extended_prop_set.
00454 { 00455 if (instance->engine->extended_prop_set) { 00456 instance->engine->extended_prop_set(instance, property, value); 00457 } 00458 }
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.
instance | The RTP instance | |
timeout | Value to set the timeout to |
Example usage:
ast_rtp_instance_set_hold_timeout(instance, 5000);
This sets the RTP hold timeout value on 'instance' to be 5000.
Definition at line 1748 of file rtp_engine.c.
References ast_rtp_instance::holdtimeout.
Referenced by check_rtp_timeout(), and dialog_initialize_rtp().
01749 { 01750 instance->holdtimeout = timeout; 01751 }
void ast_rtp_instance_set_keepalive | ( | struct ast_rtp_instance * | instance, | |
int | timeout | |||
) |
Set the RTP keepalive interval.
instance | The RTP instance | |
period | Value to set the keepalive interval to |
Example usage:
ast_rtp_instance_set_keepalive(instance, 5000);
This sets the RTP keepalive interval on 'instance' to be 5000.
Definition at line 1753 of file rtp_engine.c.
References ast_rtp_instance::keepalive.
Referenced by dialog_initialize_rtp().
01754 { 01755 instance->keepalive = interval; 01756 }
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.
instance | The RTP instance to change the address on | |
address | Address to set it to |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_set_local_address(instance, &sin);
This changes the local address that RTP is expected on to the address given in the sin structure.
Definition at line 384 of file rtp_engine.c.
References ast_sockaddr_copy(), and ast_rtp_instance::local_address.
Referenced by ast_rtp_new().
00386 { 00387 ast_sockaddr_copy(&instance->local_address, address); 00388 return 0; 00389 }
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.
instance | The RTP instance to set the property on | |
property | The property to modify | |
value | The value to set the property to |
Example usage:
ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1);
This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.
Definition at line 469 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(), sip_set_rtp_peer(), and start_rtp().
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.
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 |
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.
Definition at line 774 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().
int ast_rtp_instance_set_read_format | ( | struct ast_rtp_instance * | instance, | |
format_t | format | |||
) |
Request that the underlying RTP engine provide audio frames in a specific format.
instance | The RTP instance to change read format on | |
format | Format that frames are wanted in |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_set_read_format(instance, AST_FORMAT_ULAW);
This requests that the RTP engine provide audio frames in the ULAW format.
Definition at line 1672 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::set_read_format.
Referenced by sip_new(), and sip_setoption().
01673 { 01674 return instance->engine->set_read_format ? instance->engine->set_read_format(instance, format) : -1; 01675 }
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.
instance | The RTP instance to change the address on | |
address | Address to set it to |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_set_remote_address(instance, &sin);
This changes the remote address that RTP will be sent to on instance to the address given in the sin structure.
Definition at line 391 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().
00393 { 00394 ast_sockaddr_copy(&instance->remote_address, address); 00395 00396 /* moo */ 00397 00398 if (instance->engine->remote_address_set) { 00399 instance->engine->remote_address_set(instance, &instance->remote_address); 00400 } 00401 00402 return 0; 00403 }
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.
chan | Channel to set the statistics on | |
instance | The RTP instance that statistics will be retrieved from |
Example usage:
ast_rtp_instance_set_stats_vars(chan, rtp);
This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to by chan.
Definition at line 1638 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().
01639 { 01640 char quality_buf[AST_MAX_USER_FIELD], *quality; 01641 struct ast_channel *bridge = ast_bridged_channel(chan); 01642 01643 if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) { 01644 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOS", quality); 01645 if (bridge) { 01646 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSBRIDGED", quality); 01647 } 01648 } 01649 01650 if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf)))) { 01651 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSJITTER", quality); 01652 if (bridge) { 01653 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSJITTERBRIDGED", quality); 01654 } 01655 } 01656 01657 if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf)))) { 01658 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSLOSS", quality); 01659 if (bridge) { 01660 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSLOSSBRIDGED", quality); 01661 } 01662 } 01663 01664 if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf)))) { 01665 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSRTT", quality); 01666 if (bridge) { 01667 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSRTTBRIDGED", quality); 01668 } 01669 } 01670 }
void ast_rtp_instance_set_timeout | ( | struct ast_rtp_instance * | instance, | |
int | timeout | |||
) |
Set the RTP timeout value.
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.
Definition at line 1743 of file rtp_engine.c.
References ast_rtp_instance::timeout.
Referenced by check_rtp_timeout(), and dialog_initialize_rtp().
01744 { 01745 instance->timeout = timeout; 01746 }
int ast_rtp_instance_set_write_format | ( | struct ast_rtp_instance * | instance, | |
format_t | format | |||
) |
Tell underlying RTP engine that audio frames will be provided in a specific format.
instance | The RTP instance to change write format on | |
format | Format that frames will be provided in |
0 | success | |
-1 | failure |
Example usage:
ast_rtp_instance_set_write_format(instance, AST_FORMAT_ULAW);
This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
Definition at line 1677 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::set_write_format.
Referenced by sip_new(), and sip_setoption().
01678 { 01679 return instance->engine->set_write_format ? instance->engine->set_write_format(instance, format) : -1; 01680 }
void ast_rtp_instance_stop | ( | struct ast_rtp_instance * | instance | ) |
Stop an RTP instance.
instance | Instance that media is no longer going to at this time |
Example usage:
ast_rtp_instance_stop(instance);
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.
Definition at line 779 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().
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.
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'.
Definition at line 1734 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().
01737 { 01738 if (instance->engine->stun_request) { 01739 instance->engine->stun_request(instance, suggestion, username); 01740 } 01741 }
void ast_rtp_instance_update_source | ( | struct ast_rtp_instance * | instance | ) |
Indicate that the RTP marker bit should be set on an RTP stream.
instance | Instance that the new media source is feeding into |
Example usage:
ast_rtp_instance_update_source(instance);
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.
Definition at line 760 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().
00761 { 00762 if (instance->engine->update_source) { 00763 instance->engine->update_source(instance); 00764 } 00765 }
int ast_rtp_instance_write | ( | struct ast_rtp_instance * | instance, | |
struct ast_frame * | frame | |||
) |
Send a frame out over RTP.
instance | The RTP instance to send frame out on | |
frame | the frame to send out |
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.
Definition at line 374 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().
char* ast_rtp_lookup_mime_multiple2 | ( | struct ast_str * | buf, | |
const format_t | capability, | |||
const int | asterisk_format, | |||
enum ast_rtp_options | options | |||
) |
Convert formats into a string and put them into a buffer.
buf | Buffer to put the mime output into | |
capability | Formats that we are looking up | |
asterisk_format | Non-zero if the given capability are Asterisk format capabilities | |
options | Additional options that may change the result |
non-NULL | success | |
NULL | failure |
Example usage:
char buf[256] = ""; char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), AST_FORMAT_ULAW | AST_FORMAT_ALAW, 1, 0);
This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
Definition at line 703 of file rtp_engine.c.
References ast_rtp_lookup_mime_subtype2(), AST_RTP_MAX, ast_str_append(), ast_str_buffer(), format, and name.
Referenced by process_sdp().
00704 { 00705 format_t format; 00706 int found = 0; 00707 00708 if (!buf) { 00709 return NULL; 00710 } 00711 00712 ast_str_append(&buf, 0, "0x%llx (", (unsigned long long) capability); 00713 00714 for (format = 1; format <= AST_RTP_MAX; format <<= 1) { 00715 if (capability & format) { 00716 const char *name = ast_rtp_lookup_mime_subtype2(asterisk_format, format, options); 00717 ast_str_append(&buf, 0, "%s|", name); 00718 found = 1; 00719 } 00720 } 00721 00722 ast_str_append(&buf, 0, "%s", found ? ")" : "nothing)"); 00723 00724 return ast_str_buffer(buf); 00725 }
const char* ast_rtp_lookup_mime_subtype2 | ( | const int | asterisk_format, | |
const format_t | code, | |||
enum ast_rtp_options | options | |||
) |
Retrieve mime subtype information on a payload.
asterisk_format | Non-zero if the given code is an Asterisk format value | |
code | Format to look up | |
options | Additional options that may change the result |
Mime | subtype success | |
NULL | failure |
Example usage:
const char *subtype = ast_rtp_lookup_mime_subtype2(1, AST_FORMAT_ULAW, 0);
This looks up the mime subtype for the ULAW format.
Definition at line 673 of file rtp_engine.c.
References ARRAY_LEN, AST_FORMAT_G726_AAL2, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rtp_payload_type::asterisk_format, ast_rtp_mime_type::payload_type, 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().
00674 { 00675 int i; 00676 00677 for (i = 0; i < ARRAY_LEN(ast_rtp_mime_types); i++) { 00678 if (ast_rtp_mime_types[i].payload_type.code == code && ast_rtp_mime_types[i].payload_type.asterisk_format == asterisk_format) { 00679 if (asterisk_format && (code == AST_FORMAT_G726_AAL2) && (options & AST_RTP_OPT_G726_NONSTANDARD)) { 00680 return "G726-32"; 00681 } else { 00682 return ast_rtp_mime_types[i].subtype; 00683 } 00684 } 00685 } 00686 00687 return ""; 00688 }
unsigned int ast_rtp_lookup_sample_rate2 | ( | int | asterisk_format, | |
format_t | code | |||
) |
Get the sample rate associated with known RTP payload types.
asterisk_format | True if the value in the 'code' parameter is an AST_FORMAT value | |
code | Format code, either from AST_FORMAT list or from AST_RTP list |
Definition at line 690 of file rtp_engine.c.
References ARRAY_LEN, ast_rtp_mime_types, ast_rtp_payload_type::asterisk_format, ast_rtp_mime_type::payload_type, 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().
00691 { 00692 unsigned int i; 00693 00694 for (i = 0; i < ARRAY_LEN(ast_rtp_mime_types); ++i) { 00695 if ((ast_rtp_mime_types[i].payload_type.code == code) && (ast_rtp_mime_types[i].payload_type.asterisk_format == asterisk_format)) { 00696 return ast_rtp_mime_types[i].sample_rate; 00697 } 00698 } 00699 00700 return 0; 00701 }
int ast_rtp_red_buffer | ( | struct ast_rtp_instance * | instance, | |
struct ast_frame * | frame | |||
) |
Buffer a frame in an RTP instance for RED.
instance | The instance to buffer the frame on | |
frame | Frame that we want to buffer |
0 | success | |
-1 | failure |
Definition at line 1588 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::red_buffer.
Referenced by sip_write().
01589 { 01590 return instance->engine->red_buffer ? instance->engine->red_buffer(instance, frame) : -1; 01591 }
int ast_rtp_red_init | ( | struct ast_rtp_instance * | instance, | |
int | buffer_time, | |||
int * | payloads, | |||
int | generations | |||
) |
Initialize RED support on an RTP instance.
instance | The instance to initialize RED support on | |
buffer_time | How long to buffer before sending | |
payloads | Payload values | |
generations | Number of generations |
0 | success | |
-1 | failure |
Definition at line 1583 of file rtp_engine.c.
References ast_rtp_instance::engine, and ast_rtp_engine::red_init.
Referenced by process_sdp().
static void instance_destructor | ( | void * | obj | ) | [static] |
Definition at line 281 of file rtp_engine.c.
References ast_debug, ast_module_unref(), ast_rtp_instance::data, ast_srtp_res::destroy, ast_rtp_engine::destroy, ast_rtp_instance::engine, ast_rtp_engine::mod, ast_rtp_engine::name, and ast_rtp_instance::srtp.
Referenced by ast_rtp_instance_new().
00282 { 00283 struct ast_rtp_instance *instance = obj; 00284 00285 /* Pass us off to the engine to destroy */ 00286 if (instance->data && instance->engine->destroy(instance)) { 00287 ast_debug(1, "Engine '%s' failed to destroy RTP instance '%p'\n", instance->engine->name, instance); 00288 return; 00289 } 00290 00291 if (instance->srtp) { 00292 res_srtp->destroy(instance->srtp); 00293 } 00294 00295 /* Drop our engine reference */ 00296 ast_module_unref(instance->engine->mod); 00297 00298 ast_debug(1, "Destroyed RTP instance '%p'\n", instance); 00299 }
static enum ast_bridge_result local_bridge_loop | ( | struct ast_channel * | c0, | |
struct ast_channel * | c1, | |||
struct ast_rtp_instance * | instance0, | |||
struct ast_rtp_instance * | instance1, | |||
int | timeoutms, | |||
int | flags, | |||
struct ast_frame ** | fo, | |||
struct ast_channel ** | rc, | |||
void * | pvt0, | |||
void * | pvt1 | |||
) | [static] |
Definition at line 808 of file rtp_engine.c.
References AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, AST_BRIDGE_IGNORE_SIGS, AST_BRIDGE_RETRY, ast_channel_connected_line_macro(), ast_channel_redirecting_macro(), ast_channel_unlock, ast_check_hangup(), AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_is_empty(), ast_frfree, ast_indicate_data(), ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_remaining_ms(), ast_tvnow(), ast_waitfor_n(), ast_write(), ast_channel::audiohooks, ast_rtp_instance::bridged, ast_frame::data, ast_frame::datalen, ast_rtp_instance::engine, ast_channel::framehooks, ast_frame::frametype, ast_frame_subclass::integer, ast_rtp_engine::local_bridge, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_frame::ptr, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_frame::subclass, and ast_channel::tech_pvt.
Referenced by ast_rtp_instance_bridge().
00809 { 00810 enum ast_bridge_result res = AST_BRIDGE_FAILED; 00811 struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, }; 00812 struct ast_frame *fr = NULL; 00813 struct timeval start; 00814 00815 /* Start locally bridging both instances */ 00816 if (instance0->engine->local_bridge && instance0->engine->local_bridge(instance0, instance1)) { 00817 ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", c0->name, c1->name); 00818 ast_channel_unlock(c0); 00819 ast_channel_unlock(c1); 00820 return AST_BRIDGE_FAILED_NOWARN; 00821 } 00822 if (instance1->engine->local_bridge && instance1->engine->local_bridge(instance1, instance0)) { 00823 ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", c1->name, c0->name); 00824 if (instance0->engine->local_bridge) { 00825 instance0->engine->local_bridge(instance0, NULL); 00826 } 00827 ast_channel_unlock(c0); 00828 ast_channel_unlock(c1); 00829 return AST_BRIDGE_FAILED_NOWARN; 00830 } 00831 00832 ast_channel_unlock(c0); 00833 ast_channel_unlock(c1); 00834 00835 instance0->bridged = instance1; 00836 instance1->bridged = instance0; 00837 00838 ast_poll_channel_add(c0, c1); 00839 00840 /* Hop into a loop waiting for a frame from either channel */ 00841 cs[0] = c0; 00842 cs[1] = c1; 00843 cs[2] = NULL; 00844 start = ast_tvnow(); 00845 for (;;) { 00846 int ms; 00847 /* If the underlying formats have changed force this bridge to break */ 00848 if ((c0->rawreadformat != c1->rawwriteformat) || (c1->rawreadformat != c0->rawwriteformat)) { 00849 ast_debug(1, "rtp-engine-local-bridge: Oooh, formats changed, backing out\n"); 00850 res = AST_BRIDGE_FAILED_NOWARN; 00851 break; 00852 } 00853 /* Check if anything changed */ 00854 if ((c0->tech_pvt != pvt0) || 00855 (c1->tech_pvt != pvt1) || 00856 (c0->masq || c0->masqr || c1->masq || c1->masqr) || 00857 (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) || 00858 (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) { 00859 ast_debug(1, "rtp-engine-local-bridge: Oooh, something is weird, backing out\n"); 00860 /* If a masquerade needs to happen we have to try to read in a frame so that it actually happens. Without this we risk being called again and going into a loop */ 00861 if ((c0->masq || c0->masqr) && (fr = ast_read(c0))) { 00862 ast_frfree(fr); 00863 } 00864 if ((c1->masq || c1->masqr) && (fr = ast_read(c1))) { 00865 ast_frfree(fr); 00866 } 00867 res = AST_BRIDGE_RETRY; 00868 break; 00869 } 00870 /* Wait on a channel to feed us a frame */ 00871 ms = ast_remaining_ms(start, timeoutms); 00872 if (!(who = ast_waitfor_n(cs, 2, &ms))) { 00873 if (!ms) { 00874 res = AST_BRIDGE_RETRY; 00875 break; 00876 } 00877 ast_debug(2, "rtp-engine-local-bridge: Ooh, empty read...\n"); 00878 if (ast_check_hangup(c0) || ast_check_hangup(c1)) { 00879 break; 00880 } 00881 continue; 00882 } 00883 /* Read in frame from channel */ 00884 fr = ast_read(who); 00885 other = (who == c0) ? c1 : c0; 00886 /* Depending on the frame we may need to break out of our bridge */ 00887 if (!fr || ((fr->frametype == AST_FRAME_DTMF_BEGIN || fr->frametype == AST_FRAME_DTMF_END) && 00888 ((who == c0) && (flags & AST_BRIDGE_DTMF_CHANNEL_0)) | 00889 ((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1)))) { 00890 /* Record received frame and who */ 00891 *fo = fr; 00892 *rc = who; 00893 ast_debug(1, "rtp-engine-local-bridge: Ooh, got a %s\n", fr ? "digit" : "hangup"); 00894 res = AST_BRIDGE_COMPLETE; 00895 break; 00896 } else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) { 00897 if ((fr->subclass.integer == AST_CONTROL_HOLD) || 00898 (fr->subclass.integer == AST_CONTROL_UNHOLD) || 00899 (fr->subclass.integer == AST_CONTROL_VIDUPDATE) || 00900 (fr->subclass.integer == AST_CONTROL_SRCUPDATE) || 00901 (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS) || 00902 (fr->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER)) { 00903 /* If we are going on hold, then break callback mode and P2P bridging */ 00904 if (fr->subclass.integer == AST_CONTROL_HOLD) { 00905 if (instance0->engine->local_bridge) { 00906 instance0->engine->local_bridge(instance0, NULL); 00907 } 00908 if (instance1->engine->local_bridge) { 00909 instance1->engine->local_bridge(instance1, NULL); 00910 } 00911 instance0->bridged = NULL; 00912 instance1->bridged = NULL; 00913 } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) { 00914 if (instance0->engine->local_bridge) { 00915 instance0->engine->local_bridge(instance0, instance1); 00916 } 00917 if (instance1->engine->local_bridge) { 00918 instance1->engine->local_bridge(instance1, instance0); 00919 } 00920 instance0->bridged = instance1; 00921 instance1->bridged = instance0; 00922 } 00923 /* Since UPDATE_BRIDGE_PEER is only used by the bridging code, don't forward it */ 00924 if (fr->subclass.integer != AST_CONTROL_UPDATE_RTP_PEER) { 00925 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 00926 } 00927 ast_frfree(fr); 00928 } else if (fr->subclass.integer == AST_CONTROL_CONNECTED_LINE) { 00929 if (ast_channel_connected_line_macro(who, other, fr, other == c0, 1)) { 00930 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 00931 } 00932 ast_frfree(fr); 00933 } else if (fr->subclass.integer == AST_CONTROL_REDIRECTING) { 00934 if (ast_channel_redirecting_macro(who, other, fr, other == c0, 1)) { 00935 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 00936 } 00937 ast_frfree(fr); 00938 } else { 00939 *fo = fr; 00940 *rc = who; 00941 ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name); 00942 res = AST_BRIDGE_COMPLETE; 00943 break; 00944 } 00945 } else { 00946 if ((fr->frametype == AST_FRAME_DTMF_BEGIN) || 00947 (fr->frametype == AST_FRAME_DTMF_END) || 00948 (fr->frametype == AST_FRAME_VOICE) || 00949 (fr->frametype == AST_FRAME_VIDEO) || 00950 (fr->frametype == AST_FRAME_IMAGE) || 00951 (fr->frametype == AST_FRAME_HTML) || 00952 (fr->frametype == AST_FRAME_MODEM) || 00953 (fr->frametype == AST_FRAME_TEXT)) { 00954 ast_write(other, fr); 00955 } 00956 00957 ast_frfree(fr); 00958 } 00959 /* Swap priority */ 00960 cs[2] = cs[0]; 00961 cs[0] = cs[1]; 00962 cs[1] = cs[2]; 00963 } 00964 00965 /* Stop locally bridging both instances */ 00966 if (instance0->engine->local_bridge) { 00967 instance0->engine->local_bridge(instance0, NULL); 00968 } 00969 if (instance1->engine->local_bridge) { 00970 instance1->engine->local_bridge(instance1, NULL); 00971 } 00972 00973 instance0->bridged = NULL; 00974 instance1->bridged = NULL; 00975 00976 ast_poll_channel_del(c0, c1); 00977 00978 return res; 00979 }
static enum ast_bridge_result remote_bridge_loop | ( | struct ast_channel * | c0, | |
struct ast_channel * | c1, | |||
struct ast_rtp_instance * | instance0, | |||
struct ast_rtp_instance * | instance1, | |||
struct ast_rtp_instance * | vinstance0, | |||
struct ast_rtp_instance * | vinstance1, | |||
struct ast_rtp_instance * | tinstance0, | |||
struct ast_rtp_instance * | tinstance1, | |||
struct ast_rtp_glue * | glue0, | |||
struct ast_rtp_glue * | glue1, | |||
format_t | codec0, | |||
format_t | codec1, | |||
int | timeoutms, | |||
int | flags, | |||
struct ast_frame ** | fo, | |||
struct ast_channel ** | rc, | |||
void * | pvt0, | |||
void * | pvt1 | |||
) | [static] |
Definition at line 981 of file rtp_engine.c.
References AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_FAILED, AST_BRIDGE_IGNORE_SIGS, AST_BRIDGE_RETRY, ast_channel_connected_line_macro(), ast_channel_redirecting_macro(), ast_channel_unlock, ast_check_hangup(), AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, AST_CONTROL_VIDUPDATE, ast_debug, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_is_empty(), ast_frfree, ast_getformatname(), ast_indicate_data(), ast_log(), ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_remaining_ms(), ast_rtp_instance_get_glue(), ast_rtp_instance_get_remote_address(), ast_sockaddr_cmp(), ast_sockaddr_copy(), ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_test_flag, ast_tvnow(), ast_waitfor_n(), ast_write(), ast_channel::audiohooks, ast_rtp_instance::bridged, ast_frame::data, ast_frame::datalen, ast_channel::framehooks, ast_frame::frametype, ast_rtp_glue::get_codec, ast_frame_subclass::integer, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_frame::ptr, ast_frame::subclass, ast_channel::tech, ast_channel::tech_pvt, ast_channel_tech::type, and ast_rtp_glue::update_peer.
Referenced by ast_rtp_instance_bridge().
00985 { 00986 enum ast_bridge_result res = AST_BRIDGE_FAILED; 00987 struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, }; 00988 format_t oldcodec0 = codec0, oldcodec1 = codec1; 00989 struct ast_sockaddr ac1 = {{0,}}, vac1 = {{0,}}, tac1 = {{0,}}, ac0 = {{0,}}, vac0 = {{0,}}, tac0 = {{0,}}; 00990 struct ast_sockaddr t1 = {{0,}}, vt1 = {{0,}}, tt1 = {{0,}}, t0 = {{0,}}, vt0 = {{0,}}, tt0 = {{0,}}; 00991 struct ast_frame *fr = NULL; 00992 struct timeval start; 00993 00994 /* Test the first channel */ 00995 if (!(glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0))) { 00996 ast_rtp_instance_get_remote_address(instance1, &ac1); 00997 if (vinstance1) { 00998 ast_rtp_instance_get_remote_address(vinstance1, &vac1); 00999 } 01000 if (tinstance1) { 01001 ast_rtp_instance_get_remote_address(tinstance1, &tac1); 01002 } 01003 } else { 01004 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); 01005 } 01006 01007 /* Test the second channel */ 01008 if (!(glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0))) { 01009 ast_rtp_instance_get_remote_address(instance0, &ac0); 01010 if (vinstance0) { 01011 ast_rtp_instance_get_remote_address(instance0, &vac0); 01012 } 01013 if (tinstance0) { 01014 ast_rtp_instance_get_remote_address(instance0, &tac0); 01015 } 01016 } else { 01017 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c1->name, c0->name); 01018 } 01019 01020 ast_channel_unlock(c0); 01021 ast_channel_unlock(c1); 01022 01023 instance0->bridged = instance1; 01024 instance1->bridged = instance0; 01025 01026 ast_poll_channel_add(c0, c1); 01027 01028 /* Go into a loop handling any stray frames that may come in */ 01029 cs[0] = c0; 01030 cs[1] = c1; 01031 cs[2] = NULL; 01032 start = ast_tvnow(); 01033 for (;;) { 01034 int ms; 01035 /* Check if anything changed */ 01036 if ((c0->tech_pvt != pvt0) || 01037 (c1->tech_pvt != pvt1) || 01038 (c0->masq || c0->masqr || c1->masq || c1->masqr) || 01039 (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) || 01040 (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) { 01041 ast_debug(1, "Oooh, something is weird, backing out\n"); 01042 res = AST_BRIDGE_RETRY; 01043 break; 01044 } 01045 01046 /* Check if they have changed their address */ 01047 ast_rtp_instance_get_remote_address(instance1, &t1); 01048 if (vinstance1) { 01049 ast_rtp_instance_get_remote_address(vinstance1, &vt1); 01050 } 01051 if (tinstance1) { 01052 ast_rtp_instance_get_remote_address(tinstance1, &tt1); 01053 } 01054 if (glue1->get_codec) { 01055 codec1 = glue1->get_codec(c1); 01056 } 01057 01058 ast_rtp_instance_get_remote_address(instance0, &t0); 01059 if (vinstance0) { 01060 ast_rtp_instance_get_remote_address(vinstance0, &vt0); 01061 } 01062 if (tinstance0) { 01063 ast_rtp_instance_get_remote_address(tinstance0, &tt0); 01064 } 01065 if (glue0->get_codec) { 01066 codec0 = glue0->get_codec(c0); 01067 } 01068 01069 if ((ast_sockaddr_cmp(&t1, &ac1)) || 01070 (vinstance1 && ast_sockaddr_cmp(&vt1, &vac1)) || 01071 (tinstance1 && ast_sockaddr_cmp(&tt1, &tac1)) || 01072 (codec1 != oldcodec1)) { 01073 ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n", 01074 c1->name, ast_sockaddr_stringify(&t1), 01075 ast_getformatname(codec1)); 01076 ast_debug(1, "Oooh, '%s' changed end vaddress to %s (format %s)\n", 01077 c1->name, ast_sockaddr_stringify(&vt1), 01078 ast_getformatname(codec1)); 01079 ast_debug(1, "Oooh, '%s' changed end taddress to %s (format %s)\n", 01080 c1->name, ast_sockaddr_stringify(&tt1), 01081 ast_getformatname(codec1)); 01082 ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", 01083 c1->name, ast_sockaddr_stringify(&ac1), 01084 ast_getformatname(oldcodec1)); 01085 ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", 01086 c1->name, ast_sockaddr_stringify(&vac1), 01087 ast_getformatname(oldcodec1)); 01088 ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", 01089 c1->name, ast_sockaddr_stringify(&tac1), 01090 ast_getformatname(oldcodec1)); 01091 if (glue0->update_peer(c0, 01092 ast_sockaddr_isnull(&t1) ? NULL : instance1, 01093 ast_sockaddr_isnull(&vt1) ? NULL : vinstance1, 01094 ast_sockaddr_isnull(&tt1) ? NULL : tinstance1, 01095 codec1, 0)) { 01096 ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name); 01097 } 01098 ast_sockaddr_copy(&ac1, &t1); 01099 ast_sockaddr_copy(&vac1, &vt1); 01100 ast_sockaddr_copy(&tac1, &tt1); 01101 oldcodec1 = codec1; 01102 } 01103 if ((ast_sockaddr_cmp(&t0, &ac0)) || 01104 (vinstance0 && ast_sockaddr_cmp(&vt0, &vac0)) || 01105 (tinstance0 && ast_sockaddr_cmp(&tt0, &tac0)) || 01106 (codec0 != oldcodec0)) { 01107 ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n", 01108 c0->name, ast_sockaddr_stringify(&t0), 01109 ast_getformatname(codec0)); 01110 ast_debug(1, "Oooh, '%s' was %s/(format %s)\n", 01111 c0->name, ast_sockaddr_stringify(&ac0), 01112 ast_getformatname(oldcodec0)); 01113 if (glue1->update_peer(c1, t0.len ? instance0 : NULL, 01114 vt0.len ? vinstance0 : NULL, 01115 tt0.len ? tinstance0 : NULL, 01116 codec0, 0)) { 01117 ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name); 01118 } 01119 ast_sockaddr_copy(&ac0, &t0); 01120 ast_sockaddr_copy(&vac0, &vt0); 01121 ast_sockaddr_copy(&tac0, &tt0); 01122 oldcodec0 = codec0; 01123 } 01124 01125 ms = ast_remaining_ms(start, timeoutms); 01126 /* Wait for frame to come in on the channels */ 01127 if (!(who = ast_waitfor_n(cs, 2, &ms))) { 01128 if (!ms) { 01129 res = AST_BRIDGE_RETRY; 01130 break; 01131 } 01132 ast_debug(1, "Ooh, empty read...\n"); 01133 if (ast_check_hangup(c0) || ast_check_hangup(c1)) { 01134 break; 01135 } 01136 continue; 01137 } 01138 fr = ast_read(who); 01139 other = (who == c0) ? c1 : c0; 01140 if (!fr || ((fr->frametype == AST_FRAME_DTMF_BEGIN || fr->frametype == AST_FRAME_DTMF_END) && 01141 (((who == c0) && (flags & AST_BRIDGE_DTMF_CHANNEL_0)) || 01142 ((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) { 01143 /* Break out of bridge */ 01144 *fo = fr; 01145 *rc = who; 01146 ast_debug(1, "Oooh, got a %s\n", fr ? "digit" : "hangup"); 01147 res = AST_BRIDGE_COMPLETE; 01148 break; 01149 } else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) { 01150 if ((fr->subclass.integer == AST_CONTROL_HOLD) || 01151 (fr->subclass.integer == AST_CONTROL_UNHOLD) || 01152 (fr->subclass.integer == AST_CONTROL_VIDUPDATE) || 01153 (fr->subclass.integer == AST_CONTROL_SRCUPDATE) || 01154 (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS) || 01155 (fr->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER)) { 01156 if (fr->subclass.integer == AST_CONTROL_HOLD) { 01157 /* If we someone went on hold we want the other side to reinvite back to us */ 01158 if (who == c0) { 01159 glue1->update_peer(c1, NULL, NULL, NULL, 0, 0); 01160 } else { 01161 glue0->update_peer(c0, NULL, NULL, NULL, 0, 0); 01162 } 01163 } else if (fr->subclass.integer == AST_CONTROL_UNHOLD || 01164 fr->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER) { 01165 /* If they went off hold they should go back to being direct, or if we have 01166 * been told to force a peer update, go ahead and do it. */ 01167 if (who == c0) { 01168 glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0); 01169 } else { 01170 glue0->update_peer(c0, instance1, vinstance1, tinstance1, codec1, 0); 01171 } 01172 } 01173 /* Update local address information */ 01174 ast_rtp_instance_get_remote_address(instance0, &t0); 01175 ast_sockaddr_copy(&ac0, &t0); 01176 ast_rtp_instance_get_remote_address(instance1, &t1); 01177 ast_sockaddr_copy(&ac1, &t1); 01178 /* Update codec information */ 01179 if (glue0->get_codec && c0->tech_pvt) { 01180 oldcodec0 = codec0 = glue0->get_codec(c0); 01181 } 01182 if (glue1->get_codec && c1->tech_pvt) { 01183 oldcodec1 = codec1 = glue1->get_codec(c1); 01184 } 01185 /* Since UPDATE_BRIDGE_PEER is only used by the bridging code, don't forward it */ 01186 if (fr->subclass.integer != AST_CONTROL_UPDATE_RTP_PEER) { 01187 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 01188 } 01189 ast_frfree(fr); 01190 } else if (fr->subclass.integer == AST_CONTROL_CONNECTED_LINE) { 01191 if (ast_channel_connected_line_macro(who, other, fr, other == c0, 1)) { 01192 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 01193 } 01194 ast_frfree(fr); 01195 } else if (fr->subclass.integer == AST_CONTROL_REDIRECTING) { 01196 if (ast_channel_redirecting_macro(who, other, fr, other == c0, 1)) { 01197 ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); 01198 } 01199 ast_frfree(fr); 01200 } else { 01201 *fo = fr; 01202 *rc = who; 01203 ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name); 01204 return AST_BRIDGE_COMPLETE; 01205 } 01206 } else { 01207 if ((fr->frametype == AST_FRAME_DTMF_BEGIN) || 01208 (fr->frametype == AST_FRAME_DTMF_END) || 01209 (fr->frametype == AST_FRAME_VOICE) || 01210 (fr->frametype == AST_FRAME_VIDEO) || 01211 (fr->frametype == AST_FRAME_IMAGE) || 01212 (fr->frametype == AST_FRAME_HTML) || 01213 (fr->frametype == AST_FRAME_MODEM) || 01214 (fr->frametype == AST_FRAME_TEXT)) { 01215 ast_write(other, fr); 01216 } 01217 ast_frfree(fr); 01218 } 01219 /* Swap priority */ 01220 cs[2] = cs[0]; 01221 cs[0] = cs[1]; 01222 cs[1] = cs[2]; 01223 } 01224 01225 if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) { 01226 ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c0->name); 01227 } else if (c0->tech_pvt != pvt0) { 01228 ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", c0->name, c1->name); 01229 } else if (glue0 != ast_rtp_instance_get_glue(c0->tech->type)) { 01230 ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", c0->name, c1->name); 01231 } else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) { 01232 ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); 01233 } 01234 if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) { 01235 ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c1->name); 01236 } else if (c1->tech_pvt != pvt1) { 01237 ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", c1->name, c0->name); 01238 } else if (glue1 != ast_rtp_instance_get_glue(c1->tech->type)) { 01239 ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", c1->name, c0->name); 01240 } else if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) { 01241 ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name); 01242 } 01243 01244 instance0->bridged = NULL; 01245 instance1->bridged = NULL; 01246 01247 ast_poll_channel_del(c0, c1); 01248 01249 return res; 01250 }
static void unref_instance_cond | ( | struct ast_rtp_instance ** | instance | ) | [static] |
Conditionally unref an rtp instance.
Definition at line 1255 of file rtp_engine.c.
References ao2_ref.
Referenced by ast_rtp_instance_bridge(), ast_rtp_instance_early_bridge(), and ast_rtp_instance_early_bridge_make_compatible().
01256 { 01257 if (*instance) { 01258 ao2_ref(*instance, -1); 01259 *instance = NULL; 01260 } 01261 }
struct ast_rtp_mime_type ast_rtp_mime_types[] [static] |
The following array defines the MIME Media type (and subtype) for each of our codecs, or RTP-specific data type.
Referenced by ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_lookup_mime_subtype2(), and ast_rtp_lookup_sample_rate2().
struct ast_srtp_res* res_srtp = NULL |
Definition at line 48 of file rtp_engine.c.
struct ast_srtp_policy_res* res_srtp_policy = NULL |
Definition at line 49 of file rtp_engine.c.
struct ast_rtp_payload_type static_RTP_PT[AST_RTP_MAX_PT] [static] |
Mapping between Asterisk codecs and rtp payload types.
Static (i.e., well-known) RTP payload types for our "AST_FORMAT..."s: also, our own choices for dynamic payload types. This is our master table for transmission
See http://www.iana.org/assignments/rtp-parameters for a list of assigned values
Definition at line 147 of file rtp_engine.c.