[svn-commits] file: branch file/originate_dial r387101 - /team/file/originate_dial/main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed May 1 08:23:05 CDT 2013


Author: file
Date: Wed May  1 08:23:01 2013
New Revision: 387101

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387101
Log:
Obey the early_media option.

Modified:
    team/file/originate_dial/main/pbx.c

Modified: team/file/originate_dial/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/file/originate_dial/main/pbx.c?view=diff&rev=387101&r1=387100&r2=387101
==============================================================================
--- team/file/originate_dial/main/pbx.c (original)
+++ team/file/originate_dial/main/pbx.c Wed May  1 08:23:01 2013
@@ -10020,6 +10020,25 @@
 	return NULL;
 }
 
+/*! \brief Internal dialing state callback which causes early media to trigger an answer */
+static void pbx_outgoing_state_callback(struct ast_dial *dial)
+{
+	struct ast_channel *channel;
+
+	if (ast_dial_state(dial) != AST_DIAL_RESULT_PROGRESS) {
+		return;
+	}
+
+	if (!(channel = ast_dial_channel(dial, 0))) {
+		return;
+	}
+
+	ast_verb(4, "Treating progress as answer on '%s' due to early media option\n",
+		ast_channel_name(channel));
+
+	ast_queue_control(channel, AST_CONTROL_ANSWER);
+}
+
 static int pbx_outgoing_attempt(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context,
 	const char *exten, int priority, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num,
 	const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel, int early_media)
@@ -10077,6 +10096,10 @@
 		connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
 
 		ast_channel_set_connected_line(dialed, &connected, NULL);
+	}
+
+	if (early_media) {
+		ast_dial_set_state_callback(outgoing->dial, &pbx_outgoing_state_callback);
 	}
 
 	ast_mutex_init(&outgoing->lock);




More information about the svn-commits mailing list