]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3172 this also fixes the incorrect usage of L16 on payload 10 which may or may...
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 21 Mar 2011 19:31:10 +0000 (14:31 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 21 Mar 2011 19:31:16 +0000 (14:31 -0500)
src/include/switch_types.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_pcm.c
src/switch_rtp.c

index 79494d89796587a1d4cb5c7928e6d5bb0b6eb1ce..3383a9d88cc7ba814606bb3e2187256bb9a135a8 100644 (file)
@@ -542,7 +542,7 @@ typedef enum {
        SWITCH_RTP_FLAG_BREAK = (1 << 10),
        SWITCH_RTP_FLAG_UDPTL = (1 << 11),
        SWITCH_RTP_FLAG_DATAWAIT = (1 << 12),
-       SWITCH_RTP_FLAG_BUGGY_2833 = (1 << 13),
+       SWITCH_RTP_FLAG_BYTESWAP = (1 << 13),
        SWITCH_RTP_FLAG_PASS_RFC2833 = (1 << 14),
        SWITCH_RTP_FLAG_AUTO_CNG = (1 << 15),
        SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 << 16),
index 44cf96b6e92cea1f51afe28f1bdcfbf77e50f44e..cbb8cb34852c625fd5dba875e95d496bac9e1668 100644 (file)
@@ -2965,6 +2965,17 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
                flags |= SWITCH_RTP_FLAG_AUTO_CNG;
        }
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+       if (!strcasecmp(tech_pvt->read_impl.iananame, "L16")) {
+               flags |= SWITCH_RTP_FLAG_BYTESWAP;
+       }
+#endif
+       
+       if ((flags & SWITCH_RTP_FLAG_BYTESWAP) && (val = switch_channel_get_variable(tech_pvt->channel, "rtp_disable_byteswap")) && switch_true(val)) {
+               flags &= ~SWITCH_RTP_FLAG_BYTESWAP;
+       }
+
+
        if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
                //const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
                //const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
index 8fbfefed10e75bfb35a276fb215befca6b151aed..f0dfe86da33d81cf65ddcbdf478f4f2d0be255bc 100644 (file)
@@ -374,7 +374,7 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
                }
                for (; countb > 0; countb--) {
                        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                                SWITCH_CODEC_TYPE_AUDIO, 10, "L16", NULL, rate, rate, bps,
+                                                                                                SWITCH_CODEC_TYPE_AUDIO, 70, "L16", NULL, rate, rate, bps,
                                                                                                 mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, spf * countb,
                                                                                                 switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
                }
@@ -391,7 +391,7 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
 
        for (x = 0; x < 5; x++) {
                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,    /* enumeration defining the type of the codec */
-                                                                                        10,    /* the IANA code number */
+                                                                                        70,    /* the IANA code number */
                                                                                         "L16", /* the IANA code name */
                                                                                         NULL,  /* default fmtp to send (can be overridden by the init function) */
                                                                                         12000, /* samples transferred per second */
index dbf6e7cceae82a6d838f74ccffb2a113de1f66d8..e33fc95eb173925e414254a2d27d406b7d5268d7 100644 (file)
@@ -2427,8 +2427,13 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
        status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes);
        ts = ntohl(rtp_session->recv_msg.header.ts);
 
-       if (*bytes ) {
+       if (*bytes) {
                uint16_t seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
+               
+               if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BYTESWAP) && rtp_session->recv_msg.header.pt == rtp_session->rpayload) {
+                       switch_swap_linear((int16_t *)rtp_session->recv_msg.body, (int) *bytes - rtp_header_len);
+               }
+
 
                if (rtp_session->last_seq && rtp_session->last_seq+1 != seq) {
 #ifdef DEBUG_MISSED_SEQ
@@ -3708,6 +3713,11 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
        if (send) {
                send_msg->header.seq = htons(++rtp_session->seq);
 
+               if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BYTESWAP) && send_msg->header.pt == rtp_session->payload) {
+                       switch_swap_linear((int16_t *)send_msg->body, (int) datalen);
+               }
+
+
                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
                        int sbytes = (int) bytes;
                        err_status_t stat;