fix FSCORE-212
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10189 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4c51457d72
commit
217c16602a
|
@ -45,6 +45,10 @@ SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void)
|
||||||
SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t *session)
|
SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
session->real_read_codec = session->read_codec = NULL;
|
session->real_read_codec = session->read_codec = NULL;
|
||||||
|
session->raw_read_frame.codec = session->read_codec;
|
||||||
|
session->raw_write_frame.codec = session->read_codec;
|
||||||
|
session->enc_read_frame.codec = session->read_codec;
|
||||||
|
session->enc_write_frame.codec = session->read_codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
|
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
|
||||||
|
@ -60,33 +64,37 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
|
||||||
char tmp[30];
|
char tmp[30];
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (!codec || !codec->implementation) {
|
if (codec && !codec->implementation) {
|
||||||
|
codec = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codec) {
|
||||||
|
if (!session->real_read_codec) {
|
||||||
|
session->read_codec = session->real_read_codec = codec;
|
||||||
|
session->read_impl = *codec->implementation;
|
||||||
|
} else {
|
||||||
|
session->read_codec = codec;
|
||||||
|
session->read_impl = *codec->implementation;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (session->read_codec == session->real_read_codec) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (session->real_read_codec) {
|
if (session->real_read_codec) {
|
||||||
session->read_codec = session->real_read_codec;
|
session->read_codec = session->real_read_codec;
|
||||||
|
session->read_impl = *session->real_read_codec->implementation;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Restore original codec.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Restore original codec.\n");
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set UNINITIALIZED codec!\n");
|
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!session->real_read_codec) {
|
|
||||||
session->read_codec = session->real_read_codec = codec;
|
|
||||||
} else {
|
|
||||||
session->read_codec = codec;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session->read_codec) {
|
if (!session->read_codec) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No READ codec!\n");
|
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
session->read_impl = *session->read_codec->implementation;
|
|
||||||
|
|
||||||
|
|
||||||
if (session->read_codec && session->read_impl.decoded_bytes_per_packet) {
|
if (session->read_codec && session->read_impl.decoded_bytes_per_packet) {
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_event_set_data(session->channel, event);
|
switch_channel_event_set_data(session->channel, event);
|
||||||
|
@ -101,8 +109,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
|
||||||
switch_channel_set_variable(channel, "read_codec", session->read_impl.iananame);
|
switch_channel_set_variable(channel, "read_codec", session->read_impl.iananame);
|
||||||
switch_snprintf(tmp, sizeof(tmp), "%d", session->read_impl.actual_samples_per_second);
|
switch_snprintf(tmp, sizeof(tmp), "%d", session->read_impl.actual_samples_per_second);
|
||||||
switch_channel_set_variable(channel, "read_rate", tmp);
|
switch_channel_set_variable(channel, "read_rate", tmp);
|
||||||
|
|
||||||
|
|
||||||
session->raw_read_frame.codec = session->read_codec;
|
session->raw_read_frame.codec = session->read_codec;
|
||||||
session->raw_write_frame.codec = session->read_codec;
|
session->raw_write_frame.codec = session->read_codec;
|
||||||
session->enc_read_frame.codec = session->read_codec;
|
session->enc_read_frame.codec = session->read_codec;
|
||||||
|
|
|
@ -445,6 +445,7 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses
|
||||||
switch_channel_set_private(channel, "_bridge_", NULL);
|
switch_channel_set_private(channel, "_bridge_", NULL);
|
||||||
if (bd->session == session && *bd->b_uuid) {
|
if (bd->session == session && *bd->b_uuid) {
|
||||||
audio_bridge_thread(NULL, (void *) bd);
|
audio_bridge_thread(NULL, (void *) bd);
|
||||||
|
switch_core_session_reset(session, SWITCH_TRUE);
|
||||||
} else {
|
} else {
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
}
|
}
|
||||||
|
@ -563,7 +564,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
|
||||||
switch_channel_clear_flag(channel, CF_TRANSFER);
|
switch_channel_clear_flag(channel, CF_TRANSFER);
|
||||||
switch_channel_clear_flag(other_channel, CF_TRANSFER);
|
switch_channel_clear_flag(other_channel, CF_TRANSFER);
|
||||||
switch_core_session_reset(session, SWITCH_TRUE);
|
switch_core_session_reset(session, SWITCH_TRUE);
|
||||||
switch_core_session_reset(other_session, SWITCH_TRUE);
|
|
||||||
|
|
||||||
ready_a = switch_channel_ready(channel);
|
ready_a = switch_channel_ready(channel);
|
||||||
ready_b = switch_channel_ready(other_channel);
|
ready_b = switch_channel_ready(other_channel);
|
||||||
|
|
Loading…
Reference in New Issue