[svn-commits] mmichelson: branch group/CCSS r234800 - in /team/group/CCSS: channels/ includ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 14 16:21:51 CST 2009


Author: mmichelson
Date: Mon Dec 14 16:21:49 2009
New Revision: 234800

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234800
Log:
Put some experimental code in chan_dahdi to allow CCNR
in a call-forward scenario.

Unfortunately, call-forwarding on analog phones does not
work in trunk right now, so I am unable to test this.


Modified:
    team/group/CCSS/channels/chan_dahdi.c
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_dahdi.c?view=diff&rev=234800&r1=234799&r2=234800
==============================================================================
--- team/group/CCSS/channels/chan_dahdi.c (original)
+++ team/group/CCSS/channels/chan_dahdi.c Mon Dec 14 16:21:49 2009
@@ -117,6 +117,7 @@
 #include "asterisk/event.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/paths.h"
+#include "asterisk/ccss.h"
 
 /*** DOCUMENTATION
 	<application name="DAHDISendKeypadFacility" language="en_US">
@@ -7944,6 +7945,27 @@
 	return f;
 }
 
+static int dahdi_cc_is_possible(struct ast_channel *chan, const char * const device_name)
+{
+	struct ast_cc_config_params *cc_params = ast_channel_get_cc_config_params(chan);
+	enum ast_cc_monitor_policies monitor_policy = ast_get_cc_monitor_policy(cc_params);
+	const char *monitor_type;
+
+	if (monitor_policy == AST_CC_MONITOR_GENERIC || monitor_policy == AST_CC_MONITOR_ALWAYS) {
+		monitor_type = "generic";
+	} else if (monitor_policy == AST_CC_MONITOR_NATIVE) {
+		monitor_type = "DAHDI";
+	} else {
+		return 0;
+	}
+
+	if (ast_cc_monitor_count(device_name, monitor_type) >= ast_get_cc_max_monitors(cc_params)) {
+		return 0;
+	}
+
+	return 1;
+}
+
 static struct ast_frame *dahdi_read(struct ast_channel *ast)
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
@@ -8018,8 +8040,24 @@
 #endif
 
 	if (p->subs[idx].needringing) {
+		if (p->call_forward) {
+			char device_name[256];
+			ast_channel_get_device_name(p->owner, device_name, sizeof(device_name));
+			if (dahdi_cc_is_possible(p->owner, device_name)) {
+				/* XXX I unfortunately cannot test this at the moment because analog
+				 * call forwarding is broken in trunk.
+				 */
+				if (!ast_cc_build_frame(p->owner, p->cc_params, device_name, AST_CC_CCNR, &p->subs[idx].f)) {
+					p->subs[idx].needringing = 0;
+					ast_mutex_unlock(&p->lock);
+					return &p->subs[idx].f;
+				}
+			}
+			/* If CC isn't possible or if we can't build the CC frame properly,
+			 * then we drop into the typical behavior instead
+			 */
+		}
 		/* Send ringing frame if requested */
-		p->subs[idx].needringing = 0;
 		p->subs[idx].f.frametype = AST_FRAME_CONTROL;
 		p->subs[idx].f.subclass.integer = AST_CONTROL_RINGING;
 		ast_setstate(ast, AST_STATE_RINGING);

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=234800&r1=234799&r2=234800
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Mon Dec 14 16:21:49 2009
@@ -1161,7 +1161,7 @@
  * \retval -1 Failure. At some point there was a failure. Do not attempt to use the frame in this case.
  * \retval 0 Success
  */
-int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, struct ast_frame *frame);
+int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, enum ast_cc_service_type service, struct ast_frame *frame);
 
 /*!
  * \since 1.6.4

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=234800&r1=234799&r2=234800
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Mon Dec 14 16:21:49 2009
@@ -3134,7 +3134,7 @@
 			cc_ref(core_instance, "Ref core instance for status response callback"));
 }
 
-static int cc_build_payload(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, struct ast_control_cc_payload *payload)
+static int cc_build_payload(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, enum ast_cc_service_type service, struct ast_control_cc_payload *payload)
 {
 	struct ast_datastore *datastore;
 	struct dialed_cc_interfaces *cc_interfaces;
@@ -3152,7 +3152,7 @@
 	dial_parent_id = cc_interfaces->dial_parent_id;
 	ast_channel_unlock(chan);
 
-	payload->service = AST_CC_CCBS;
+	payload->service = service;
 	if (monitor_policy == AST_CC_MONITOR_GENERIC || monitor_policy == AST_CC_MONITOR_ALWAYS) {
 		payload->monitor_type = "generic";
 	} else if (monitor_policy == AST_CC_MONITOR_NATIVE) {
@@ -3190,17 +3190,17 @@
 		return -1;
 	}
 
-	if (ast_cc_build_frame(chan, ast_channel_get_cc_config_params(chan), chan_name, &frame)) {
+	if (ast_cc_build_frame(chan, ast_channel_get_cc_config_params(chan), chan_name, service, &frame)) {
 		/* Frame building failed. We can't use this. */
 		return -1;
 	}
 	return ast_queue_frame(chan, &frame);
 }
 
-int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, struct ast_frame *frame)
+int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char * const interface_name, enum ast_cc_service_type service, struct ast_frame *frame)
 {
 	struct ast_control_cc_payload *payload = ast_calloc(1, sizeof(*payload));
-	if (cc_build_payload(chan, cc_params, interface_name, payload)) {
+	if (cc_build_payload(chan, cc_params, interface_name, service, payload)) {
 		/* Something screwed up, we can't make a frame with this */
 		ast_free(payload);
 		return -1;
@@ -3218,7 +3218,7 @@
 void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name)
 {
 	struct ast_control_cc_payload payload;
-	if (cc_build_payload(inbound, cc_params, interface_name, &payload)) {
+	if (cc_build_payload(inbound, cc_params, interface_name, AST_CC_CCBS, &payload)) {
 		/* Something screwed up. Don't try to handle this payload */
 		return;
 	}




More information about the svn-commits mailing list