[asterisk-commits] file: branch file/earlybridge r43270 - in /team/file/earlybridge: apps/ chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Sep 19 09:22:53 MST 2006


Author: file
Date: Tue Sep 19 11:22:52 2006
New Revision: 43270

URL: http://svn.digium.com/view/asterisk?rev=43270&view=rev
Log:
Make early bridging a technology specific thing, instead of just calling the RTP one every time

Modified:
    team/file/earlybridge/apps/app_dial.c
    team/file/earlybridge/channels/chan_sip.c
    team/file/earlybridge/include/asterisk/channel.h
    team/file/earlybridge/include/asterisk/rtp.h
    team/file/earlybridge/main/channel.c
    team/file/earlybridge/main/rtp.c

Modified: team/file/earlybridge/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/apps/app_dial.c?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/apps/app_dial.c (original)
+++ team/file/earlybridge/apps/app_dial.c Tue Sep 19 11:22:52 2006
@@ -575,8 +575,8 @@
 							       OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
 							       OPT_CALLEE_PARK | OPT_CALLER_PARK |
 							       DIAL_NOFORWARDHTML);
-						/* Setup RTP early bridge if appropriate */
-						ast_rtp_early_bridge(in, peer);
+						/* Setup early bridge if appropriate */
+						ast_channel_early_bridge(in, peer);
 					}
 					/* If call has been answered, then the eventual hangup is likely to be normal hangup */
 					in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
@@ -605,7 +605,7 @@
 						ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", c->name);
 					/* Setup early media if appropriate */
 					if (single)
-						ast_rtp_early_bridge(in, c);
+						ast_channel_early_bridge(in, c);
 					if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
 						ast_indicate(in, AST_CONTROL_RINGING);
 						(*sentringing)++;
@@ -616,7 +616,7 @@
 						ast_verbose (VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", c->name, in->name);
 					/* Setup early media if appropriate */
 					if (single)
-						ast_rtp_early_bridge(in, c);
+						ast_channel_early_bridge(in, c);
 					if (!ast_test_flag(outgoing, OPT_RINGBACK))
 						ast_indicate(in, AST_CONTROL_PROGRESS);
 					break;
@@ -629,7 +629,7 @@
 					if (option_verbose > 2)
 						ast_verbose (VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", c->name, in->name);
 					if (single)
-						ast_rtp_early_bridge(in, c);
+						ast_channel_early_bridge(in, c);
 					if (!ast_test_flag(outgoing, OPT_RINGBACK))
 						ast_indicate(in, AST_CONTROL_PROCEEDING);
 					break;
@@ -1624,7 +1624,7 @@
 		sentringing = 0;
 		ast_indicate(chan, -1);
 	}
-	ast_rtp_early_bridge(chan, NULL);
+	ast_channel_early_bridge(chan, NULL);
 	hanguptree(outgoing, NULL);
 	pbx_builtin_setvar_helper(chan, "DIALSTATUS", status);
 	if (option_debug)

Modified: team/file/earlybridge/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/channels/chan_sip.c?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/channels/chan_sip.c (original)
+++ team/file/earlybridge/channels/chan_sip.c Tue Sep 19 11:22:52 2006
@@ -1527,6 +1527,7 @@
 	.send_digit_begin = sip_senddigit_begin,
 	.send_digit_end = sip_senddigit_end,
 	.bridge = ast_rtp_bridge,
+	.early_bridge = ast_rtp_early_bridge,
 	.send_text = sip_sendtext,
 };
 

Modified: team/file/earlybridge/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/include/asterisk/channel.h?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/include/asterisk/channel.h (original)
+++ team/file/earlybridge/include/asterisk/channel.h Tue Sep 19 11:22:52 2006
@@ -237,6 +237,9 @@
 	/*! \brief Bridge two channels of the same type together */
 	enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,
 						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
+
+	/*! \brief Bridge two channels of the same type together (early) */
+	enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
 
 	/*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */
 	int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);
@@ -965,6 +968,13 @@
  * \return Returns 0 on success and -1 if it could not be done */
 int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);
 
+/*! Bridge two channels together (early)
+ * \param c0 first channel to bridge
+ * \param c1 second channel to bridge
+ * Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet.
+ * \return Returns 0 on success and -1 if it could not be done */
+int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
+
 /*! Bridge two channels together 
  * \param c0 first channel to bridge
  * \param c1 second channel to bridge

Modified: team/file/earlybridge/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/include/asterisk/rtp.h?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/include/asterisk/rtp.h (original)
+++ team/file/earlybridge/include/asterisk/rtp.h Tue Sep 19 11:22:52 2006
@@ -196,7 +196,7 @@
 
 /*! \brief If possible, create an early bridge directly between the devices without
            having to send a re-invite later */
-int ast_rtp_early_bridge(struct ast_channel *dest, struct ast_channel *src);
+int ast_rtp_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
 
 void ast_rtp_stop(struct ast_rtp *rtp);
 

Modified: team/file/earlybridge/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/main/channel.c?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/main/channel.c (original)
+++ team/file/earlybridge/main/channel.c Tue Sep 19 11:22:52 2006
@@ -3675,6 +3675,16 @@
 	return res;
 }
 
+/*! \brief Bridge two channels together (early) */
+int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
+{
+	/* Make sure we can early bridge, if not error out */
+	if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
+		return -1;
+
+	return c0->tech->early_bridge(c0, c1);
+}
+
 /*! \brief Bridge two channels together */
 enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1,
 					  struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)

