Skip to content

Commit 193b7a8

Browse files
InterLinked1Friendly Automation
authored andcommitted
chan_pjsip: Add ability to send flash events.
PJSIP currently is capable of receiving flash events and converting them to FLASH control frames, but it currently lacks support for doing the reverse: taking a FLASH control frame and converting it into a flash event in the SIP domain. This adds the ability for PJSIP to process flash control frames by converting them into the appropriate SIP INFO message, which can then be sent to the peer. This allows, for example, flash events to be sent between Asterisk systems using PJSIP. ASTERISK-29941 #close Change-Id: I1590221a4d238597f79672fa5825dd4a920c94dd
1 parent 92d408f commit 193b7a8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

channels/chan_pjsip.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,10 @@ static int handle_topology_request_change(struct ast_sip_session *session,
16011601
SCOPE_EXIT_RTN_VALUE(res, "RC: %d\n", res);
16021602
}
16031603

1604+
/* Forward declarations */
1605+
static int transmit_info_dtmf(void *data);
1606+
static struct info_dtmf_data *info_dtmf_data_alloc(struct ast_sip_session *session, char digit, unsigned int duration);
1607+
16041608
/*! \brief Function called by core to ask the channel to indicate some sort of condition */
16051609
static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
16061610
{
@@ -1621,6 +1625,10 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
16211625
.data.ptr = (void *)data,
16221626
};
16231627
char condition_name[256];
1628+
unsigned int duration;
1629+
char digit;
1630+
struct info_dtmf_data *dtmf_data;
1631+
16241632
SCOPE_ENTER(3, "%s: Indicated %s\n", ast_channel_name(ast),
16251633
ast_frame_subclass2str(&f, condition_name, sizeof(condition_name), NULL, 0));
16261634

@@ -1680,6 +1688,22 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
16801688
}
16811689
ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "PJSIP/%s", ast_sorcery_object_get_id(channel->session->endpoint));
16821690
break;
1691+
case AST_CONTROL_FLASH:
1692+
duration = 300;
1693+
digit = '!';
1694+
dtmf_data = info_dtmf_data_alloc(channel->session, digit, duration);
1695+
1696+
if (!dtmf_data) {
1697+
res = -1;
1698+
break;
1699+
}
1700+
1701+
if (ast_sip_push_task(channel->session->serializer, transmit_info_dtmf, dtmf_data)) {
1702+
ast_log(LOG_WARNING, "Error sending FLASH via INFO on channel %s\n", ast_channel_name(ast));
1703+
ao2_ref(dtmf_data, -1); /* dtmf_data can't be null here */
1704+
res = -1;
1705+
}
1706+
break;
16831707
case AST_CONTROL_VIDUPDATE:
16841708
for (i = 0; i < AST_VECTOR_SIZE(&channel->session->active_media_state->sessions); ++i) {
16851709
media = AST_VECTOR_GET(&channel->session->active_media_state->sessions, i);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Subject: chan_pjsip
2+
3+
Hook flash events can now be sent on a PJSIP channel
4+
if requested to do so.

0 commit comments

Comments
 (0)