]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Tweaks to logging in spandsp
authorSteve Underwood <steveu@haswell.coppice.org>
Sat, 5 Oct 2013 08:07:19 +0000 (16:07 +0800)
committerSteve Underwood <steveu@haswell.coppice.org>
Sat, 5 Oct 2013 08:07:19 +0000 (16:07 +0800)
libs/spandsp/src/fax_modems.c
libs/spandsp/src/spandsp/bit_operations.h
libs/spandsp/src/spandsp/fax_modems.h
libs/spandsp/src/spandsp/t30_logging.h
libs/spandsp/src/t30.c
libs/spandsp/src/t30_logging.c

index 413a464330ff5cfd5b4fe261d81de0178fc4d6cd..f3c175eb8cb97c7fe2099c5cbeab3c5416b71441 100644 (file)
 
 #define HDLC_FRAMING_OK_THRESHOLD               5
 
+SPAN_DECLARE(const char *) fax_modem_to_str(int modem)
+{
+    switch (modem)
+    {
+    case FAX_MODEM_NONE:
+        return "None";
+    case FAX_MODEM_FLUSH:
+        return "Flush";
+    case FAX_MODEM_SILENCE_TX:
+        return "Silence Tx";
+    case FAX_MODEM_SILENCE_RX:
+        return "Silence Rx";
+    case FAX_MODEM_CED_TONE_TX:
+        return "CED Tx";
+    case FAX_MODEM_CNG_TONE_TX:
+        return "CNG Tx";
+    case FAX_MODEM_NOCNG_TONE_TX:
+        return "No CNG Tx";
+    case FAX_MODEM_CED_TONE_RX:
+        return "CED Rx";
+    case FAX_MODEM_CNG_TONE_RX:
+        return "CNG Rx";
+    case FAX_MODEM_V21_TX:
+        return "V.21 Tx";
+    case FAX_MODEM_V17_TX:
+        return "V.17 Tx";
+    case FAX_MODEM_V27TER_TX:
+        return "V.27ter Tx";
+    case FAX_MODEM_V29_TX:
+        return "V.29 Tx";
+    case FAX_MODEM_V21_RX:
+        return "V.21 Rx";
+    case FAX_MODEM_V17_RX:
+        return "V.17 Rx";
+    case FAX_MODEM_V27TER_RX:
+        return "V.27ter Rx";
+    case FAX_MODEM_V29_RX:
+        return "V.29 Rx";
+    }
+    /*endswitch*/
+    return "???";
+}
+/*- End of function --------------------------------------------------------*/
+
 static void fax_modems_hdlc_accept(void *user_data, const uint8_t *msg, int len, int ok)
 {
     fax_modems_state_t *s;
index 2deca2828aacc588ac4a7121a780b7f8a3abb36e..311408123e026dc203ab616a9d44d49c591f9319 100644 (file)
@@ -42,7 +42,7 @@ extern "C"
 /*! \brief Find the bit position of the highest set bit in a word
     \param bits The word to be searched
     \return The bit number of the highest set bit, or -1 if the word is zero. */
-static __inline__ int top_bit(unsigned int bits)
+static __inline__ int top_bit(uint32_t bits)
 {
 #if defined(SPANDSP_USE_86_ASM)
     int res;
@@ -141,7 +141,7 @@ static __inline__ int top_bit(unsigned int bits)
 /*! \brief Find the bit position of the lowest set bit in a word
     \param bits The word to be searched
     \return The bit number of the lowest set bit, or -1 if the word is zero. */
-static __inline__ int bottom_bit(unsigned int bits)
+static __inline__ int bottom_bit(uint32_t bits)
 {
     int res;
 
index 3c76022575a9743ebd790f3a20950bf5868e5e2e..73a85de9b45461f9dea489f978683ad17a294327 100644 (file)
@@ -59,6 +59,12 @@ extern "C"
 {
 #endif
 
+/*! Convert a FAX modem type to a short text description.
+    \brief Convert a FAX modem type to a short text description.
+    \param modem The modem code.
+    \return A pointer to the description. */
+SPAN_DECLARE(const char *) fax_modem_to_str(int modem);
+
 /* N.B. the following are currently a work in progress */
 SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len);
 SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len);
index 2dc9bb321c64ccb0ef602eb326b2ddd66d07c153..7122b1c6eb169d82aad61f63e75a70ec84c206c8 100644 (file)
@@ -53,6 +53,12 @@ SPAN_DECLARE(void) t30_decode_dis_dtc_dcs(t30_state_t *s, const uint8_t *dis, in
     \return A pointer to the description. */
 SPAN_DECLARE(const char *) t30_completion_code_to_str(int result);
 
+/*! Convert a T.30 modem type to a short text description.
+    \brief Convert a T.30 modem type to a short text description.
+    \param modem The modem code.
+    \return A pointer to the description. */
+SPAN_DECLARE(const char *) t30_modem_to_str(int modem);
+
 #if defined(__cplusplus)
 }
 #endif
index 7defb47d1534bb511252de76d0241e7ca8522212..de71d910673abe00d80ec976f6f94f9a29ef2a35 100644 (file)
@@ -421,7 +421,7 @@ static const struct
     { 7200, T30_MODEM_V29,      T30_SUPPORT_V29,    (DISBIT4 | DISBIT3)},
     { 4800, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, DISBIT4},
     { 2400, T30_MODEM_V27TER,   T30_SUPPORT_V27TER, 0},
-    {    0, 0, 0, 0}
+    {    0, 0,                  0,                  0}
 };
 
 static void queue_phase(t30_state_t *s, int phase);
@@ -437,6 +437,7 @@ static void decode_20digit_msg(t30_state_t *s, char *msg, const uint8_t *pkt, in
 static void decode_url_msg(t30_state_t *s, char *msg, const uint8_t *pkt, int len);
 static int decode_nsf_nss_nsc(t30_state_t *s, uint8_t *msg[], const uint8_t *pkt, int len);
 static void set_min_scan_time(t30_state_t *s);
+static int build_dcs(t30_state_t *s);
 static void timer_t2_start(t30_state_t *s);
 static void timer_t2a_start(t30_state_t *s);
 static void timer_t2b_start(t30_state_t *s);
@@ -470,6 +471,27 @@ static int find_fallback_entry(int dcs_code)
 }
 /*- End of function --------------------------------------------------------*/
 
+static int step_fallback_entry(t30_state_t *s)
+{
+    while (fallback_sequence[++s->current_fallback].bit_rate)
+    {
+        if ((fallback_sequence[s->current_fallback].which & s->current_permitted_modems))
+            break;
+    }
+    if (fallback_sequence[s->current_fallback].bit_rate == 0)
+    {
+        /* Reset the fallback sequence */
+        s->current_fallback = 0;
+        return -1;
+    }
+    /* We need to update the minimum scan time, in case we are in non-ECM mode. */
+    set_min_scan_time(s);
+    /* Now we need to rebuild the DCS message we will send. */
+    build_dcs(s);
+    return s->current_fallback;
+}
+/*- End of function --------------------------------------------------------*/
+
 static int terminate_operation_in_progress(t30_state_t *s)
 {
     /* Make sure any FAX in progress is tidied up. If the tidying up has
@@ -2242,23 +2264,6 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
 }
 /*- End of function --------------------------------------------------------*/
 
-static int step_fallback_entry(t30_state_t *s)
-{
-    while (fallback_sequence[++s->current_fallback].which)
-    {
-        if ((fallback_sequence[s->current_fallback].which & s->current_permitted_modems))
-            break;
-    }
-    if (fallback_sequence[s->current_fallback].which == 0)
-        return -1;
-    /* We need to update the minimum scan time, in case we are in non-ECM mode. */
-    set_min_scan_time(s);
-    /* Now we need to rebuild the DCS message we will send. */
-    build_dcs(s);
-    return s->current_fallback;
-}
-/*- End of function --------------------------------------------------------*/
-
 static void send_dcn(t30_state_t *s)
 {
     queue_phase(s, T30_PHASE_D_TX);
@@ -2710,6 +2715,13 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len)
             send_dcn(s);
             return -1;
         }
+        /* Start document transmission */
+        span_log(&s->logging,
+                 SPAN_LOG_FLOW,
+                 "Put document with modem (%d) %s at %dbps\n",
+                 fallback_sequence[s->current_fallback].modem_type,
+                 t30_modem_to_str(fallback_sequence[s->current_fallback].modem_type),
+                 fallback_sequence[s->current_fallback].bit_rate);
         s->retries = 0;
         send_dcs_sequence(s, true);
         return 0;
@@ -2773,9 +2785,10 @@ static int process_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
     /* Start document reception */
     span_log(&s->logging,
              SPAN_LOG_FLOW,
-             "Get document at %dbps, modem %d\n",
-             fallback_sequence[s->current_fallback].bit_rate,
-             fallback_sequence[s->current_fallback].modem_type);
+             "Get document with modem (%d) %s at %dbps\n",
+             fallback_sequence[s->current_fallback].modem_type,
+             t30_modem_to_str(fallback_sequence[s->current_fallback].modem_type),
+             fallback_sequence[s->current_fallback].bit_rate);
     if (s->rx_file[0] == '\0')
     {
         span_log(&s->logging, SPAN_LOG_FLOW, "No document to receive\n");
@@ -3439,7 +3452,6 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len
         if (step_fallback_entry(s) < 0)
         {
             /* We have fallen back as far as we can go. Give up. */
-            s->current_fallback = 0;
             t30_set_status(s, T30_ERR_CANNOT_TRAIN);
             send_dcn(s);
             break;
@@ -4091,7 +4103,6 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
             if (step_fallback_entry(s) < 0)
             {
                 /* We have fallen back as far as we can go. Give up. */
-                s->current_fallback = 0;
                 t30_set_status(s, T30_ERR_CANNOT_TRAIN);
                 send_dcn(s);
                 break;
@@ -4152,7 +4163,6 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
             if (step_fallback_entry(s) < 0)
             {
                 /* We have fallen back as far as we can go. Give up. */
-                s->current_fallback = 0;
                 t30_set_status(s, T30_ERR_CANNOT_TRAIN);
                 send_dcn(s);
                 break;
@@ -4186,7 +4196,6 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len)
                 if (step_fallback_entry(s) < 0)
                 {
                     /* We have fallen back as far as we can go. Give up. */
-                    s->current_fallback = 0;
                     t30_set_status(s, T30_ERR_CANNOT_TRAIN);
                     send_dcn(s);
                     break;
index a3dea97b2e2e598827f551fd90bd903a2bddaebe..51739999d1244d59a43c509c146eeabbe9a8f63e 100644 (file)
@@ -246,6 +246,36 @@ SPAN_DECLARE(const char *) t30_completion_code_to_str(int result)
 }
 /*- End of function --------------------------------------------------------*/
 
+SPAN_DECLARE(const char *) t30_modem_to_str(int modem)
+{
+    switch (modem)
+    {
+    case T30_MODEM_NONE:
+        return "None";
+    case T30_MODEM_PAUSE:
+        return "Pause";
+    case T30_MODEM_CED:
+        return "CED";
+    case T30_MODEM_CNG:
+        return "CNG";
+    case T30_MODEM_V21:
+        return "V.21";
+    case T30_MODEM_V27TER:
+        return "V.27ter";
+    case T30_MODEM_V29:
+        return "V.29";
+    case T30_MODEM_V17:
+        return "V.17";
+    case T30_MODEM_V34HDX:
+        return "V.34HDX";
+    case T30_MODEM_DONE:
+        return "Done";
+    }
+    /*endswitch*/
+    return "???";
+}
+/*- End of function --------------------------------------------------------*/
+
 SPAN_DECLARE(const char *) t30_frametype(uint8_t x)
 {
     switch (x)