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


Detailed Description

PJSIP dialplan functions header file.

Definition in file pjsip/include/dialplan_functions.h.


Function Documentation

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

CHANNEL function read callback.

Parameters:
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
Return values:
0 on success
-1 on failure

Definition at line 728 of file pjsip/dialplan_functions.c.

References args, AST_APP_ARG, ast_channel_name(), ast_channel_tech(), ast_channel_tech_pvt(), AST_DECLARE_APP_ARGS, ast_log, AST_LOG_WARNING, ast_sip_push_task_synchronous(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, pjsip_func_args::buf, pjsip_func_args::chan, pjsip_func_args::field, pjsip_func_args::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::type, and type.

00729 {
00730    struct pjsip_func_args func_args = { 0, };
00731    struct ast_sip_channel_pvt *channel;
00732    char *parse = ast_strdupa(data);
00733 
00734    AST_DECLARE_APP_ARGS(args,
00735       AST_APP_ARG(param);
00736       AST_APP_ARG(type);
00737       AST_APP_ARG(field);
00738    );
00739 
00740    if (!chan) {
00741       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00742       return -1;
00743    }
00744    channel = ast_channel_tech_pvt(chan);
00745 
00746    /* Check for zero arguments */
00747    if (ast_strlen_zero(parse)) {
00748       ast_log(LOG_ERROR, "Cannot call %s without arguments\n", cmd);
00749       return -1;
00750    }
00751 
00752    AST_STANDARD_APP_ARGS(args, parse);
00753 
00754    /* Sanity check */
00755    if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
00756       ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
00757       return 0;
00758    }
00759 
00760    if (!channel) {
00761       ast_log(AST_LOG_WARNING, "Channel %s has no pvt!\n", ast_channel_name(chan));
00762       return -1;
00763    }
00764 
00765    memset(buf, 0, len);
00766 
00767    func_args.chan = chan;
00768    func_args.param = args.param;
00769    func_args.type = args.type;
00770    func_args.field = args.field;
00771    func_args.buf = buf;
00772    func_args.len = len;
00773    if (ast_sip_push_task_synchronous(channel->session->serializer, read_pjsip, &func_args)) {
00774       ast_log(LOG_WARNING, "Unable to read properties of channel %s: failed to push task\n", ast_channel_name(chan));
00775       return -1;
00776    }
00777 
00778    return func_args.ret;
00779 }

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:
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
Return values:
0 on success
-1 on failure

Definition at line 781 of file pjsip/dialplan_functions.c.

References ao2_cleanup, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, args, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_free_ptr, ast_log, ast_sip_get_sorcery(), ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts(), 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_strlen_zero, LOG_WARNING, NULL, RAII_VAR, S_OR, strsep(), and ast_sip_contact::uri.

00782 {
00783    RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
00784    RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);
00785    const char *aor_name;
00786    char *rest;
00787 
00788    AST_DECLARE_APP_ARGS(args,
00789       AST_APP_ARG(endpoint_name);
00790       AST_APP_ARG(aor_name);
00791       AST_APP_ARG(request_user);
00792    );
00793 
00794    AST_STANDARD_APP_ARGS(args, data);
00795 
00796    if (ast_strlen_zero(args.endpoint_name)) {
00797       ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);
00798       return -1;
00799    } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {
00800       ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);
00801       return -1;
00802    }
00803 
00804    aor_name = S_OR(args.aor_name, endpoint->aors);
00805 
00806    if (ast_strlen_zero(aor_name)) {
00807       ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);
00808       return -1;
00809    } else if (!(dial = ast_str_create(len))) {
00810       ast_log(LOG_WARNING, "Could not get enough buffer space for dialing contacts\n");
00811       return -1;
00812    } else if (!(rest = ast_strdupa(aor_name))) {
00813       ast_log(LOG_WARNING, "Could not duplicate provided AORs\n");
00814       return -1;
00815    }
00816 
00817    while ((aor_name = strsep(&rest, ","))) {
00818       RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
00819       RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
00820       struct ao2_iterator it_contacts;
00821       struct ast_sip_contact *contact;
00822 
00823       if (!aor) {
00824          /* If the AOR provided is not found skip it, there may be more */
00825          continue;
00826       } else if (!(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
00827          /* No contacts are available, skip it as well */
00828          continue;
00829       } else if (!ao2_container_count(contacts)) {
00830          /* We were given a container but no contacts are in it... */
00831          continue;
00832       }
00833 
00834       it_contacts = ao2_iterator_init(contacts, 0);
00835       for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
00836          ast_str_append(&dial, -1, "PJSIP/");
00837 
00838          if (!ast_strlen_zero(args.request_user)) {
00839             ast_str_append(&dial, -1, "%s@", args.request_user);
00840          }
00841          ast_str_append(&dial, -1, "%s/%s&", args.endpoint_name, contact->uri);
00842       }
00843       ao2_iterator_destroy(&it_contacts);
00844    }
00845 
00846    /* Trim the '&' at the end off */
00847    ast_str_truncate(dial, ast_str_strlen(dial) - 1);
00848 
00849    ast_copy_string(buf, ast_str_buffer(dial), len);
00850 
00851    return 0;
00852 }

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:
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
Return values:
0 on success
-1 on failure

Definition at line 906 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.

00907 {
00908    struct ast_sip_channel_pvt *channel;
00909 
00910    if (!chan) {
00911       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00912       return -1;
00913    }
00914 
00915    if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
00916       ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
00917       return -1;
00918    }
00919 
00920    channel = ast_channel_tech_pvt(chan);
00921 
00922    if (!strcmp(data, "audio")) {
00923       return media_offer_read_av(channel->session, buf, len, AST_MEDIA_TYPE_AUDIO);
00924    } else if (!strcmp(data, "video")) {
00925       return media_offer_read_av(channel->session, buf, len, AST_MEDIA_TYPE_VIDEO);
00926    }
00927 
00928    return 0;
00929 }

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:
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
Return values:
0 on success
-1 on failure

Definition at line 931 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_synchronous(), 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.

00932 {
00933    struct ast_sip_channel_pvt *channel;
00934    struct media_offer_data mdata = {
00935       .value = value
00936    };
00937 
00938    if (!chan) {
00939       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00940       return -1;
00941    }
00942 
00943    if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) {
00944       ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd);
00945       return -1;
00946    }
00947 
00948    channel = ast_channel_tech_pvt(chan);
00949    mdata.session = channel->session;
00950 
00951    if (!strcmp(data, "audio")) {
00952       mdata.media_type = AST_MEDIA_TYPE_AUDIO;
00953    } else if (!strcmp(data, "video")) {
00954       mdata.media_type = AST_MEDIA_TYPE_VIDEO;
00955    }
00956 
00957    return ast_sip_push_task_synchronous(channel->session->serializer, media_offer_write_av, &mdata);
00958 }


Generated on Thu Apr 16 06:30:40 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6