diff --git a/src/mod/codecs/mod_g729/mod_g729.c b/src/mod/codecs/mod_g729/mod_g729.c index 1ef51ed8e0..800d4dffde 100644 --- a/src/mod/codecs/mod_g729/mod_g729.c +++ b/src/mod/codecs/mod_g729/mod_g729.c @@ -57,7 +57,7 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla } else { if (encoding) { - g729_init_coder(&context->encoder_object, 0); + g729_init_coder(&context->encoder_object, 1); } if (decoding) { @@ -140,7 +140,8 @@ static switch_status switch_g729_decode(switch_codec *codec, { struct g729_context *context = codec->private_info; - + int divisor = 10; + int plen = 10; if (!context) { @@ -149,43 +150,52 @@ static switch_status switch_g729_decode(switch_codec *codec, } + if (encoded_data_len % 2 == 0) { - if (encoded_data_len % 10 == 0) { - - int loops = (int) encoded_data_len / 10; - - char *edp = encoded_data; - - short *ddp = decoded_data; - - int x; - - unsigned int new_len = 0; - - for (x = 0; x < loops && new_len < *decoded_data_len; x++) { - - g729_decoder(&context->decoder_object, ddp, edp, 10); - - ddp += 80; - - edp += 10; - - new_len += 160; - - } - - if (new_len <= *decoded_data_len) { - - *decoded_data_len = new_len; - + if (encoded_data_len % 12 == 0) { + return SWITCH_STATUS_BREAK; + //divisor = 12; + //plen = 10; + } else if (encoded_data_len % 10 != 0) { + //*decoded_data_len = (encoded_data_len / 2) * 160; + //memset(decoded_data, 255, *decoded_data_len); + return SWITCH_STATUS_BREAK; } else { - - switch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!!\n"); - - return SWITCH_STATUS_FALSE; - + divisor = plen = 10; } + if (encoded_data_len % divisor == 0) { + + int loops = (int) encoded_data_len / divisor; + + char *edp = encoded_data; + + short *ddp = decoded_data; + + int x; + + unsigned int new_len = 0; + + for (x = 0; x < loops && new_len < *decoded_data_len; x++) { + g729_decoder(&context->decoder_object, ddp, edp, plen); + + ddp += 80; + edp += divisor; + new_len += 160; + } + + if (new_len <= *decoded_data_len) { + + *decoded_data_len = new_len; + + } else { + + switch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!!\n"); + + return SWITCH_STATUS_FALSE; + + } + } } else { switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len); diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 4fe709018e..8cfb620020 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -712,7 +712,7 @@ static switch_status wanpipe_write_frame(switch_core_session *session, switch_fr write(tech_pvt->fd, bp, (int) globals.mtu); #endif towrite = bytes >= globals.mtu ? globals.mtu : bytes; - + //printf("write %d\n", towrite); res = sangoma_sendmsg_socket(tech_pvt->socket, &tech_pvt->hdrframe, sizeof(tech_pvt->hdrframe), bp, towrite, 0); if (res < 0) { diff --git a/src/switch_core.c b/src/switch_core.c index fc836e1149..9b7327e1d6 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1071,7 +1071,6 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio session->write_codec->implementation->samples_per_second, session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag); - switch (status) { case SWITCH_STATUS_RESAMPLE: write_frame = &session->raw_write_frame; @@ -1087,6 +1086,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio case SWITCH_STATUS_SUCCESS: write_frame = &session->raw_write_frame; break; + case SWITCH_STATUS_BREAK: + return SWITCH_STATUS_SUCCESS; + break; case SWITCH_STATUS_NOOP: write_frame = frame; status = SWITCH_STATUS_SUCCESS; @@ -1119,7 +1121,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio if (!session->raw_write_buffer) { size_t bytes = session->write_codec->implementation->bytes_per_frame * 10; switch_console_printf(SWITCH_CHANNEL_CONSOLE, - "Engaging Write Buffer at %d bytes to accomidate %d->%d\n", + "Engaging Write Buffer at %d bytes to accomodate %d->%d\n", bytes, write_frame->datalen, session->write_codec->implementation->bytes_per_frame); if ((status =