Asterisk - The Open Source Telephony Project
18.5.0
|
PJSIP channel dialplan functions. More...
#include "asterisk.h"
#include <pjsip.h>
#include <pjlib.h>
#include <pjsip_ua.h>
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/acl.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "asterisk/stream.h"
#include "asterisk/format.h"
#include "asterisk/dsp.h"
#include "asterisk/pbx.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "include/chan_pjsip.h"
#include "include/dialplan_functions.h"
Go to the source code of this file.
Data Structures | |
struct | media_offer_data |
struct | parse_uri_args |
Struct used to push PJSIP_PARSE_URI function arguments to task processor. More... | |
struct | pjsip_func_args |
Struct used to push function arguments to task processor. More... | |
struct | refresh_data |
struct | session_refresh_state |
Session refresh state information. More... | |
Functions | |
static int | channel_read_pjsip (struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen) |
static int | channel_read_rtcp (struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen) |
static int | channel_read_rtp (struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen) |
static int | dtmf_mode_refresh_cb (void *obj) |
static int | media_offer_read_av (struct ast_sip_session *session, char *buf, size_t len, enum ast_media_type media_type) |
static int | media_offer_write_av (void *obj) |
static int | parse_uri_cb (void *data) |
int | pjsip_acf_channel_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
CHANNEL function read callback. More... | |
int | pjsip_acf_dial_contacts_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
PJSIP_DIAL_CONTACTS function read callback. More... | |
int | pjsip_acf_dtmf_mode_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
PJSIP_DTMF_MODE function read callback. More... | |
int | pjsip_acf_dtmf_mode_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
PJSIP_DTMF_MODE function write callback. More... | |
int | pjsip_acf_media_offer_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
PJSIP_MEDIA_OFFER function read callback. More... | |
int | pjsip_acf_media_offer_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
PJSIP_MEDIA_OFFER function write callback. More... | |
int | pjsip_acf_moh_passthrough_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
PJSIP_MOH_PASSTHROUGH function read callback. More... | |
int | pjsip_acf_moh_passthrough_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
PJSIP_MOH_PASSTHROUGH function write callback. More... | |
int | pjsip_acf_parse_uri_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen) |
PJSIP_PARSE_URI function read callback. More... | |
int | pjsip_acf_session_refresh_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
PJSIP_SEND_SESSION_REFRESH function write callback. More... | |
static int | print_escaped_uri (struct ast_channel *chan, const char *type, pjsip_uri_context_e context, const void *uri, char *buf, size_t size) |
static int | read_pjsip (void *data) |
static int | refresh_write_cb (void *obj) |
static void | session_refresh_state_destroy (void *obj) |
Destructor for session refresh information. More... | |
static struct session_refresh_state * | session_refresh_state_get_or_alloc (struct ast_sip_session *session) |
Helper function which retrieves or allocates a session refresh state information datastore. More... | |
static int | sip_session_response_cb (struct ast_sip_session *session, pjsip_rx_data *rdata) |
Variables | |
static const struct ast_datastore_info | session_refresh_datastore |
Datastore for attaching session refresh state information. More... | |
static const char * | t38state_to_string [T38_MAX_ENUM] |
String representations of the T.38 state enum. More... | |
PJSIP channel dialplan functions.
Definition in file pjsip/dialplan_functions.c.
|
static |
Definition at line 760 of file pjsip/dialplan_functions.c.
References ao2_cleanup, ast_channel_name(), ast_channel_tech_pvt(), ast_copy_pj_str(), ast_copy_string(), ast_escape_quoted(), ast_log, AST_LOG_WARNING, ast_sip_get_pjsip_endpoint(), ast_sip_session_get_datastore(), ast_strdupa, ast_strlen_zero, ast_sip_session::inv_session, transport_info_data::local_addr, LOG_WARNING, NULL, pool, print_escaped_uri(), RAII_VAR, transport_info_data::remote_addr, ast_sip_session::request_uri, ast_sip_channel_pvt::session, ast_sip_session::t38state, and t38state_to_string.
Referenced by read_pjsip().
|
static |
Definition at line 619 of file pjsip/dialplan_functions.c.
References ast_sip_session::active_media_state, ast_channel_name(), ast_channel_tech_pvt(), ast_log, AST_LOG_WARNING, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, ast_rtp_instance_get_quality(), ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_ALL, 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_strlen_zero, ast_sip_session_media_state::default_session, 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, name, ast_rtp_instance_stats::normdevrtt, NULL, 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_sip_session_media::rtp, ast_rtp_instance_stats::rtt, ast_rtp_instance_stats::rxcount, ast_rtp_instance_stats::rxjitter, ast_rtp_instance_stats::rxploss, S_OR, session, ast_sip_channel_pvt::session, ast_rtp_instance_stats::stdevrtt, ast_rtp_instance_stats::txcount, ast_rtp_instance_stats::txjitter, ast_rtp_instance_stats::txploss, and type.
Referenced by read_pjsip().
|
static |
Definition at line 552 of file pjsip/dialplan_functions.c.
References ast_sip_session::active_media_state, ast_channel_name(), ast_channel_tech_pvt(), ast_copy_string(), ast_log, AST_LOG_WARNING, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, ast_rtp_instance_get_local_address(), ast_rtp_instance_get_remote_address, ast_sockaddr_stringify(), AST_SRTP_CRYPTO_OFFER_OK, ast_strlen_zero, ast_test_flag, ast_sip_session_media_state::default_session, ast_sip_session_media::direct_media_addr, ast_sip_session_media::remotely_held, ast_sip_session_media::rtp, S_OR, session, ast_sip_channel_pvt::session, and ast_sip_session_media::srtp.
Referenced by read_pjsip().
|
static |
Definition at line 1513 of file pjsip/dialplan_functions.c.
References ast_channel_name(), ast_debug, ast_sip_session_refresh(), ast_sip_session_regenerate_answer(), ast_sip_session::channel, ast_sip_session::inv_session, refresh_data::method, NULL, refresh_data::session, and sip_session_response_cb().
Referenced by pjsip_acf_dtmf_mode_write().
|
static |
Definition at line 1232 of file pjsip/dialplan_functions.c.
References ao2_ref, ast_format_cap_count(), ast_format_cap_get_format(), ast_format_get_name(), ast_stream_get_formats(), ast_stream_get_state(), ast_stream_get_type(), AST_STREAM_STATE_REMOVED, ast_stream_topology_clone(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_sip_session::endpoint, ast_sip_session::inv_session, ast_sip_endpoint::media, session_refresh_state::media_state, NULL, ast_sip_session::pending_media_state, session_refresh_state_get_or_alloc(), state, ast_sip_session_media_state::topology, and ast_sip_endpoint_media_configuration::topology.
Referenced by pjsip_acf_media_offer_read().
|
static |
Definition at line 1318 of file pjsip/dialplan_functions.c.
References ao2_ref, ast_format_cap_alloc, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_remove_by_type(), ast_format_cap_update_by_allow_disallow(), AST_MEDIA_TYPE_UNKNOWN, ast_stream_get_formats(), ast_stream_set_formats(), ast_stream_set_metadata(), ast_stream_topology_clone(), ast_stream_topology_get_first_stream_by_type(), ast_sip_session::endpoint, ast_sip_session::inv_session, ast_sip_endpoint::media, session_refresh_state::media_state, media_offer_data::media_type, ast_sip_session::pending_media_state, media_offer_data::session, session_refresh_state_get_or_alloc(), state, ast_sip_session_media_state::topology, ast_sip_endpoint_media_configuration::topology, and media_offer_data::value.
Referenced by pjsip_acf_media_offer_write().
|
static |
Definition at line 1121 of file pjsip/dialplan_functions.c.
References args, ast_copy_pj_str(), ast_log, AST_LOG_WARNING, ast_sip_get_pjsip_endpoint(), parse_uri_args::buf, parse_uri_args::buflen, LOG_ERROR, LOG_WARNING, pool, parse_uri_args::ret, tmp(), parse_uri_args::type, and parse_uri_args::uri.
Referenced by pjsip_acf_parse_uri_read().
int pjsip_acf_channel_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
CHANNEL function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 916 of file pjsip/dialplan_functions.c.
References ao2_bump, ao2_ref, args, AST_APP_ARG, ast_channel_lock, ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_log, ast_sip_push_task_wait_serializer(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, buf, pjsip_func_args::buf, pjsip_func_args::field, pjsip_func_args::len, len(), LOG_ERROR, LOG_WARNING, pjsip_func_args::param, parse(), read_pjsip(), pjsip_func_args::ret, ast_sip_session::serializer, ast_sip_channel_pvt::session, pjsip_func_args::session, type, and pjsip_func_args::type.
int pjsip_acf_dial_contacts_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
PJSIP_DIAL_CONTACTS function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 983 of file pjsip/dialplan_functions.c.
References ao2_cleanup, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_sip_contact::aor, args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_free_ptr(), ast_log, AST_SIP_CONTACT_FILTER_REACHABLE, ast_sip_get_sorcery(), ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts_filtered(), ast_sorcery_retrieve_by_id(), AST_STANDARD_APP_ARGS, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_strlen(), ast_str_truncate(), ast_strdupa, ast_strip(), ast_strlen_zero, LOG_WARNING, NULL, RAII_VAR, S_OR, strsep(), and ast_sip_contact::uri.
int pjsip_acf_dtmf_mode_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
PJSIP_DTMF_MODE function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 1429 of file pjsip/dialplan_functions.c.
References ast_channel_lock, ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_log, ast_sip_dtmf_to_str(), ast_sip_session::dtmf, LOG_WARNING, ast_sip_channel_pvt::session, and type.
int pjsip_acf_dtmf_mode_write | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
const char * | value | ||
) |
PJSIP_DTMF_MODE function write callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
value | Value to be set by the function |
0 | on success |
-1 | on failure |
Definition at line 1530 of file pjsip/dialplan_functions.c.
References ast_sip_session::active_media_state, ast_channel_lock, ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_dsp_free(), ast_dsp_get_features(), ast_dsp_new(), ast_dsp_set_features(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_RTP_DTMF_MODE_INBAND, AST_RTP_DTMF_MODE_NONE, AST_RTP_DTMF_MODE_RFC2833, ast_rtp_instance_dtmf_mode_get(), ast_rtp_instance_dtmf_mode_set(), ast_rtp_instance_set_prop(), AST_RTP_PROPERTY_DTMF, AST_SIP_DTMF_AUTO, AST_SIP_DTMF_AUTO_INFO, AST_SIP_DTMF_INBAND, AST_SIP_DTMF_INFO, AST_SIP_DTMF_NONE, AST_SIP_DTMF_RFC_4733, ast_sip_push_task_wait_serializer(), AST_SIP_SESSION_REFRESH_METHOD_INVITE, ast_sip_str_to_dtmf(), ast_sip_session_media_state::default_session, ast_sip_session::dsp, DSP_FEATURE_DIGIT_DETECT, ast_sip_session::dtmf, dtmf_mode_refresh_cb(), LOG_WARNING, refresh_data::method, NULL, ast_sip_session_media::rtp, ast_sip_session::serializer, ast_sip_channel_pvt::session, refresh_data::session, and type.
int pjsip_acf_media_offer_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
PJSIP_MEDIA_OFFER function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 1372 of file pjsip/dialplan_functions.c.
References ast_channel_tech(), ast_channel_tech_pvt(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, LOG_WARNING, media_offer_read_av(), ast_sip_channel_pvt::session, and type.
int pjsip_acf_media_offer_write | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
const char * | value | ||
) |
PJSIP_MEDIA_OFFER function write callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
value | Value to be set by the function |
0 | on success |
-1 | on failure |
Definition at line 1400 of file pjsip/dialplan_functions.c.
References ast_channel_tech(), ast_channel_tech_pvt(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, ast_sip_push_task_wait_serializer(), LOG_WARNING, media_offer_write_av(), media_offer_data::media_type, ast_sip_session::serializer, ast_sip_channel_pvt::session, media_offer_data::session, type, and media_offer_data::value.
int pjsip_acf_moh_passthrough_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
PJSIP_MOH_PASSTHROUGH function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 1457 of file pjsip/dialplan_functions.c.
References ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_log, AST_YESNO, LOG_WARNING, ast_sip_session::moh_passthrough, ast_sip_channel_pvt::session, and type.
int pjsip_acf_moh_passthrough_write | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
const char * | value | ||
) |
PJSIP_MOH_PASSTHROUGH function write callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
value | Value to be set by the function |
0 | on success |
-1 | on failure |
Definition at line 1628 of file pjsip/dialplan_functions.c.
References ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_log, ast_true(), LOG_WARNING, ast_sip_session::moh_passthrough, ast_sip_channel_pvt::session, and type.
int pjsip_acf_parse_uri_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) |
PJSIP_PARSE_URI function read callback.
chan | The channel the function is called on |
cmd | The name of the function |
data | Arguments passed to the function |
buf | Out buffer that should be populated with the data |
len | Size of the buffer |
0 | on success |
-1 | on failure |
Definition at line 1197 of file pjsip/dialplan_functions.c.
References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, ast_sip_push_task_wait_serializer(), AST_STANDARD_APP_ARGS, ast_strlen_zero, buf, parse_uri_args::buf, parse_uri_args::buflen, LOG_WARNING, NULL, parse_uri_cb(), parse_uri_args::ret, type, parse_uri_args::type, and parse_uri_args::uri.
int pjsip_acf_session_refresh_write | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
const char * | value | ||
) |
PJSIP_SEND_SESSION_REFRESH function write callback.
chan | The channel the function is called on |
cmd | the Name of the function |
data | Arguments passed to the function |
value | Value to be set by the function |
0 | on success |
-1 | on failure |
Definition at line 1671 of file pjsip/dialplan_functions.c.
References ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), ast_log, ast_sip_push_task_wait_serializer(), AST_SIP_SESSION_REFRESH_METHOD_INVITE, AST_SIP_SESSION_REFRESH_METHOD_UPDATE, AST_STATE_UP, LOG_WARNING, refresh_data::method, refresh_write_cb(), ast_sip_session::serializer, ast_sip_channel_pvt::session, refresh_data::session, and type.
|
static |
Definition at line 736 of file pjsip/dialplan_functions.c.
References ast_channel_name(), ast_escape_quoted(), ast_log, ast_strdupa, and LOG_ERROR.
Referenced by channel_read_pjsip().
|
static |
Definition at line 862 of file pjsip/dialplan_functions.c.
References ast_sip_session::aor, ast_channel_name(), ast_log, AST_LOG_WARNING, ast_sorcery_object_get_id(), pjsip_func_args::buf, ast_sip_session::channel, channel_read_pjsip(), channel_read_rtcp(), channel_read_rtp(), ast_sip_session::contact, ast_sip_session::endpoint, pjsip_func_args::field, func_args(), pjsip_func_args::len, pjsip_func_args::param, pjsip_func_args::ret, pjsip_func_args::session, and pjsip_func_args::type.
Referenced by pjsip_acf_channel_read().
|
static |
Definition at line 1652 of file pjsip/dialplan_functions.c.
References ast_sip_session_refresh(), ast_sip_session_remove_datastore(), session_refresh_state::media_state, refresh_data::method, NULL, refresh_data::session, session_refresh_state_get_or_alloc(), sip_session_response_cb(), and state.
Referenced by pjsip_acf_session_refresh_write().
|
static |
Destructor for session refresh information.
Definition at line 1063 of file pjsip/dialplan_functions.c.
References ast_free, ast_sip_session_media_state_free(), and session_refresh_state::media_state.
|
static |
Helper function which retrieves or allocates a session refresh state information datastore.
Definition at line 1078 of file pjsip/dialplan_functions.c.
References ao2_cleanup, ast_calloc, ast_sip_session_add_datastore(), ast_sip_session_alloc_datastore(), ast_sip_session_get_datastore(), ast_sip_session_media_state_alloc(), ast_sip_session_remove_datastore(), ast_stream_topology_clone(), ast_sip_session::endpoint, ast_sip_endpoint::media, session_refresh_state::media_state, NULL, RAII_VAR, state, ast_sip_session_media_state::topology, and ast_sip_endpoint_media_configuration::topology.
Referenced by media_offer_read_av(), media_offer_write_av(), and refresh_write_cb().
|
static |
Definition at line 1490 of file pjsip/dialplan_functions.c.
References ao2_ref, ast_channel_nativeformats(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_format_cap_get_best_by_type(), AST_MEDIA_TYPE_AUDIO, and ast_sip_session::channel.
Referenced by dtmf_mode_refresh_cb(), and refresh_write_cb().
|
static |
Datastore for attaching session refresh state information.
Definition at line 1072 of file pjsip/dialplan_functions.c.
|
static |
String representations of the T.38 state enum.
Definition at line 541 of file pjsip/dialplan_functions.c.
Referenced by channel_read_pjsip().