Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch

This commit is contained in:
Michael S Collins 2012-07-18 16:30:04 -07:00
commit 0235d6a6fb
30 changed files with 347 additions and 222 deletions

View File

@ -4646,7 +4646,7 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const
static ftdm_status_t load_config(void) static ftdm_status_t load_config(void)
{ {
const char const cfg_name[] = "freetdm.conf"; const char cfg_name[] = "freetdm.conf";
ftdm_config_t cfg; ftdm_config_t cfg;
char *var, *val; char *var, *val;
int catno = -1; int catno = -1;

View File

@ -417,11 +417,11 @@ static int msn_filter_foreach(ftdm_libpri_data_t *isdn_data, int (* func)(const
ftdm_mutex_lock(isdn_data->msn_mutex); ftdm_mutex_lock(isdn_data->msn_mutex);
for (iter = hashtable_first(isdn_data->msn_hash); iter; iter = hashtable_next(iter)) { for (iter = hashtable_first(isdn_data->msn_hash); iter; iter = hashtable_next(iter)) {
const char *msn = NULL; const void *msn = NULL;
hashtable_this(iter, (const void **)&msn, NULL, NULL); hashtable_this(iter, &msn, NULL, NULL);
if (ftdm_strlen_zero(msn)) if (ftdm_strlen_zero((const char *)msn))
break; break;
if ((ret = func(msn, data)) != FTDM_SUCCESS) if ((ret = func(msn, data)) != FTDM_SUCCESS)
break; break;

View File

@ -100,6 +100,7 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v17_v21_rx(void *user_data, const int16_t am
s->rx_handler = (span_rx_handler_t) &fsk_rx; s->rx_handler = (span_rx_handler_t) &fsk_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin;
s->rx_user_data = &s->v21_rx; s->rx_user_data = &s->v21_rx;
s->rx_fillin_user_data = &s->v21_rx;
} }
/*endif*/ /*endif*/
return 0; return 0;
@ -131,6 +132,7 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t
s->rx_handler = (span_rx_handler_t) &fsk_rx; s->rx_handler = (span_rx_handler_t) &fsk_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin;
s->rx_user_data = &s->v21_rx; s->rx_user_data = &s->v21_rx;
s->rx_fillin_user_data = &s->v21_rx;
} }
/*endif*/ /*endif*/
return 0; return 0;
@ -162,6 +164,7 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx(void *user_data, const int16_t am
s->rx_handler = (span_rx_handler_t) &fsk_rx; s->rx_handler = (span_rx_handler_t) &fsk_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &fsk_rx_fillin;
s->rx_user_data = &s->v21_rx; s->rx_user_data = &s->v21_rx;
s->rx_fillin_user_data = &s->v21_rx;
} }
/*endif*/ /*endif*/
return 0; return 0;
@ -201,6 +204,7 @@ static void v17_rx_status_handler(void *user_data, int status)
s->rx_handler = (span_rx_handler_t) &v17_rx; s->rx_handler = (span_rx_handler_t) &v17_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &v17_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &v17_rx_fillin;
s->rx_user_data = &s->fast_modems.v17_rx; s->rx_user_data = &s->fast_modems.v17_rx;
s->rx_fillin_user_data = &s->fast_modems.v17_rx;
break; break;
} }
/*endswitch*/ /*endswitch*/
@ -219,6 +223,7 @@ static void v27ter_rx_status_handler(void *user_data, int status)
s->rx_handler = (span_rx_handler_t) &v27ter_rx; s->rx_handler = (span_rx_handler_t) &v27ter_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &v27ter_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &v27ter_rx_fillin;
s->rx_user_data = &s->fast_modems.v27ter_rx; s->rx_user_data = &s->fast_modems.v27ter_rx;
s->rx_fillin_user_data = &s->fast_modems.v27ter_rx;
break; break;
} }
/*endswitch*/ /*endswitch*/
@ -237,6 +242,7 @@ static void v29_rx_status_handler(void *user_data, int status)
s->rx_handler = (span_rx_handler_t) &v29_rx; s->rx_handler = (span_rx_handler_t) &v29_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &v29_rx_fillin; s->rx_fillin_handler = (span_rx_fillin_handler_t) &v29_rx_fillin;
s->rx_user_data = &s->fast_modems.v29_rx; s->rx_user_data = &s->fast_modems.v29_rx;
s->rx_fillin_user_data = &s->fast_modems.v29_rx;
break; break;
} }
/*endswitch*/ /*endswitch*/
@ -326,6 +332,7 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
s->rx_handler = (span_rx_handler_t) &span_dummy_rx; s->rx_handler = (span_rx_handler_t) &span_dummy_rx;
s->rx_fillin_handler = (span_rx_fillin_handler_t) &span_dummy_rx; s->rx_fillin_handler = (span_rx_fillin_handler_t) &span_dummy_rx;
s->rx_user_data = NULL; s->rx_user_data = NULL;
s->rx_fillin_user_data = NULL;
s->tx_handler = (span_tx_handler_t) &silence_gen; s->tx_handler = (span_tx_handler_t) &silence_gen;
s->tx_user_data = &s->silence_gen; s->tx_user_data = &s->silence_gen;
return s; return s;

View File

@ -43,6 +43,9 @@ typedef __int64 int64_t;
#if !defined(UINT16_MAX) #if !defined(UINT16_MAX)
#define UINT16_MAX 0xFFFF #define UINT16_MAX 0xFFFF
#endif #endif
#if !defined(UINT32_MAX)
#define UINT32_MAX 0xFFFFFFFF
#endif
#if !defined(INT16_MAX) #if !defined(INT16_MAX)
#define INT16_MAX 0x7FFF #define INT16_MAX 0x7FFF

View File

@ -21,8 +21,6 @@
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software * License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: spandsp.h.in,v 1.19.4.1 2009/12/19 09:47:56 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -38,6 +36,10 @@
#define SPANDSP_USE_EXPORT_CAPABILITY 1 #define SPANDSP_USE_EXPORT_CAPABILITY 1
#undef SPANDSP_SUPPORT_T42
#undef SPANDSP_SUPPORT_T43
#undef SPANDSP_SUPPORT_V34
#include <stdlib.h> #include <stdlib.h>
#include <msvc/inttypes.h> #include <msvc/inttypes.h>
#include <string.h> #include <string.h>
@ -56,6 +58,7 @@
#include <spandsp/schedule.h> #include <spandsp/schedule.h>
#include <spandsp/g711.h> #include <spandsp/g711.h>
#include <spandsp/timing.h> #include <spandsp/timing.h>
#include <spandsp/math_fixed.h>
#include <spandsp/vector_float.h> #include <spandsp/vector_float.h>
#include <spandsp/complex_vector_float.h> #include <spandsp/complex_vector_float.h>
#include <spandsp/vector_int.h> #include <spandsp/vector_int.h>
@ -88,6 +91,9 @@
#include <spandsp/fsk.h> #include <spandsp/fsk.h>
#include <spandsp/modem_connect_tones.h> #include <spandsp/modem_connect_tones.h>
#include <spandsp/silence_gen.h> #include <spandsp/silence_gen.h>
#include <spandsp/v8.h>
#include <spandsp/v42.h>
#include <spandsp/v42bis.h>
#include <spandsp/v29rx.h> #include <spandsp/v29rx.h>
#include <spandsp/v29tx.h> #include <spandsp/v29tx.h>
#include <spandsp/v17rx.h> #include <spandsp/v17rx.h>
@ -95,17 +101,21 @@
#include <spandsp/v22bis.h> #include <spandsp/v22bis.h>
#include <spandsp/v27ter_rx.h> #include <spandsp/v27ter_rx.h>
#include <spandsp/v27ter_tx.h> #include <spandsp/v27ter_tx.h>
#include <spandsp/v8.h>
#include <spandsp/v18.h> #include <spandsp/v18.h>
#include <spandsp/v42.h>
#include <spandsp/v42bis.h>
#include <spandsp/timezone.h> #include <spandsp/timezone.h>
#include <spandsp/t4_rx.h> #include <spandsp/t4_rx.h>
#include <spandsp/t4_tx.h> #include <spandsp/t4_tx.h>
#include <spandsp/t4_t6_decode.h> #include <spandsp/image_translate.h>
#include <spandsp/t4_t6_decode.h>
#include <spandsp/t4_t6_encode.h> #include <spandsp/t4_t6_encode.h>
#include <spandsp/t81_t82_arith_coding.h> #include <spandsp/t81_t82_arith_coding.h>
#include <spandsp/t85.h> #include <spandsp/t85.h>
#if defined(SPANDSP_SUPPORT_T42)
#include <spandsp/t42.h>
#endif
#if defined(SPANDSP_SUPPORT_T43)
#include <spandsp/t43.h>
#endif
#include <spandsp/t30.h> #include <spandsp/t30.h>
#include <spandsp/t30_api.h> #include <spandsp/t30_api.h>
#include <spandsp/t30_fcf.h> #include <spandsp/t30_fcf.h>

View File

@ -99,6 +99,7 @@ struct fax_modems_state_s
/*! \brief The current receive missing signal fill-in handler */ /*! \brief The current receive missing signal fill-in handler */
span_rx_fillin_handler_t rx_fillin_handler; span_rx_fillin_handler_t rx_fillin_handler;
void *rx_user_data; void *rx_user_data;
void *rx_fillin_user_data;
/*! \brief The current transmit signal handler */ /*! \brief The current transmit signal handler */
span_tx_handler_t tx_handler; span_tx_handler_t tx_handler;
@ -109,12 +110,12 @@ struct fax_modems_state_s
span_tx_handler_t next_tx_handler; span_tx_handler_t next_tx_handler;
void *next_tx_user_data; void *next_tx_user_data;
/*! The current bit rate of the transmitter. */ /*! \brief The current bit rate of the transmitter. */
int tx_bit_rate; int tx_bit_rate;
/*! The current bit rate of the receiver. */ /*! \brief The current bit rate of the receiver. */
int rx_bit_rate; int rx_bit_rate;
/*! If TRUE, transmission is in progress */ /*! \brief If TRUE, transmission is in progress */
int transmit; int transmit;
/*! \brief Audio logging file handle for received audio. */ /*! \brief Audio logging file handle for received audio. */
int audio_rx_log; int audio_rx_log;

View File

@ -73,7 +73,7 @@ struct v17_rx_state_s
void *qam_user_data; void *qam_user_data;
#if defined(SPANDSP_USE_FIXED_POINTx) #if defined(SPANDSP_USE_FIXED_POINTx)
/*! \brief The scaling factor accessed by the AGC algorithm. */ /*! \brief The scaling factor assessed by the AGC algorithm. */
float agc_scaling; float agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
float agc_scaling_save; float agc_scaling_save;
@ -110,7 +110,7 @@ struct v17_rx_state_s
/*! \brief A pointer to the current constellation. */ /*! \brief A pointer to the current constellation. */
const complexi16_t *constellation; const complexi16_t *constellation;
#else #else
/*! \brief The scaling factor accessed by the AGC algorithm. */ /*! \brief The scaling factor assessed by the AGC algorithm. */
float agc_scaling; float agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
float agc_scaling_save; float agc_scaling_save;
@ -150,7 +150,7 @@ struct v17_rx_state_s
/*! \brief Current offset into the RRC pulse shaping filter buffer. */ /*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step; int rrc_filter_step;
/*! \brief The state of the differential decoder */ /*! \brief The current state of the differential decoder */
int diff; int diff;
/*! \brief The register for the data scrambler. */ /*! \brief The register for the data scrambler. */
uint32_t scramble_reg; uint32_t scramble_reg;
@ -228,7 +228,6 @@ struct v17_rx_state_s
from the last states of the trellis. */ from the last states of the trellis. */
float distances[8]; float distances[8];
#endif #endif
/*! \brief Error and flow logging control */ /*! \brief Error and flow logging control */
logging_state_t logging; logging_state_t logging;
}; };

View File

@ -65,6 +65,12 @@ enum
V22BIS_TX_TRAINING_STAGE_PARKED V22BIS_TX_TRAINING_STAGE_PARKED
}; };
#if defined(SPANDSP_USE_FIXED_POINTx)
extern const complexi16_t v22bis_constellation[16];
#else
extern const complexf_t v22bis_constellation[16];
#endif
/*! /*!
V.22bis modem descriptor. This defines the working state for a single instance V.22bis modem descriptor. This defines the working state for a single instance
of a V.22bis modem. of a V.22bis modem.
@ -93,10 +99,11 @@ struct v22bis_state_s
/* Receive section */ /* Receive section */
struct struct
{ {
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINTx) #if defined(SPANDSP_USE_FIXED_POINTx)
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
int16_t rrc_filter[V22BIS_RX_FILTER_STEPS]; int16_t rrc_filter[V22BIS_RX_FILTER_STEPS];
#else #else
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
float rrc_filter[V22BIS_RX_FILTER_STEPS]; float rrc_filter[V22BIS_RX_FILTER_STEPS];
#endif #endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */ /*! \brief Current offset into the RRC pulse shaping filter buffer. */
@ -156,7 +163,9 @@ struct v22bis_state_s
/*! \brief The equalizer signal buffer. */ /*! \brief The equalizer signal buffer. */
complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1];
#else #else
/*! \brief The adaptive equalizer coefficients. */
complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1];
/*! \brief The equalizer signal buffer. */
complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1];
#endif #endif
/*! \brief Current offset into the equalizer buffer. */ /*! \brief Current offset into the equalizer buffer. */
@ -186,7 +195,7 @@ struct v22bis_state_s
/*! \brief The gain factor needed to achieve the specified output power. */ /*! \brief The gain factor needed to achieve the specified output power. */
float gain; float gain;
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS]; complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS];
/*! \brief Current offset into the RRC pulse shaping filter buffer. */ /*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step; int rrc_filter_step;

View File

@ -70,7 +70,7 @@ struct v27ter_rx_state_s
void *qam_user_data; void *qam_user_data;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The scaling factor accessed by the AGC algorithm. */ /*! \brief The scaling factor assessed by the AGC algorithm. */
int16_t agc_scaling; int16_t agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
int16_t agc_scaling_save; int16_t agc_scaling_save;
@ -95,7 +95,7 @@ struct v27ter_rx_state_s
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
int16_t rrc_filter[V27TER_RX_FILTER_STEPS]; int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
#else #else
/*! \brief The scaling factor accessed by the AGC algorithm. */ /*! \brief The scaling factor assessed by the AGC algorithm. */
float agc_scaling; float agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
float agc_scaling_save; float agc_scaling_save;

View File

@ -61,82 +61,8 @@ struct v29_rx_state_s
routine. */ routine. */
void *qam_user_data; void *qam_user_data;
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
int16_t rrc_filter[V29_RX_FILTER_STEPS]; /*! \brief The scaling factor assessed by the AGC algorithm. */
#else
float rrc_filter[V29_RX_FILTER_STEPS];
#endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
/*! \brief The register for the data scrambler. */
uint32_t scramble_reg;
/*! \brief The register for the training scrambler. */
uint8_t training_scramble_reg;
/*! \brief The current step in the table of CD constellation positions. */
int training_cd;
/*! \brief TRUE if the previous trained values are to be reused. */
int old_train;
/*! \brief The section of the training data we are currently in. */
int training_stage;
/*! \brief A count of how far through the current training step we are. */
int training_count;
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
/*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
int16_t last_sample;
/*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */
int signal_present;
/*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
int carrier_drop_pending;
/*! \brief A count of the current consecutive samples below the carrier off threshold. */
int low_samples;
/*! \brief A highest magnitude sample seen. */
int16_t high_sample;
/*! \brief The position of the current symbol in the constellation, used for
differential decoding. */
int constellation_state;
/*! \brief The current phase of the carrier (i.e. the DDS parameter). */
uint32_t carrier_phase;
/*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
int32_t carrier_phase_rate;
/*! \brief The carrier update rate saved for reuse when using short training. */
int32_t carrier_phase_rate_save;
#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The proportional part of the carrier tracking filter. */
int32_t carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
int32_t carrier_track_i;
#else
/*! \brief The proportional part of the carrier tracking filter. */
float carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
float carrier_track_i;
#endif
/*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
power_meter_t power;
/*! \brief The power meter level at which carrier on is declared. */
int32_t carrier_on_power;
/*! \brief The power meter level at which carrier off is declared. */
int32_t carrier_off_power;
/*! \brief Current read offset into the equalizer buffer. */
int eq_step;
/*! \brief Current write offset into the equalizer buffer. */
int eq_put_step;
/*! \brief Symbol counter to the next equalizer update. */
int eq_skip;
/*! \brief The current half of the baud. */
int baud_half;
#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The scaling factor accessed by the AGC algorithm. */
int16_t agc_scaling; int16_t agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
int16_t agc_scaling_save; int16_t agc_scaling_save;
@ -158,8 +84,19 @@ struct v29_rx_state_s
int32_t symbol_sync_dc_filter[2]; int32_t symbol_sync_dc_filter[2];
/*! Baud phase for symbol sync. */ /*! Baud phase for symbol sync. */
int32_t baud_phase; int32_t baud_phase;
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
/*! \brief The proportional part of the carrier tracking filter. */
int32_t carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
int32_t carrier_track_i;
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
int16_t rrc_filter[V29_RX_FILTER_STEPS];
#else #else
/*! \brief The scaling factor accessed by the AGC algorithm. */ /*! \brief The scaling factor assessed by the AGC algorithm. */
float agc_scaling; float agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
float agc_scaling_save; float agc_scaling_save;
@ -181,7 +118,67 @@ struct v29_rx_state_s
float symbol_sync_dc_filter[2]; float symbol_sync_dc_filter[2];
/*! Baud phase for symbol sync. */ /*! Baud phase for symbol sync. */
float baud_phase; float baud_phase;
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
/*! \brief The proportional part of the carrier tracking filter. */
float carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
float carrier_track_i;
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
float rrc_filter[V29_RX_FILTER_STEPS];
#endif #endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
/*! \brief The register for the data scrambler. */
uint32_t scramble_reg;
/*! \brief The register for the training scrambler. */
uint8_t training_scramble_reg;
/*! \brief The current step in the table of CD constellation positions. */
int training_cd;
/*! \brief TRUE if the previous trained values are to be reused. */
int old_train;
/*! \brief The section of the training data we are currently in. */
int training_stage;
/*! \brief A count of how far through the current training step we are. */
int training_count;
/*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
int16_t last_sample;
/*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */
int signal_present;
/*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
int carrier_drop_pending;
/*! \brief A count of the current consecutive samples below the carrier off threshold. */
int low_samples;
/*! \brief A highest magnitude sample seen. */
int16_t high_sample;
/*! \brief The current phase of the carrier (i.e. the DDS parameter). */
uint32_t carrier_phase;
/*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
int32_t carrier_phase_rate;
/*! \brief The carrier update rate saved for reuse when using short training. */
int32_t carrier_phase_rate_save;
/*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
power_meter_t power;
/*! \brief The power meter level at which carrier on is declared. */
int32_t carrier_on_power;
/*! \brief The power meter level at which carrier off is declared. */
int32_t carrier_off_power;
/*! \brief Current read offset into the equalizer buffer. */
int eq_step;
/*! \brief Current write offset into the equalizer buffer. */
int eq_put_step;
/*! \brief Symbol counter to the next equalizer update. */
int eq_skip;
/*! \brief The current half of the baud. */
int baud_half;
/*! \brief The total symbol timing correction since the carrier came up. /*! \brief The total symbol timing correction since the carrier came up.
This is only for performance analysis purposes. */ This is only for performance analysis purposes. */
@ -191,6 +188,11 @@ struct v29_rx_state_s
int32_t start_angles[2]; int32_t start_angles[2];
/*! \brief History list of phase angles for the coarse carrier aquisition step. */ /*! \brief History list of phase angles for the coarse carrier aquisition step. */
int32_t angles[16]; int32_t angles[16];
/*! \brief The position of the current symbol in the constellation, used for
differential decoding. */
int constellation_state;
/*! \brief Error and flow logging control */ /*! \brief Error and flow logging control */
logging_state_t logging; logging_state_t logging;
}; };

View File

@ -47,21 +47,23 @@ struct v29_tx_state_s
/*! \brief A user specified opaque pointer passed to the status function. */ /*! \brief A user specified opaque pointer passed to the status function. */
void *status_user_data; void *status_user_data;
#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief Gain required to achieve the specified output power, not allowing /*! \brief Gain required to achieve the specified output power, not allowing
for the size of the current constellation. */ for the size of the current constellation. */
float base_gain; float base_gain;
/*! \brief Gain required to achieve the specified output power, allowing /*! \brief Gain required to achieve the specified output power, allowing
for the size of the current constellation. */ for the size of the current constellation. */
#if defined(SPANDSP_USE_FIXED_POINT)
int32_t gain; int32_t gain;
#else /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
float gain;
#endif
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t rrc_filter[2*V29_TX_FILTER_STEPS]; complexi16_t rrc_filter[2*V29_TX_FILTER_STEPS];
#else #else
/*! \brief Gain required to achieve the specified output power, not allowing
for the size of the current constellation. */
float base_gain;
/*! \brief Gain required to achieve the specified output power, allowing
for the size of the current constellation. */
float gain;
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
complexf_t rrc_filter[2*V29_TX_FILTER_STEPS]; complexf_t rrc_filter[2*V29_TX_FILTER_STEPS];
#endif #endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */ /*! \brief Current offset into the RRC pulse shaping filter buffer. */

View File

@ -293,7 +293,7 @@ SPAN_DECLARE_NONSTD(int) v17_rx_fillin(v17_rx_state_t *s, int len);
\param coeffs The vector of complex coefficients. \param coeffs The vector of complex coefficients.
\return The number of coefficients in the vector. */ \return The number of coefficients in the vector. */
#if defined(SPANDSP_USE_FIXED_POINTx) #if defined(SPANDSP_USE_FIXED_POINTx)
SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexi_t **coeffs); SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexi16_t **coeffs);
#else #else
SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs); SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs);
#endif #endif

View File

@ -61,8 +61,6 @@ enum
*/ */
typedef struct v22bis_state_s v22bis_state_t; typedef struct v22bis_state_s v22bis_state_t;
extern const complexf_t v22bis_constellation[16];
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" extern "C"
{ {
@ -88,7 +86,11 @@ SPAN_DECLARE_NONSTD(int) v22bis_rx_fillin(v22bis_state_t *s, int len);
\brief Get a snapshot of the current equalizer coefficients. \brief Get a snapshot of the current equalizer coefficients.
\param coeffs The vector of complex coefficients. \param coeffs The vector of complex coefficients.
\return The number of coefficients in the vector. */ \return The number of coefficients in the vector. */
#if defined(SPANDSP_USE_FIXED_POINTx)
SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexi16_t **coeffs);
#else
SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs); SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs);
#endif
/*! Get the current received carrier frequency. /*! Get the current received carrier frequency.
\param s The modem context. \param s The modem context.

View File

@ -126,7 +126,11 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len);
\brief Get a snapshot of the current equalizer coefficients. \brief Get a snapshot of the current equalizer coefficients.
\param coeffs The vector of complex coefficients. \param coeffs The vector of complex coefficients.
\return The number of coefficients in the vector. */ \return The number of coefficients in the vector. */
#if defined(SPANDSP_USE_FIXED_POINTx)
SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexi16_t **coeffs);
#else
SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs); SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs);
#endif
/*! Get the current received carrier frequency. /*! Get the current received carrier frequency.
\param s The modem context. \param s The modem context.

View File

@ -118,7 +118,11 @@ scrambler register) cannot be trusted for the test. The receive modem,
therefore, only tests that bits starting at bit 24 are really ones. therefore, only tests that bits starting at bit 24 are really ones.
*/ */
#if defined(SPANDSP_USE_FIXED_POINTx)
typedef void (*qam_report_handler_t)(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol);
#else
typedef void (*qam_report_handler_t)(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol); typedef void (*qam_report_handler_t)(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol);
#endif
/*! /*!
V.29 modem receive side descriptor. This defines the working state for a V.29 modem receive side descriptor. This defines the working state for a

View File

@ -5633,7 +5633,7 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_
break; break;
default: default:
span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_chunk in bad state %d\n", s->state); span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_chunk in bad state %d\n", s->state);
len = 0; len = -1;
break; break;
} }
return len; return len;

View File

@ -724,13 +724,21 @@ static int stream_non_ecm(t31_state_t *s)
case T38_TIMED_STEP_NON_ECM_MODEM: case T38_TIMED_STEP_NON_ECM_MODEM:
/* Create a 75ms silence */ /* Create a 75ms silence */
if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL) if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL)
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); {
if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
}
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_2; fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_2;
fe->next_tx_samples = fe->samples; fe->next_tx_samples = fe->samples;
break; break;
case T38_TIMED_STEP_NON_ECM_MODEM_2: case T38_TIMED_STEP_NON_ECM_MODEM_2:
/* Switch on a fast modem, and give the training time to complete */ /* Switch on a fast modem, and give the training time to complete */
delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator); if ((delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator)) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_3; fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_3;
break; break;
case T38_TIMED_STEP_NON_ECM_MODEM_3: case T38_TIMED_STEP_NON_ECM_MODEM_3:
@ -762,12 +770,18 @@ static int stream_non_ecm(t31_state_t *s)
else else
{ {
/* If we are sending quickly there seems no point in doing any padding */ /* If we are sending quickly there seems no point in doing any padding */
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5; fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5;
delay = 0; delay = 0;
} }
} }
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA) < 0)
{
/* ???????? */
}
delay = bits_to_us(s, 8*len); delay = bits_to_us(s, 8*len);
break; break;
case T38_TIMED_STEP_NON_ECM_MODEM_4: case T38_TIMED_STEP_NON_ECM_MODEM_4:
@ -778,7 +792,10 @@ static int stream_non_ecm(t31_state_t *s)
{ {
len += fe->non_ecm_trailer_bytes; len += fe->non_ecm_trailer_bytes;
memset(buf, 0, len); memset(buf, 0, len);
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_SIG_END, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA_END) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5; fe->timed_step = T38_TIMED_STEP_NON_ECM_MODEM_5;
/* Allow a bit more time than the data will take to play out, to ensure the far ATA does not /* Allow a bit more time than the data will take to play out, to ensure the far ATA does not
cut things short. */ cut things short. */
@ -789,13 +806,19 @@ static int stream_non_ecm(t31_state_t *s)
break; break;
} }
memset(buf, 0, len); memset(buf, 0, len);
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_T4_NON_ECM_DATA, buf, len, T38_PACKET_CATEGORY_IMAGE_DATA) < 0)
{
/* ???????? */
}
delay = bits_to_us(s, 8*len); delay = bits_to_us(s, 8*len);
break; break;
case T38_TIMED_STEP_NON_ECM_MODEM_5: case T38_TIMED_STEP_NON_ECM_MODEM_5:
/* This should not be needed, since the message above indicates the end of the signal, but it /* This should not be needed, since the message above indicates the end of the signal, but it
seems like it can improve compatibility with quirky implementations. */ seems like it can improve compatibility with quirky implementations. */
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_NONE; fe->timed_step = T38_TIMED_STEP_NONE;
return delay; return delay;
} }
@ -822,13 +845,21 @@ static int stream_hdlc(t31_state_t *s)
case T38_TIMED_STEP_HDLC_MODEM: case T38_TIMED_STEP_HDLC_MODEM:
/* Create a 75ms silence */ /* Create a 75ms silence */
if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL) if (fe->t38.current_tx_indicator != T38_IND_NO_SIGNAL)
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); {
if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_2; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_2;
fe->next_tx_samples = fe->samples + ms_to_samples(75); fe->next_tx_samples = fe->samples + ms_to_samples(75);
break; break;
case T38_TIMED_STEP_HDLC_MODEM_2: case T38_TIMED_STEP_HDLC_MODEM_2:
/* Send HDLC preambling */ /* Send HDLC preambling */
delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator); if ((delay = t38_core_send_indicator(&fe->t38, fe->next_tx_indicator)) < 0)
{
/* ???????? */
}
delay += t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator); delay += t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator);
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
@ -864,7 +895,10 @@ static int stream_hdlc(t31_state_t *s)
data_fields[1].field = NULL; data_fields[1].field = NULL;
data_fields[1].field_len = 0; data_fields[1].field_len = 0;
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END;
t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category); if (t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5;
/* We add a bit of extra time here, as with some implementations /* We add a bit of extra time here, as with some implementations
the carrier falling too abruptly causes data loss. */ the carrier falling too abruptly causes data loss. */
@ -880,7 +914,10 @@ static int stream_hdlc(t31_state_t *s)
data_fields[1].field = NULL; data_fields[1].field = NULL;
data_fields[1].field_len = 0; data_fields[1].field_len = 0;
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category); if (t38_core_send_data_multi_field(&fe->t38, fe->current_tx_data_type, data_fields, 2, category) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits); delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits);
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
@ -888,14 +925,20 @@ static int stream_hdlc(t31_state_t *s)
break; break;
} }
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_4; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_4;
} }
else else
{ {
i = fe->octets_per_data_packet; i = fe->octets_per_data_packet;
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_DATA, &s->hdlc_tx.buf[s->hdlc_tx.ptr], i, category) < 0)
{
/* ???????? */
}
s->hdlc_tx.ptr += i; s->hdlc_tx.ptr += i;
} }
delay = bits_to_us(s, i*8); delay = bits_to_us(s, i*8);
@ -911,7 +954,10 @@ static int stream_hdlc(t31_state_t *s)
s->hdlc_tx.len = 0; s->hdlc_tx.len = 0;
s->hdlc_tx.final = FALSE; s->hdlc_tx.final = FALSE;
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category); if (t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_5;
/* We add a bit of extra time here, as with some implementations /* We add a bit of extra time here, as with some implementations
the carrier falling too abruptly causes data loss. */ the carrier falling too abruptly causes data loss. */
@ -923,7 +969,10 @@ static int stream_hdlc(t31_state_t *s)
} }
/* Finish the current frame off, and prepare for the next one. */ /* Finish the current frame off, and prepare for the next one. */
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA : T38_PACKET_CATEGORY_IMAGE_DATA;
t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category); if (t38_core_send_data(&fe->t38, previous, T38_FIELD_HDLC_FCS_OK, NULL, 0, category) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3; fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
/* We should now wait enough time for everything to clear through an analogue modem at the far end. */ /* We should now wait enough time for everything to clear through an analogue modem at the far end. */
@ -935,8 +984,14 @@ static int stream_hdlc(t31_state_t *s)
/* Note that some boxes do not like us sending a T38_FIELD_HDLC_SIG_END at this point. /* Note that some boxes do not like us sending a T38_FIELD_HDLC_SIG_END at this point.
A T38_IND_NO_SIGNAL should always be OK. */ A T38_IND_NO_SIGNAL should always be OK. */
category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END; category = (s->t38_fe.current_tx_data_type == T38_DATA_V21) ? T38_PACKET_CATEGORY_CONTROL_DATA_END : T38_PACKET_CATEGORY_IMAGE_DATA_END;
t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_SIG_END, NULL, 0, category); if (t38_core_send_data(&fe->t38, fe->current_tx_data_type, T38_FIELD_HDLC_SIG_END, NULL, 0, category) < 0)
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); {
/* ???????? */
}
if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
fe->timed_step = T38_TIMED_STEP_NONE; fe->timed_step = T38_TIMED_STEP_NONE;
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_OK); at_put_response_code(&s->at_state, AT_RESPONSE_CODE_OK);
t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND); t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND);
@ -963,14 +1018,20 @@ static int stream_ced(t31_state_t *s)
of silence, starting the delay with a no signal indication makes sense. of silence, starting the delay with a no signal indication makes sense.
We do need a 200ms delay, as that is a specification requirement. */ We do need a 200ms delay, as that is a specification requirement. */
fe->timed_step = T38_TIMED_STEP_CED_2; fe->timed_step = T38_TIMED_STEP_CED_2;
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
delay = 200000; delay = 200000;
fe->next_tx_samples = fe->samples; fe->next_tx_samples = fe->samples;
break; break;
case T38_TIMED_STEP_CED_2: case T38_TIMED_STEP_CED_2:
/* Initial 200ms delay over. Send the CED indicator */ /* Initial 200ms delay over. Send the CED indicator */
fe->timed_step = T38_TIMED_STEP_CED_3; fe->timed_step = T38_TIMED_STEP_CED_3;
delay = t38_core_send_indicator(&fe->t38, T38_IND_CED); if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_CED)) < 0)
{
/* ???????? */
}
fe->current_tx_data_type = T38_DATA_NONE; fe->current_tx_data_type = T38_DATA_NONE;
break; break;
case T38_TIMED_STEP_CED_3: case T38_TIMED_STEP_CED_3:
@ -1000,7 +1061,10 @@ static int stream_cng(t31_state_t *s)
be sending 200ms of silence, according to T.30, starting that delay with be sending 200ms of silence, according to T.30, starting that delay with
a no signal indication makes sense. */ a no signal indication makes sense. */
fe->timed_step = T38_TIMED_STEP_CNG_2; fe->timed_step = T38_TIMED_STEP_CNG_2;
delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL); if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_NO_SIGNAL)) < 0)
{
/* ???????? */
}
delay = 200000; delay = 200000;
fe->next_tx_samples = fe->samples; fe->next_tx_samples = fe->samples;
break; break;
@ -1009,7 +1073,10 @@ static int stream_cng(t31_state_t *s)
coming the other way interrupts it, or a long timeout controlled by the T.30 engine coming the other way interrupts it, or a long timeout controlled by the T.30 engine
expires. */ expires. */
fe->timed_step = T38_TIMED_STEP_NONE; fe->timed_step = T38_TIMED_STEP_NONE;
delay = t38_core_send_indicator(&fe->t38, T38_IND_CNG); if ((delay = t38_core_send_indicator(&fe->t38, T38_IND_CNG)) < 0)
{
/* ???????? */
}
fe->current_tx_data_type = T38_DATA_NONE; fe->current_tx_data_type = T38_DATA_NONE;
return delay; return delay;
} }
@ -1775,7 +1842,10 @@ static int restart_modem(t31_state_t *s, int new_modem)
case FAX_MODEM_SILENCE_TX: case FAX_MODEM_SILENCE_TX:
if (s->t38_mode) if (s->t38_mode)
{ {
t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL); if (t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL) < 0)
{
/* ???????? */
}
s->t38_fe.next_tx_samples = s->t38_fe.samples + ms_to_samples(700); s->t38_fe.next_tx_samples = s->t38_fe.samples + ms_to_samples(700);
s->t38_fe.timed_step = T38_TIMED_STEP_PAUSE; s->t38_fe.timed_step = T38_TIMED_STEP_PAUSE;
s->t38_fe.current_tx_data_type = T38_DATA_NONE; s->t38_fe.current_tx_data_type = T38_DATA_NONE;
@ -1802,7 +1872,10 @@ static int restart_modem(t31_state_t *s, int new_modem)
/* Send 200ms of silence to "push" the last audio out */ /* Send 200ms of silence to "push" the last audio out */
if (s->t38_mode) if (s->t38_mode)
{ {
t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL); if (t38_core_send_indicator(&s->t38_fe.t38, T38_IND_NO_SIGNAL) < 0)
{
/* ???????? */
}
} }
else else
{ {

View File

@ -81,10 +81,6 @@
#include "faxfont.h" #include "faxfont.h"
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffff
#endif
/*! The number of centimetres in one inch */ /*! The number of centimetres in one inch */
#define CM_PER_INCH 2.54f #define CM_PER_INCH 2.54f

View File

@ -46,10 +46,6 @@
#include "spandsp/private/t81_t82_arith_coding.h" #include "spandsp/private/t81_t82_arith_coding.h"
#include "spandsp/private/t85.h" #include "spandsp/private/t85.h"
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffff
#endif
/* Image length update status */ /* Image length update status */
enum enum
{ {

View File

@ -8290,14 +8290,14 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
conference->name = switch_core_strdup(conference->pool, name); conference->name = switch_core_strdup(conference->pool, name);
if (presence_id && (name_domain = strchr(presence_id, '@'))) { if ((name_domain = strchr(conference->name, '@'))) {
name_domain++;
conference->domain = switch_core_strdup(conference->pool, name_domain);
} else if ((name_domain = strchr(conference->name, '@'))) {
name_domain++; name_domain++;
conference->domain = switch_core_strdup(conference->pool, name_domain); conference->domain = switch_core_strdup(conference->pool, name_domain);
} else if (domain) { } else if (domain) {
conference->domain = switch_core_strdup(conference->pool, domain); conference->domain = switch_core_strdup(conference->pool, domain);
} else if (presence_id && (name_domain = strchr(presence_id, '@'))) {
name_domain++;
conference->domain = switch_core_strdup(conference->pool, name_domain);
} else { } else {
conference->domain = "cluecon.com"; conference->domain = "cluecon.com";
} }

View File

@ -934,7 +934,7 @@ SWITCH_STANDARD_API(http_cache_tryget)
switch_memory_pool_t *pool = NULL; switch_memory_pool_t *pool = NULL;
char *filename; char *filename;
if (zstr(cmd) || strncmp("http://", cmd, strlen("http://"))) { if (!isUrl(cmd)) {
stream->write_function(stream, "USAGE: %s\n", HTTP_GET_SYNTAX); stream->write_function(stream, "USAGE: %s\n", HTTP_GET_SYNTAX);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }

View File

@ -34,7 +34,7 @@
<param name="file-prefix" value="faxrx"/> <param name="file-prefix" value="faxrx"/>
</fax-settings> </fax-settings>
<descriptors> <descriptors debug-level="0">
<!-- These tones are defined in Annex to ITU Operational Bulletin No. 781 - 1.II.2003 --> <!-- These tones are defined in Annex to ITU Operational Bulletin No. 781 - 1.II.2003 -->
<!-- Various Tones Used in National Networks (According to ITU-T Recommendation E.180)(03/1998) --> <!-- Various Tones Used in National Networks (According to ITU-T Recommendation E.180)(03/1998) -->

View File

@ -492,8 +492,6 @@ switch_status_t load_configuration(switch_bool_t reload)
spandsp_globals.ident = "SpanDSP Fax Ident"; spandsp_globals.ident = "SpanDSP Fax Ident";
spandsp_globals.header = "SpanDSP Fax Header"; spandsp_globals.header = "SpanDSP Fax Header";
spandsp_globals.timezone = ""; spandsp_globals.timezone = "";
/* TODO make configuration param */
spandsp_globals.tonedebug = 0; spandsp_globals.tonedebug = 0;
if ((xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL)) || (xml = switch_xml_open_cfg("fax.conf", &cfg, NULL))) { if ((xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL)) || (xml = switch_xml_open_cfg("fax.conf", &cfg, NULL))) {
@ -592,6 +590,16 @@ switch_status_t load_configuration(switch_bool_t reload)
/* Configure call progress detector */ /* Configure call progress detector */
if ((callprogress = switch_xml_child(cfg, "descriptors"))) { if ((callprogress = switch_xml_child(cfg, "descriptors"))) {
/* check if debugging is enabled */
const char *debug = switch_xml_attr(callprogress, "debug-level");
if (!zstr(debug) && switch_is_number(debug)) {
int debug_val = atoi(debug);
if (debug_val > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting tone detector debug-level to : %d\n", debug_val);
spandsp_globals.tonedebug = debug_val;
}
}
for (xdescriptor = switch_xml_child(callprogress, "descriptor"); xdescriptor; xdescriptor = switch_xml_next(xdescriptor)) { for (xdescriptor = switch_xml_child(callprogress, "descriptor"); xdescriptor; xdescriptor = switch_xml_next(xdescriptor)) {
const char *name = switch_xml_attr(xdescriptor, "name"); const char *name = switch_xml_attr(xdescriptor, "name");
const char *tone_name = NULL; const char *tone_name = NULL;

View File

@ -742,7 +742,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons
/* start listening for tones */ /* start listening for tones */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Starting tone detection for '%s'\n", switch_channel_get_name(channel), name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Starting tone detection for '%s'\n", switch_channel_get_name(channel), name);
switch_core_media_bug_add(session, "spandsp_tone_detect", NULL, switch_core_media_bug_add(session, "spandsp_tone_detect", NULL,
callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_STREAM, &bug); callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_REPLACE, &bug);
if (!bug) { if (!bug) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -761,32 +761,30 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons
*/ */
static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{ {
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_frame_t frame = { 0 };
tone_detector_t *detector = (tone_detector_t *)user_data; tone_detector_t *detector = (tone_detector_t *)user_data;
switch_core_session_t *session = switch_core_media_bug_get_session(bug); switch_core_session_t *session = switch_core_media_bug_get_session(bug);
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
frame.data = data;
frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
switch(type) { switch(type) {
case SWITCH_ABC_TYPE_INIT: case SWITCH_ABC_TYPE_INIT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) initializing tone detector\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) initializing tone detector\n", switch_channel_get_name(channel));
tone_detector_init(detector); tone_detector_init(detector);
break; break;
case SWITCH_ABC_TYPE_READ: case SWITCH_ABC_TYPE_READ_REPLACE:
{ {
switch_frame_t *frame;
const char *detected_tone = NULL; const char *detected_tone = NULL;
if (!detector->spandsp_detector) { if (!detector->spandsp_detector) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) detector is destroyed\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) detector is destroyed\n", switch_channel_get_name(channel));
return SWITCH_FALSE; return SWITCH_FALSE;
} }
if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { if (!(frame = switch_core_media_bug_get_read_replace_frame(bug))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) error reading frame\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) error reading frame\n", switch_channel_get_name(channel));
return SWITCH_FALSE; return SWITCH_FALSE;
} }
tone_detector_process_buffer(detector, frame.data, frame.samples, &detected_tone); tone_detector_process_buffer(detector, frame->data, frame->samples, &detected_tone);
if (detected_tone) { if (detected_tone) {
switch_event_t *event = NULL; switch_event_t *event = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) DETECTED TONE: %s\n", switch_channel_get_name(channel), detected_tone); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) DETECTED TONE: %s\n", switch_channel_get_name(channel), detected_tone);
@ -798,20 +796,14 @@ static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bu
} }
break; break;
} }
case SWITCH_ABC_TYPE_WRITE:
break;
case SWITCH_ABC_TYPE_WRITE_REPLACE:
break;
case SWITCH_ABC_TYPE_READ_REPLACE:
break;
case SWITCH_ABC_TYPE_READ_PING:
break;
case SWITCH_ABC_TYPE_CLOSE: case SWITCH_ABC_TYPE_CLOSE:
if (detector->spandsp_detector) { if (detector->spandsp_detector) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) destroying tone detector\n", switch_channel_get_name(channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) destroying tone detector\n", switch_channel_get_name(channel));
tone_detector_destroy(detector); tone_detector_destroy(detector);
} }
break; break;
default:
break;
} }
return SWITCH_TRUE; return SWITCH_TRUE;
} }

View File

@ -2489,9 +2489,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
tech_pvt->transports[LDL_TPORT_RTP].codec_index = -1; tech_pvt->transports[LDL_TPORT_RTP].codec_index = -1;
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index = -1; tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_index = -1;
switch_set_flag(tech_pvt, TFLAG_SECURE);
mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND);
mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND);
switch_channel_set_flag(tech_pvt->channel, TFLAG_SECURE);
@ -4101,7 +4101,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); mdl_build_crypto(tech_pvt, LDL_TPORT_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND);
mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND); mdl_build_crypto(tech_pvt, LDL_TPORT_VIDEO_RTP, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND);
switch_channel_set_flag(tech_pvt->channel, TFLAG_SECURE); switch_set_flag(tech_pvt, TFLAG_SECURE);
if (!(tech_pvt->transports[LDL_TPORT_RTP].local_port = switch_rtp_request_port(profile->ip))) { if (!(tech_pvt->transports[LDL_TPORT_RTP].local_port = switch_rtp_request_port(profile->ip))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "No RTP port available!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "No RTP port available!\n");

View File

@ -438,9 +438,11 @@ typedef enum {
struct sofia_gateway_subscription { struct sofia_gateway_subscription {
sofia_gateway_t *gateway; sofia_gateway_t *gateway;
nua_handle_t *nh;
char *expires_str; char *expires_str;
char *event; /* eg, 'message-summary' to subscribe to MWI events */ char *event; /* eg, 'message-summary' to subscribe to MWI events */
char *content_type; /* eg, application/simple-message-summary in the case of MWI events */ char *content_type; /* eg, application/simple-message-summary in the case of MWI events */
char *request_uri;
uint32_t freq; uint32_t freq;
int32_t retry_seconds; int32_t retry_seconds;
time_t expires; time_t expires;
@ -452,7 +454,6 @@ struct sofia_gateway_subscription {
struct sofia_gateway { struct sofia_gateway {
sofia_private_t *sofia_private; sofia_private_t *sofia_private;
nua_handle_t *nh; nua_handle_t *nh;
nua_handle_t *sub_nh;
sofia_profile_t *profile; sofia_profile_t *profile;
char *name; char *name;
char *register_scheme; char *register_scheme;
@ -491,7 +492,6 @@ struct sofia_gateway {
int32_t retry_seconds; int32_t retry_seconds;
int32_t reg_timeout_seconds; int32_t reg_timeout_seconds;
int32_t failure_status; int32_t failure_status;
sub_state_t sub_state;
reg_state_t state; reg_state_t state;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
int deleted; int deleted;

View File

@ -2510,6 +2510,7 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_
if ((gw_sub = switch_core_alloc(profile->pool, sizeof(*gw_sub)))) { if ((gw_sub = switch_core_alloc(profile->pool, sizeof(*gw_sub)))) {
char *expire_seconds = "3600", *retry_seconds = "30", *content_type = "NO_CONTENT_TYPE"; char *expire_seconds = "3600", *retry_seconds = "30", *content_type = "NO_CONTENT_TYPE";
uint32_t username_in_request = 0;
char *event = (char *) switch_xml_attr_soft(subscription_tag, "event"); char *event = (char *) switch_xml_attr_soft(subscription_tag, "event");
gw_sub->event = switch_core_strdup(gateway->pool, event); gw_sub->event = switch_core_strdup(gateway->pool, event);
gw_sub->gateway = gateway; gw_sub->gateway = gateway;
@ -2524,6 +2525,8 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_
retry_seconds = val; retry_seconds = val;
} else if (!strcmp(var, "content-type")) { } else if (!strcmp(var, "content-type")) {
content_type = val; content_type = val;
} else if (!strcmp(var, "username-in-request")) {
username_in_request = switch_true(val);
} }
} }
@ -2539,6 +2542,13 @@ static void parse_gateway_subscriptions(sofia_profile_t *profile, sofia_gateway_
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gw_sub->freq); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gw_sub->freq);
gw_sub->freq = 3600; gw_sub->freq = 3600;
} }
if(username_in_request) {
gw_sub->request_uri = gateway->register_to;
} else {
gw_sub->request_uri = gateway->register_url;
}
gw_sub->freq -= 2; gw_sub->freq -= 2;
gw_sub->content_type = switch_core_strdup(gateway->pool, content_type); gw_sub->content_type = switch_core_strdup(gateway->pool, content_type);
gw_sub->next = gateway->subscriptions; gw_sub->next = gateway->subscriptions;
@ -2741,12 +2751,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
su_guid_generate(guid); su_guid_generate(guid);
su_guid_sprintf(str_guid, su_guid_strlen + 1, guid); su_guid_sprintf(str_guid, su_guid_strlen + 1, guid);
str_rfc_5626 = switch_core_sprintf(gateway->pool, ";reg-id=%s;+sip.instance=\"<urn:uuid:%s>\"",reg_id,str_guid); str_rfc_5626 = switch_core_sprintf(gateway->pool, ";reg-id=%s;+sip.instance=\"<urn:uuid:%s>\"",reg_id,str_guid);
} }
if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) {
parse_gateway_subscriptions(profile, gateway, gw_subs_tag);
}
if (zstr(realm)) { if (zstr(realm)) {
if (zstr(proxy)) { if (zstr(proxy)) {
@ -2960,7 +2965,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
gateway->freq = 3600; gateway->freq = 3600;
} }
if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) {
parse_gateway_subscriptions(profile, gateway, gw_subs_tag);
}
sofia_reg_add_gateway(profile, gateway->name, gateway); sofia_reg_add_gateway(profile, gateway->name, gateway);
} }
@ -7406,6 +7414,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Transfer-Exten", exten); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Transfer-Exten", exten);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Full-Refer-To", full_ref_to); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Full-Refer-To", full_ref_to);
switch_channel_event_set_data(channel, event); switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
} }
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Blind Transfer 1 Legged calls\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot Blind Transfer 1 Legged calls\n");

View File

@ -3732,7 +3732,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
now = switch_epoch_time_now(NULL); now = switch_epoch_time_now(NULL);
sql = switch_mprintf("insert into sip_dialogs (sip_from_user,sip_from_host,call_info,call_info_state,hostname,expires,rcd,profile_name) " sql = switch_mprintf("insert into sip_dialogs (sip_from_user,sip_from_host,call_info,call_info_state,hostname,expires,rcd,profile_name) "
"values ('%q','%q','%q','seized','%q',%ld,%ld,'%q')", "values ('%q','%q','%q','seized','%q',%"SWITCH_TIME_T_FMT",%ld,'%q')",
to_user, to_host, switch_str_nil(p), mod_sofia_globals.hostname, to_user, to_host, switch_str_nil(p), mod_sofia_globals.hostname,
switch_epoch_time_now(NULL) + exp_delta, (long)now, profile->name); switch_epoch_time_now(NULL) + exp_delta, (long)now, profile->name);
@ -3979,10 +3979,10 @@ void sofia_presence_handle_sip_r_subscribe(int status,
gw_sub_ptr->state = SUB_STATE_FAILED; gw_sub_ptr->state = SUB_STATE_FAILED;
if (sofia_private) { if (sofia_private) {
if (sofia_private->gateway->sub_nh) { if (gw_sub_ptr->nh) {
nua_handle_bind(sofia_private->gateway->sub_nh, NULL); nua_handle_bind(gw_sub_ptr->nh, NULL);
nua_handle_destroy(sofia_private->gateway->sub_nh); nua_handle_destroy(gw_sub_ptr->nh);
sofia_private->gateway->sub_nh = NULL; gw_sub_ptr->nh = NULL;
} }
} else { } else {
nua_handle_destroy(nh); nua_handle_destroy(nh);

View File

@ -65,26 +65,27 @@ static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach)
} }
} }
static void sofia_reg_new_sub_handle(sofia_gateway_t *gateway_ptr, int attach) static void sofia_reg_new_sub_handle(sofia_gateway_subscription_t *gw_sub_ptr, int attach)
{ {
sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway;
char *user_via = NULL; char *user_via = NULL;
char *register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy); char *register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy);
int ss_state = nua_callstate_authenticating; int ss_state = nua_callstate_authenticating;
/* check for NAT and place a Via header if necessary (hostname or non-local IP) */ /* check for NAT and place a Via header if necessary (hostname or non-local IP) */
if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) { if (register_host && sofia_glue_check_nat(gateway_ptr->profile, register_host)) {
user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport); user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
} }
if (gateway_ptr->sub_nh) { if (gw_sub_ptr->nh) {
nua_handle_bind(gateway_ptr->sub_nh, NULL); nua_handle_bind(gw_sub_ptr->nh, NULL);
nua_handle_destroy(gateway_ptr->sub_nh); nua_handle_destroy(gw_sub_ptr->nh);
gateway_ptr->sub_nh = NULL; gw_sub_ptr->nh = NULL;
sofia_private_free(gateway_ptr->sofia_private); sofia_private_free(gateway_ptr->sofia_private);
} }
gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL, gw_sub_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL,
NUTAG_URL(gateway_ptr->register_proxy), NUTAG_URL(gateway_ptr->register_proxy),
TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
SIPTAG_TO_STR(gateway_ptr->register_to), SIPTAG_TO_STR(gateway_ptr->register_to),
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
@ -96,31 +97,32 @@ static void sofia_reg_new_sub_handle(sofia_gateway_t *gateway_ptr, int attach)
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
gateway_ptr->sofia_private->gateway = gateway_ptr; gateway_ptr->sofia_private->gateway = gateway_ptr;
nua_handle_bind(gateway_ptr->sub_nh, gateway_ptr->sofia_private); nua_handle_bind(gw_sub_ptr->nh, gateway_ptr->sofia_private);
} }
switch_safe_free(register_host); switch_safe_free(register_host);
switch_safe_free(user_via); switch_safe_free(user_via);
} }
static void sofia_reg_kill_sub(sofia_gateway_t *gateway_ptr) static void sofia_reg_kill_sub(sofia_gateway_subscription_t *gw_sub_ptr)
{ {
sofia_gateway_t *gateway_ptr = gw_sub_ptr->gateway;
if (gateway_ptr->sub_nh) { if (gw_sub_ptr->nh) {
nua_handle_bind(gateway_ptr->sub_nh, NULL); nua_handle_bind(gw_sub_ptr->nh, NULL);
} }
if (gateway_ptr->sub_state != SUB_STATE_SUBED && gateway_ptr->sub_state != SUB_STATE_UNSUBSCRIBE) { if (gw_sub_ptr->state != SUB_STATE_SUBED && gw_sub_ptr->state != SUB_STATE_UNSUBSCRIBE) {
if (gateway_ptr->sub_nh) { if (gw_sub_ptr->nh) {
nua_handle_destroy(gateway_ptr->sub_nh); nua_handle_destroy(gw_sub_ptr->nh);
gateway_ptr->sub_nh = NULL; gw_sub_ptr->nh = NULL;
} }
return; return;
} }
if (gateway_ptr->sub_nh) { if (gw_sub_ptr->nh) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Subbing %s\n", gateway_ptr->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Subbing %s %s\n", gateway_ptr->name, gw_sub_ptr->event);
nua_unsubscribe(gateway_ptr->sub_nh, NUTAG_URL(gateway_ptr->register_url), TAG_END()); nua_unsubscribe(gw_sub_ptr->nh, NUTAG_URL(gw_sub_ptr->request_uri), TAG_END());
} }
} }
@ -182,7 +184,7 @@ void sofia_reg_unregister(sofia_profile_t *profile)
for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) { for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) {
if (gw_sub_ptr->state == SUB_STATE_SUBED) { if (gw_sub_ptr->state == SUB_STATE_SUBED) {
sofia_reg_kill_sub(gateway_ptr); sofia_reg_kill_sub(gw_sub_ptr);
} }
} }
@ -211,7 +213,7 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
gw_sub_ptr->expires_str = "0"; gw_sub_ptr->expires_str = "0";
} }
gateway_ptr->sub_state = gw_sub_ptr->state; //gateway_ptr->sub_state = gw_sub_ptr->state;
switch (ostate) { switch (ostate) {
case SUB_STATE_NOSUB: case SUB_STATE_NOSUB:
@ -222,19 +224,19 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
break; break;
case SUB_STATE_UNSUBSCRIBE: case SUB_STATE_UNSUBSCRIBE:
gw_sub_ptr->state = SUB_STATE_NOSUB; gw_sub_ptr->state = SUB_STATE_NOSUB;
sofia_reg_kill_sub(gateway_ptr); sofia_reg_kill_sub(gw_sub_ptr);
break; break;
case SUB_STATE_UNSUBED: case SUB_STATE_UNSUBED:
sofia_reg_new_sub_handle(gateway_ptr, 1); sofia_reg_new_sub_handle(gw_sub_ptr, 1);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name);
if (now) { if (now) {
nua_subscribe(gateway_ptr->sub_nh, nua_subscribe(gw_sub_ptr->nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gw_sub_ptr->request_uri),
SIPTAG_EVENT_STR(gw_sub_ptr->event), SIPTAG_EVENT_STR(gw_sub_ptr->event),
SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
@ -242,10 +244,10 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now)
TAG_NULL()); TAG_NULL());
gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds; gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds;
} else { } else {
nua_unsubscribe(gateway_ptr->sub_nh, nua_unsubscribe(gw_sub_ptr->nh,
NUTAG_URL(gateway_ptr->register_url), NUTAG_URL(gw_sub_ptr->request_uri),
SIPTAG_EVENT_STR(gw_sub_ptr->event), SIPTAG_EVENT_STR(gw_sub_ptr->event),
SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), TAG_IF(strcmp(gw_sub_ptr->content_type, "NO_CONTENT_TYPE"), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type)),
SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from),
SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_TO_STR(gateway_ptr->register_from),
SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), TAG_NULL()); SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), TAG_NULL());

