[asterisk-dev] Hook flash events

asterisk at phreaknet.org asterisk at phreaknet.org
Sat Mar 27 18:58:56 CDT 2021


Hello,

    I have patched chan_sip to recognize application/hook-flash as a 
hook flash event (AST_CONTROL_FLASH), and with that am now proceeding to 
add full flash support to Asterisk. My current understanding is Asterisk 
will propagate these events across channels if possible, but is unable 
to do anything with them itself. I'd like to be able to trigger dialplan 
activity on flashes, so I'm thinking making this available as an AMI 
event might be the way to go (I haven't used AMI before either, but it 
seems like this would be the correct way to do this). Then I could see 
that event and spawn dialplan activity "out of band" in a new channel 
and manipulate the channel on which the flash occurred as needed.

I've started by patching channel.c and file.c to print out information 
about flash events. I have tested 3 different SIP clients in 4 different 
modes. When SIP INFO is used, all is well. When RFC2833/AVT is used, 
there are duplicate events. I'm stopping here to figure this out because 
if duplicate AMI events are sent, that would defeat the purpose.

I took a packet capture of a tSIP call for simplicity and discovered 
that for each hook flash event, there were:

9 packets of "Payload type=RTP Event, Flash"

3 packets of "Payload type=RTP Event, Flash (end)"

So, with hook flashes conveyed via RTP, there is a "start" and an "end", 
or 2 events per flash. However, unlike ...DTMF_BEGIN and ...DTMF_EVENT, 
there is only one ...CONTROL_FLASH event to work with in Asterisk.

Rearchitecting AST_CONTROL_FLASH seems like it would not be feasible. 
Might there be a good way to filter out one of the two RTP events, 
without having to keep track of "start" and "end" like the DTMF events 
do? This is a non-issue for SIP INFO, of course, and only happens with 
RFC2833 flash events. Some agents only support one or the other.

Grandstream: applicaiton/hook-flash:
[Mar 27 19:39:00] * DTMF-relay event received: FLASH
[2021-03-27 19:39:00] WARNING[12451][C-0000000c]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:39:00] WARNING[12451][C-0000000c]: channel.c:3309 
ast_waitfordigit_full: Place 2: Received hook flash on channel <- only 
prints for this ATA for some reason, but this is an "ignore" event anyways

tSIP with RFC2833 FLASH (R):
[2021-03-27 19:41:06] WARNING[12910][C-00000022]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:41:06] WARNING[12910][C-00000022]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:41:06] WARNING[12910][C-00000022]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:41:06] WARNING[12910][C-00000022]: file.c:1707 
waitstream_core: Hook flash in file.c

Linksys SPA112 with INFO:
[Mar 27 19:39:27] * DTMF-relay event received: FLASH
[2021-03-27 19:39:27] WARNING[12653][C-00000016]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:39:27] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:39:27] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:39:27] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:39:27] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c

Linksys SPA112 with AVT:
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: channel.c:3866 
__ast_read: Place 1: Received hook flash on channel
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:40:35] WARNING[12801][C-0000001c]: file.c:1707 
waitstream_core: Hook flash in file.c

Linksys both AVT and INFO, flashing from local ATA reorder after 2nd 
call hangs up to first original call still up:
[2021-03-27 19:39:32] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:39:32] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
[2021-03-27 19:39:32] WARNING[12653][C-00000016]: file.c:1707 
waitstream_core: Hook flash in file.c
*Comment: This event should be ignored anyways, so the absence of "Place 
1: ..." is not concerning. If one hangs up for longer than a flash and 
picks up the first call, this does not happen at all.




More information about the asterisk-dev mailing list