diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index 52151b9681..f5d14137b7 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -129,7 +129,6 @@ SWITCH_DECLARE(void) switch_core_media_bug_flush(switch_media_bug_t *bug) bug->record_frame_size = 0; bug->record_pre_buffer_count = 0; - } SWITCH_DECLARE(void) switch_core_media_bug_inuse(switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep) @@ -207,7 +206,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b bug->record_pre_buffer_count++; return SWITCH_STATUS_FALSE; } - + + if (!bug->record_frame_size) { + if (do_read && do_write) { + switch_size_t frame_size; + switch_codec_implementation_t read_impl = { 0 }; + switch_codec_implementation_t other_read_impl = { 0 }; + switch_core_session_t *other_session; + + switch_core_session_get_read_impl(bug->session, &read_impl); + frame_size = read_impl.decoded_bytes_per_packet; + + if (switch_core_session_get_partner(bug->session, &other_session) == SWITCH_STATUS_SUCCESS) { + switch_core_session_get_read_impl(other_session, &other_read_impl); + switch_core_session_rwunlock(other_session); + + if (read_impl.decoded_bytes_per_packet < other_read_impl.decoded_bytes_per_packet) { + frame_size = other_read_impl.decoded_bytes_per_packet; + } + } + + bug->record_frame_size = frame_size; + } + } + + if (bug->record_frame_size) { if ((do_read && do_read < bug->record_frame_size) || (do_write && do_write < bug->record_frame_size)) { return SWITCH_STATUS_FALSE; @@ -220,16 +243,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b if (do_write && do_write > bug->record_frame_size) { do_write = bug->record_frame_size; } - } else { - if (do_read && do_write) { - if (do_read > do_write) { - do_read = do_write; - } else if (do_write > do_read) { - do_write = do_read; - } - - bug->record_frame_size = do_read; - } } fill_read = !do_read; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index f42104bdc3..6551158522 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -724,11 +724,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit } } + message->_file = NULL; message->_func = NULL; message->_line = 0; if (switch_channel_up_nosig(session->channel)) { + if (message->message_id == SWITCH_MESSAGE_INDICATE_BRIDGE || message->message_id == SWITCH_MESSAGE_INDICATE_UNBRIDGE) { + switch_core_media_bug_flush_all(session); + } + switch (message->message_id) { case SWITCH_MESSAGE_REDIRECT_AUDIO: case SWITCH_MESSAGE_INDICATE_ANSWER: