]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweaks
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 17 Mar 2006 19:27:26 +0000 (19:27 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 17 Mar 2006 19:27:26 +0000 (19:27 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@867 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/codecs/mod_g729/mod_g729.c
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
src/switch_core.c

index 1ef51ed8e0f4fb1400d1cf2a75ca5cda44c1d15e..800d4dffde496e0a9c878732a778fbeff93894be 100644 (file)
@@ -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;
+               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 {
+                       divisor = plen = 10;
+               }
 
-               unsigned int new_len = 0;
+               if (encoded_data_len % divisor == 0) {
 
-               for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
+                       int loops = (int) encoded_data_len / divisor;
 
-                       g729_decoder(&context->decoder_object, ddp, edp, 10);
+                       char *edp = encoded_data;
 
-                       ddp += 80;
+                       short *ddp = decoded_data;
 
-                       edp += 10;
+                       int x;
 
-                       new_len += 160;
+                       unsigned int new_len = 0;
 
-               }
+                       for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
+                               g729_decoder(&context->decoder_object, ddp, edp, plen);
 
-               if (new_len <= *decoded_data_len) {
+                               ddp += 80;
+                               edp += divisor;
+                               new_len += 160;
+                       }
 
-                       *decoded_data_len = new_len;
+                       if (new_len <= *decoded_data_len) {
 
-               } else {
+                               *decoded_data_len = new_len;
 
-                       switch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!!\n");
+                       } else {
 
-                       return SWITCH_STATUS_FALSE;
+                               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);
index 4fe709018e800bce468a2686a1f5b21d09166249..8cfb620020c4660f99a8efd04db6585c9f436bb2 100644 (file)
@@ -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) {
index fc836e1149de20ab9d2947976f5965e8a002c7a9..9b7327e1d63a59dddfeac3de5b53c6c4e5673574 100644 (file)
@@ -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 =