[asterisk-commits] kmoore: branch 1.8 r328823 - in /branches/1.8: channels/ include/asterisk/ ma...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 19 12:57:24 CDT 2011


Author: kmoore
Date: Tue Jul 19 12:57:18 2011
New Revision: 328823

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=328823
Log:
RTP bridge away with inband DTMF and feature detection

When deciding whether Asterisk was allowed to bridge the call away from the
core, chan_sip did not take into account the usage of features on dialed
channels that require monitoring of DTMF on channels utilizing inband DTMF.
This would cause Asterisk to allow the call to be locally or remotely bridged, 
preventing access to the data required to detect activations of such features.

(closes 17237)
Review: https://reviewboard.asterisk.org/r/1302/

Modified:
    branches/1.8/channels/chan_sip.c
    branches/1.8/include/asterisk/rtp_engine.h
    branches/1.8/main/rtp_engine.c
    branches/1.8/res/res_rtp_asterisk.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=328823&r1=328822&r2=328823
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Tue Jul 19 12:57:18 2011
@@ -4193,10 +4193,11 @@
 	}
 
 	if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) ||
-            (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO)) {
-		if (!p->rtp || ast_rtp_instance_dtmf_mode_set(p->rtp, AST_RTP_DTMF_MODE_INBAND)) {
-			features |= DSP_FEATURE_DIGIT_DETECT;
-                }
+	    (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO)) {
+		if (p->rtp) {
+			ast_rtp_instance_dtmf_mode_set(p->rtp, AST_RTP_DTMF_MODE_INBAND);
+		}
+		features |= DSP_FEATURE_DIGIT_DETECT;
 	}
 
 	if (ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT_CNG)) {
@@ -6886,8 +6887,8 @@
 
 	if ((ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) ||
 	    (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_AUTO)) {
-		if (!i->rtp || ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_INBAND)) {
-			enable_dsp_detect(i);
+		if (i->rtp) {
+			ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_INBAND);
 		}
 	} else if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) {
 		if (i->rtp) {

Modified: branches/1.8/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/rtp_engine.h?view=diff&rev=328823&r1=328822&r2=328823
==============================================================================
--- branches/1.8/include/asterisk/rtp_engine.h (original)
+++ branches/1.8/include/asterisk/rtp_engine.h Tue Jul 19 12:57:18 2011
@@ -345,6 +345,8 @@
 	void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
 	/*! Callback for changing DTMF mode */
 	int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
+	/*! Callback for getting DTMF mode */
+	enum ast_rtp_dtmf_mode (*dtmf_mode_get)(struct ast_rtp_instance *instance);
 	/*! Callback for retrieving statistics */
 	int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
 	/*! Callback for setting QoS values */

Modified: branches/1.8/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/rtp_engine.c?view=diff&rev=328823&r1=328822&r2=328823
==============================================================================
--- branches/1.8/main/rtp_engine.c (original)
+++ branches/1.8/main/rtp_engine.c Tue Jul 19 12:57:18 2011
@@ -68,8 +68,6 @@
 	int holdtimeout;
 	/*! RTP keepalive interval */
 	int keepalive;
-	/*! DTMF mode in use */
-	enum ast_rtp_dtmf_mode dtmf_mode;
 	/*! Glue currently in use */
 	struct ast_rtp_glue *glue;
 	/*! Channel associated with the instance */
@@ -746,18 +744,12 @@
 
 int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
 {
-	if (!instance->engine->dtmf_mode_set || instance->engine->dtmf_mode_set(instance, dtmf_mode)) {
-		return -1;
-	}
-
-	instance->dtmf_mode = dtmf_mode;
-
-	return 0;
+	return (!instance->engine->dtmf_mode_set || instance->engine->dtmf_mode_set(instance, dtmf_mode)) ? -1 : 0;
 }
 
 enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
 {
-	return instance->dtmf_mode;
+	return instance->engine->dtmf_mode_get ? instance->engine->dtmf_mode_get(instance) : 0;
 }
 
 void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
@@ -1255,6 +1247,7 @@
 	enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
 	enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
 	enum ast_bridge_result res = AST_BRIDGE_FAILED;
+	enum ast_rtp_dtmf_mode dmode;
 	format_t codec0 = 0, codec1 = 0;
 	int unlock_chans = 1;
 
@@ -1310,11 +1303,13 @@
 	}
 
 	/* If we need to get DTMF see if we can do it outside of the RTP stream itself */
-	if ((flags & AST_BRIDGE_DTMF_CHANNEL_0) && instance0->properties[AST_RTP_PROPERTY_DTMF]) {
+	dmode = ast_rtp_instance_dtmf_mode_get(instance0);
+	if ((flags & AST_BRIDGE_DTMF_CHANNEL_0) && dmode) {
 		res = AST_BRIDGE_FAILED_NOWARN;
 		goto done;
 	}
-	if ((flags & AST_BRIDGE_DTMF_CHANNEL_1) && instance1->properties[AST_RTP_PROPERTY_DTMF]) {
+	dmode = ast_rtp_instance_dtmf_mode_get(instance1);
+	if ((flags & AST_BRIDGE_DTMF_CHANNEL_1) && dmode) {
 		res = AST_BRIDGE_FAILED_NOWARN;
 		goto done;
 	}

Modified: branches/1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_rtp_asterisk.c?view=diff&rev=328823&r1=328822&r2=328823
==============================================================================
--- branches/1.8/res/res_rtp_asterisk.c (original)
+++ branches/1.8/res/res_rtp_asterisk.c Tue Jul 19 12:57:18 2011
@@ -147,6 +147,7 @@
 	unsigned int dtmf_duration;     /*!< Total duration in samples since the digit start event */
 	unsigned int dtmf_timeout;      /*!< When this timestamp is reached we consider END frame lost and forcibly abort digit */
 	unsigned int dtmfsamples;
+	enum ast_rtp_dtmf_mode dtmfmode;/*!< The current DTMF mode of the RTP stream */
 	/* DTMF Transmission Variables */
 	unsigned int lastdigitts;
 	char sending_digit;	/*!< boolean - are we sending digits */
@@ -260,6 +261,8 @@
 static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit);
 static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit);
 static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration);
+static int ast_rtp_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
+static enum ast_rtp_dtmf_mode ast_rtp_dtmf_mode_get(struct ast_rtp_instance *instance);
 static void ast_rtp_update_source(struct ast_rtp_instance *instance);
 static void ast_rtp_change_source(struct ast_rtp_instance *instance);
 static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
@@ -286,6 +289,8 @@
 	.dtmf_begin = ast_rtp_dtmf_begin,
 	.dtmf_end = ast_rtp_dtmf_end,
 	.dtmf_end_with_duration = ast_rtp_dtmf_end_with_duration,
+	.dtmf_mode_set = ast_rtp_dtmf_mode_set,
+	.dtmf_mode_get = ast_rtp_dtmf_mode_get,
 	.update_source = ast_rtp_update_source,
 	.change_source = ast_rtp_change_source,
 	.write = ast_rtp_write,
@@ -532,6 +537,19 @@
 	ast_free(rtp);
 
 	return 0;
+}
+
+static int ast_rtp_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
+{
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	rtp->dtmfmode = dtmf_mode;
+	return 0;
+}
+
+static enum ast_rtp_dtmf_mode ast_rtp_dtmf_mode_get(struct ast_rtp_instance *instance)
+{
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	return rtp->dtmfmode;
 }
 
 static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit)




More information about the asterisk-commits mailing list