[asterisk-commits] file: trunk r413089 - in /trunk: ./ channels/chan_pjsip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 29 06:27:23 CDT 2014
Author: file
Date: Tue Apr 29 06:27:14 2014
New Revision: 413089
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413089
Log:
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
Modified:
trunk/ (props changed)
trunk/channels/chan_pjsip.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_pjsip.c?view=diff&rev=413089&r1=413088&r2=413089
==============================================================================
--- trunk/channels/chan_pjsip.c (original)
+++ trunk/channels/chan_pjsip.c Tue Apr 29 06:27:14 2014
@@ -57,12 +57,16 @@
#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"
#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_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 @@
.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
};
@@ -897,6 +903,36 @@
}
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 {
More information about the asterisk-commits
mailing list