Asterisk - The Open Source Telephony Project  18.5.0
Functions
pjsip/include/dialplan_functions.h File Reference

PJSIP dialplan functions header file. More...

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

Go to the source code of this file.

Functions

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 len)
 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...
 

Detailed Description

PJSIP dialplan functions header file.

Definition in file pjsip/include/dialplan_functions.h.

Function Documentation

◆ pjsip_acf_channel_read()

int pjsip_acf_channel_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)

CHANNEL function read callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

917 {
918  struct pjsip_func_args func_args = { 0, };
920  char *parse = ast_strdupa(data);
921 
923  AST_APP_ARG(param);
924  AST_APP_ARG(type);
925  AST_APP_ARG(field);
926  );
927 
928  if (!chan) {
929  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
930  return -1;
931  }
932 
933  /* Check for zero arguments */
934  if (ast_strlen_zero(parse)) {
935  ast_log(LOG_ERROR, "Cannot call %s without arguments\n", cmd);
936  return -1;
937  }
938 
939  AST_STANDARD_APP_ARGS(args, parse);
940 
941  ast_channel_lock(chan);
942 
943  /* Sanity check */
944  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
945  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
946  ast_channel_unlock(chan);
947  return 0;
948  }
949 
950  channel = ast_channel_tech_pvt(chan);
951  if (!channel) {
952  ast_log(LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
953  ast_channel_unlock(chan);
954  return -1;
955  }
956 
957  if (!channel->session) {
958  ast_log(LOG_WARNING, "Channel %s has no session\n", ast_channel_name(chan));
959  ast_channel_unlock(chan);
960  return -1;
961  }
962 
963  func_args.session = ao2_bump(channel->session);
964  ast_channel_unlock(chan);
965 
966  memset(buf, 0, len);
967 
968  func_args.param = args.param;
969  func_args.type = args.type;
970  func_args.field = args.field;
971  func_args.buf = buf;
972  func_args.len = len;
973  if (ast_sip_push_task_wait_serializer(func_args.session->serializer, read_pjsip, &func_args)) {
974  ast_log(LOG_WARNING, "Unable to read properties of channel %s: failed to push task\n", ast_channel_name(chan));
975  ao2_ref(func_args.session, -1);
976  return -1;
977  }
978  ao2_ref(func_args.session, -1);
979 
980  return func_args.ret;
981 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
static int read_pjsip(void *data)
const char * args
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ast_log
Definition: astobj2.c:42
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.
Definition: res_pjsip.c:5218
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0' ...
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
struct ast_taskprocessor * serializer
#define LOG_ERROR
Definition: logger.h:285
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_sip_session * session
Struct used to push function arguments to task processor.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define AST_APP_ARG(name)
Define an application argument.

◆ pjsip_acf_dial_contacts_read()

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.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

984 {
985  RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
986  RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);
987  const char *aor_name;
988  char *rest;
989 
991  AST_APP_ARG(endpoint_name);
992  AST_APP_ARG(aor_name);
993  AST_APP_ARG(request_user);
994  );
995 
997 
998  if (ast_strlen_zero(args.endpoint_name)) {
999  ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
1000  return -1;
1001  } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {
1002  ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);
1003  return -1;
1004  }
1005 
1006  aor_name = S_OR(args.aor_name, endpoint->aors);
1007 
1008  if (ast_strlen_zero(aor_name)) {
1009  ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);
1010  return -1;
1011  } else if (!(dial = ast_str_create(len))) {
1012  ast_log(LOG_WARNING, "Could not get enough buffer space for dialing contacts\n");
1013  return -1;
1014  } else if (!(rest = ast_strdupa(aor_name))) {
1015  ast_log(LOG_WARNING, "Could not duplicate provided AORs\n");
1016  return -1;
1017  }
1018 
1019  while ((aor_name = ast_strip(strsep(&rest, ",")))) {
1021  RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
1022  struct ao2_iterator it_contacts;
1023  struct ast_sip_contact *contact;
1024 
1025  if (!aor) {
1026  /* If the AOR provided is not found skip it, there may be more */
1027  continue;
1029  /* No contacts are available, skip it as well */
1030  continue;
1031  } else if (!ao2_container_count(contacts)) {
1032  /* We were given a container but no contacts are in it... */
1033  continue;
1034  }
1035 
1036  it_contacts = ao2_iterator_init(contacts, 0);
1037  for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
1038  ast_str_append(&dial, -1, "PJSIP/");
1039 
1040  if (!ast_strlen_zero(args.request_user)) {
1041  ast_str_append(&dial, -1, "%s@", args.request_user);
1042  }
1043  ast_str_append(&dial, -1, "%s/%s&", args.endpoint_name, contact->uri);
1044  }
1045  ao2_iterator_destroy(&it_contacts);
1046  }
1047 
1048  /* Trim the '&' at the end off */
1049  ast_str_truncate(dial, ast_str_strlen(dial) - 1);
1050 
1052 
1053  return 0;
1054 }
A SIP address of record.
Definition: res_pjsip.h:361
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1091
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const char * args
#define NULL
Definition: resample.c:96
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1771
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition: strings.h:738
#define ast_strlen_zero(foo)
Definition: strings.h:52
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:219
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Contact associated with an address of record.
Definition: res_pjsip.h:281
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:688
const ast_string_field aor
Definition: res_pjsip.h:303
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...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
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.
Definition: location.c:252
Return only reachable or unknown contacts.
Definition: res_pjsip.h:1009
Generic container type.
const ast_string_field uri
Definition: res_pjsip.h:303
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:620
#define AST_APP_ARG(name)
Define an application argument.

