]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix stuff that was wrong
authorMichael Jerris <mike@jerris.com>
Thu, 13 Apr 2006 16:19:49 +0000 (16:19 +0000)
committerMichael Jerris <mike@jerris.com>
Thu, 13 Apr 2006 16:19:49 +0000 (16:19 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1140 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/switch_rtp.c

index 2f50c4edbbb11f266865efd3404748b1633dfb70..5052ab7ba6eec4400b97bf839fbb89490a0e37c6 100644 (file)
@@ -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;
                }
index e94a789db7c3878ad7beeaf0bdd896b4c9fcfa4a..9f4c578dd3acac3fe10841d16e32a5b7ee27eed9 100644 (file)
@@ -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) {