538 #include <pjsip_ua.h>
552 #include "include/dialplan_functions.h"
593 }
else if (!strcmp(field,
"video")) {
600 if (!media || !media->
rtp) {
606 if (!strcmp(
type,
"src")) {
609 }
else if (!strcmp(
type,
"dest")) {
612 }
else if (!strcmp(
type,
"direct")) {
614 }
else if (!strcmp(
type,
"secure")) {
618 snprintf(
buf, buflen,
"%d",
flag ? 1 : 0);
620 snprintf(
buf, buflen,
"%d", 0);
622 }
else if (!strcmp(
type,
"hold")) {
659 }
else if (!strcmp(field,
"video")) {
666 if (!media || !media->
rtp) {
672 if (!strncasecmp(
type,
"all", 3)) {
675 if (!strcasecmp(
type,
"all_jitter")) {
677 }
else if (!strcasecmp(
type,
"all_rtt")) {
679 }
else if (!strcasecmp(
type,
"all_loss")) {
692 enum { INT, DBL }
type;
698 {
"txcount", INT, { .i4 = &stats.
txcount, }, },
699 {
"rxcount", INT, { .i4 = &stats.
rxcount, }, },
700 {
"txjitter", DBL, { .d8 = &stats.
txjitter, }, },
701 {
"rxjitter", DBL, { .d8 = &stats.
rxjitter, }, },
710 {
"txploss", INT, { .i4 = &stats.
txploss, }, },
711 {
"rxploss", INT, { .i4 = &stats.
rxploss, }, },
720 {
"rtt", DBL, { .d8 = &stats.
rtt, }, },
721 {
"maxrtt", DBL, { .d8 = &stats.
maxrtt, }, },
722 {
"minrtt", DBL, { .d8 = &stats.
minrtt, }, },
723 {
"normdevrtt", DBL, { .d8 = &stats.
normdevrtt, }, },
724 {
"stdevrtt", DBL, { .d8 = &stats.
stdevrtt, }, },
725 {
"local_ssrc", INT, { .i4 = &stats.
local_ssrc, }, },
726 {
"remote_ssrc", INT, { .i4 = &stats.
remote_ssrc, }, },
736 if (!strcasecmp(
type, lookup[i].
name)) {
737 if (lookup[i].
type == INT) {
738 snprintf(
buf, buflen,
"%u", *lookup[i].i4);
740 snprintf(
buf, buflen,
"%f", *lookup[i].d8);
753 pjsip_uri_context_e
context,
const void *uri,
char *
buf,
size_t size)
758 res = pjsip_uri_print(
context, uri,
buf, size);
760 ast_log(
LOG_ERROR,
"Channel %s: Unescaped %s too long for %d byte buffer\n",
793 }
else if (!strcmp(
type,
"call-id")) {
794 snprintf(
buf, buflen,
"%.*s", (
int) pj_strlen(&dlg->call_id->id), pj_strbuf(&dlg->call_id->id));
795 }
else if (!strcmp(
type,
"secure")) {
796 #ifdef HAVE_PJSIP_GET_DEST_INFO
797 pjsip_host_info dest;
799 pjsip_get_dest_info(dlg->target,
NULL, pool, &dest);
800 snprintf(
buf, buflen,
"%d", dest.flag & PJSIP_TRANSPORT_SECURE ? 1 : 0);
803 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");
806 }
else if (!strcmp(
type,
"target_uri")) {
809 }
else if (!strcmp(
type,
"local_uri")) {
812 }
else if (!strcmp(
type,
"local_tag")) {
816 }
else if (!strcmp(
type,
"remote_uri")) {
818 dlg->remote.info->uri,
buf, buflen);
819 }
else if (!strcmp(
type,
"remote_tag")) {
823 }
else if (!strcmp(
type,
"request_uri")) {
828 }
else if (!strcmp(
type,
"t38state")) {
830 }
else if (!strcmp(
type,
"local_addr")) {
839 transport_data = datastore->data;
841 if (pj_sockaddr_has_addr(&transport_data->
local_addr)) {
842 pj_sockaddr_print(&transport_data->
local_addr,
buf, buflen, 3);
844 }
else if (!strcmp(
type,
"remote_addr")) {
853 transport_data = datastore->data;
855 if (pj_sockaddr_has_addr(&transport_data->
remote_addr)) {
890 }
else if (!strcmp(
func_args->param,
"rtcp")) {
898 }
else if (!strcmp(
func_args->param,
"endpoint")) {
906 }
else if (!strcmp(
func_args->param,
"contact")) {
911 }
else if (!strcmp(
func_args->param,
"aor")) {
916 }
else if (!strcmp(
func_args->param,
"pjsip")) {
1003 const char *aor_name;
1015 ast_log(
LOG_WARNING,
"An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
1022 aor_name =
S_OR(
args.aor_name, endpoint->aors);
1025 ast_log(
LOG_WARNING,
"No AOR has been provided and no AORs are configured on endpoint '%s'\n",
args.endpoint_name);
1089 .
type =
"pjsip_session_refresh",
1101 return datastore->data;
1110 state = datastore->data;
1112 if (!
state->media_state) {
1117 if (!
state->media_state->topology) {
1122 datastore->data =
state;
1141 pjsip_name_addr *
uri;
1142 pjsip_sip_uri *sip_uri;
1154 pj_strdup2_with_null(pool, &
tmp,
args->uri);
1155 uri = (pjsip_name_addr *)pjsip_parse_uri(pool,
tmp.ptr,
tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
1156 if (!
uri || (!PJSIP_URI_SCHEME_IS_SIP(
uri) && !PJSIP_URI_SCHEME_IS_SIPS(
uri))) {
1163 if (!strcmp(
args->type,
"scheme")) {
1167 }
else if (!strcmp(
args->type,
"display")) {
1173 sip_uri = pjsip_uri_get_uri(
uri);
1181 if (!strcmp(
args->type,
"user")) {
1183 }
else if (!strcmp(
args->type,
"passwd")) {
1185 }
else if (!strcmp(
args->type,
"host")) {
1187 }
else if (!strcmp(
args->type,
"port")) {
1188 snprintf(
args->buf,
args->buflen,
"%d", sip_uri->port);
1189 }
else if (!strcmp(
args->type,
"user_param")) {
1191 }
else if (!strcmp(
args->type,
"method_param")) {
1193 }
else if (!strcmp(
args->type,
"transport_param")) {
1195 }
else if (!strcmp(
args->type,
"ttl_param")) {
1196 snprintf(
args->buf,
args->buflen,
"%d", sip_uri->ttl_param);
1197 }
else if (!strcmp(
args->type,
"lr_param")) {
1198 snprintf(
args->buf,
args->buflen,
"%d", sip_uri->lr_param);
1199 }
else if (!strcmp(
args->type,
"maddr_param")) {
1225 ast_log(
LOG_WARNING,
"An URI must be specified when using the '%s' dialplan function\n", cmd);
1230 ast_log(
LOG_WARNING,
"A type part of the URI must be specified when using the '%s' dialplan function\n", cmd);
1257 if (
session->inv_session->dlg->state == PJSIP_DIALOG_STATE_ESTABLISHED) {
1265 topology =
state->media_state->topology;
1268 if (!
session->pending_media_state->topology) {
1270 if (!
session->pending_media_state->topology) {
1274 topology =
session->pending_media_state->topology;
1320 buf[accum - 1] =
',';
1324 buf[accum ? accum - 1 : 0] =
'\0';
1349 topology =
state->media_state->topology;
1404 if (!strcmp(data,
"audio")) {
1406 }
else if (!strcmp(data,
"video")) {
1436 if (!strcmp(data,
"audio")) {
1438 }
else if (!strcmp(data,
"video")) {
1550 int dsp_features = 0;
1590 if (media && media->
rtp) {
1712 if (!strcmp(
value,
"invite")) {
1714 }
else if (!strcmp(
value,
"update")) {
Access Control of various sorts.
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_iterator_next(iter)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static char context[AST_MAX_CONTEXT]
static void parse(struct mgcp_request *req)
PJSIP Channel Driver shared data structures.
enum sip_cc_notify_state state
General Asterisk PBX channel definitions.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#define ast_channel_unlock(chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
ast_channel_state
ast_channel states
ast_media_type
Types of media.
Convenient Signal Processing routines.
void ast_dsp_free(struct ast_dsp *dsp)
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
#define DSP_FEATURE_DIGIT_DETECT
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * strsep(char **str, const char *delims)
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Core PBX routines and definitions.
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_moh_passthrough_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
PJSIP_MOH_PASSTHROUGH function read callback.
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.
int pjsip_acf_media_offer_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_MEDIA_OFFER function write callback.
static int read_pjsip(void *data)
static int refresh_write_cb(void *obj)
int pjsip_acf_dtmf_mode_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_DTMF_MODE function write callback.
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.
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 sip_session_response_cb(struct ast_sip_session *session, pjsip_rx_data *rdata)
static int channel_read_rtp(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
static void session_refresh_state_destroy(void *obj)
Destructor for session refresh information.
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 const char * t38state_to_string[T38_MAX_ENUM]
String representations of the T.38 state enum.
int pjsip_acf_moh_passthrough_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
PJSIP_MOH_PASSTHROUGH function write callback.
static int dtmf_mode_refresh_cb(void *obj)
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.
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 channel_read_pjsip(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
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.
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.
static const struct ast_datastore_info session_refresh_datastore
Datastore for attaching session refresh state information.
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.
static int channel_read_rtcp(struct ast_channel *chan, const char *type, const char *field, char *buf, size_t buflen)
static int parse_uri_cb(void *data)
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
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.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
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.
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
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.
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
ast_sip_session_refresh_method
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
struct ast_sip_session_media_state * ast_sip_session_media_state_alloc(void)
Allocate a session media state structure.
struct ast_datastore * ast_sip_session_get_datastore(struct ast_sip_session *session, const char *name)
Retrieve a session datastore.
int ast_sip_session_regenerate_answer(struct ast_sip_session *session, ast_sip_session_sdp_creation_cb on_sdp_creation)
Regenerate SDP Answer.
struct ast_datastore * ast_sip_session_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
int ast_sip_session_add_datastore(struct ast_sip_session *session, struct ast_datastore *datastore)
Add a datastore to a SIP session.
void ast_sip_session_remove_datastore(struct ast_sip_session *session, const char *name)
Remove a session datastore from the session.
void ast_sip_session_media_state_free(struct ast_sip_session_media_state *media_state)
Free a session media state structure.
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.
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
@ AST_RTP_DTMF_MODE_RFC2833
@ AST_RTP_DTMF_MODE_INBAND
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.
ast_rtp_instance_stat_field
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER
@ AST_RTP_INSTANCE_STAT_ALL
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
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.
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_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
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.
#define AST_SRTP_CRYPTO_OFFER_OK
media_type
Media types generate different "dummy answers" for not accepting the offer of a media stream....
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
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.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
@ AST_STREAM_STATE_REMOVED
Set when the stream has been removed/declined.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define AST_YESNO(x)
return Yes or No depending on the argument.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Main Channel structure associated with a channel.
Structure for a data store type.
Structure for a data store object.
double remote_stdevrxploss
double local_normdevjitter
double local_normdevrxploss
double remote_normdevrxploss
double local_stdevrxploss
double remote_normdevjitter
double remote_stdevjitter
structure for secure RTP audio
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
An entity with which Asterisk communicates.
struct ast_sip_endpoint_media_configuration media
A structure describing a SIP session.
struct ast_sip_endpoint * endpoint
enum ast_sip_session_t38state t38state
struct ast_channel * channel
unsigned int moh_passthrough
struct ast_sip_session_media_state * active_media_state
struct ast_sip_session_media_state * pending_media_state
struct pjsip_inv_session * inv_session
enum ast_sip_dtmf_mode dtmf
struct ast_taskprocessor * serializer
Socket address structure.
Support for dynamic strings.
Struct used to push PJSIP_PARSE_URI function arguments to task processor.
Struct used to push function arguments to task processor.
struct ast_sip_session * session
struct ast_sip_session * session
enum ast_sip_session_refresh_method method
Session refresh state information.
struct ast_sip_session_media_state * media_state
Created proposed media state.
Transport information stored in transport_info datastore.
pj_sockaddr local_addr
Our address that received the request.
pj_sockaddr remote_addr
The address that sent the request.
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.