[Freeswitch-svn] [commit] r9445 - freeswitch/trunk/src/mod/applications/mod_fax

Freeswitch SVN agx at freeswitch.org
Thu Sep 4 12:25:24 EDT 2008


Author: agx
Date: Thu Sep  4 12:25:24 2008
New Revision: 9445

Modified:
   freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c

Log:
include latest debug things


Modified: freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c	Thu Sep  4 12:25:24 2008
@@ -220,14 +220,14 @@
 {
     switch_channel_t *channel;
     switch_codec_t *orig_read_codec = NULL;
-    switch_codec_t *orig_write_codec = NULL;
     switch_codec_t read_codec = {0};
     switch_codec_t write_codec = {0};
     switch_frame_t *read_frame = {0};
     switch_frame_t write_frame = {0};
     switch_status_t status;
     fax_state_t fax;
-    int16_t buf[512];
+	#define FAX_BUFFER_SIZE		4096
+    int16_t buf[FAX_BUFFER_SIZE];		//TODO original value: 512
     int tx = 0;
     /*TODO: int calling_party = FALSE; DEPRECATED */
     /* Channels variable parsing */
@@ -378,14 +378,11 @@
         goto done;
     }
 
-	// NEW
-    orig_write_codec = switch_core_session_get_write_codec(session);
-
     if (switch_core_codec_init(&write_codec, 
                                "L16", 
                                NULL, 
-                               orig_write_codec->implementation->samples_per_second, 
-                               orig_write_codec->implementation->microseconds_per_frame / 1000, 
+                               orig_read_codec->implementation->samples_per_second, 
+                               orig_read_codec->implementation->microseconds_per_frame / 1000, 
                                1, 
                                SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, 
                                NULL, 
@@ -412,14 +409,24 @@
             goto done;
         }
 
+		//DEBUG switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Frame Read: %d\n" , read_frame->samples);
+
         /* pass the new incoming audio frame to the fax_rx application */
-        fax_rx(&fax, (int16_t *)read_frame->data, read_frame->samples);
+        if( fax_rx(&fax, (int16_t *)read_frame->data, read_frame->samples) ) {
+			//TODO
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "FAX_RX error\n" );
+		}
+		//TODO
+		if (read_frame->samples > 256 ) 
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SAMPLES TOO BIG\n" );
+
         if ((tx = fax_tx(&fax, (int16_t *) &buf, write_codec.implementation->samples_per_frame)) < 0) {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fax Error\n");
+            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fax_Tx Error\n");
             goto done;
         }
+		//DEBUG switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fax   Tx  : %d %d\n" , tx, write_codec.implementation->samples_per_frame);
         
-        if (tx) {
+        if (tx!=0) {
             write_frame.datalen = tx * sizeof(int16_t);
             write_frame.samples = tx;
         
@@ -430,7 +437,11 @@
 				);
                 goto done;
             }
-        }
+			//DEBUG switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Frame TX  : %d %d\n" , write_frame.datalen, write_frame.samples);
+        } else {
+			// TODO
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "non trasmitting\n" );
+		}
     }
 
  done:
@@ -456,10 +467,6 @@
         switch_core_session_set_read_codec(session, orig_read_codec);
     }
 
-    if (orig_write_codec) {
-        switch_core_session_set_write_codec(session, orig_write_codec);
-    }
-
 }
 
 SWITCH_STANDARD_APP(txfax_function)



More information about the Freeswitch-svn mailing list