提交 b91edd01 authored 作者: Anthony Minessale's avatar Anthony Minessale

update

git-svn-id: http://svn.freeswitch.org/svn/local/src/freeswitch@21 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 7362b108
...@@ -8,7 +8,7 @@ APR_CONFIG=$(prefix)/bin/apr-1-config ...@@ -8,7 +8,7 @@ APR_CONFIG=$(prefix)/bin/apr-1-config
AM_CFLAGS = $(shell $(APR_CONFIG) --cflags --cppflags --includes) AM_CFLAGS = $(shell $(APR_CONFIG) --cflags --cppflags --includes)
AM_LDFLAGS = $(shell $(APR_CONFIG) --link-ld --libs ) -Wl,-E -L$(PREFIX)/lib AM_LDFLAGS = $(shell $(APR_CONFIG) --link-ld --libs ) -Wl,-E -L$(PREFIX)/lib
AM_CFLAGS += -fPIC -Wall 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_MOD_DIR=\"$(PREFIX)/mod\"
AM_CFLAGS += -DSWITCH_PREFIX_DIR=\"$(PREFIX)\" AM_CFLAGS += -DSWITCH_PREFIX_DIR=\"$(PREFIX)\"
AM_CFLAGS += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" AM_CFLAGS += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
......
...@@ -136,7 +136,7 @@ MAKE = gmake ...@@ -136,7 +136,7 @@ MAKE = gmake
NAME = freeswitch NAME = freeswitch
PREFIX = $(prefix)/${NAME} PREFIX = $(prefix)/${NAME}
APR_CONFIG = $(prefix)/bin/apr-1-config 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 AM_LDFLAGS = $(shell $(APR_CONFIG) --link-ld --libs ) -Wl,-E -L$(PREFIX)/lib
libfreeswitch_la_SOURCES = \ libfreeswitch_la_SOURCES = \
......
...@@ -471,12 +471,14 @@ static void activate_rtp(struct private_object *tech_pvt) ...@@ -471,12 +471,14 @@ static void activate_rtp(struct private_object *tech_pvt)
tech_pvt->remote_sdp_audio_port, tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.codec_interface->ianacode, tech_pvt->read_codec.codec_interface->ianacode,
ms, ms,
ms * 15); ms * 15,
(ms / 1000) * 2);
if (tech_pvt->rtp_session) { if (tech_pvt->rtp_session) {
tech_pvt->ssrc = ccrtp4c_get_ssrc(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); 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); switch_set_flag(tech_pvt, TFLAG_RTP);
} else { } else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Oh oh?\n"); 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 ...@@ -522,8 +524,6 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
struct private_object *tech_pvt = NULL; struct private_object *tech_pvt = NULL;
size_t bytes = 0, samples = 0, frames=0, ms=0; size_t bytes = 0, samples = 0, frames=0, ms=0;
switch_channel *channel = NULL; switch_channel *channel = NULL;
switch_time_t reference, now;
int mult = 1;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
...@@ -550,35 +550,34 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram ...@@ -550,35 +550,34 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
assert(tech_pvt->rtp_session != NULL); assert(tech_pvt->rtp_session != NULL);
tech_pvt->read_frame.datalen = 0; 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) { 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 = int offset;
ccrtp4c_read(tech_pvt->rtp_session,
tech_pvt->read_frame.data, tech_pvt->read_frame.datalen = ccrtp4c_read(tech_pvt->rtp_session,
sizeof(tech_pvt->read_buf), tech_pvt->read_frame.data,
&tech_pvt->timestamp_recv))) { 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; bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
frames = (tech_pvt->read_frame.datalen / bytes); frames = (tech_pvt->read_frame.datalen / bytes);
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame; samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame; ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += samples; tech_pvt->timestamp_recv += samples;
break; 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); 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); //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 ...@@ -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); //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; tech_pvt->timestamp_send += (int)samples;
switch_clear_flag(tech_pvt, TFLAG_WRITING); switch_clear_flag(tech_pvt, TFLAG_WRITING);
...@@ -1084,7 +1083,6 @@ static void handle_answer(eXosip_event_t *event) ...@@ -1084,7 +1083,6 @@ static void handle_answer(eXosip_event_t *event)
assert(channel != NULL); assert(channel != NULL);
switch_channel_answer(channel); switch_channel_answer(channel);
} }
static void log_event(eXosip_event_t *je) static void log_event(eXosip_event_t *je)
......
...@@ -1087,7 +1087,7 @@ SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *s ...@@ -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_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_endpoint_interface *endpoint_interface;
const switch_event_handler_table *driver_event_handlers = NULL; const switch_event_handler_table *driver_event_handlers = NULL;
const switch_event_handler_table *application_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) ...@@ -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) { while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
if (state != laststate) { if (state != laststate) {
midstate = state;
switch ( state ) { switch ( state ) {
case CS_NEW: /* Just created, Waiting for first instructions */ case CS_NEW: /* Just created, Waiting for first instructions */
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State NEW\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State NEW\n");
...@@ -1131,10 +1134,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session) ...@@ -1131,10 +1134,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State HANGUP\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State HANGUP\n");
if (!driver_event_handlers->on_hangup || if (!driver_event_handlers->on_hangup ||
(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 || if (!application_event_handlers || !application_event_handlers->on_hangup ||
(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); switch_core_standard_on_hangup(session);
} }
} }
...@@ -1144,10 +1149,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *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"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
if (!driver_event_handlers->on_init || if (!driver_event_handlers->on_init ||
(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 || if (!application_event_handlers || !application_event_handlers->on_init ||
(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); switch_core_standard_on_init(session);
} }
} }
...@@ -1156,10 +1163,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *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"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State RING\n");
if (!driver_event_handlers->on_ring || if (!driver_event_handlers->on_ring ||
(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 || if (!application_event_handlers || !application_event_handlers->on_ring ||
(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); switch_core_standard_on_ring(session);
} }
} }
...@@ -1168,10 +1177,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *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"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State EXECUTE\n");
if (!driver_event_handlers->on_execute || if (!driver_event_handlers->on_execute ||
(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 || if (!application_event_handlers || !application_event_handlers->on_execute ||
(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); switch_core_standard_on_execute(session);
} }
} }
...@@ -1180,10 +1191,12 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *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"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State LOOPBACK\n");
if (!driver_event_handlers->on_loopback || if (!driver_event_handlers->on_loopback ||
(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 || if (!application_event_handlers || !application_event_handlers->on_loopback ||
(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); switch_core_standard_on_loopback(session);
} }
} }
...@@ -1192,19 +1205,22 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *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"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State TRANSMIT\n");
if (!driver_event_handlers->on_transmit || if (!driver_event_handlers->on_transmit ||
(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 || if (!application_event_handlers || !application_event_handlers->on_transmit ||
(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); switch_core_standard_on_transmit(session);
} }
} }
break; 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); switch_thread_cond_wait(session->cond, session->mutex);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论