spandsp  3.0.0
v18.c File Reference
#include <stdlib.h>
#include <inttypes.h>
#include <memory.h>
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/fast_convert.h"
#include "spandsp/queue.h"
#include "spandsp/async.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/dtmf.h"
#include "spandsp/modem_connect_tones.h"
#include "spandsp/v8.h"
#include "spandsp/v18.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/queue.h"
#include "spandsp/private/tone_generate.h"
#include "spandsp/private/async.h"
#include "spandsp/private/power_meter.h"
#include "spandsp/private/fsk.h"
#include "spandsp/private/dtmf.h"
#include "spandsp/private/modem_connect_tones.h"
#include "spandsp/private/v18.h"

Classes

struct  dtmf_to_ascii_s
 

Macros

#define GOERTZEL_SAMPLES_PER_BLOCK   102
 
#define FP_SCALE(x)   (x)
 
#define BAUDOT_FIGURE_SHIFT   0x1B
 
#define BAUDOT_LETTER_SHIFT   0x1F
 

Functions

const char * v18_status_to_str (int status)
 
const char * v18_mode_to_str (int mode)
 Return a short name for a V.18 mode. More...
 
int v18_tx (v18_state_t *s, int16_t *amp, int max_len)
 
int v18_rx (v18_state_t *s, const int16_t amp[], int len)
 Process a block of received V.18 audio samples. More...
 
int v18_rx_fillin (v18_state_t *s, int len)
 Fake processing of a missing block of received V.18 audio samples. More...
 
int v18_put (v18_state_t *s, const char msg[], int len)
 Put a string to a V.18 context's input buffer. More...
 
int v18_get_current_mode (v18_state_t *s)
 Get the current mode of a V.18 connection. More...
 
logging_state_tv18_get_logging_state (v18_state_t *s)
 
int v18_set_stored_message (v18_state_t *s, const char *msg)
 Set the stored message, as per V.18/5.2.12.1. This message may be up to 80 bytes long. More...
 
v18_state_tv18_init (v18_state_t *s, bool calling_party, int mode, int nation, span_put_msg_func_t put_msg, void *put_msg_user_data, span_modem_status_func_t status_handler, void *status_handler_user_data)
 Initialise a V.18 context. More...
 
int v18_release (v18_state_t *s)
 Release a V.18 context. More...
 
int v18_free (v18_state_t *s)
 Release a V.18 context. More...
 

Macro Definition Documentation

◆ BAUDOT_FIGURE_SHIFT

#define BAUDOT_FIGURE_SHIFT   0x1B

The baudot code to shift from alpha to digits and symbols

◆ BAUDOT_LETTER_SHIFT

#define BAUDOT_LETTER_SHIFT   0x1F

The baudot code to shift from digits and symbols to alpha

Function Documentation

◆ v18_free()

int v18_free ( v18_state_t s)

Release a V.18 context.

Free a V.18 context.

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

References queue_release().

◆ v18_get_current_mode()

int v18_get_current_mode ( v18_state_t s)

Get the current mode of a V.18 connection.

Parameters
sThe V.18 context.
Returns
The mode.

◆ v18_init()

v18_state_t* v18_init ( v18_state_t s,
bool  calling_party,
int  mode,
int  nation,
span_put_msg_func_t  put_msg,
void *  put_msg_user_data,
span_modem_status_func_t  status_handler,
void *  status_handler_user_data 
)

Initialise a V.18 context.

Initialise a V.18 context.

Parameters
sThe V.18 context.
calling_partyTrue if caller mode, else answerer mode.
modeMode of operation.
nationNational variant for automoding.
put_msgA callback routine called to deliver the received text to the application.
put_msg_user_dataAn opaque pointer for the put_msg callback routine.
status_handlerA callback routine called to deliver status reports.
status_handler_user_dataAn opaque pointer for the status callback routine.
Returns
A pointer to the V.18 context, or NULL if there was a problem.

◆ v18_mode_to_str()

const char* v18_mode_to_str ( int  mode)

Return a short name for a V.18 mode.

Parameters
modeThe code for the V.18 mode.
Returns
A pointer to the name.

◆ v18_put()

int v18_put ( v18_state_t s,
const char  msg[],
int  len 
)

Put a string to a V.18 context's input buffer.

Parameters
sThe V.18 context.
msgThe string to be added.
lenThe length of the string. If negative, the string is assumed to be a NULL terminated string.
Returns
The number of characters actually added. This may be less than the length of the digit string, if the buffer fills up. If the string is invalid, this function will return -1.

◆ v18_release()

int v18_release ( v18_state_t s)

Release a V.18 context.

Release a V.18 context.

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

References queue_release().

◆ v18_rx()

int v18_rx ( v18_state_t s,
const int16_t  amp[],
int  len 
)

Process a block of received V.18 audio samples.

Process a block of received V.18 audio samples.

Parameters
sThe V.18 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of unprocessed samples.

◆ v18_rx_fillin()

int v18_rx_fillin ( v18_state_t s,
int  len 
)

Fake processing of a missing block of received V.18 audio samples.

Fake processing of a missing block of received V.18 audio samples. (e.g due to packet loss).

Parameters
sThe V.18 context.
lenThe number of samples to fake.
Returns
The number of unprocessed samples.

◆ v18_set_stored_message()

int v18_set_stored_message ( v18_state_t s,
const char *  msg 
)

Set the stored message, as per V.18/5.2.12.1. This message may be up to 80 bytes long.

Parameters
sThe V.18 context.
msgThe string to be set.