update to snapshot spandsp-20090212

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12187 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris committed 2009-02-20 18:25:22 +00:00
1 parent 6cd7446a20
commit 374a129094
22 files changed
+185 -91

No files matched your search

+35 -12
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: hdlc.c,v 1.70 2009/02/10 13:06:46 steveu Exp $
* $Id: hdlc.c,v 1.71 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -43,10 +43,19 @@
#include "spandsp/hdlc.h"
#include "spandsp/private/hdlc.h"
static void rx_special_condition(hdlc_rx_state_t *s, int condition)
static void report_status_change(hdlc_rx_state_t *s, int status)
{
if (s->status_handler)
s->status_handler(s->status_user_data, status);
else if (s->frame_handler)
s->frame_handler(s->frame_user_data, NULL, status, TRUE);
}
/*- End of function --------------------------------------------------------*/
static void rx_special_condition(hdlc_rx_state_t *s, int status)
{
/* Special conditions */
switch (condition)
switch (status)
{
case SIG_STATUS_CARRIER_UP:
case SIG_STATUS_TRAINING_SUCCEEDED:
@@ -61,7 +70,7 @@ static void rx_special_condition(hdlc_rx_state_t *s, int condition)
case SIG_STATUS_TRAINING_FAILED:
case SIG_STATUS_CARRIER_DOWN:
case SIG_STATUS_END_OF_DATA:
s->frame_handler(s->user_data, NULL, condition, TRUE);
report_status_change(s, status);
break;
default:
//printf("Eh!\n");
@@ -82,7 +91,7 @@ static __inline__ void octet_set_and_count(hdlc_rx_state_t *s)
if (--s->octet_count <= 0)
{
s->octet_count = s->octet_count_report_interval;
s->frame_handler(s->user_data, NULL, SIG_STATUS_OCTET_REPORT, TRUE);
report_status_change(s, SIG_STATUS_OCTET_REPORT);
}
}
else
@@ -105,7 +114,7 @@ static __inline__ void octet_count(hdlc_rx_state_t *s)
if (--s->octet_count <= 0)
{
s->octet_count = s->octet_count_report_interval;
s->frame_handler(s->user_data, NULL, SIG_STATUS_OCTET_REPORT, TRUE);
report_status_change(s, SIG_STATUS_OCTET_REPORT);
}
}
}
@@ -117,7 +126,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
{
/* Hit HDLC abort */
s->rx_aborts++;
s->frame_handler(s->user_data, NULL, SIG_STATUS_ABORT, TRUE);
report_status_change(s, SIG_STATUS_ABORT);
/* If we have not yet seen enough flags, restart the count. If we
are beyond that point, just back off one step, so we need to see
another flag before proceeding to collect frame octets. */
@@ -147,7 +156,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->rx_frames++;
s->rx_bytes += s->len - s->crc_bytes;
s->len -= s->crc_bytes;
s->frame_handler(s->user_data, s->buffer, s->len, TRUE);
s->frame_handler(s->frame_user_data, s->buffer, s->len, TRUE);
}
else
{
@@ -155,7 +164,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
if (s->report_bad_frames)
{
s->len -= s->crc_bytes;
s->frame_handler(s->user_data, s->buffer, s->len, FALSE);
s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE);
}
}
}
@@ -170,7 +179,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->len -= s->crc_bytes;
else
s->len = 0;
s->frame_handler(s->user_data, s->buffer, s->len, FALSE);
s->frame_handler(s->frame_user_data, s->buffer, s->len, FALSE);
}
s->rx_length_errors++;
}
@@ -194,7 +203,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
}
if (++s->flags_seen >= s->framing_ok_threshold && !s->framing_ok_announced)
{
s->frame_handler(s->user_data, NULL, SIG_STATUS_FRAMING_OK, TRUE);
report_status_change(s, SIG_STATUS_FRAMING_OK);
s->framing_ok_announced = TRUE;
}
}
@@ -309,7 +318,7 @@ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s,
}
memset(s, 0, sizeof(*s));
s->frame_handler = handler;
s->user_data = user_data;
s->frame_user_data = user_data;
s->crc_bytes = (crc32) ? 4 : 2;
s->report_bad_frames = report_bad_frames;
s->framing_ok_threshold = (framing_ok_threshold < 1) ? 1 : framing_ok_threshold;
@@ -318,6 +327,20 @@ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s,
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) hdlc_rx_set_frame_handler(hdlc_rx_state_t *s, hdlc_frame_handler_t handler, void *user_data)
{
s->frame_handler = handler;
s->frame_user_data = user_data;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_rx_status_func_t handler, void *user_data)
{
s->status_handler = handler;
s->status_user_data = user_data;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) hdlc_rx_release(hdlc_rx_state_t *s)
{
return 0;
+3 -3
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: logging.c,v 1.31 2009/02/10 13:06:46 steveu Exp $
* $Id: logging.c,v 1.32 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
@@ -241,7 +241,7 @@ SPAN_DECLARE(void) span_set_error_handler(error_handler_func_t func)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) span_log_init(logging_state_t *s, int level, const char *tag)
SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, const char *tag)
{
if (s == NULL)
{
@@ -256,7 +256,7 @@ SPAN_DECLARE(int) span_log_init(logging_state_t *s, int level, const char *tag)
s->samples_per_second = SAMPLE_RATE;
s->elapsed_samples = 0;
return 0;
return s;
}
/*- End of function --------------------------------------------------------*/
+2 -2
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: spandsp.h.in,v 1.16 2009/02/03 16:28:40 steveu Exp $
* $Id: spandsp.h.in,v 1.17 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -69,8 +69,8 @@
#include <spandsp/echo.h>
#include <spandsp/modem_echo.h>
#include <spandsp/crc.h>
#include <spandsp/hdlc.h>
#include <spandsp/async.h>
#include <spandsp/hdlc.h>
#include <spandsp/noise.h>
#include <spandsp/saturated.h>
#include <spandsp/time_scale.h>
+2 -2
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: spandsp.h.in,v 1.16 2009/02/03 16:28:40 steveu Exp $
* $Id: spandsp.h.in,v 1.17 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -69,8 +69,8 @@
#include <spandsp/echo.h>
#include <spandsp/modem_echo.h>
#include <spandsp/crc.h>
#include <spandsp/hdlc.h>
#include <spandsp/async.h>
#include <spandsp/hdlc.h>
#include <spandsp/noise.h>
#include <spandsp/saturated.h>
#include <spandsp/time_scale.h>
+3 -3
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: async.h,v 1.23 2009/02/10 13:06:47 steveu Exp $
* $Id: async.h,v 1.24 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -100,10 +100,10 @@ typedef void (*put_bit_func_t)(void *user_data, int bit);
typedef int (*get_bit_func_t)(void *user_data);
/*! Completion callback function for tx data pumps */
typedef int (*modem_tx_status_func_t)(void *user_data, int status);
typedef void (*modem_tx_status_func_t)(void *user_data, int status);
/*! Completion callback function for rx data pumps */
typedef int (*modem_rx_status_func_t)(void *user_data, int status);
typedef void (*modem_rx_status_func_t)(void *user_data, int status);
enum
{
+25 -1
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: hdlc.h,v 1.43 2009/02/10 13:06:47 steveu Exp $
* $Id: hdlc.h,v 1.44 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -101,8 +101,32 @@ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s,
hdlc_frame_handler_t handler,
void *user_data);
/*! Change the put_bit function associated with an HDLC receiver context.
\brief Change the put_bit function associated with an HDLC receiver context.
\param s A pointer to an HDLC receiver context.
\param handler The function to be called when a good HDLC frame is received.
\param user_data An opaque parameter for the callback routine.
*/
SPAN_DECLARE(void) hdlc_rx_set_frame_handler(hdlc_rx_state_t *s, hdlc_frame_handler_t handler, void *user_data);
/*! Change the status report function associated with an HDLC receiver context.
\brief Change the status report function associated with an HDLC receiver context.
\param s A pointer to an HDLC receiver context.
\param handler The callback routine used to report status changes.
\param user_data An opaque parameter for the callback routine.
*/
SPAN_DECLARE(void) hdlc_rx_set_status_handler(hdlc_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
/*! Release an HDLC receiver context.
\brief Release an HDLC receiver context.
\param s A pointer to an HDLC receiver context.
\return 0 for OK */
SPAN_DECLARE(int) hdlc_rx_release(hdlc_rx_state_t *s);
/*! Free an HDLC receiver context.
\brief Free an HDLC receiver context.
\param s A pointer to an HDLC receiver context.
\return 0 for OK */
SPAN_DECLARE(int) hdlc_rx_free(hdlc_rx_state_t *s);
/*! \brief Set the maximum frame length for an HDLC receiver context.
+2 -2
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: logging.h,v 1.19 2009/02/10 13:06:47 steveu Exp $
* $Id: logging.h,v 1.20 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
@@ -127,7 +127,7 @@ SPAN_DECLARE(void) span_set_message_handler(message_handler_func_t func);
SPAN_DECLARE(void) span_set_error_handler(error_handler_func_t func);
SPAN_DECLARE(int) span_log_init(logging_state_t *s, int level, const char *tag);
SPAN_DECLARE(logging_state_t *) span_log_init(logging_state_t *s, int level, const char *tag);
SPAN_DECLARE(int) span_log_release(logging_state_t *s);
+7 -3
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: hdlc.h,v 1.2 2009/01/31 08:48:11 steveu Exp $
* $Id: hdlc.h,v 1.3 2009/02/12 12:38:39 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_HDLC_H_)
@@ -39,8 +39,12 @@ struct hdlc_rx_state_s
size_t max_frame_len;
/*! \brief The callback routine called to process each good received frame. */
hdlc_frame_handler_t frame_handler;
/*! \brief An opaque parameter passed to the callback routine. */
void *user_data;
/*! \brief An opaque parameter passed to the frame callback routine. */
void *frame_user_data;
/*! \brief The callback routine called to report status changes. */
modem_rx_status_func_t status_handler;
/*! \brief An opaque parameter passed to the status callback routine. */
void *status_user_data;
/*! \brief TRUE if bad frames are to be reported. */
int report_bad_frames;
/*! \brief The number of consecutive flags which must be seen before framing is
+5 -1
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: t31.h,v 1.6 2009/01/16 15:13:16 steveu Exp $
* $Id: t31.h,v 1.7 2009/02/12 12:38:39 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T31_H_)
@@ -103,6 +103,10 @@ typedef struct
int extra_bits;
} hdlc_tx;
/*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary
with clunky class 1 modems. */
int ecm_mode;
/*! \brief Counter for trailing non-ECM bytes, used to flush out the far end's modem. */
int non_ecm_trailer_bytes;
+2 -2
View File
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
#define SPANDSP_RELEASE_DATE 20090210
#define SPANDSP_RELEASE_TIME 172413
#define SPANDSP_RELEASE_DATE 20090212
#define SPANDSP_RELEASE_TIME 142337
#endif
/*- End of file ------------------------------------------------------------*/
+2 -2
View File
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: super_tone_tx.c,v 1.29 2009/02/10 13:06:46 steveu Exp $
* $Id: super_tone_tx.c,v 1.30 2009/02/10 17:44:18 steveu Exp $
*/
/*! \file */
@@ -120,7 +120,7 @@ SPAN_DECLARE(int) super_tone_tx_free_tone(super_tone_tx_step_t *s)
{
/* Follow nesting... */
if (s->nest)
super_tone_tx_free(s->nest);
super_tone_tx_free_tone(s->nest);
t = s;
s = s->next;
free(t);
+60 -12
View File
@@ -25,7 +25,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: t31.c,v 1.140 2009/02/10 13:06:46 steveu Exp $
* $Id: t31.c,v 1.142 2009/02/12 14:14:58 steveu Exp $
*/
/*! \file */
@@ -82,6 +82,7 @@
#include "spandsp/at_interpreter.h"
#include "spandsp/fax_modems.h"
#include "spandsp/t31.h"
#include "spandsp/t30_fcf.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/t38_core.h"
@@ -115,9 +116,24 @@
typedef const char *(*at_cmd_service_t)(t31_state_t *s, const char *cmd);
#define ETX 0x03
#define DLE 0x10
#define SUB 0x1A
enum
{
ETX = 0x03,
DLE = 0x10,
SUB = 0x1A
};
enum
{
DISBIT1 = 0x01,
DISBIT2 = 0x02,
DISBIT3 = 0x04,
DISBIT4 = 0x08,
DISBIT5 = 0x10,
DISBIT6 = 0x20,
DISBIT7 = 0x40,
DISBIT8 = 0x80
};
/* BEWARE: right now this must match up with a list in the AT interpreter code. */
enum
@@ -159,12 +175,17 @@ enum
T38_TIMED_STEP_HDLC_MODEM_3 = 0x22,
T38_TIMED_STEP_HDLC_MODEM_4 = 0x23,
T38_TIMED_STEP_HDLC_MODEM_5 = 0x24,
T38_TIMED_STEP_CED = 0x30,
T38_TIMED_STEP_CED_2 = 0x31,
T38_TIMED_STEP_CED_3 = 0x32,
T38_TIMED_STEP_CNG = 0x40,
T38_TIMED_STEP_CNG_2 = 0x41,
T38_TIMED_STEP_PAUSE = 0x50
T38_TIMED_STEP_FAKE_HDLC_MODEM = 0x30,
T38_TIMED_STEP_FAKE_HDLC_MODEM_2 = 0x31,
T38_TIMED_STEP_FAKE_HDLC_MODEM_3 = 0x32,
T38_TIMED_STEP_FAKE_HDLC_MODEM_4 = 0x33,
T38_TIMED_STEP_FAKE_HDLC_MODEM_5 = 0x34,
T38_TIMED_STEP_CED = 0x40,
T38_TIMED_STEP_CED_2 = 0x41,
T38_TIMED_STEP_CED_3 = 0x42,
T38_TIMED_STEP_CNG = 0x50,
T38_TIMED_STEP_CNG_2 = 0x51,
T38_TIMED_STEP_PAUSE = 0x60
};
static int restart_modem(t31_state_t *s, int new_modem);
@@ -186,6 +207,30 @@ static __inline__ void t31_set_at_rx_mode(t31_state_t *s, int new_mode)
}
/*- End of function --------------------------------------------------------*/
#if 0
static void monitor_control_messages(t31_state_t *s, const uint8_t *buf, int len)
{
/* Monitor the control messages, at the point where we have the whole message, so we can
see what is happening to things like training success/failure. */
span_log(&s->logging, SPAN_LOG_FLOW, "Monitoring %s\n", t30_frametype(buf[2]));
if (len < 3)
return;
/*endif*/
switch (buf[2])
{
case T30_DCS:
case T30_DCS | 1:
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
s->t38_fe.ecm_mode = (len >= 7) && (buf[6] & DISBIT3);
break;
default:
break;
}
/*endswitch*/
}
/*- End of function --------------------------------------------------------*/
#endif
static void front_end_status(t31_state_t *s, int status)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Front end status %d\n", status);
@@ -980,6 +1025,9 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples)
case T38_TIMED_STEP_HDLC_MODEM:
delay = stream_hdlc(s);
break;
//case T38_TIMED_STEP_FAKE_HDLC_MODEM:
// delay = stream_fake_hdlc(s);
// break;
case T38_TIMED_STEP_CED:
delay = stream_ced(s);
break;
@@ -2244,7 +2292,7 @@ static int v29_v21_rx(void *user_data, const int16_t amp[], int len)
}
/*- End of function --------------------------------------------------------*/
static void t31_fax_modems_init(fax_modems_state_t *s, int use_tep, void *user_data)
static fax_modems_state_t *t31_fax_modems_init(fax_modems_state_t *s, int use_tep, void *user_data)
{
s->use_tep = use_tep;
@@ -2273,6 +2321,7 @@ static void t31_fax_modems_init(fax_modems_state_t *s, int use_tep, void *user_d
s->rx_user_data = NULL;
s->tx_handler = (span_tx_handler_t *) &silence_gen;
s->tx_user_data = &s->silence_gen;
return s;
}
/*- End of function --------------------------------------------------------*/
@@ -2458,7 +2507,6 @@ static int t31_t38_fe_init(t31_state_t *t,
2,
NULL,
NULL);
return 0;
}
/*- End of function --------------------------------------------------------*/
+8 -5
View File
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: t38_gateway.c,v 1.154 2009/02/10 13:06:46 steveu Exp $
* $Id: t38_gateway.c,v 1.155 2009/02/12 12:38:39 steveu Exp $
*/
/*! \file */
@@ -747,7 +747,10 @@ static void edit_control_messages(t38_gateway_state_t *s, int from_modem, uint8_
}
/*- End of function --------------------------------------------------------*/
static void monitor_control_messages(t38_gateway_state_t *s, int from_modem, uint8_t *buf, int len)
static void monitor_control_messages(t38_gateway_state_t *s,
int from_modem,
const uint8_t *buf,
int len)
{
static const struct
{
@@ -1704,7 +1707,7 @@ static void hdlc_rx_status(hdlc_rx_state_t *t, int status)
{
t38_gateway_state_t *s;
s = (t38_gateway_state_t *) t->user_data;
s = (t38_gateway_state_t *) t->frame_user_data;
span_log(&s->logging, SPAN_LOG_FLOW, "HDLC signal status is %s (%d)\n", signal_status_to_str(status), status);
switch (status)
{
@@ -1761,7 +1764,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t)
t38_gateway_state_t *s;
t38_gateway_to_t38_state_t *u;
s = (t38_gateway_state_t *) t->user_data;
s = (t38_gateway_state_t *) t->frame_user_data;
u = &s->core.to_t38;
if ((t->raw_bit_stream & 0x80))
{
@@ -1916,7 +1919,7 @@ static void t38_hdlc_rx_put_bit(hdlc_rx_state_t *t, int new_bit)
return;
}
/*endif*/
s = (t38_gateway_state_t *) t->user_data;
s = (t38_gateway_state_t *) t->frame_user_data;
u = &s->core.to_t38;
t->buffer[t->len] = (uint8_t) t->byte_in_progress;
/* Calculate the CRC progressively, before we start altering the frame */