[Freeswitch-dev] Howto stop or cancel a bridge
Achim Stamm
stamm at lyth.de
Wed Jul 21 00:44:34 PDT 2010
Hello!
I have following problem:
I have bridged my current session to "user/1012 at 192.168.1.30" with
timeout of 60 seconds.
The call of bridge runs in a thread using modificated bgapi.
The phone 1012 rings and i play a sound file to another phone with
number 1010.
Phone with 1010 wants to have the call.
I want to stop or cancel the bridge to phone 1012 without hanging up my
current session.
Is there a core command to stop/cancel a bridge (like sending a message
"Cancel bridge" or something else) ?
With this stop/cancel a bridge command the phone 1012 should stop
ringing, but my originator session should not
hang up (see snippet of my DoingBridge -> @ToDo Cancel or Stop Bridge:
???????).
Here is a snippet of my Dialplan:
-----------------------------------------------------
<extension name="Externer-Anrufer">
<condition field="destination_number" expression="^70$">
<action application="info"/>
<action application="set" data="hangup_after_bridge=false"/>
<action application="set" data="ignore_early_media=true"/>
<action application="myapplication" data="DoingBridge"/>
</condition>
</extension>
------------------------------------------------------
Here is a snippet of my DoingBridge from myapplication:
-------------------------------------------
static switch_status_t DoingBridge(switch_core_session_t *session,
switch_input_args_t *args)
{
switch_codec_t codec = { 0 };
switch_status_t status;
switch_frame_t *read_frame;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_t * PartnerSession = NULL;
switch_core_session_t *sessionNebenstelle = NULL;
switch_channel_t *channelNebenstelle = NULL;
switch_stream_handle_t dstream = { 0 };
switch_stream_handle_t astream = { 0 };
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
// Bridge to phone in a thread:
SWITCH_STANDARD_STREAM(dstream);
mybg_bridge("user/1012 at 192.168.1.30" ,60, session, &dstream);
bool bNebenStelleAntwortet =
switch_channel_test_flag(channel,CF_ANSWERED);
const char * NebenStelle_uuid = NULL;
while (! phone1010WantsCall && !BridgeAnsweredBy1012)
{
// PlayAudio File:
switch_channel_state_t aktStatus =
switch_channel_get_state(channel);
NebenStelle_uuid = switch_channel_get_variable_partner(channel ,
"signal_bond");
bNebenStelleAntwortet =
switch_channel_test_flag(channel,CF_ANSWERED);
if (NebenStelle_uuid && !sessionNebenstelle)
{
sessionNebenstelle =
switch_core_session_locate(NebenStelle_uuid);
if (sessionNebenstelle)
{
channelNebenstelle =
switch_core_session_get_channel(sessionNebenstelle);
}
}
PlayAudioFile("1010");
}
// Stop Playing:
StopPlayingAudioFile(session);
if (switch_channel_ready(channel))
{
// sessionNebenstelle is 1012
if (sessionNebenstelle)
{
// @ToDo Cancel or Stop Bridge:
// ?????????????????????????????????????????????
answerSession(session);
}
}
....
}
---------------------------------------------------
regards
Achim Stamm
--
Achim Stamm, Dipl.-Inform. (FH)
Lyncker & Theis GmbH
Wilhelmstr. 16
65185 Wiesbaden
Germany
Fon +49 611/9006951
Fax +49 611/9406125
Handelsregister: HRB 23156 Amtsgericht Wiesbaden
Steuernummer: 04323897052
USt-IdNr.: DE255806399
Geschäftsführer:
Filip Lyncker,
Armin Theis
More information about the FreeSWITCH-dev
mailing list