[asterisk-commits] file: branch file/bridge_native r386132 - in /team/file/bridge_native: apps/ ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 19 11:31:36 CDT 2013
Author: file
Date: Fri Apr 19 11:31:32 2013
New Revision: 386132
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386132
Log:
Reconfigure the bridge when external applications tell us to, and allow a native_rtp bridge to work within a smart bridge leave operation.
Modified:
team/file/bridge_native/apps/app_chanspy.c
team/file/bridge_native/apps/app_mixmonitor.c
team/file/bridge_native/bridges/bridge_native_rtp.c
team/file/bridge_native/main/bridging.c
Modified: team/file/bridge_native/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/apps/app_chanspy.c?view=diff&rev=386132&r1=386131&r2=386132
==============================================================================
--- team/file/bridge_native/apps/app_chanspy.c (original)
+++ team/file/bridge_native/apps/app_chanspy.c Fri Apr 19 11:31:32 2013
@@ -489,8 +489,12 @@
ast_set_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC | AST_AUDIOHOOK_SMALL_QUEUE);
res = ast_audiohook_attach(autochan->chan, audiohook);
- if (!res && ast_test_flag(ast_channel_flags(autochan->chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(autochan->chan))) {
- ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
+ if (!res) {
+ if (ast_test_flag(ast_channel_flags(autochan->chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(autochan->chan))) {
+ ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
+ } else if (ast_channel_internal_bridge(autochan->chan)) {
+ ast_softhangup(autochan->chan, AST_SOFTHANGUP_UNBRIDGE);
+ }
}
return res;
}
Modified: team/file/bridge_native/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/apps/app_mixmonitor.c?view=diff&rev=386132&r1=386131&r2=386132
==============================================================================
--- team/file/bridge_native/apps/app_mixmonitor.c (original)
+++ team/file/bridge_native/apps/app_mixmonitor.c Fri Apr 19 11:31:32 2013
@@ -419,8 +419,13 @@
ast_audiohook_attach(chan, audiohook);
- if (!res && ast_test_flag(ast_channel_flags(chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
- ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
+ if (!res) {
+ if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) {
+ ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
+ } else if (ast_channel_internal_bridge(chan)) {
+ ast_softhangup(chan, AST_SOFTHANGUP_UNBRIDGE);
+ }
+ }
return res;
}
Modified: team/file/bridge_native/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/bridges/bridge_native_rtp.c?view=diff&rev=386132&r1=386131&r2=386132
==============================================================================
--- team/file/bridge_native/bridges/bridge_native_rtp.c (original)
+++ team/file/bridge_native/bridges/bridge_native_rtp.c Fri Apr 19 11:31:32 2013
@@ -92,15 +92,17 @@
enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
if (!(*glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) ||
- !(*glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
+ (c1 && !(*glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type)))) {
return AST_RTP_GLUE_RESULT_FORBID;
}
audio_glue0_res = (*glue0)->get_rtp_info(c0, instance0);
video_glue0_res = (*glue0)->get_vrtp_info ? (*glue0)->get_vrtp_info(c0, vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
- audio_glue1_res = (*glue1)->get_rtp_info(c1, instance1);
- video_glue1_res = (*glue1)->get_vrtp_info ? (*glue1)->get_vrtp_info(c1, vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
+ if (c1) {
+ audio_glue1_res = (*glue1)->get_rtp_info(c1, instance1);
+ video_glue1_res = (*glue1)->get_vrtp_info ? (*glue1)->get_vrtp_info(c1, vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
+ }
/* Apply any limitations on direct media bridging that may be present */
if (audio_glue0_res == audio_glue1_res && audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
@@ -111,7 +113,7 @@
audio_glue0_res = audio_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
}
}
- if (video_glue0_res == video_glue1_res && video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
+ if (c1 && video_glue0_res == video_glue1_res && video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) {
if ((*glue0)->allow_vrtp_remote && !((*glue0)->allow_vrtp_remote(c0, *instance1))) {
/* if the allow_vrtp_remote indicates that remote isn't allowed, revert to local bridge */
video_glue0_res = video_glue1_res = AST_RTP_GLUE_RESULT_LOCAL;
@@ -124,12 +126,12 @@
if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
}
- if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
+ if (c1 && video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
}
/* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
- if (audio_glue0_res == AST_RTP_GLUE_RESULT_FORBID || audio_glue1_res == AST_RTP_GLUE_RESULT_FORBID) {
+ if (audio_glue0_res == AST_RTP_GLUE_RESULT_FORBID || (c1 && audio_glue1_res == AST_RTP_GLUE_RESULT_FORBID)) {
return 0;
}
@@ -299,8 +301,13 @@
ast_rtp_instance_set_bridged(instance0, instance1);
ast_rtp_instance_set_bridged(instance1, instance0);
} else {
+ /* Due to direct RTP setup the bridge *must* exist on the channel to allow media to be redirected */
+ ast_channel_internal_bridge_set(c0->chan, bridge);
+ ast_channel_internal_bridge_set(c1->chan, bridge);
glue0->update_peer(c0->chan, instance1, vinstance1, tinstance1, cap1, 0);
glue1->update_peer(c1->chan, instance0, vinstance0, tinstance0, cap0, 0);
+ ast_channel_internal_bridge_set(c0->chan, NULL);
+ ast_channel_internal_bridge_set(c1->chan, NULL);
}
return 0;
@@ -313,29 +320,35 @@
static void native_rtp_bridge_leave(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
{
- struct ast_bridge_channel *c0 = AST_LIST_FIRST(&bridge->channels);
+ struct ast_bridge_channel *c0 = AST_LIST_FIRST(&bridge->channels) ? AST_LIST_FIRST(&bridge->channels) : bridge_channel;
struct ast_bridge_channel *c1 = AST_LIST_LAST(&bridge->channels);
enum ast_rtp_glue_result native_type;
- struct ast_rtp_glue *glue0, *glue1;
+ struct ast_rtp_glue *glue0, *glue1 = NULL;
struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL, *vinstance0 = NULL, *vinstance1 = NULL;
native_rtp_bridge_framehook_detach(c0);
- native_rtp_bridge_framehook_detach(c1);
-
- native_type = native_rtp_bridge_get(c0->chan, c1->chan, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1);
+ if (c1) {
+ native_rtp_bridge_framehook_detach(c1);
+ }
+
+ native_type = native_rtp_bridge_get(c0->chan, c1 ? c1->chan : NULL, &glue0, &glue1, &instance0, &instance1, &vinstance0, &vinstance1);
if (native_type == AST_RTP_GLUE_RESULT_LOCAL) {
if (ast_rtp_instance_get_engine(instance0)->local_bridge) {
ast_rtp_instance_get_engine(instance0)->local_bridge(instance0, NULL);
}
- if (ast_rtp_instance_get_engine(instance1)->local_bridge) {
+ if (instance1 && ast_rtp_instance_get_engine(instance1)->local_bridge) {
ast_rtp_instance_get_engine(instance1)->local_bridge(instance1, NULL);
}
ast_rtp_instance_set_bridged(instance0, instance1);
- ast_rtp_instance_set_bridged(instance1, instance0);
+ if (instance1) {
+ ast_rtp_instance_set_bridged(instance1, instance0);
+ }
} else {
glue0->update_peer(c0->chan, NULL, NULL, NULL, NULL, 0);
- glue1->update_peer(c1->chan, NULL, NULL, NULL, NULL, 0);
+ if (glue1) {
+ glue1->update_peer(c1->chan, NULL, NULL, NULL, NULL, 0);
+ }
}
}
Modified: team/file/bridge_native/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/main/bridging.c?view=diff&rev=386132&r1=386131&r2=386132
==============================================================================
--- team/file/bridge_native/main/bridging.c (original)
+++ team/file/bridge_native/main/bridging.c Fri Apr 19 11:31:32 2013
@@ -916,6 +916,8 @@
bridge_channel, custom_play, playfile, moh_class);
}
+static void bridge_reconfigured(struct ast_bridge *bridge);
+
/*!
* \internal
* \brief Feed notification that a frame is waiting on a channel into the bridging core
@@ -938,6 +940,11 @@
}
switch (frame->frametype) {
case AST_FRAME_NULL:
+ if (ast_channel_softhangup_internal_flag(bridge_channel->chan) & AST_SOFTHANGUP_UNBRIDGE) {
+ ast_channel_clear_softhangup(bridge_channel->chan, AST_SOFTHANGUP_UNBRIDGE);
+ bridge_channel->bridge->reconfigured = 1;
+ bridge_reconfigured(bridge_channel->bridge);
+ }
/* Just discard it. */
ast_frfree(frame);
return;
More information about the asterisk-commits
mailing list