View File

@ -1688,6 +1688,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
memset(policy, 0, sizeof(*policy)); memset(policy, 0, sizeof(*policy));
switch_channel_set_variable(channel, "send_silence_when_idle", "true");
switch (crypto_key->type) { switch (crypto_key->type) {
case AES_CM_128_HMAC_SHA1_80: case AES_CM_128_HMAC_SHA1_80:
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp); crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp);
@ -3066,7 +3068,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
} }
#ifdef ENABLE_SRTP #ifdef ENABLE_SRTP
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV) && (!rtp_session->ice.ice_user || rtp_session->recv_msg.header.version == 2)) { if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV) && (!rtp_session->ice.ice_user || rtp_session->rtcp_recv_msg.header.version == 2)) {
int sbytes = (int) *bytes; int sbytes = (int) *bytes;
err_status_t stat = 0; err_status_t stat = 0;
@ -4499,6 +4501,8 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
if (switch_test_flag(frame, SFF_PROXY_PACKET) || switch_test_flag(frame, SFF_UDPTL_PACKET) || if (switch_test_flag(frame, SFF_PROXY_PACKET) || switch_test_flag(frame, SFF_UDPTL_PACKET) ||
switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) { switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
//if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
switch_size_t bytes; switch_size_t bytes;
//char bufa[30]; //char bufa[30];
@ -4512,11 +4516,13 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
send_msg = frame->packet; send_msg = frame->packet;
/*
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
send_msg->header.pt = rtp_session->payload; send_msg->header.pt = rtp_session->payload;
} }
*/
send_msg->header.ssrc = htonl(rtp_session->ssrc);
if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, frame->packet, &bytes) != SWITCH_STATUS_SUCCESS) { if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, frame->packet, &bytes) != SWITCH_STATUS_SUCCESS) {
return -1; return -1;