diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 507ac276e7708b110cf687b7f7ad09a0249f913e..6c7c15884e03ffb50e6d5a987ea1f62bcdff1ca5 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1676,6 +1676,7 @@ static int sip_transfer(struct ast_channel *ast, const char *dest); static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan); static int sip_senddigit_begin(struct ast_channel *ast, char digit); static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration); +static char *sip_get_callid(struct ast_channel *chan); static int handle_request_do(struct sip_request *req, struct sockaddr_in *sin); static int sip_standard_port(struct sip_socket s); @@ -2036,6 +2037,7 @@ static const struct ast_channel_tech sip_tech = { .early_bridge = ast_rtp_early_bridge, .send_text = sip_sendtext, /* called with chan locked */ .func_channel_read = acf_channel_read, + .get_pvt_uniqueid = sip_get_callid, }; /*! \brief This version of the sip channel tech has no send_digit_begin @@ -3238,6 +3240,15 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data return 0; } +/*! \brief Deliver SIP call ID for the call */ +static char *sip_get_callid(struct ast_channel *chan) +{ + struct sip_pvt *p = chan->tech_pvt; + if (!p) + return ""; + return ((char *)p->callid); +} + /*! \brief Send SIP MESSAGE text within a call Called from PBX core sendtext() application */ static int sip_sendtext(struct ast_channel *ast, const char *text) @@ -14381,6 +14392,10 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate", "Channel: %s\r\nChanneltype: %s\r\nUniqueid: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\nPeername: %s\r\n", p->owner->name, p->owner->uniqueid, "SIP", p->callid, p->fullcontact, p->peername); + /* Set bridged channel variable */ + bridgepeer = ast_bridged_channel(p->owner); + if (bridgepeer) + pbx_builtin_setvar_helper(bridgepeer, "SIP_BRIDGED_CALLID", p->callid); } else { /* RE-invite */ ast_queue_frame(p->owner, &ast_null_frame); } diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index efb87fde6efdbd2a4096784eec883fa35c1d8ab5..58fec7a468fccd798ec93e2b379ef1b69c8a66ca 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -335,6 +335,9 @@ struct ast_channel_tech { /*! \brief Set base channel (agent and local) */ int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base); + + /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */ + char * (* get_pvt_uniqueid)(struct ast_channel *chan); }; struct ast_epoll_data; diff --git a/main/channel.c b/main/channel.c index d9e01831064833e3402c5b17a1dbfb41dfe6b0c8..d4d878008b02214b31c70e373200c56f3bcfcb9b 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4222,6 +4222,10 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1->name); if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0->name); + if (c0->tech->get_pvt_uniqueid) + pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0->tech->get_pvt_uniqueid(c0)); + if (c1->tech->get_pvt_uniqueid) + pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1->tech->get_pvt_uniqueid(c1)); if (c0->tech->bridge && (config->timelimit == 0) &&