Modified: team/file/earlybridge/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/file/earlybridge/main/rtp.c?rev=43270&r1=43269&r2=43270&view=diff
==============================================================================
--- team/file/earlybridge/main/rtp.c (original)
+++ team/file/earlybridge/main/rtp.c Tue Sep 19 11:22:52 2006
@@ -1374,8 +1374,9 @@
 	return cur;
 }
 
-int ast_rtp_early_bridge(struct ast_channel *dest, struct ast_channel *src)
-{
+int ast_rtp_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
+{
+	// dest = c0, src = c1
 	struct ast_rtp *destp = NULL, *srcp = NULL;		/* Audio RTP Channels */
 	struct ast_rtp *vdestp = NULL, *vsrcp = NULL;		/* Video RTP channels */
 	struct ast_rtp_protocol *destpr = NULL, *srcpr = NULL;
@@ -1384,68 +1385,68 @@
 	int srccodec;
 
 	/* Lock channels */
-	ast_channel_lock(dest);
-	if (src) {
-		while(ast_channel_trylock(src)) {
-			ast_channel_unlock(dest);
+	ast_channel_lock(c0);
+	if (c1) {
+		while(ast_channel_trylock(c1)) {
+			ast_channel_unlock(c0);
 			usleep(1);
-			ast_channel_lock(dest);
+			ast_channel_lock(c0);
 		}
 	}
 
 	/* Find channel driver interfaces */
-	destpr = get_proto(dest);
-	if (src)
-		srcpr = get_proto(src);
+	destpr = get_proto(c0);
+	if (c1)
+		srcpr = get_proto(c1);
 	if (!destpr) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", dest->name);
-		ast_channel_unlock(dest);
-		if (src)
-			ast_channel_unlock(src);
-		return 0;
+			ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", c0->name);
+		ast_channel_unlock(c0);
+		if (c1)
+			ast_channel_unlock(c1);
+		return -1;
 	}
 	if (!srcpr) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", src ? src->name : "<unspecified>");
-		ast_channel_unlock(dest);
-		if (src)
-			ast_channel_unlock(src);
-		return 0;
+			ast_log(LOG_DEBUG, "Channel '%s' has no RTP, not doing anything\n", c1 ? c1->name : "<unspecified>");
+		ast_channel_unlock(c0);
+		if (c1)
+			ast_channel_unlock(c1);
+		return -1;
 	}
 
 	/* Get audio and video interface (if native bridge is possible) */
-	audio_dest_res = destpr->get_rtp_info(dest, &destp);
-	video_dest_res = destpr->get_vrtp_info ? destpr->get_vrtp_info(dest, &vdestp) : AST_RTP_GET_FAILED;
+	audio_dest_res = destpr->get_rtp_info(c0, &destp);
+	video_dest_res = destpr->get_vrtp_info ? destpr->get_vrtp_info(c0, &vdestp) : AST_RTP_GET_FAILED;
 	if (srcpr) {
-		audio_src_res = srcpr->get_rtp_info(src, &srcp);
-		video_src_res = srcpr->get_vrtp_info ? srcpr->get_vrtp_info(src, &vsrcp) : AST_RTP_GET_FAILED;
+		audio_src_res = srcpr->get_rtp_info(c1, &srcp);
+		video_src_res = srcpr->get_vrtp_info ? srcpr->get_vrtp_info(c1, &vsrcp) : AST_RTP_GET_FAILED;
 	}
 
 	/* Check if bridge is still possible (In SIP canreinvite=no stops this, like NAT) */
 	if (audio_dest_res != AST_RTP_TRY_NATIVE) {
 		/* Somebody doesn't want to play... */
-		ast_channel_unlock(dest);
-		if (src)
-			ast_channel_unlock(src);
-		return 0;
+		ast_channel_unlock(c0);
+		if (c1)
+			ast_channel_unlock(c1);
+		return -1;
 	}
 	if (audio_src_res == AST_RTP_TRY_NATIVE && srcpr->get_codec)
-		srccodec = srcpr->get_codec(src);
+		srccodec = srcpr->get_codec(c1);
 	else
 		srccodec = 0;
 	/* Consider empty media as non-existant */
 	if (audio_src_res == AST_RTP_TRY_NATIVE && !srcp->them.sin_addr.s_addr)
 		srcp = NULL;
 	/* Bridge media early */
-	if (destpr->set_rtp_peer(dest, srcp, vsrcp, srccodec, srcp ? ast_test_flag(srcp, FLAG_NAT_ACTIVE) : 0))
-		ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", dest->name, src ? src->name : "<unspecified>");
-	ast_channel_unlock(dest);
-	if (src)
-		ast_channel_unlock(src);
+	if (destpr->set_rtp_peer(c0, srcp, vsrcp, srccodec, srcp ? ast_test_flag(srcp, FLAG_NAT_ACTIVE) : 0))
+		ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+	ast_channel_unlock(c0);
+	if (c1)
+		ast_channel_unlock(c1);
 	if (option_debug)
-		ast_log(LOG_DEBUG, "Setting early bridge SDP of '%s' with that of '%s'\n", dest->name, src ? src->name : "<unspecified>");
-	return 1;
+		ast_log(LOG_DEBUG, "Setting early bridge SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+	return 0;
 }
 
 int ast_rtp_make_compatible(struct ast_channel *dest, struct ast_channel *src, int media)



More information about the asterisk-commits mailing list