◆ pjsip_acf_dtmf_mode_read()

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.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

1430 {
1431  struct ast_sip_channel_pvt *channel;
1432 
1433  if (!chan) {
1434  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1435  return -1;
1436  }
1437 
1438  ast_channel_lock(chan);
1439  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1440  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1441  ast_channel_unlock(chan);
1442  return -1;
1443  }
1444 
1445  channel = ast_channel_tech_pvt(chan);
1446 
1447  if (ast_sip_dtmf_to_str(channel->session->dtmf, buf, len) < 0) {
1448  ast_log(LOG_WARNING, "Unknown DTMF mode %d on PJSIP channel %s\n", channel->session->dtmf, ast_channel_name(chan));
1449  ast_channel_unlock(chan);
1450  return -1;
1451  }
1452 
1453  ast_channel_unlock(chan);
1454  return 0;
1455 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
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.
Definition: res_pjsip.c:5484
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_sip_dtmf_mode dtmf
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const char * ast_channel_name(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ pjsip_acf_dtmf_mode_write()

int pjsip_acf_dtmf_mode_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_DTMF_MODE function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on 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.

1531 {
1532  struct ast_sip_channel_pvt *channel;
1533  struct ast_sip_session_media *media;
1534  int dsp_features = 0;
1535  int dtmf = -1;
1536  struct refresh_data rdata = {
1538  };
1539 
1540  if (!chan) {
1541  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1542  return -1;
1543  }
1544 
1545  ast_channel_lock(chan);
1546  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1547  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1548  ast_channel_unlock(chan);
1549  return -1;
1550  }
1551 
1552  channel = ast_channel_tech_pvt(chan);
1553  rdata.session = channel->session;
1554 
1555  dtmf = ast_sip_str_to_dtmf(value);
1556 
1557  if (dtmf == -1) {
1558  ast_log(LOG_WARNING, "Cannot set DTMF mode to '%s' on channel '%s' as value is invalid.\n", value,
1559  ast_channel_name(chan));
1560  ast_channel_unlock(chan);
1561  return -1;
1562  }
1563 
1564  if (channel->session->dtmf == dtmf) {
1565  /* DTMF mode unchanged, nothing to do! */
1566  ast_channel_unlock(chan);
1567  return 0;
1568  }
1569 
1570  channel->session->dtmf = dtmf;
1571 
1573 
1574  if (media && media->rtp) {
1575  if (channel->session->dtmf == AST_SIP_DTMF_RFC_4733) {
1578  } else if (channel->session->dtmf == AST_SIP_DTMF_INFO) {
1581  } else if (channel->session->dtmf == AST_SIP_DTMF_INBAND) {
1584  } else if (channel->session->dtmf == AST_SIP_DTMF_NONE) {
1587  } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1589  /* no RFC4733 negotiated, enable inband */
1591  }
1592  } else if (channel->session->dtmf == AST_SIP_DTMF_AUTO_INFO) {
1595  /* if inband, switch to INFO */
1597  }
1598  }
1599  }
1600 
1601  if (channel->session->dsp) {
1602  dsp_features = ast_dsp_get_features(channel->session->dsp);
1603  }
1604  if (channel->session->dtmf == AST_SIP_DTMF_INBAND ||
1605  channel->session->dtmf == AST_SIP_DTMF_AUTO) {
1606  dsp_features |= DSP_FEATURE_DIGIT_DETECT;
1607  } else {
1608  dsp_features &= ~DSP_FEATURE_DIGIT_DETECT;
1609  }
1610  if (dsp_features) {
1611  if (!channel->session->dsp) {
1612  if (!(channel->session->dsp = ast_dsp_new())) {
1613  ast_channel_unlock(chan);
1614  return 0;
1615  }
1616  }
1617  ast_dsp_set_features(channel->session->dsp, dsp_features);
1618  } else if (channel->session->dsp) {
1619  ast_dsp_free(channel->session->dsp);
1620  channel->session->dsp = NULL;
1621  }
1622 
1623  ast_channel_unlock(chan);
1624 
1626 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
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.
Definition: rtp_engine.c:2123
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1770
#define DSP_FEATURE_DIGIT_DETECT
Definition: dsp.h:28
#define LOG_WARNING
Definition: logger.h:274
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Definition: dsp.c:1745
struct ast_sip_session_media * default_session[AST_MEDIA_TYPE_END]
Default media sessions for each type.
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition: res_pjsip.c:5513
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
struct ast_sip_session_media_state * active_media_state
enum ast_sip_session_refresh_method method
struct ast_dsp * dsp
#define ast_log
Definition: astobj2.c:42
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
Definition: dsp.c:1764
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.
Definition: res_pjsip.c:5218
struct ast_taskprocessor * serializer
enum ast_sip_dtmf_mode dtmf
#define ast_channel_unlock(chan)
Definition: channel.h:2946
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
Definition: dsp.c:1755
struct ast_sip_session * session
static int dtmf_mode_refresh_cb(void *obj)
A structure containing SIP session media information.
struct ast_rtp_instance * rtp
RTP instance itself.
const char * ast_channel_name(const struct ast_channel *chan)
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
Definition: rtp_engine.c:2137
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.
Definition: rtp_engine.c:705
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ pjsip_acf_media_offer_read()

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.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

