From 81cb064f4b378976529abc0490e6746869fc54a1 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 13 Apr 2006 16:19:49 +0000 Subject: [PATCH] fix stuff that was wrong git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1140 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_dingaling/mod_dingaling.c | 10 +++++++--- src/switch_rtp.c | 11 ++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 2f50c4edbb..5052ab7ba6 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -116,6 +116,7 @@ struct private_object { int32_t timestamp_send; int32_t timestamp_recv; int32_t timestamp_dtmf; + uint32_t last_read; char *codec_name; uint8_t codec_num; }; @@ -360,7 +361,7 @@ static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void tech_pvt->codec_num, tech_pvt->read_codec.implementation->encoded_bytes_per_frame, tech_pvt->read_codec.implementation->microseconds_per_frame, - 0, + SWITCH_RTP_FLAG_USE_TIMER, NULL, &err, switch_core_session_get_pool(tech_pvt->session)))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err); @@ -632,7 +633,10 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra } } - + if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) { + tech_pvt->read_frame.datalen = tech_pvt->last_read; + } + if (tech_pvt->read_frame.datalen > 0) { bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame; frames = (tech_pvt->read_frame.datalen / bytes); @@ -640,7 +644,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame; tech_pvt->timestamp_recv += (int32_t) samples; tech_pvt->read_frame.samples = (int) samples; - + tech_pvt->last_read = tech_pvt->read_frame.datalen; //printf("READ bytes=%d payload=%d frames=%d samples=%d ms=%d ts=%d sampcount=%d\n", (int)tech_pvt->read_frame.datalen, (int)payload, (int)frames, (int)samples, (int)ms, (int)tech_pvt->timestamp_recv, (int)tech_pvt->read_frame.samples); break; } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index e94a789db7..9f4c578dd3 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -268,6 +268,7 @@ SWITCH_DECLARE(switch_status) switch_rtp_create(switch_rtp **new_rtp_session, } rtp_session->pool = pool; + rtp_session->flags = flags; /* for from address on recvfrom calls */ switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool); @@ -493,15 +494,15 @@ static int rtp_common_read(switch_rtp *rtp_session, void *data, int *payload_typ } if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { - if ((switch_time_now() - rtp_session->next_read) > 1000) { /* We're late! We're Late!*/ - memset(&rtp_session->recv_msg, 0, 13); + memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD); rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD; *flags |= SFF_CNG; - /* RE-Sync the clock and return a CNG frame */ - rtp_session->next_read = switch_time_now() + rtp_session->ms_per_packet; - return 13; + /* Set the next waypoint and return a CNG frame */ + rtp_session->next_read += rtp_session->ms_per_packet; + *payload_type = SWITCH_RTP_CNG_PAYLOAD; + return SWITCH_RTP_CNG_PAYLOAD; } if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {