[asterisk-commits] file: branch group/pimp_my_sip r380195 - in /team/group/pimp_my_sip: channels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 27 14:50:27 CST 2013


Author: file
Date: Sun Jan 27 14:50:24 2013
New Revision: 380195

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380195
Log:
Make the DTMF mode configurable. Right now only rfc4733, inband, and none are supported.

Modified:
    team/group/pimp_my_sip/channels/chan_gulp.c
    team/group/pimp_my_sip/configs/res_sip.conf.sample
    team/group/pimp_my_sip/res/res_sip.c
    team/group/pimp_my_sip/res/res_sip_sdp_audio.c

Modified: team/group/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=380195&r1=380194&r2=380195
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Sun Jan 27 14:50:24 2013
@@ -369,20 +369,43 @@
 static int gulp_digit_begin(struct ast_channel *chan, char digit)
 {
 	struct ast_sip_session *session = ast_channel_tech_pvt(chan);
-
-	ast_rtp_instance_dtmf_begin(session->media.audio, digit);
-
-	return 0;
+	int res = 0;
+
+	switch (session->endpoint->dtmf) {
+	case AST_SIP_DTMF_RFC_4733:
+		ast_rtp_instance_dtmf_begin(session->media.audio, digit);
+	case AST_SIP_DTMF_NONE:
+		break;
+	case AST_SIP_DTMF_INBAND:
+		res = -1;
+		break;
+	default:
+		break;
+	}
+
+	return res;
 }
 
 /*! \brief Function called by core to stop a DTMF digit */
 static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
 	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
-
-	ast_rtp_instance_dtmf_end_with_duration(session->media.audio, digit, duration);
-
-	return 0;
+	int res = 0;
+
+	switch (session->endpoint->dtmf) {
+	case AST_SIP_DTMF_INFO:
+		/* TODO: Send INFO dtmf here */
+		break;
+	case AST_SIP_DTMF_RFC_4733:
+		ast_rtp_instance_dtmf_end_with_duration(session->media.audio, digit, duration);
+	case AST_SIP_DTMF_NONE:
+		break;
+	case AST_SIP_DTMF_INBAND:
+		res = -1;
+		break;
+	}
+
+	return res;
 }
 
 /*! \brief Function called by core to actually start calling a remote party */

Modified: team/group/pimp_my_sip/configs/res_sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/configs/res_sip.conf.sample?view=diff&rev=380195&r1=380194&r2=380195
==============================================================================
--- team/group/pimp_my_sip/configs/res_sip.conf.sample (original)
+++ team/group/pimp_my_sip/configs/res_sip.conf.sample Sun Jan 27 14:50:24 2013
@@ -12,3 +12,4 @@
 context=default
 disallow=all
 allow=ulaw
+dtmfmode=rfc4733 ; Supported DTMF modes are rfc4733, inband, info, and none

Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=380195&r1=380194&r2=380195
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Sun Jan 27 14:50:24 2013
@@ -123,6 +123,25 @@
 	return 0;
 }
 
+static int dtmf_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+	struct ast_sip_endpoint *endpoint = obj;
+
+	if (!strcasecmp(var->value, "rfc4733")) {
+		endpoint->dtmf = AST_SIP_DTMF_RFC_4733;
+	} else if (!strcasecmp(var->value, "inband")) {
+		endpoint->dtmf = AST_SIP_DTMF_INBAND;
+	} else if (!strcasecmp(var->value, "info")) {
+		endpoint->dtmf = AST_SIP_DTMF_INFO;
+	} else if (!strcasecmp(var->value, "none")) {
+		endpoint->dtmf = AST_SIP_DTMF_NONE;
+	} else {
+		return -1;
+	}
+
+	return 0;
+}
+
 static int sip_initialize_sorcery(void)
 {
 	if (!(sip_sorcery = ast_sorcery_open())) {
@@ -151,6 +170,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disallow", "", OPT_CODEC_T, 0, FLDSET(struct ast_sip_endpoint, prefs, codecs));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow", "", OPT_CODEC_T, 1, FLDSET(struct ast_sip_endpoint, prefs, codecs));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "host", "", host_handler, NULL, 0, 0);
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmfmode", "rfc4733", dtmf_handler, NULL, 0, 0);
 
 	if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");

Modified: team/group/pimp_my_sip/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_sdp_audio.c?view=diff&rev=380195&r1=380194&r2=380195
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_sdp_audio.c (original)
+++ team/group/pimp_my_sip/res/res_sip_sdp_audio.c Sun Jan 27 14:50:24 2013
@@ -218,8 +218,7 @@
 	char tmp[32];
 	pj_str_t stmp;
 	pjmedia_sdp_attr *attr;
-	int index = 0, min_packet_size = 0, noncodec = AST_RTP_DTMF;
-	/* TODO: Make DTMF configurable */
+	int index = 0, min_packet_size = 0, noncodec = (session->endpoint->dtmf == AST_SIP_DTMF_RFC_4733) ? AST_RTP_DTMF : 0;
 
 	if (!ast_format_cap_has_type(session->endpoint->codecs, AST_FORMAT_TYPE_AUDIO)) {
 		/* If no audio formats are configured don't add a stream */




More information about the asterisk-commits mailing list