switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30];
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+
switch_mutex_lock(session->codec_read_mutex);
if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) {
session->read_codec = session->real_read_codec = codec;
session->read_impl = *codec->implementation;
} else {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n",
+ switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
+ codec->next = session->read_codec;
session->read_codec = codec;
session->read_impl = *codec->implementation;
}
if (session->read_codec == session->real_read_codec) {
goto end;
}
- if (session->real_read_codec) {
+
+ if (session->read_codec->next) {
+ switch_codec_t *old = session->read_codec;
+ session->read_codec = session->read_codec->next;
+ session->read_impl = *session->read_codec->implementation;
+ old->next = NULL;
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Restore previous codec %s:%d.\n",
+ switch_channel_get_name(session->channel),
+ session->read_codec->implementation->iananame, session->read_codec->implementation->ianacode);
+
+ } else if (session->real_read_codec) {
session->read_codec = session->real_read_codec;
session->read_impl = *session->real_read_codec->implementation;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Restore original codec.\n");
read_impl.number_of_channels,
read_impl.actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
status = SWITCH_STATUS_NOTFOUND;
continue;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
status = SWITCH_STATUS_GENERR;
continue;
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Setup timer failed!\n");
switch_core_codec_destroy(&codec);
switch_core_file_close(fh);
- switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
status = SWITCH_STATUS_GENERR;
continue;
}
switch_safe_free(abuf);
- switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
return status;
}
read_impl.number_of_channels,
read_impl.actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
return SWITCH_STATUS_NOTFOUND;
}
switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
timer_name = switch_channel_get_variable(channel, "timer_name");
- switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+ switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
read_codec = switch_core_session_get_read_codec(session);
rate = read_impl.actual_samples_per_second;