add yucky hacks to make googletalk work with ilbc (shame on them)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1204 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-04-19 20:38:02 +00:00
parent 0aab549821
commit ed53c98d67
5 changed files with 27 additions and 9 deletions

View 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;
/*!

View 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++) {

View 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;
}

View 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,

View 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) {