]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 17 Nov 2005 16:21:58 +0000 (16:21 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 17 Nov 2005 16:21:58 +0000 (16:21 +0000)
git-svn-id: http://svn.freeswitch.org/svn/local/src/freeswitch@21 d0543943-73ff-0310-b7d9-9358b9ac24b2

Makefile.am
Makefile.in
src/mod/mod_exosip/mod_exosip.c
src/switch_core.c

index daf43fb0eea6cd4ccd8f61b588c32342184a8ab1..362f0d5d03b73c617c778e1fbef42ae674bbb36a 100644 (file)
@@ -8,7 +8,7 @@ APR_CONFIG=$(prefix)/bin/apr-1-config
 AM_CFLAGS  = $(shell $(APR_CONFIG) --cflags --cppflags --includes)
 AM_LDFLAGS = $(shell $(APR_CONFIG) --link-ld --libs ) -Wl,-E -L$(PREFIX)/lib
 AM_CFLAGS  += -fPIC -Wall
-AM_CFLAGS  +=-I$(PWD) -I$(PWD)/include -I$(PREFIX)/include
+AM_CFLAGS  +=-I$(PWD) -I$(PWD)/src/include -I$(PREFIX)/include
 AM_CFLAGS      += -DSWITCH_MOD_DIR=\"$(PREFIX)/mod\"
 AM_CFLAGS      += -DSWITCH_PREFIX_DIR=\"$(PREFIX)\"
 AM_CFLAGS      += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
index 38cc8b85bed25c628b9cfee291d171fbdee73529..e8382773a1cda9473e69c5bcd1ed8c45b48f0163 100644 (file)
@@ -136,7 +136,7 @@ MAKE = gmake
 NAME = freeswitch
 PREFIX = $(prefix)/${NAME}
 APR_CONFIG = $(prefix)/bin/apr-1-config
-AM_CFLAGS = $(shell $(APR_CONFIG) --cflags --cppflags --includes) -fPIC -Wall -I$(PWD) -I$(PWD)/include -I$(PREFIX)/include -DSWITCH_MOD_DIR=\"$(PREFIX)/mod\" -DSWITCH_PREFIX_DIR=\"$(PREFIX)\" -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
+AM_CFLAGS = $(shell $(APR_CONFIG) --cflags --cppflags --includes) -fPIC -Wall -I$(PWD) -I$(PWD)/src/include -I$(PREFIX)/include -DSWITCH_MOD_DIR=\"$(PREFIX)/mod\" -DSWITCH_PREFIX_DIR=\"$(PREFIX)\" -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
 AM_LDFLAGS = $(shell $(APR_CONFIG) --link-ld --libs ) -Wl,-E -L$(PREFIX)/lib
 
 libfreeswitch_la_SOURCES = \
index ac3526d24b4fb4eb51427d2786fb1b2e78a9e85b..00c67b2e9cc97b81e0cfc60d5ceeae974097e5c3 100644 (file)
@@ -471,12 +471,14 @@ static void activate_rtp(struct private_object *tech_pvt)
                                                                                tech_pvt->remote_sdp_audio_port,
                                                                                tech_pvt->read_codec.codec_interface->ianacode,
                                                                                ms,
-                                                                               ms * 15);
+                                                                               ms * 15,
+                                                                               (ms / 1000) * 2);
 
        if (tech_pvt->rtp_session) {
                tech_pvt->ssrc = ccrtp4c_get_ssrc(tech_pvt->rtp_session);
+               //tech_pvt->timestamp_recv = tech_pvt->timestamp_send = 
                ccrtp4c_start(tech_pvt->rtp_session);
-               tech_pvt->timestamp_recv = tech_pvt->timestamp_send = ccrtp4c_current_timestamp(tech_pvt->rtp_session);
+               switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Initial Timestamp %u\n", tech_pvt->timestamp_recv);
                switch_set_flag(tech_pvt, TFLAG_RTP);
        } else {
                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Oh oh?\n");
@@ -522,8 +524,6 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
        struct private_object *tech_pvt = NULL;
        size_t bytes = 0, samples = 0, frames=0, ms=0;
        switch_channel *channel = NULL;
-       switch_time_t reference, now;
-       int mult = 1;
 
        channel = switch_core_session_get_channel(session);
        assert(channel != NULL);
@@ -550,35 +550,34 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
                assert(tech_pvt->rtp_session != NULL);
                tech_pvt->read_frame.datalen = 0;
 
-               reference = switch_time_now();
-               reference += (ms * mult);
                while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
-                       if ((tech_pvt->read_frame.datalen = 
-                                ccrtp4c_read(tech_pvt->rtp_session,
-                                                         tech_pvt->read_frame.data,
-                                                         sizeof(tech_pvt->read_buf),
-                                                         &tech_pvt->timestamp_recv))) {
+                       int offset;
+
+                       tech_pvt->read_frame.datalen = ccrtp4c_read(tech_pvt->rtp_session,
+                                                                                                               tech_pvt->read_frame.data,
+                                                                                                               sizeof(tech_pvt->read_buf),
+                                                                                                               tech_pvt->timestamp_recv,
+                                                                                                               &offset);
+
+                       if (tech_pvt->read_frame.datalen > 0) {
                                bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
                                frames = (tech_pvt->read_frame.datalen / bytes);
                                samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
                                ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
                                tech_pvt->timestamp_recv += samples;
                                break;
+                       } else if (offset) {
+                               switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Timestamp behind by %d samples... auto-correcting\n", offset);
+                               tech_pvt->timestamp_recv += offset;
+                               continue;
                        }
                        
-                       now = switch_time_now();
-                       if (now >= reference) {
-                               //printf("TO\n");
-                               memset(tech_pvt->read_buf, 0, bytes * mult);
-                               tech_pvt->timestamp_recv += (samples * mult);
-                               reference += (ms * mult);
-                               tech_pvt->read_frame.datalen = bytes *2;
-                               break;
-                       }
-
                        switch_yield(100);
                }
-               
+
+               //tech_pvt->timestamp_recv += samples;
+
+
                //printf("%s %s->%s recv %d bytes %d samples in %d frames taking up %d ms ts=%d\n", switch_channel_get_name(channel), tech_pvt->local_sdp_audio_ip, tech_pvt->local_sdp_audio_ip, tech_pvt->read_frame.datalen, samples, frames, ms, tech_pvt->timestamp_recv);
                
 
@@ -646,7 +645,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
        //printf("%s %s->%s send %d bytes %d samples in %d frames taking up %d ms ts=%d\n", switch_channel_get_name(channel), tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, ms, tech_pvt->timestamp_send);
 
 
-       ccrtp4c_write(tech_pvt->rtp_session, frame->data, frame->datalen, &tech_pvt->timestamp_send);
+       ccrtp4c_write(tech_pvt->rtp_session, frame->data, frame->datalen, tech_pvt->timestamp_send);
        tech_pvt->timestamp_send += (int)samples;
 
        switch_clear_flag(tech_pvt, TFLAG_WRITING);
@@ -1084,7 +1083,6 @@ static void handle_answer(eXosip_event_t *event)
        assert(channel != NULL);
 
        switch_channel_answer(channel);
-
 }
 
 static void log_event(eXosip_event_t *je)
