[Freeswitch-users] Correct way to hangup a channel
    Stephen Wilde 
    wstephen80 at gmail.com
       
    Fri Nov 11 00:17:11 MSK 2011
    
    
  
I have the necessity to hangup a channel inside a media bug callback in a
my custom module.
Currently, what I do is:
static switch_bool_t my_media_callback(switch_media_bug_t *bug, void
*user_data, switch_abc_type_t type)
{
    struct my_custom_helper * my_helper = (struct my_custom_helper *)
user_data;
    switch (type) {
    case SWITCH_ABC_TYPE_READ_REPLACE:
    case SWITCH_ABC_TYPE_WRITE_REPLACE:
        {
            switch_frame_t *frame;
            if (sth->read) {
                frame = switch_core_media_bug_get_read_replace_frame(bug);
            } else {
                frame = switch_core_media_bug_get_write_replace_frame(bug);
            }
            /*
            ....
            media analysis
            ....
            */
            if (to_hangup) {
                switch_channel_t *channel =
switch_core_session_get_channel(my_helper->session);
                if (channel) {
                    switch_channel_hangup(channel,
SWITCH_CAUSE_NORMAL_CLEARING);
                }
            }
        }
    return SWITCH_TRUE;
}
The dropped channel is a b-leg, previously bridged with an a-leg (incoming
call).
Probably in my code there is an error because the code works fine and the
channel is correctly dropped but inside Freeswitch remain some "zombies"
calls.
If I issue a fs_cli  "show channels" I see that there are some calls
dropped by my module showed in "ACTIVE" state.
What is wrong with my channel hangup?
Thanks in advance
Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111110/b39c2a9d/attachment.html 
    
    
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list