1373 {
1374  struct ast_sip_channel_pvt *channel;
1375 
1376  if (!chan) {
1377  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1378  return -1;
1379  }
1380 
1381  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1382  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1383  return -1;
1384  }
1385 
1386  channel = ast_channel_tech_pvt(chan);
1387 
1388  if (!strcmp(data, "audio")) {
1390  } else if (!strcmp(data, "video")) {
1392  } else {
1393  /* Ensure that the buffer is empty */
1394  buf[0] = '\0';
1395  }
1396 
1397  return 0;
1398 }
static const char type[]
Definition: chan_ooh323.c:109
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int media_offer_read_av(struct ast_sip_session *session, char *buf, size_t len, enum ast_media_type media_type)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ pjsip_acf_media_offer_write()

int pjsip_acf_media_offer_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_MEDIA_OFFER function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on 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.

1401 {
1402  struct ast_sip_channel_pvt *channel;
1403  struct media_offer_data mdata = {
1404  .value = value
1405  };
1406 
1407  if (!chan) {
1408  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1409  return -1;
1410  }
1411 
1412  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1413  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1414  return -1;
1415  }
1416 
1417  channel = ast_channel_tech_pvt(chan);
1418  mdata.session = channel->session;
1419 
1420  if (!strcmp(data, "audio")) {
1422  } else if (!strcmp(data, "video")) {
1424  }
1425 
1427 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type media_type
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
static int media_offer_write_av(void *obj)
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
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.
Definition: res_pjsip.c:5218
struct ast_taskprocessor * serializer
struct ast_sip_session * session
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ pjsip_acf_moh_passthrough_read()

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.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

1458 {
1459  struct ast_sip_channel_pvt *channel;
1460 
1461  if (!chan) {
1462  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1463  return -1;
1464  }
1465 
1466  if (len < 3) {
1467  ast_log(LOG_WARNING, "%s: buffer too small\n", cmd);
1468  return -1;
1469  }
1470 
1471  ast_channel_lock(chan);
1472  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1473  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1474  ast_channel_unlock(chan);
1475  return -1;
1476  }
1477 
1478  channel = ast_channel_tech_pvt(chan);
1479  strncpy(buf, AST_YESNO(channel->session->moh_passthrough), len);
1480 
1481  ast_channel_unlock(chan);
1482  return 0;
1483 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
#define ast_log
Definition: astobj2.c:42
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define AST_YESNO(x)
return Yes or No depending on the argument.
Definition: strings.h:139
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
unsigned int moh_passthrough

