]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update wip
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 Mar 2007 21:21:42 +0000 (21:21 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 Mar 2007 21:21:42 +0000 (21:21 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4470 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_rtp.c

index 7992c33b38430420db6b4adaab9517c7e54730c2..2b1760c4dc861782947ea04f08e99627ab64fe77 100644 (file)
@@ -874,6 +874,8 @@ static void attach_private(switch_core_session_t *session,
        switch_core_session_add_stream(session, NULL);
        channel = switch_core_session_get_channel(session);
        
+       switch_channel_set_flag(channel, CF_ACCEPT_CNG);
+       
        switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
        switch_mutex_lock(tech_pvt->flag_mutex);
        tech_pvt->flags = profile->flags;
@@ -1891,14 +1893,15 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
 
        switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
+       if (!switch_test_flag(frame, SFF_CNG)) {
+               if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+                       bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+                       frames = ((int) frame->datalen / bytes);
+               } else
+                       frames = 1;
 
-       if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
-               bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-               frames = ((int) frame->datalen / bytes);
-       } else
-               frames = 1;
-
-       samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+               samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
+       }
 
 #if 0
        printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n",
index a93c5f514c5a90ceeb233095fc1934b487671d9a..228d23de1c318e463a16f44827b3573aa5125450 100644 (file)
@@ -1364,11 +1364,24 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
        void *data;
        uint32_t len;
        uint8_t mark = 0;
+       switch_payload_t payload;
 
        if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
                return -1;
        }
        
+       assert(frame != NULL);
+
+       if (switch_test_flag(frame, SFF_CNG)) {
+               payload = rtp_session->cng_pt;
+       } else {
+               payload = frame->payload;
+       }
+
+       if (payload) {
+               payload = rtp_session->payload;
+       }
+
        if (fwd && !packetize) {
                data = frame->packet;
                len = frame->packetlen;
@@ -1394,7 +1407,7 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
                rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
        }
 
-       return rtp_common_write(rtp_session, data, len, mark, rtp_session->payload, &frame->flags);
+       return rtp_common_write(rtp_session, data, len, mark, payload, &frame->flags);
 
 }