From: Anthony Minessale Date: Mon, 21 Mar 2011 19:31:10 +0000 (-0500) Subject: FS-3172 this also fixes the incorrect usage of L16 on payload 10 which may or may... X-Git-Tag: v1.2-rc1~171^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e657e32fcac6f29fabfea8e38ce7a7dcf5beb8af;p=thirdparty%2Ffreeswitch.git FS-3172 this also fixes the incorrect usage of L16 on payload 10 which may or may not break interop with other sip devices if we do it right. also added rtp_disable_byteswap variable that can be set to false to disable byteswap when a device is encountered that is incompat (inluding all precious version of FS up till now) --- diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 79494d8979..3383a9d88c 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -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), diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 44cf96b6e9..cbb8cb3485 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -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); diff --git a/src/switch_pcm.c b/src/switch_pcm.c index 8fbfefed10..f0dfe86da3 100644 --- a/src/switch_pcm.c +++ b/src/switch_pcm.c @@ -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 */ diff --git a/src/switch_rtp.c b/src/switch_rtp.c index dbf6e7ccea..e33fc95eb1 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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;