◆ pjsip_acf_moh_passthrough_write()

int pjsip_acf_moh_passthrough_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)

PJSIP_MOH_PASSTHROUGH function write callback.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on 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.

1629 {
1630  struct ast_sip_channel_pvt *channel;
1631 
1632  if (!chan) {
1633  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1634  return -1;
1635  }
1636 
1637  ast_channel_lock(chan);
1638  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1639  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1640  ast_channel_unlock(chan);
1641  return -1;
1642  }
1643 
1644  channel = ast_channel_tech_pvt(chan);
1645  channel->session->moh_passthrough = ast_true(value);
1646 
1647  ast_channel_unlock(chan);
1648 
1649  return 0;
1650 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
int value
Definition: syslog.c:37
#define ast_log
Definition: astobj2.c:42
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".
Definition: main/utils.c:1951
#define ast_channel_unlock(chan)
Definition: channel.h:2946
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
unsigned int moh_passthrough

◆ pjsip_acf_parse_uri_read()

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.

Parameters
chanThe channel the function is called on
cmdThe name of the function
dataArguments passed to the function
bufOut buffer that should be populated with the data
lenSize of the buffer
Return values
0on success
-1on 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.

1198 {
1199  struct parse_uri_args func_args = { 0, };
1200 
1202  AST_APP_ARG(uri_str);
1203  AST_APP_ARG(type);
1204  );
1205 
1206  AST_STANDARD_APP_ARGS(args, data);
1207 
1208  if (ast_strlen_zero(args.uri_str)) {
1209  ast_log(LOG_WARNING, "An URI must be specified when using the '%s' dialplan function\n", cmd);
1210  return -1;
1211  }
1212 
1213  if (ast_strlen_zero(args.type)) {
1214  ast_log(LOG_WARNING, "A type part of the URI must be specified when using the '%s' dialplan function\n", cmd);
1215  return -1;
1216  }
1217 
1218  memset(buf, 0, buflen);
1219 
1220  func_args.uri = args.uri_str;
1221  func_args.type = args.type;
1222  func_args.buf = buf;
1223  func_args.buflen = buflen;
1225  ast_log(LOG_WARNING, "Unable to parse URI: failed to push task\n");
1226  return -1;
1227  }
1228 
1229  return func_args.ret;
1230 }
static const char type[]
Definition: chan_ooh323.c:109
Struct used to push PJSIP_PARSE_URI function arguments to task processor.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
static int parse_uri_cb(void *data)
#define ast_log
Definition: astobj2.c:42
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.
Definition: res_pjsip.c:5218
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with &#39;\0&#39; ...
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ pjsip_acf_session_refresh_write()

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.

Parameters
chanThe channel the function is called on
cmdthe Name of the function
dataArguments passed to the function
valueValue to be set by the function
Return values
0on success
-1on 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.

1672 {
1673  struct ast_sip_channel_pvt *channel;
1674  struct refresh_data rdata = {
1676  };
1677 
1678  if (!chan) {
1679  ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
1680  return -1;
1681  }
1682 
1683  if (ast_channel_state(chan) != AST_STATE_UP) {
1684  ast_log(LOG_WARNING, "'%s' not allowed on unanswered channel '%s'.\n", cmd, ast_channel_name(chan));
1685  return -1;
1686  }
1687 
1688  if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
1689  ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
1690  return -1;
1691  }
1692 
1693  channel = ast_channel_tech_pvt(chan);
1694  rdata.session = channel->session;
1695 
1696  if (!strcmp(value, "invite")) {
1698  } else if (!strcmp(value, "update")) {
1700  }
1701 
1703 }
static const char type[]
Definition: chan_ooh323.c:109
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
ast_channel_state
ast_channel states
Definition: channelstate.h:35
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
Definition: muted.c:95
int value
Definition: syslog.c:37
enum ast_sip_session_refresh_method method
#define ast_log
Definition: astobj2.c:42
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.
Definition: res_pjsip.c:5218
struct ast_taskprocessor * serializer
struct ast_sip_session * session
static int refresh_write_cb(void *obj)
const char * ast_channel_name(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)