diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 7f5fc1263d..125a0e8bb2 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -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 */ 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; /*! diff --git a/src/mod/codecs/mod_ilbc/mod_ilbc.c b/src/mod/codecs/mod_ilbc/mod_ilbc.c index fe3f889358..277e953913 100644 --- a/src/mod/codecs/mod_ilbc/mod_ilbc.c +++ b/src/mod/codecs/mod_ilbc/mod_ilbc.c @@ -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++) { diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index af51d10ef7..4c9b72b650 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -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; } diff --git a/src/switch_core.c b/src/switch_core.c index 03d5d3d991..a247724ac1 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -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, diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 12e6130d2b..49fd624a61 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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) {