[asterisk-commits] oej: branch oej/applefrog-early-media-in-originate-trunk r338482 - in /team/o...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 29 08:19:02 CDT 2011


Author: oej
Date: Thu Sep 29 08:18:54 2011
New Revision: 338482

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338482
Log:
Look ma, it compiles. 

Modified:
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_originate.c
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/channel.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/pbx.h
    team/oej/applefrog-early-media-in-originate-trunk/main/channel.c
    team/oej/applefrog-early-media-in-originate-trunk/main/manager.c
    team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c
    team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_clioriginate.c

Modified: team/oej/applefrog-early-media-in-originate-trunk/apps/app_originate.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/apps/app_originate.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/apps/app_originate.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/apps/app_originate.c Thu Sep 29 08:18:54 2011
@@ -170,7 +170,7 @@
 
 		ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
 				timeout * 1000, args.arg1, exten, priority, &outgoing_status, 0, NULL,
-				NULL, NULL, NULL, NULL);
+				NULL, NULL, NULL, NULL, 0);
 	} else if (!strcasecmp(args.type, "app")) {
 		ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
 				chantech, chandata, args.arg1, S_OR(args.arg2, ""));

Modified: team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/channel.h?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/channel.h (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/channel.h Thu Sep 29 08:18:54 2011
@@ -978,6 +978,7 @@
 	const char *context;
 	const char *exten;
 	int priority;
+	int connect_on_earlymedia;	/* If set, treat session progress as answer */
 	const char *cid_num;
 	const char *cid_name;
 	const char *account;

Modified: team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/pbx.h?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/pbx.h (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/pbx.h Thu Sep 29 08:18:54 2011
@@ -889,7 +889,7 @@
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular extension */
-int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, const int earlymedia);
 
 /*! Synchronously or asynchronously make an outbound call and send it to a
    particular application with given extension */

Modified: team/oej/applefrog-early-media-in-originate-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/main/channel.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/main/channel.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/main/channel.c Thu Sep 29 08:18:54 2011
@@ -5576,8 +5576,14 @@
 					timeout = 0;		/* trick to force exit from the while() */
 					break;
 
+				case AST_CONTROL_PROGRESS:
+					if (oh->connect_on_earlymedia) {
+						*outstate = f->subclass.integer;
+						timeout = 0;		/* trick to force exit from the while() */
+						break;
+					}
+					/* Fallthrough */
 				/* Ignore these */
-				case AST_CONTROL_PROGRESS:
 				case AST_CONTROL_PROCEEDING:
 				case AST_CONTROL_HOLD:
 				case AST_CONTROL_UNHOLD:

Modified: team/oej/applefrog-early-media-in-originate-trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/main/manager.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/main/manager.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/main/manager.c Thu Sep 29 08:18:54 2011
@@ -448,6 +448,9 @@
 			</parameter>
 			<parameter name="Account">
 				<para>Account code.</para>
+			</parameter>
+			<parameter name="Earlymedia">
+				<para>Set to <literal>true</literal> to force call bridge on early media..</para>
 			</parameter>
 			<parameter name="Async">
 				<para>Set to <literal>true</literal> for fast origination.</para>
@@ -3605,6 +3608,7 @@
 	char data[512];
 	int timeout;
 	struct ast_format_cap *cap;				/*!< Codecs used for a call */
+	int earlymedia;
 	AST_DECLARE_STRING_FIELDS (
 		AST_STRING_FIELD(app);
 		AST_STRING_FIELD(appdata);
@@ -3636,7 +3640,7 @@
 		res = ast_pbx_outgoing_exten(in->tech, in->cap, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
-			in->vars, in->account, &chan);
+			in->vars, in->account, &chan, in->earlymedia);
 	}
 
 	if (!chan) {
@@ -3915,6 +3919,7 @@
 	const char *async = astman_get_header(m, "Async");
 	const char *id = astman_get_header(m, "ActionID");
 	const char *codecs = astman_get_header(m, "Codecs");
+	const char *earlymedia = astman_get_header(m, "Earlymedia");
 	struct ast_variable *vars;
 	char *tech, *data;
 	char *l = NULL, *n = NULL;
@@ -3927,6 +3932,7 @@
 	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
 	struct ast_format tmp_fmt;
 	pthread_t th;
+	int bridgeearly = 0;
 
 	if (!cap) {
 		astman_send_error(s, m, "Internal Error. Memory allocation failure.");
@@ -4000,6 +4006,10 @@
 	/* Allocate requested channel variables */
 	vars = astman_get_variables(m);
 
+	/* For originate async - we can bridge in early media stage */
+	bridgeearly = ast_true(earlymedia);
+	
+
 	if (ast_true(async)) {
 		struct fast_originate_helper *fast = ast_calloc(1, sizeof(*fast));
 		if (!fast || ast_string_field_init(fast, 252)) {
@@ -4024,6 +4034,7 @@
 			fast->cap = cap;
 			cap = NULL; /* transfered originate helper the capabilities structure.  It is now responsible for freeing it. */
 			fast->timeout = to;
+			fast->earlymedia = bridgeearly;
 			fast->priority = pi;
 			if (ast_pthread_create_detached(&th, NULL, fast_originate, fast)) {
 				ast_format_cap_destroy(fast->cap);
@@ -4038,7 +4049,7 @@
 		res = ast_pbx_outgoing_app(tech, cap, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
 	} else {
 		if (exten && context && pi) {
-			res = ast_pbx_outgoing_exten(tech, cap, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
+			res = ast_pbx_outgoing_exten(tech, cap, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL, bridgeearly);
 		} else {
 			astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
 			if (vars) {

Modified: team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c Thu Sep 29 08:18:54 2011
@@ -8668,6 +8668,7 @@
 	int timeout;
 	char app[AST_MAX_EXTENSION];
 	char appdata[1024];
+	int earlymedia;			/* Connect the bridge if early media arrives, don't wait for answer */
 };
 
 static void *async_wait(void *data)
@@ -8678,6 +8679,7 @@
 	int res;
 	struct ast_frame *f;
 	struct ast_app *app;
+	int haveearlymedia = 0;
 
 	while (timeout && (chan->_state != AST_STATE_UP)) {
 		res = ast_waitfor(chan, timeout);
@@ -8694,10 +8696,17 @@
 				ast_frfree(f);
 				break;
 			}
+			if (as->earlymedia && f->subclass.integer == AST_CONTROL_PROGRESS) {
+				haveearlymedia = 1;
+				break;
+			}
 		}
 		ast_frfree(f);
 	}
-	if (chan->_state == AST_STATE_UP) {
+	if (chan->_state == AST_STATE_UP || haveearlymedia) {
+		if (haveearlymedia && option_debug > 1) {
+			ast_log(LOG_DEBUG, "Activating pbx since we have early media \n");
+		}
 		if (!ast_strlen_zero(as->app)) {
 			app = pbx_findapp(as->app);
 			if (app) {
@@ -8758,12 +8767,14 @@
 	return 0;  /* success */
 }
 
-int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel, const int earlymedia)
 {
 	struct ast_channel *chan;
 	struct async_stat *as;
 	int res = -1, cdr_res = -1;
 	struct outgoing_helper oh;
+
+	oh.connect_on_earlymedia = earlymedia;
 
 	if (synchronous) {
 		oh.context = context;
@@ -8782,9 +8793,9 @@
 				ast_channel_lock(chan);
 		}
 		if (chan) {
-			if (chan->_state == AST_STATE_UP) {
-					res = 0;
-				ast_verb(4, "Channel %s was answered.\n", chan->name);
+			if (chan->_state == AST_STATE_UP || (earlymedia && *reason == AST_CONTROL_PROGRESS) ) {
+				res = 0;
+				ast_verb(4, "Channel %s was answered (or got early media).\n", chan->name);
 
 				if (synchronous > 1) {
 					if (channel)

Modified: team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c Thu Sep 29 08:18:54 2011
@@ -353,7 +353,7 @@
 		o->vars = NULL;
 	} else {
 		ast_verb(3, "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
-		res = ast_pbx_outgoing_exten(o->tech, o->capabilities, (void *) o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
+		res = ast_pbx_outgoing_exten(o->tech, o->capabilities, (void *) o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL, 0);
 		o->vars = NULL;
 	}
 	if (res) {

Modified: team/oej/applefrog-early-media-in-originate-trunk/res/res_clioriginate.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/res/res_clioriginate.c?view=diff&rev=338482&r1=338481&r2=338482
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/res/res_clioriginate.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/res/res_clioriginate.c Thu Sep 29 08:18:54 2011
@@ -119,7 +119,7 @@
 		return CLI_FAILURE;
 	}
 	ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-	ast_pbx_outgoing_exten(chantech, cap, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 0, NULL, NULL, NULL, NULL, NULL);
+	ast_pbx_outgoing_exten(chantech, cap, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 0, NULL, NULL, NULL, NULL, NULL, 0);
 	cap = ast_format_cap_destroy(cap);
 
 	return CLI_SUCCESS;




More information about the asterisk-commits mailing list