[asterisk-commits] qwell: branch qwell/pimp_my_dtmf r385856 - /team/qwell/pimp_my_dtmf/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 16 09:50:23 CDT 2013
Author: qwell
Date: Tue Apr 16 09:50:20 2013
New Revision: 385856
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385856
Log:
Add support for sending DTMF via INFO.
Modified:
team/qwell/pimp_my_dtmf/channels/chan_gulp.c
Modified: team/qwell/pimp_my_dtmf/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/pimp_my_dtmf/channels/chan_gulp.c?view=diff&rev=385856&r1=385855&r2=385856
==============================================================================
--- team/qwell/pimp_my_dtmf/channels/chan_gulp.c (original)
+++ team/qwell/pimp_my_dtmf/channels/chan_gulp.c Tue Apr 16 09:50:20 2013
@@ -827,6 +827,47 @@
return res;
}
+struct info_dtmf_data {
+ char digit;
+ unsigned int duration;
+ struct ast_sip_session *session;
+};
+
+static int transmit_info_dtmf(void *data)
+{
+ struct info_dtmf_data *dtmf_data = data;
+
+ struct ast_sip_session *session = dtmf_data->session;
+ struct pjsip_tx_data *tdata;
+
+ RAII_VAR(struct ast_str *, body_text, NULL, ast_free_ptr);
+
+ struct ast_sip_body body = {
+ .type = "application",
+ .subtype = "dtmf-relay",
+ };
+
+ if (!(body_text = ast_str_create(32))) {
+ ast_log(LOG_ERROR, "Could not allocate buffer for INFO DTMF.\n");
+ return -1;
+ }
+ ast_str_set(&body_text, 0, "Signal=%c\r\nDuration=%u\r\n", dtmf_data->digit, dtmf_data->duration);
+
+ body.body_text = ast_str_buffer(body_text);
+
+ if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, &tdata)) {
+ ast_log(LOG_ERROR, "Could not create DTMF INFO request\n");
+ return -1;
+ }
+ if (ast_sip_add_body(tdata, &body)) {
+ ast_log(LOG_ERROR, "Could not add body to DTMF INFO request\n");
+ return -1;
+ }
+ ast_sip_session_send_request(session, tdata);
+
+ return 0;
+}
+
/*! \brief Function called by core to stop a DTMF digit */
static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
{
@@ -837,8 +878,15 @@
switch (session->endpoint->dtmf) {
case AST_SIP_DTMF_INFO:
- /* TODO: Send INFO dtmf here */
- break;
+ {
+ struct info_dtmf_data dtmf_data;
+ dtmf_data.digit = digit;
+ dtmf_data.duration = duration;
+ dtmf_data.session = session;
+
+ ast_sip_push_task_synchronous(session->serializer, transmit_info_dtmf, &dtmf_data);
+ break;
+ }
case AST_SIP_DTMF_RFC_4733:
if (!media || !media->rtp) {
return -1;
More information about the asterisk-commits
mailing list