index 585fef5c1f74023e3aa0c9b6059efdfe2cda7a2a..2de1705c3b523f537f29fd78f8c94557f01d44b6 100644 (file)
@@ -1087,7 +1087,7 @@ SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *s
 
 SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
 {
-       switch_channel_state state = CS_NEW, laststate = CS_HANGUP;
+       switch_channel_state state = CS_NEW, laststate = CS_HANGUP, midstate = CS_DONE;
        const switch_endpoint_interface *endpoint_interface;
        const switch_event_handler_table *driver_event_handlers = NULL;
        const switch_event_handler_table *application_event_handlers = NULL;
@@ -1120,6 +1120,9 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
 
        while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
                if (state != laststate) {
+
+                       midstate = state;
+
                        switch ( state ) {
                        case CS_NEW: /* Just created, Waiting for first instructions */
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State NEW\n");
@@ -1131,10 +1134,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State HANGUP\n");
                                if (!driver_event_handlers->on_hangup ||
                                        (driver_event_handlers->on_hangup &&
-                                        driver_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_hangup ||
                                                (application_event_handlers->on_hangup &&
-                                                application_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_hangup(session);
                                        }
                                }
@@ -1144,10 +1149,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
                                if (!driver_event_handlers->on_init ||
                                        (driver_event_handlers->on_init &&
-                                        driver_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_init ||
                                                (application_event_handlers->on_init &&
-                                                application_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_init(session);
                                        }
                                }
@@ -1156,10 +1163,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State RING\n");
                                if (!driver_event_handlers->on_ring ||
                                        (driver_event_handlers->on_ring &&
-                                        driver_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_ring ||
                                                (application_event_handlers->on_ring &&
-                                                application_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_ring(session);
                                        }
                                }
@@ -1168,10 +1177,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State EXECUTE\n");
                                if (!driver_event_handlers->on_execute ||
                                        (driver_event_handlers->on_execute &&
-                                        driver_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_execute ||
                                                (application_event_handlers->on_execute &&
-                                                application_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_execute(session);
                                        }
                                }
@@ -1180,10 +1191,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State LOOPBACK\n");
                                if (!driver_event_handlers->on_loopback ||
                                        (driver_event_handlers->on_loopback &&
-                                        driver_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_loopback ||
                                                (application_event_handlers->on_loopback &&
-                                                application_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_loopback(session);
                                        }
                                }
@@ -1192,19 +1205,22 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State TRANSMIT\n");
                                if (!driver_event_handlers->on_transmit ||
                                        (driver_event_handlers->on_transmit &&
-                                        driver_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS)) {
+                                        driver_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS && 
+                                        midstate == switch_channel_get_state(session->channel))) {
                                        if (!application_event_handlers || !application_event_handlers->on_transmit ||
                                                (application_event_handlers->on_transmit &&
-                                                application_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS)) {
+                                                application_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS && 
+                                                midstate == switch_channel_get_state(session->channel))) {
                                                switch_core_standard_on_transmit(session);
                                        }
                                }
                                break;
                        }
-                       laststate = state;
+
+                       laststate = midstate;
                }
 
-               if (state < CS_DONE) {
+               if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
                        switch_thread_cond_wait(session->cond, session->mutex);
                }
        }