]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
let codecs see current frame via the codec obj
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 29 Oct 2012 20:07:50 +0000 (15:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 29 Oct 2012 20:07:50 +0000 (15:07 -0500)
src/include/switch_module_interfaces.h
src/switch_core_io.c

index deb96e4d47dcbd320c840fde190f8eabbd997946..d9fa1b2abf0b73961c12981cb1e9cc3077649679 100644 (file)
@@ -618,6 +618,7 @@ struct switch_codec {
        switch_mutex_t *mutex;
        struct switch_codec *next;
        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 */
index 7dbfdb2ac8161ea527266519bba1f38df6f01e86..f175cf2e07b1fbf75c45036e0cad4706edcb8bdb 100644 (file)
@@ -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_thread_rwlock_rdlock(session->bug_rwlock);
                                        codec->session = session;
+                                       codec->cur_frame = read_frame;
                                        status = switch_core_codec_decode(codec,
                                                                                                          session->read_codec,
                                                                                                          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, 
                                                                                                          &read_frame->flags);
                                        codec->session = NULL;
+                                       codec->cur_frame = NULL;
                                        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->data != NULL);
                                session->read_codec->session = session;
+                               session->read_codec->cur_frame = enc_frame;
                                status = switch_core_codec_encode(session->read_codec,
                                                                                                  enc_frame->codec,
                                                                                                  enc_frame->data,
                                                                                                  enc_frame->datalen,
                                                                                                  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;
                                switch (status) {
                                case SWITCH_STATUS_RESAMPLE:
@@ -908,6 +912,7 @@ 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;
                status = switch_core_codec_decode(frame->codec,
                                                                                  session->write_codec,
                                                                                  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->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;
 
                if (do_resample && status == SWITCH_STATUS_SUCCESS) {
                        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;
                        session->enc_write_frame.datalen = session->enc_write_frame.buflen;
                        session->write_codec->session = session;
+                       session->write_codec->cur_frame = frame;
                        status = switch_core_codec_encode(session->write_codec,
                                                                                          frame->codec,
                                                                                          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->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;
                        switch (status) {
                        case SWITCH_STATUS_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;
                                }
                                session->write_codec->session = session;
+                               session->write_codec->cur_frame = frame;
                                status = switch_core_codec_encode(session->write_codec,
                                                                                                  frame->codec,
                                                                                                  enc_frame->data,
@@ -1206,6 +1212,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
                                                                                                  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;
 
                                switch (status) {
                                case SWITCH_STATUS_RESAMPLE: