[Asterisk-code-review] chan_pjsip: Add ability to send flash events. (asterisk[18])

N A asteriskteam at digium.com
Fri Apr 1 06:13:31 CDT 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18350 )


Change subject: chan_pjsip: Add ability to send flash events.
......................................................................

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
---
M channels/chan_pjsip.c
A doc/CHANGES-staging/chan_pjsip_flash.txt
2 files changed, 28 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/50/18350/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index e8fbb3d..a303b32 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -1609,6 +1609,10 @@
 	SCOPE_EXIT_RTN_VALUE(res, "RC: %d\n", res);
 }
 
+/* Forward declarations */
+static int transmit_info_dtmf(void *data);
+static struct info_dtmf_data *info_dtmf_data_alloc(struct ast_sip_session *session, char digit, unsigned int duration);
+
 /*! \brief Function called by core to ask the channel to indicate some sort of condition */
 static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
@@ -1629,6 +1633,10 @@
 		.data.ptr = (void *)data,
 	};
 	char condition_name[256];
+	unsigned int duration;
+	char digit;
+	struct info_dtmf_data *dtmf_data;
+
 	SCOPE_ENTER(3, "%s: Indicated %s\n", ast_channel_name(ast),
 		ast_frame_subclass2str(&f, condition_name, sizeof(condition_name), NULL, 0));
 
@@ -1684,6 +1692,22 @@
 		}
 		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "PJSIP/%s", ast_sorcery_object_get_id(channel->session->endpoint));
 		break;
+	case AST_CONTROL_FLASH:
+		duration = 300;
+		digit = '!';
+		dtmf_data = info_dtmf_data_alloc(channel->session, digit, duration);
+
+		if (!dtmf_data) {
+			res = -1;
+			break;
+		}
+
+		if (ast_sip_push_task(channel->session->serializer, transmit_info_dtmf, dtmf_data)) {
+			ast_log(LOG_WARNING, "Error sending FLASH via INFO on channel %s\n", ast_channel_name(ast));
+			ao2_ref(dtmf_data, -1); /* dtmf_data can't be null here */
+			res = -1;
+		}
+		break;
 	case AST_CONTROL_VIDUPDATE:
 		for (i = 0; i < AST_VECTOR_SIZE(&channel->session->active_media_state->sessions); ++i) {
 			media = AST_VECTOR_GET(&channel->session->active_media_state->sessions, i);
diff --git a/doc/CHANGES-staging/chan_pjsip_flash.txt b/doc/CHANGES-staging/chan_pjsip_flash.txt
new file mode 100644
index 0000000..34da796
--- /dev/null
+++ b/doc/CHANGES-staging/chan_pjsip_flash.txt
@@ -0,0 +1,4 @@
+Subject: chan_pjsip
+
+Hook flash events can now be sent on a PJSIP channel
+if requested to do so.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18350
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: I1590221a4d238597f79672fa5825dd4a920c94dd
Gerrit-Change-Number: 18350
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220401/ac808852/attachment.html>


More information about the asterisk-code-review mailing list