]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add yucky hacks to make googletalk work with ilbc (shame on them)
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 19 Apr 2006 20:38:02 +0000 (20:38 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 19 Apr 2006 20:38:02 +0000 (20:38 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1204 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/mod/codecs/mod_ilbc/mod_ilbc.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/switch_core.c
src/switch_rtp.c

index 7f5fc1263d3d781515ebfee150a154b34c31c641..125a0e8bb2d0d0d485d3e8e0a49126a62164a0e0 100644 (file)
@@ -104,6 +104,7 @@ SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
        SWITCH_RTP_FLAG_SECURE       - Secure RTP
        SWITCH_RTP_FLAG_AUTOADJ      - Auto-Adjust the dest based on the source
        SWITCH_RTP_FLAG_RAW_WRITE    - Try to forward packets unscathed
+       SWITCH_RTP_FLAG_GOOGLEHACK   - Convert payload from 102 to 97
 </pre>
  */
 typedef enum {
@@ -112,7 +113,8 @@ typedef enum {
        SWITCH_RTP_FLAG_USE_TIMER = (1 << 2),
        SWITCH_RTP_FLAG_SECURE = (1 << 3),
        SWITCH_RTP_FLAG_AUTOADJ = (1 << 4),
-       SWITCH_RTP_FLAG_RAW_WRITE = (1 << 5)
+       SWITCH_RTP_FLAG_RAW_WRITE = (1 << 5),
+       SWITCH_RTP_FLAG_GOOGLEHACK = (1 << 6)
 } switch_rtp_flag_t;
 
 /*!
index fe3f88935857c53d4973bbdb519bcb30ec50a5f2..277e953913ff61a26735b06ba538af65455a5849 100644 (file)
@@ -161,7 +161,7 @@ static switch_status switch_ilbc_decode(switch_codec *codec,
                unsigned int new_len = 0;
                float buf[240];
 
-
+               printf("WTF %d\n", encoded_data_len);
                for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
                        iLBC_decode(buf, edp, &context->decoder, 1);
                        for(y = 0; y < context->dbytes / sizeof(short) ; y++) {
index af51d10ef7e734121975f58dc6b7c0326212db0d..4c9b72b650f6e1735eef2b0b171d93dcd3166416 100644 (file)
@@ -230,7 +230,7 @@ static int activate_rtp(struct private_object *tech_pvt)
                return 0;
        }
 
-       if (!strcasecmp(tech_pvt->codec_name, "ilbc")) {
+       if (!strncasecmp(tech_pvt->codec_name, "ilbc", 4)) {
                ms = 30;
        }
 
@@ -276,7 +276,7 @@ static int activate_rtp(struct private_object *tech_pvt)
                                                                                                 tech_pvt->codec_num,
                                                                                                 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
                                                                                                 tech_pvt->read_codec.implementation->microseconds_per_frame,
-                                                                                                SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ,
+                                                                                                SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_GOOGLEHACK,
                                                                                                 NULL,
                                                                                                 &err, switch_core_session_get_pool(tech_pvt->session)))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
@@ -357,6 +357,15 @@ static int do_candidates(struct private_object *tech_pvt, int force)
        return 0;
 }
 
+static char *lame(char *in)
+{
+       if (!strncasecmp(in, "ilbc", 4)) {
+               return "iLBC";
+       } else {
+               return in;
+       }
+}
+
 static int do_describe(struct private_object *tech_pvt, int force)
 {
        ldl_payload_t payloads[5];
@@ -380,15 +389,15 @@ static int do_describe(struct private_object *tech_pvt, int force)
        if (force || !switch_test_flag(tech_pvt, TFLAG_CODEC_READY)) {
                if (tech_pvt->codec_index < 0) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't have my codec yet here's one\n");
-                       tech_pvt->codec_name = tech_pvt->codecs[0]->iananame;
+                       tech_pvt->codec_name = lame(tech_pvt->codecs[0]->iananame);
                        tech_pvt->codec_num = tech_pvt->codecs[0]->ianacode;
                        tech_pvt->codec_index = 0;
                                        
-                       payloads[0].name = tech_pvt->codecs[0]->iananame;
+                       payloads[0].name = lame(tech_pvt->codecs[0]->iananame);
                        payloads[0].id = tech_pvt->codecs[0]->ianacode;
-                                       
+                       
                } else {
-                       payloads[0].name = tech_pvt->codecs[tech_pvt->codec_index]->iananame;
+                       payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
                        payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
                }
 
@@ -695,7 +704,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
        while (!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
                tech_pvt->read_frame.flags = 0;
                status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame);
-
+               
                if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
                        return SWITCH_STATUS_FALSE;
                }
index 03d5d3d991b14053fcc3e593b4c9ba9dd33d210f..a247724ac158a014661061da358fcce3a18e2118 100644 (file)
@@ -1194,6 +1194,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
        if (need_codec) {
                if (frame->codec) {
                        session->raw_write_frame.datalen = session->raw_write_frame.buflen;
+                       printf("ASS %u\n", frame->datalen);
 
                        status = switch_core_codec_decode(frame->codec,
                                                                                          session->write_codec,
index 12e6130d2b5ccd38adec64443ba1d451e76fd323..49fd624a61df18d466ab8de76f3345fc801f032d 100644 (file)
@@ -541,6 +541,9 @@ static int rtp_common_read(switch_rtp *rtp_session, switch_payload_t *payload_ty
                }
 
                if (rtp_session->recv_msg.header.version == 2) {
+                       if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
+                               rtp_session->recv_msg.header.pt = 97;
+                       }
                        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ) && rtp_session->from_addr->port && 
                                (rtp_session->from_addr->port != rtp_session->remote_port)) {
                                uint32_t old = rtp_session->remote_port;
@@ -679,6 +682,9 @@ static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datale
                bytes = sbytes;
        }
 
+       if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->send_msg.header.pt == 97) {
+               rtp_session->recv_msg.header.pt = 102;
+       }
        switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)send_msg, &bytes);
        
        if (rtp_session->ice_user) {