522 #include <pjsip_ua.h> 536 #include "include/dialplan_functions.h" 577 }
else if (!strcmp(field,
"video")) {
584 if (!media || !media->
rtp) {
590 if (!strcmp(type,
"src")) {
593 }
else if (!strcmp(type,
"dest")) {
596 }
else if (!strcmp(type,
"direct")) {
598 }
else if (!strcmp(type,
"secure")) {
602 snprintf(buf, buflen,
"%d", flag ? 1 : 0);
604 snprintf(buf, buflen,
"%d", 0);
606 }
else if (!strcmp(type,
"hold")) {
643 }
else if (!strcmp(field,
"video")) {
650 if (!media || !media->
rtp) {
656 if (!strncasecmp(type,
"all", 3)) {
659 if (!strcasecmp(type,
"all_jitter")) {
661 }
else if (!strcasecmp(type,
"all_rtt")) {
663 }
else if (!strcasecmp(type,
"all_loss")) {
676 enum { INT, DBL }
type;
682 {
"txcount", INT, { .i4 = &stats.
txcount, }, },
683 {
"rxcount", INT, { .i4 = &stats.
rxcount, }, },
684 {
"txjitter", DBL, { .d8 = &stats.
txjitter, }, },
685 {
"rxjitter", DBL, { .d8 = &stats.
rxjitter, }, },
694 {
"txploss", INT, { .i4 = &stats.
txploss, }, },
695 {
"rxploss", INT, { .i4 = &stats.
rxploss, }, },
704 {
"rtt", DBL, { .d8 = &stats.
rtt, }, },
705 {
"maxrtt", DBL, { .d8 = &stats.
maxrtt, }, },
706 {
"minrtt", DBL, { .d8 = &stats.
minrtt, }, },
707 {
"normdevrtt", DBL, { .d8 = &stats.
normdevrtt, }, },
708 {
"stdevrtt", DBL, { .d8 = &stats.
stdevrtt, }, },
709 {
"local_ssrc", INT, { .i4 = &stats.
local_ssrc, }, },
710 {
"remote_ssrc", INT, { .i4 = &stats.
remote_ssrc, }, },
720 if (!strcasecmp(type, lookup[i].name)) {
721 if (lookup[i].type == INT) {
722 snprintf(buf, buflen,
"%u", *lookup[i].i4);
724 snprintf(buf, buflen,
"%f", *lookup[i].d8);
737 pjsip_uri_context_e
context,
const void *uri,
char *
buf,
size_t size)
742 res = pjsip_uri_print(context, uri, buf, size);
744 ast_log(
LOG_ERROR,
"Channel %s: Unescaped %s too long for %d byte buffer\n",
777 }
else if (!strcmp(type,
"call-id")) {
778 snprintf(buf, buflen,
"%.*s", (
int) pj_strlen(&dlg->call_id->id), pj_strbuf(&dlg->call_id->id));
779 }
else if (!strcmp(type,
"secure")) {
780 #ifdef HAVE_PJSIP_GET_DEST_INFO 781 pjsip_host_info dest;
783 pjsip_get_dest_info(dlg->target,
NULL, pool, &dest);
784 snprintf(buf, buflen,
"%d", dest.flag & PJSIP_TRANSPORT_SECURE ? 1 : 0);
787 ast_log(
LOG_WARNING,
"Asterisk has been built against a version of pjproject which does not have the required functionality to support the 'secure' argument. Please upgrade to version 2.3 or later.\n");
790 }
else if (!strcmp(type,
"target_uri")) {
793 }
else if (!strcmp(type,
"local_uri")) {
794 res =
print_escaped_uri(chan, type, PJSIP_URI_IN_FROMTO_HDR, dlg->local.info->uri,
796 }
else if (!strcmp(type,
"local_tag")) {
800 }
else if (!strcmp(type,
"remote_uri")) {
802 dlg->remote.info->uri, buf, buflen);
803 }
else if (!strcmp(type,
"remote_tag")) {
807 }
else if (!strcmp(type,
"request_uri")) {
812 }
else if (!strcmp(type,
"t38state")) {
814 }
else if (!strcmp(type,
"local_addr")) {
823 transport_data = datastore->data;
825 if (pj_sockaddr_has_addr(&transport_data->
local_addr)) {
826 pj_sockaddr_print(&transport_data->
local_addr, buf, buflen, 3);
828 }
else if (!strcmp(type,
"remote_addr")) {
837 transport_data = datastore->data;
839 if (pj_sockaddr_has_addr(&transport_data->
remote_addr)) {
840 pj_sockaddr_print(&transport_data->
remote_addr, buf, buflen, 3);
866 if (!strcmp(func_args->
param,
"rtp")) {
874 }
else if (!strcmp(func_args->
param,
"rtcp")) {
882 }
else if (!strcmp(func_args->
param,
"endpoint")) {
890 }
else if (!strcmp(func_args->
param,
"contact")) {
895 }
else if (!strcmp(func_args->
param,
"aor")) {
900 }
else if (!strcmp(func_args->
param,
"pjsip")) {
980 return func_args.
ret;
987 const char *aor_name;
999 ast_log(
LOG_WARNING,
"An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
1006 aor_name =
S_OR(
args.aor_name, endpoint->aors);
1009 ast_log(
LOG_WARNING,
"No AOR has been provided and no AORs are configured on endpoint '%s'\n",
args.endpoint_name);
1073 .
type =
"pjsip_session_refresh",
1085 return datastore->data;
1094 state = datastore->data;
1106 datastore->data =
state;
1125 pjsip_name_addr *
uri;
1126 pjsip_sip_uri *sip_uri;
1138 pj_strdup2_with_null(pool, &tmp, args->
uri);
1139 uri = (pjsip_name_addr *)pjsip_parse_uri(pool, tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
1140 if (!uri || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
1147 if (!strcmp(args->
type,
"scheme")) {
1151 }
else if (!strcmp(args->
type,
"display")) {
1157 sip_uri = pjsip_uri_get_uri(uri);
1165 if (!strcmp(args->
type,
"user")) {
1167 }
else if (!strcmp(args->
type,
"passwd")) {
1169 }
else if (!strcmp(args->
type,
"host")) {
1171 }
else if (!strcmp(args->
type,
"port")) {
1172 snprintf(args->
buf, args->
buflen,
"%d", sip_uri->port);
1173 }
else if (!strcmp(args->
type,
"user_param")) {
1175 }
else if (!strcmp(args->
type,
"method_param")) {
1177 }
else if (!strcmp(args->
type,
"transport_param")) {
1179 }
else if (!strcmp(args->
type,
"ttl_param")) {
1180 snprintf(args->
buf, args->
buflen,
"%d", sip_uri->ttl_param);
1181 }
else if (!strcmp(args->
type,
"lr_param")) {
1182 snprintf(args->
buf, args->
buflen,
"%d", sip_uri->lr_param);
1183 }
else if (!strcmp(args->
type,
"maddr_param")) {
1209 ast_log(
LOG_WARNING,
"An URI must be specified when using the '%s' dialplan function\n", cmd);
1214 ast_log(
LOG_WARNING,
"A type part of the URI must be specified when using the '%s' dialplan function\n", cmd);
1218 memset(buf, 0, buflen);
1229 return func_args.
ret;
1241 if (session->
inv_session->dlg->state == PJSIP_DIALOG_STATE_ESTABLISHED) {
1304 buf[accum - 1] =
',';
1308 buf[accum ? accum - 1 : 0] =
'\0';
1388 if (!strcmp(data,
"audio")) {
1390 }
else if (!strcmp(data,
"video")) {
1420 if (!strcmp(data,
"audio")) {
1422 }
else if (!strcmp(data,
"video")) {
1534 int dsp_features = 0;
1558 ast_log(
LOG_WARNING,
"Cannot set DTMF mode to '%s' on channel '%s' as value is invalid.\n", value,
1574 if (media && media->
rtp) {
1696 if (!strcmp(value,
"invite")) {
1698 }
else if (!strcmp(value,
"update")) {
double local_normdevrxploss
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.
structure for secure RTP audio
enum sip_cc_notify_state state
enum ast_sip_session_t38state t38state
#define ast_channel_lock(chan)
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)
Main Channel structure associated with a channel.
struct ast_sip_endpoint * endpoint
pj_sockaddr local_addr
Our address that received the request.
struct ast_sip_session_media_state * ast_sip_session_media_state_alloc(void)
Allocate a session media state structure.
void ast_sip_session_media_state_free(struct ast_sip_session_media_state *media_state)
Free a session media state structure.
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ast_sip_session_media_state * pending_media_state
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.
static int channel_read_rtcp(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
Struct used to push PJSIP_PARSE_URI function arguments to task processor.
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.
media_type
Media types generate different "dummy answers" for not accepting the offer of a media stream...
double remote_normdevjitter
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_test_flag(p, flag)
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
Convenient Signal Processing routines.
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static int sip_session_response_cb(struct ast_sip_session *session, pjsip_rx_data *rdata)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
double remote_stdevjitter
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
struct ast_sip_session_media_state * media_state
Created proposed media state.
static pj_pool_t * pool
Global memory pool for configuration and timers.
static int media_offer_write_av(void *obj)
Set when the stream has been removed/declined.
Session refresh state information.
int pjsip_acf_moh_passthrough_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_MOH_PASSTHROUGH function write callback.
Structure for a data store type.
ast_channel_state
ast_channel states
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
Structure for a data store object.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
int pjsip_acf_channel_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
CHANNEL function read callback.
static int read_pjsip(void *data)
static int channel_read_rtp(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
struct pjsip_inv_session * inv_session
Transport information stored in transport_info datastore.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
int ast_sip_dtmf_to_str(const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len)
Convert the DTMF mode enum value into a string.
void ast_free_ptr(void *ptr)
free() wrapper
Socket address structure.
A structure describing a SIP session.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
#define ast_strlen_zero(foo)
struct ast_sip_session_media_state * active_media_state
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
enum ast_sip_session_refresh_method method
struct ast_sip_endpoint_media_configuration media
void ast_sip_session_remove_datastore(struct ast_sip_session *session, const char *name)
Remove a session datastore from the session.
static int parse_uri_cb(void *data)
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.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
struct ast_stream * ast_stream_topology_get_first_stream_by_type(const struct ast_stream_topology *topology, enum ast_media_type type)
Gets the first active stream of a specific type from the topology.
General Asterisk PBX channel definitions.
struct ast_datastore * ast_sip_session_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
struct ast_datastore * ast_sip_session_get_datastore(struct ast_sip_session *session, const char *name)
Retrieve a session datastore.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static struct ast_mansession session
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0' ...
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.
Access Control of various sorts.
int ast_sip_session_refresh(struct ast_sip_session *session, ast_sip_session_request_creation_cb on_request_creation, ast_sip_session_sdp_creation_cb on_sdp_creation, ast_sip_session_response_cb on_response, enum ast_sip_session_refresh_method method, int generate_new_sdp, struct ast_sip_session_media_state *media_state)
Send a reinvite or UPDATE on a session.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define ao2_ref(o, delta)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#define AST_SRTP_CRYPTO_OFFER_OK
#define ast_strdupa(s)
duplicate a string in memory from the stack
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
struct ast_channel * channel
double local_stdevrxploss
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
An entity with which Asterisk communicates.
int pjsip_acf_media_offer_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_MEDIA_OFFER function write callback.
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.
static const struct ast_datastore_info session_refresh_datastore
Datastore for attaching session refresh state information.
Core PBX routines and definitions.
double remote_normdevrxploss
struct ast_taskprocessor * serializer
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
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.
pj_sockaddr remote_addr
The address that sent the request.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int pjsip_acf_dtmf_mode_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_DTMF_MODE function write callback.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_sip_dtmf_mode dtmf
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
ast_sip_session_refresh_method
#define ao2_iterator_next(iter)
static int channel_read_pjsip(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static const char * t38state_to_string[T38_MAX_ENUM]
String representations of the T.38 state enum.
PJSIP Channel Driver shared data structures.
#define ast_calloc(num, len)
A wrapper for calloc()
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
struct ast_sip_session * session
static int dtmf_mode_refresh_cb(void *obj)
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
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.
static int refresh_write_cb(void *obj)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
#define AST_YESNO(x)
return Yes or No depending on the argument.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
ast_rtp_instance_stat_field
char * strsep(char **str, const char *delims)
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
const char * ast_channel_name(const struct ast_channel *chan)
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
double remote_stdevrxploss
struct ast_sip_session * session
struct ao2_container * ast_sip_location_retrieve_aor_contacts_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR and filter based on flags.
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.
ast_media_type
Types of media.
Struct used to push function arguments to task processor.
Return only reachable or unknown contacts.
static int media_offer_read_av(struct ast_sip_session *session, char *buf, size_t len, enum ast_media_type media_type)
double local_normdevjitter
static char context[AST_MAX_CONTEXT]
int ast_sip_session_regenerate_answer(struct ast_sip_session *session, ast_sip_session_sdp_creation_cb on_sdp_creation)
Regenerate SDP Answer.
static void session_refresh_state_destroy(void *obj)
Destructor for session refresh information.
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.
struct ast_sip_contact * contact
Asterisk module definitions.
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.
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
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.
int ast_sip_session_add_datastore(struct ast_sip_session *session, struct ast_datastore *datastore)
Add a datastore to a SIP session.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
unsigned int moh_passthrough
#define AST_APP_ARG(name)
Define an application argument.