let codecs see current frame via the codec obj
This commit is contained in:
parent
d39269b217
commit
3812ebb958
|
@ -618,6 +618,7 @@ struct switch_codec {
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
struct switch_codec *next;
|
struct switch_codec *next;
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
|
switch_frame_t *cur_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
||||||
|
|
|
@ -376,6 +376,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
switch_codec_t *codec = use_codec->implementation?use_codec:read_frame->codec;
|
switch_codec_t *codec = use_codec->implementation?use_codec:read_frame->codec;
|
||||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||||
codec->session = session;
|
codec->session = session;
|
||||||
|
codec->cur_frame = read_frame;
|
||||||
status = switch_core_codec_decode(codec,
|
status = switch_core_codec_decode(codec,
|
||||||
session->read_codec,
|
session->read_codec,
|
||||||
read_frame->data,
|
read_frame->data,
|
||||||
|
@ -384,6 +385,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
|
session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate,
|
||||||
&read_frame->flags);
|
&read_frame->flags);
|
||||||
codec->session = NULL;
|
codec->session = NULL;
|
||||||
|
codec->cur_frame = NULL;
|
||||||
switch_thread_rwlock_unlock(session->bug_rwlock);
|
switch_thread_rwlock_unlock(session->bug_rwlock);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -627,12 +629,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
switch_assert(enc_frame != NULL);
|
switch_assert(enc_frame != NULL);
|
||||||
switch_assert(enc_frame->data != NULL);
|
switch_assert(enc_frame->data != NULL);
|
||||||
session->read_codec->session = session;
|
session->read_codec->session = session;
|
||||||
|
session->read_codec->cur_frame = enc_frame;
|
||||||
status = switch_core_codec_encode(session->read_codec,
|
status = switch_core_codec_encode(session->read_codec,
|
||||||
enc_frame->codec,
|
enc_frame->codec,
|
||||||
enc_frame->data,
|
enc_frame->data,
|
||||||
enc_frame->datalen,
|
enc_frame->datalen,
|
||||||
session->read_impl.actual_samples_per_second,
|
session->read_impl.actual_samples_per_second,
|
||||||
session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
|
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;
|
session->read_codec->session = NULL;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SWITCH_STATUS_RESAMPLE:
|
case SWITCH_STATUS_RESAMPLE:
|
||||||
|
@ -908,6 +912,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
if (frame->codec) {
|
if (frame->codec) {
|
||||||
session->raw_write_frame.datalen = session->raw_write_frame.buflen;
|
session->raw_write_frame.datalen = session->raw_write_frame.buflen;
|
||||||
frame->codec->session = session;
|
frame->codec->session = session;
|
||||||
|
frame->codec->cur_frame = frame;
|
||||||
status = switch_core_codec_decode(frame->codec,
|
status = switch_core_codec_decode(frame->codec,
|
||||||
session->write_codec,
|
session->write_codec,
|
||||||
frame->data,
|
frame->data,
|
||||||
|
@ -915,6 +920,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
session->write_impl.actual_samples_per_second,
|
session->write_impl.actual_samples_per_second,
|
||||||
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &frame->flags);
|
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &frame->flags);
|
||||||
frame->codec->session = NULL;
|
frame->codec->session = NULL;
|
||||||
|
frame->codec->cur_frame = NULL;
|
||||||
|
|
||||||
if (do_resample && status == SWITCH_STATUS_SUCCESS) {
|
if (do_resample && status == SWITCH_STATUS_SUCCESS) {
|
||||||
status = SWITCH_STATUS_RESAMPLE;
|
status = SWITCH_STATUS_RESAMPLE;
|
||||||
|
@ -1095,6 +1101,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
enc_frame = write_frame;
|
enc_frame = write_frame;
|
||||||
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
|
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
|
||||||
session->write_codec->session = session;
|
session->write_codec->session = session;
|
||||||
|
session->write_codec->cur_frame = frame;
|
||||||
status = switch_core_codec_encode(session->write_codec,
|
status = switch_core_codec_encode(session->write_codec,
|
||||||
frame->codec,
|
frame->codec,
|
||||||
enc_frame->data,
|
enc_frame->data,
|
||||||
|
@ -1102,9 +1109,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
session->write_impl.actual_samples_per_second,
|
session->write_impl.actual_samples_per_second,
|
||||||
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
|
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
|
||||||
session->write_codec->session = NULL;
|
session->write_codec->session = NULL;
|
||||||
|
session->write_codec->cur_frame = NULL;
|
||||||
|
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SWITCH_STATUS_RESAMPLE:
|
case SWITCH_STATUS_RESAMPLE:
|
||||||
resample++;
|
resample++;
|
||||||
|
@ -1199,6 +1204,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
rate = session->write_impl.actual_samples_per_second;
|
rate = session->write_impl.actual_samples_per_second;
|
||||||
}
|
}
|
||||||
session->write_codec->session = session;
|
session->write_codec->session = session;
|
||||||
|
session->write_codec->cur_frame = frame;
|
||||||
status = switch_core_codec_encode(session->write_codec,
|
status = switch_core_codec_encode(session->write_codec,
|
||||||
frame->codec,
|
frame->codec,
|
||||||
enc_frame->data,
|
enc_frame->data,
|
||||||
|
@ -1206,6 +1212,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
rate,
|
rate,
|
||||||
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
|
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
|
||||||
session->write_codec->session = NULL;
|
session->write_codec->session = NULL;
|
||||||
|
session->write_codec->cur_frame = NULL;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SWITCH_STATUS_RESAMPLE:
|
case SWITCH_STATUS_RESAMPLE:
|
||||||
|
|
Loading…
Reference in New Issue