I have the necessity to hangup a channel inside a media bug callback in a my custom module.<div><br><div>Currently, what I do is:</div><div><br></div><div><div>static switch_bool_t my_media_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)</div>
<div>{</div><div> struct my_custom_helper * my_helper = (struct my_custom_helper *) user_data;</div><div><br></div><div> switch (type) {</div></div><div> case SWITCH_ABC_TYPE_READ_REPLACE:</div><div> case SWITCH_ABC_TYPE_WRITE_REPLACE:</div>
<div> {</div><div> switch_frame_t *frame;</div><div><br></div><div> if (sth->read) {</div><div> frame = switch_core_media_bug_get_read_replace_frame(bug);</div><div> } else {</div>
<div> frame = switch_core_media_bug_get_write_replace_frame(bug);</div><div> }</div><div><br></div><div> /*</div><div> ....</div><div> media analysis</div><div> ....</div>
<div> */</div><div><br></div><div> if (to_hangup) {</div><div> switch_channel_t *channel = switch_core_session_get_channel(my_helper->session);</div><div><br></div><div> if (channel) {</div>
<div> switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);</div><div> }</div><div> }</div><div> }</div><div><br></div><div> return SWITCH_TRUE;</div><div>}</div>
<div><br></div><div><br></div><div>The dropped channel is a b-leg, previously bridged with an a-leg (incoming call).</div><div><br></div><div>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.</div>
<div>If I issue a fs_cli "show channels" I see that there are some calls dropped by my module showed in "ACTIVE" state.</div><div>What is wrong with my channel hangup?</div><div><br></div><div>Thanks in advance</div>
<div>Stephen </div>
</div>