spandsp 3.0.0
v8.c File Reference
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
#include "spandsp/async.h"
#include "spandsp/vector_int.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
#include "spandsp/tone_detect.h"
#include "spandsp/tone_generate.h"
#include "spandsp/super_tone_rx.h"
#include "spandsp/power_meter.h"
#include "spandsp/fsk.h"
#include "spandsp/modem_connect_tones.h"
#include "spandsp/v8.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/power_meter.h"
#include "spandsp/private/fsk.h"
#include "spandsp/private/modem_connect_tones.h"
#include "spandsp/private/v8.h"

Macros

#define Te_TIMEOUT   500
 

Enumerations

enum  {
  V8_WAIT_1S = 0 , V8_AWAIT_ANSAM , V8_CI_ON , V8_CI_OFF ,
  V8_HEARD_ANSAM , V8_CM_ON , V8_CJ_ON , V8_CM_WAIT ,
  V8_POST_CM_WAIT , V8_SIGC , V8_JM_ON , V8_SIGA ,
  V8_PARKED
}
 
enum  { V8_SYNC_UNKNOWN = 0 , V8_SYNC_CI , V8_SYNC_CM_JM , V8_SYNC_V92 }
 
enum  {
  V8_CALL_FUNCTION_TAG = 0x01 , V8_MODULATION_TAG = 0x05 , V8_PROTOCOLS_TAG = 0x0A , V8_PSTN_ACCESS_TAG = 0x0D ,
  V8_NSF_TAG = 0x0F , V8_PCM_MODEM_AVAILABILITY_TAG = 0x07 , V8_T66_TAG = 0x0E
}
 
enum  { V8_CI_SYNC_OCTET = 0x00 , V8_CM_JM_SYNC_OCTET = 0xE0 , V8_V92_SYNC_OCTET = 0x55 }
 

Functions

const char * v8_status_to_str (int status)
 
const char * v8_call_function_to_str (int call_function)
 
const char * v8_modulation_to_str (int modulation_scheme)
 
const char * v8_protocol_to_str (int protocol)
 
const char * v8_pstn_access_to_str (int pstn_access)
 
const char * v8_nsf_to_str (int nsf)
 
const char * v8_pcm_modem_availability_to_str (int pcm_modem_availability)
 
const char * v8_t66_to_str (int t66)
 
void v8_log_supported_modulations (v8_state_t *s, int modulation_schemes)
 Log the list of supported modulations.
 
int v8_tx (v8_state_t *s, int16_t *amp, int max_len)
 Generate a block of V.8 audio samples.
 
int v8_decode_rx (v8_state_t *s, const int16_t *amp, int len)
 Decode a block of received V.8 audio samples.
 
int v8_rx (v8_state_t *s, const int16_t *amp, int len)
 Process a block of received V.8 audio samples.
 
int v8_continue (v8_state_t *s, v8_parms_t *parms)
 
logging_state_tv8_get_logging_state (v8_state_t *s)
 
int v8_restart (v8_state_t *s, bool calling_party, v8_parms_t *parms)
 
v8_state_tv8_init (v8_state_t *s, bool calling_party, v8_parms_t *parms, v8_result_handler_t result_handler, void *user_data)
 Initialise a V.8 context.
 
int v8_release (v8_state_t *s)
 Release a V.8 context.
 
int v8_free (v8_state_t *s)
 Release a V.8 context.
 

Variables

enum { ... }  v8_states_e
 
enum { ... }  v8_sync_types_e
 

Function Documentation

◆ v8_continue()

int v8_continue ( v8_state_t * s,
v8_parms_t * parms )

Continue with negotiation when in gateway mode.

◆ v8_decode_rx()

int v8_decode_rx ( v8_state_t * s,
const int16_t * amp,
int len )

Decode a block of received V.8 audio samples.

Decode a block of received V.8 audio samples. N.B. This is not the function to call to run the V.8 protocol on received audio. It is for analysing audio streams, to extract the V.8 messages, for monitoring or debug applications.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

References fsk_rx(), v8_state_s::logging, MODEM_CONNECT_TONES_NONE, modem_connect_tones_rx(), modem_connect_tones_rx_get(), and span_log().

◆ v8_free()

int v8_free ( v8_state_t * s)

Release a V.8 context.

Free a V.8 context.

Parameters
sThe V.8 context.
Returns
0 for OK.

References v8_release().

◆ v8_init()

v8_state_t * v8_init ( v8_state_t * s,
bool calling_party,
v8_parms_t * parms,
v8_result_handler_t result_handler,
void * user_data )

Initialise a V.8 context.

Initialise a V.8 context.

Parameters
sThe V.8 context.
calling_partyTrue if caller mode, else answerer mode.
parmsThe allowed parameters for the call.
result_handlerThe callback routine used to handle the results of negotiation.
user_dataAn opaque pointer passed to the result_handler routine.
Returns
A pointer to the V.8 context, or NULL if there was a problem.

References v8_state_s::logging, v8_state_s::result_handler, and v8_state_s::result_handler_user_data.

Referenced by fax_init(), and t31_init().

◆ v8_log_supported_modulations()

void v8_log_supported_modulations ( v8_state_t * s,
int modulation_schemes )

Log the list of supported modulations.

Log the list of supported modulations.

Parameters
sThe V.8 context.
modulation_schemesThe list of supported modulations.

References v8_state_s::logging, and span_log().

◆ v8_release()

int v8_release ( v8_state_t * s)

Release a V.8 context.

Release a V.8 context.

Parameters
sThe V.8 context.
Returns
0 for OK.

References queue_free().

Referenced by fax_release(), t31_release(), and v8_free().

◆ v8_rx()

int v8_rx ( v8_state_t * s,
const int16_t * amp,
int len )

Process a block of received V.8 audio samples.

Process a block of received V.8 audio samples.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

References fsk_rx(), fsk_tx_init(), v8_state_s::logging, MODEM_CONNECT_TONES_NONE, modem_connect_tones_rx(), modem_connect_tones_rx_get(), queue_contents(), queue_flush(), span_log(), span_log_buf(), v8_state_s::state, V8_STATUS_FAILED, V8_STATUS_V8_CALL, and V8_STATUS_V8_OFFERED.

◆ v8_tx()

int v8_tx ( v8_state_t * s,
int16_t * amp,
int max_len )

Generate a block of V.8 audio samples.

Generate a block of V.8 audio samples.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

References fsk_tx(), v8_state_s::logging, modem_connect_tones_tx(), span_log(), and v8_state_s::state.