diff options
author | Joshua Colp <jcolp@digium.com> | 2014-04-29 11:27:14 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2014-04-29 11:27:14 +0000 |
commit | 2e39da35d0c5540399d8d5addb6ebf50c7e38b32 (patch) | |
tree | 3d08af1d7166913b431f43f44fde64d7a3fb9763 | |
parent | f7caf4e249af1f1cecf4d318c59e762597631811 (diff) |
chan_pjsip: Implement core ability to get Call-ID of a channel.
This changes implement the "get_pvt_uniqueid" which is used to return the
technology specific unique identifier. In the case of SIP this is the Call-ID
of the dialog.
Review: https://reviewboard.asterisk.org/r/3480/
........
Merged revisions 413088 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413089 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | channels/chan_pjsip.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c index fbd3e075b..b28c2d675 100644 --- a/channels/chan_pjsip.c +++ b/channels/chan_pjsip.c @@ -57,6 +57,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/stasis_endpoints.h" #include "asterisk/stasis_channels.h" #include "asterisk/indications.h" +#include "asterisk/threadstorage.h" #include "asterisk/res_pjsip.h" #include "asterisk/res_pjsip_session.h" @@ -64,6 +65,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "pjsip/include/chan_pjsip.h" #include "pjsip/include/dialplan_functions.h" +AST_THREADSTORAGE(uniqueid_threadbuf); +#define UNIQUEID_BUFSIZE 256 + static const char desc[] = "PJSIP Channel"; static const char channel_type[] = "PJSIP"; @@ -95,6 +99,7 @@ static int chan_pjsip_transfer(struct ast_channel *ast, const char *target); static int chan_pjsip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan); static int chan_pjsip_devicestate(const char *data); static int chan_pjsip_queryoption(struct ast_channel *ast, int option, void *data, int *datalen); +static const char *chan_pjsip_get_uniqueid(struct ast_channel *ast); /*! \brief PBX interface structure for channel registration */ struct ast_channel_tech chan_pjsip_tech = { @@ -117,6 +122,7 @@ struct ast_channel_tech chan_pjsip_tech = { .devicestate = chan_pjsip_devicestate, .queryoption = chan_pjsip_queryoption, .func_channel_read = pjsip_acf_channel_read, + .get_pvt_uniqueid = chan_pjsip_get_uniqueid, .properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER }; @@ -899,6 +905,36 @@ static int chan_pjsip_queryoption(struct ast_channel *ast, int option, void *dat return res; } +struct uniqueid_data { + struct ast_sip_session *session; + char *uniqueid; +}; + +static int get_uniqueid(void *data) +{ + struct uniqueid_data *uid_data = data; + + ast_copy_pj_str(uid_data->uniqueid, &uid_data->session->inv_session->dlg->call_id->id, UNIQUEID_BUFSIZE); + + return 0; +} + +static const char *chan_pjsip_get_uniqueid(struct ast_channel *ast) +{ + struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast); + struct uniqueid_data uid_data = { + .session = channel->session, + .uniqueid = ast_threadstorage_get(&uniqueid_threadbuf, UNIQUEID_BUFSIZE), + }; + + if (!uid_data.uniqueid || + ast_sip_push_task_synchronous(channel->session->serializer, get_uniqueid, &uid_data)) { + return NULL; + } + + return uid_data.uniqueid; +} + struct indicate_data { struct ast_sip_session *session; int condition; |