switch_assert(decoded_data != NULL);
if (!codec->implementation || !switch_core_codec_ready(codec)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
- abort();
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decode Codec is not initialized!\n");
return SWITCH_STATUS_NOT_INITALIZED;
}
goto done;
}
- if (!switch_core_codec_ready(&session->bug_codec)) {
+ if (!switch_core_codec_ready(&session->bug_codec) && switch_core_codec_ready(read_frame->codec)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting BUG Codec %s:%d\n",
- read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode);
+ read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode);
switch_core_codec_copy(read_frame->codec, &session->bug_codec, NULL);
+ if (!switch_core_codec_ready(&session->bug_codec)) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Error setting BUG codec %s!\n",
+ switch_core_session_get_name(session), read_frame->codec->implementation->iananame);
+ }
+ }
+
+ if (switch_core_codec_ready(&session->bug_codec)) {
+ use_codec = &session->bug_codec;
}
- use_codec = &session->bug_codec;
switch_thread_rwlock_unlock(session->bug_rwlock);
switch_thread_rwlock_wrlock(session->bug_rwlock);
memset(session->raw_read_frame.data, 255, session->raw_read_frame.datalen);
status = SWITCH_STATUS_SUCCESS;
} else {
- switch_codec_t *codec = use_codec->implementation?use_codec:read_frame->codec;
+ switch_codec_t *codec = use_codec;
+
+ if (!switch_core_codec_ready(codec)) {
+ codec = read_frame->codec;
+ }
+
switch_thread_rwlock_rdlock(session->bug_rwlock);
codec->cur_frame = read_frame;
session->read_codec->cur_frame = read_frame;