only put session pointers in when its done from a codec that comes from a session and set it to the right one

This commit is contained in:
Anthony Minessale 2012-10-30 16:56:03 -05:00
parent f1bcc387a3
commit ab99143d5f
3 changed files with 21 additions and 12 deletions

View File

@ -1167,6 +1167,8 @@ static int activate_audio_rtp(struct private_object *tech_pvt)
r = 0;
goto end;
}
tech_pvt->transports[LDL_TPORT_RTP].read_codec.session = tech_pvt->session;
tech_pvt->transports[LDL_TPORT_RTP].read_frame.rate = tech_pvt->transports[LDL_TPORT_RTP].read_codec.implementation->samples_per_second;
tech_pvt->transports[LDL_TPORT_RTP].read_frame.codec = &tech_pvt->transports[LDL_TPORT_RTP].read_codec;
@ -1186,6 +1188,7 @@ static int activate_audio_rtp(struct private_object *tech_pvt)
r = 0;
goto end;
}
tech_pvt->transports[LDL_TPORT_RTP].write_codec.session = tech_pvt->session;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set Write Codec to %s@%d\n",
tech_pvt->transports[LDL_TPORT_RTP].codec_name, (int) tech_pvt->transports[LDL_TPORT_RTP].write_codec.implementation->samples_per_second);

View File

@ -3037,6 +3037,9 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
tech_pvt->read_codec.session = tech_pvt->session;
if (switch_core_codec_init_with_bitrate(&tech_pvt->write_codec,
tech_pvt->iananame,
@ -3052,6 +3055,8 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
tech_pvt->write_codec.session = tech_pvt->session;
switch_channel_set_variable(tech_pvt->channel, "sip_use_codec_name", tech_pvt->iananame);
switch_channel_set_variable(tech_pvt->channel, "sip_use_codec_fmtp", tech_pvt->rm_fmtp);
switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_codec_rate", "%d", tech_pvt->rm_rate);

View File

@ -375,8 +375,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
} else {
switch_codec_t *codec = use_codec->implementation?use_codec:read_frame->codec;
switch_thread_rwlock_rdlock(session->bug_rwlock);
codec->session = session;
codec->cur_frame = read_frame;
session->read_codec->cur_frame = read_frame;
status = switch_core_codec_decode(codec,
session->read_codec,
read_frame->data,
@ -384,8 +384,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
session->read_impl.actual_samples_per_second,
session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
&read_frame->flags);
codec->session = NULL;
codec->cur_frame = NULL;
session->read_codec->cur_frame = NULL;
switch_thread_rwlock_unlock(session->bug_rwlock);
}
@ -628,8 +628,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_assert(session->read_codec != NULL);
switch_assert(enc_frame != NULL);
switch_assert(enc_frame->data != NULL);
session->read_codec->session = session;
session->read_codec->cur_frame = enc_frame;
enc_frame->codec->cur_frame = enc_frame;
status = switch_core_codec_encode(session->read_codec,
enc_frame->codec,
enc_frame->data,
@ -637,7 +637,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
session->read_impl.actual_samples_per_second,
session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
session->read_codec->cur_frame = NULL;
session->read_codec->session = NULL;
enc_frame->codec->cur_frame = NULL;
switch (status) {
case SWITCH_STATUS_RESAMPLE:
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Fixme 1\n");
@ -911,17 +911,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
if (frame->codec) {
session->raw_write_frame.datalen = session->raw_write_frame.buflen;
frame->codec->session = session;
frame->codec->cur_frame = frame;
session->write_codec->cur_frame = frame;
status = switch_core_codec_decode(frame->codec,
session->write_codec,
frame->data,
frame->datalen,
session->write_impl.actual_samples_per_second,
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &frame->flags);
frame->codec->session = NULL;
frame->codec->cur_frame = NULL;
session->write_codec->cur_frame = NULL;
if (do_resample && status == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_RESAMPLE;
}
@ -1100,16 +1099,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
enc_frame = write_frame;
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
session->write_codec->session = session;
session->write_codec->cur_frame = frame;
frame->codec->cur_frame = frame;
status = switch_core_codec_encode(session->write_codec,
frame->codec,
enc_frame->data,
enc_frame->datalen,
session->write_impl.actual_samples_per_second,
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
session->write_codec->session = NULL;
session->write_codec->cur_frame = NULL;
frame->codec->cur_frame = NULL;
switch (status) {
case SWITCH_STATUS_RESAMPLE:
resample++;
@ -1203,17 +1203,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
} else {
rate = session->write_impl.actual_samples_per_second;
}
session->write_codec->session = session;
session->write_codec->cur_frame = frame;
frame->codec->cur_frame = frame;
status = switch_core_codec_encode(session->write_codec,
frame->codec,
enc_frame->data,
enc_frame->datalen,
rate,
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
session->write_codec->session = NULL;
session->write_codec->cur_frame = NULL;
session->write_codec->cur_frame = NULL;
frame->codec->cur_frame = NULL;
switch (status) {
case SWITCH_STATUS_RESAMPLE:
resample++;