<HTML>
<HEAD>
<TITLE>Re: [Freeswitch-dev] Bridge problem...</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>OK, thanks. I&#8217;ll look at how mod_commands handles this.<BR>
<BR>
Also, I just realized that the problem is not that my handlers are not called but that the hangup isn&#8217;t happening. After everybody has literally hung up, using &#8220;show channels&#8221; still shows those two channels as active. They haven&#8217;t hung up yet. Using &#8220;hupall&#8221; and they hang up with my handlers being called. Somehow, the legs that I originate aren&#8217;t figuring out that the ends they connect to have hungup.<BR>
<BR>
I am calling the switch_core_session_rwunlock after the bridge completes.<BR>
<BR>
Thanks again...I&#8217;ll keep wrestling with it.<BR>
<BR>
Kevin<BR>
<BR>
<BR>
<BR>
<BR>
On 7/14/09 9:24 AM, &quot;Mathieu Rene&quot; &lt;mrene_lists@avgs.ca&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Try using an event hook on state hange instead of a state handler.<BR>
Or, if you don't need access to the session once its hung up, use a plain event handler.<BR>
<BR>
One thing you need to know about threads is that FS spaws its own thread per call. You can do your own stuff in as many threads as you want as long as you don't touch the media itself. Look at the source of api commands in mod_commands and you'll see how they interact with active calls.<BR>
<BR>
&nbsp;<BR>
Mathieu Rene<BR>
Avant-Garde Solutions Inc<BR>
Office: + 1 (514) 664-1044 x100<BR>
Cell: +1 (514) 664-1044 x200<BR>
mrene@avgs.ca<BR>
<BR>
<BR>
<BR>
&nbsp;<BR>
<BR>
Am 14-Jul-09 um 11:47 AM schrieb Kevin Snow:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'> Thanks for your help on this, I&#8217;m getting closer but still have something wrong. <BR>
&nbsp;<BR>
&nbsp;I changed the code to use the bridge function you mentioned. It does seem to work a little better as the multithreaded bridge sometimes had audio glitches that this method doesn&#8217;t<BR>
&nbsp;<BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const char* sessionUUID = switch_core_session_get_uuid(session);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const char* peerSessionUUID = switch_core_session_get_uuid(peer_session);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_status_t status = switch_ivr_uuid_bridge(sessionUUID, peerSessionUUID);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;bridge_common - Bridge complete (%d)\n&quot;,(int)status);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int addHandlerOK = switch_channel_add_state_handler( switch_core_session_get_channel(peer_session), &amp;bridge_common_state_handlers);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;+++++++++++++++++++++++++++++++++++++++++++++++++ ADDED HANDLER OK %d\n&quot;,addHandlerOK);<BR>
&nbsp;<BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'> This bridges fine and the call is working. The switch_ivr_uuid_bridge function returns immediately where the other blocked. I&#8217;m adding the handler back in and switch_channel_add_state_handler is returning a 1, which I seems OK. <BR>
&nbsp;<BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'> &nbsp;&nbsp;&nbsp;&nbsp;static switch_status_t my_hangup(switch_core_session_t *session)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;======================= HANGUP CALLED ============================\n&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return SWITCH_STATUS_SUCCESS;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static const switch_state_handler_table_t <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bridge_common_state_handlers =<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_init */ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_routing */ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_execute */ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_hangup */ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my_hangup,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_exchange_media */ NULL,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*.on_soft_execute */ &nbsp;&nbsp;NULL<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<BR>
&nbsp;<BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'> Not sure why but when the peer_session leg is hung up my_hangup routine is not called. <BR>
&nbsp;<BR>
&nbsp;One thing I should mention is that I&#8217;m originating these legs and bridging on a thread that I started. I believe that is somehow part of the problem. The situation I have is that a handset is picked up. I collect the digits dialed, when this is complete I&#8217;m creating a thread (this thread above) and having it create a leg to the number dialed and another known endpoint. I&#8217;m doing it on another thread because I want that handset to be able to hang up but leave this call in place. &nbsp;I am getting my hangup called on the handset (it&#8217;s not this above handler, it&#8217;s a different one I didn&#8217;t show you). If I leave the new thread out of this and just bridge the handset to the dialed number, I do get hangup called for both.<BR>
&nbsp;<BR>
&nbsp;Clearly, there is something I&#8217;m not understanding and have wrong here.<BR>
&nbsp;<BR>
&nbsp;Any ideas?<BR>
&nbsp;<BR>
&nbsp;Thanks in advance.<BR>
&nbsp;<BR>
&nbsp;Kevin<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;On 7/13/09 3:59 PM, &quot;Mathieu Rene&quot; &lt;mrene_lists@avgs.ca&gt; wrote:<BR>
&nbsp;<BR>
&nbsp;<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>On another note, switch_ivr_uuid_bridge() will flush the state handler table for both legs. You need to set them back after. <BR>
&nbsp;Note that event hooks aren't removed, so you can use switch_core_event_hook_add_state_change() (look in mod_limit for an example) to get a callback on state change.<BR>
&nbsp;<BR>
&nbsp;&nbsp;<BR>
&nbsp;Mathieu Rene<BR>
&nbsp;Avant-Garde Solutions Inc<BR>
&nbsp;Office: + 1 (514) 664-1044 x100<BR>
&nbsp;Cell: +1 (514) 664-1044 x200<BR>
&nbsp;mrene@avgs.ca<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;&nbsp;<BR>
&nbsp;<BR>
&nbsp;On 13-Jul-09, at 6:20 PM, Kevin Snow wrote:<BR>
&nbsp;<BR>
&nbsp;<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'> Hi,<BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;In my module (written in C) I spin up a session using the recipe you gave me a few weeks ago. I then use switch_ivr_originate twice to establish two endpoints and bridge them using switch_ivr_multi_threaded_bridge. I inherited some of this code, but I think it&#8217;s using the multithreaded bridge to be able to pass a DTMF callback. <BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;In any case, the above is working fine. My problem comes in when one of the ends hangsup, it&#8217;s not exiting the bridge function. It&#8217;s like the calls are still bridged (because I think they are). Running &#8220;show channels&#8221;, does in fact, show the two legs sitting there. Using the &#8220;hupall&#8221; command, does hang them up, handlers called and my world then shutsdown. <BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;I&#8217;m not sure what I have wrong here. Is there something special I need to do to detect when an endpoint hangup? <BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;Thanks<BR>
&nbsp;&nbsp;<BR>
&nbsp;&nbsp;Kevin <BR>
&nbsp;&nbsp;&nbsp;_______________________________________________<BR>
&nbsp;Freeswitch-dev mailing list<BR>
&nbsp;Freeswitch-dev@lists.freeswitch.org<BR>
&nbsp;<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><BR>
&nbsp;UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><BR>
&nbsp;<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
&nbsp;<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
&nbsp;<BR>
&nbsp;<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'>_______________________________________________<BR>
&nbsp;Freeswitch-dev mailing list<BR>
&nbsp;Freeswitch-dev@lists.freeswitch.org<BR>
&nbsp;<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><BR>
&nbsp;UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><BR>
&nbsp;<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
&nbsp;<BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'><BR>
&nbsp;</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'> <BR>
&nbsp;&nbsp;_______________________________________________<BR>
Freeswitch-dev mailing list<BR>
Freeswitch-dev@lists.freeswitch.org<BR>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><BR>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'>_______________________________________________<BR>
Freeswitch-dev mailing list<BR>
Freeswitch-dev@lists.freeswitch.org<BR>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><BR>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:10.0px'><BR>
</SPAN></FONT></FONT>
</BODY>
</HTML>