[Asterisk-code-review] ARI channels: exposed channel driver's unique id (which is the Call-I... (asterisk[master])
Moritz Fain
asteriskteam at digium.com
Tue Apr 26 06:16:06 CDT 2022
Moritz Fain has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18413 )
Change subject: ARI channels: exposed channel driver's unique id (which is the Call-ID for SIP/PJSIP) to ARI channel resource as 'pvt_id'
......................................................................
ARI channels: exposed channel driver's unique id (which is the Call-ID for SIP/PJSIP) to ARI channel resource as 'pvt_id'
ASTERISK-30027
Change-Id: I7cc6e7a9d29efe74bc27811d788dac20fe559b87
---
M channels/chan_pjsip.c
M include/asterisk/stasis_channels.h
M main/dial.c
M main/stasis_channels.c
4 files changed, 18 insertions(+), 9 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/18413/1
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 61c4cfb..3bd672f 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -572,6 +572,7 @@
}
ast_channel_tech_pvt_set(chan, channel);
+ ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
if (!ast_stream_topology_get_count(session->pending_media_state->topology) ||
!compatible_formats_exist(session->pending_media_state->topology, session->endpoint->media.codecs)) {
@@ -1273,7 +1274,7 @@
struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
char *uniqueid = ast_threadstorage_get(&uniqueid_threadbuf, UNIQUEID_BUFSIZE);
- if (!uniqueid) {
+ if (!channel || !uniqueid) {
return "";
}
diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h
index 80c79eb..a493c5d 100644
--- a/include/asterisk/stasis_channels.h
+++ b/include/asterisk/stasis_channels.h
@@ -103,12 +103,13 @@
*/
struct ast_channel_snapshot_base {
AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(name); /*!< ASCII unique channel name */
- AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
- AST_STRING_FIELD(accountcode); /*!< Account code for billing */
- AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
- AST_STRING_FIELD(language); /*!< The default spoken language for the channel */
- AST_STRING_FIELD(type); /*!< Type of channel technology */
+ AST_STRING_FIELD(name); /*!< ASCII unique channel name */
+ AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
+ AST_STRING_FIELD(pvt_uniqueid); /*!< Channel drivers unique id */
+ AST_STRING_FIELD(accountcode); /*!< Account code for billing */
+ AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
+ AST_STRING_FIELD(language); /*!< The default spoken language for the channel */
+ AST_STRING_FIELD(type); /*!< Type of channel technology */
);
struct timeval creationtime; /*!< The time of channel creation */
int tech_properties; /*!< Properties of the channel's technology */
diff --git a/main/dial.c b/main/dial.c
index c40b7fb..2e53ac0 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -414,6 +414,7 @@
ast_channel_unlock(chan);
}
+ ast_channel_snapshot_invalidate_segment(channel->owner, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
ast_channel_stage_snapshot_done(channel->owner);
ast_channel_unlock(channel->owner);
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index 8becf96..96f5caf 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -283,6 +283,11 @@
ast_string_field_set(snapshot, accountcode, ast_channel_accountcode(chan));
ast_string_field_set(snapshot, userfield, ast_channel_userfield(chan));
ast_string_field_set(snapshot, uniqueid, ast_channel_uniqueid(chan));
+ if (ast_channel_tech(chan)->get_pvt_uniqueid) {
+ ast_string_field_set(snapshot, pvt_uniqueid, ast_strdupa(ast_channel_tech(chan)->get_pvt_uniqueid(chan)));
+ } else {
+ ast_string_field_set(snapshot, pvt_uniqueid, ast_channel_uniqueid(chan));
+ }
ast_string_field_set(snapshot, language, ast_channel_language(chan));
snapshot->creationtime = ast_channel_creationtime(chan);
@@ -1266,14 +1271,15 @@
}
json_chan = ast_json_pack(
- /* Broken up into groups of three for readability */
- "{ s: s, s: s, s: s,"
+ /* Broken up into groups for readability */
+ "{ s: s, s: s, s: s, s: s,"
" s: o, s: o, s: s,"
" s: o, s: o, s: s }",
/* First line */
"id", snapshot->base->uniqueid,
"name", snapshot->base->name,
"state", ast_state2str(snapshot->state),
+ "pvt_id", snapshot->base->pvt_uniqueid,
/* Second line */
"caller", ast_json_name_number(
snapshot->caller->name, snapshot->caller->number),
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18413
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I7cc6e7a9d29efe74bc27811d788dac20fe559b87
Gerrit-Change-Number: 18413
Gerrit-PatchSet: 1
Gerrit-Owner: Moritz Fain <moritz at fain.io>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220426/23432a3b/attachment.html>
More information about the asterisk-code-review
mailing list