spandsp: v18.c File Reference

spandsp 0.0.6

v18.c File Reference
`#include <inttypes.h>`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <memory.h>`
`#include "floating_fudge.h"`
`#include "spandsp/telephony.h"`
`#include "spandsp/logging.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/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 | BAUDOT_FIGURE_SHIFT 0x1B
#define | BAUDOT_LETTER_SHIFT 0x1F

## Functions
int | v18_encode_dtmf (v18_state_t *s, char dtmf[], const char msg[])
| Convert a text string to a V.18 DTMF string.
int | v18_decode_dtmf (v18_state_t *s, char msg[], const char dtmf[])
| Convert a V.18 DTMF string to a text string.
uint16_t | v18_encode_baudot (v18_state_t *s, uint8_t ch)
uint8_t | v18_decode_baudot (v18_state_t *s, uint8_t ch)
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)
int | v18_put (v18_state_t *s, const char msg[], int len)
| Put a string to a V.18 context's input buffer.
logging_state_t * | v18_get_logging_state (v18_state_t *s)
v18_state_t * | v18_init (v18_state_t *s, int calling_party, int mode, put_msg_func_t put_msg, void *user_data)
| Initialise a V.18 context.
int | v18_release (v18_state_t *s)
| Release a V.18 context.
int | v18_free (v18_state_t *s)
| Release a V.18 context.
const char * | v18_mode_to_str (int mode)
| Return a short name for an V.18 mode.

## 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_decode_dtmf()

int v18_decode_dtmf | ( | v18_state_t * | s,
|  | char | msg[],
|  | const char | dtmf[] )

Convert a V.18 DTMF string to a text string.

Convert a V.18 DTMF string to a text string.

Parameters

  s | The V.18 context.
  msg | The resulting test string.
  dtmf | The DTMF string to be converted.

Returns
  The length of the text string.

## ◆ v18_encode_dtmf()

int v18_encode_dtmf | ( | v18_state_t * | s,
|  | char | dtmf[],
|  | const char | msg[] )

Convert a text string to a V.18 DTMF string.

Convert a text string to a V.18 DTMF string.

Parameters

  s | The V.18 context.
  dtmf | The resulting DTMF string.
  msg | The text string to be converted.

Returns
  The length of the DTMF string.

## ◆ v18_free()

int v18_free | ( | v18_state_t * | s | ) |

Release a V.18 context.

Free a V.18 context.

Parameters

  s | The V.18 context.

Returns
  0 for OK.

## ◆ v18_init()

v18_state_t * v18_init | ( | v18_state_t * | s,
|  | int | calling_party,
|  | int | mode,
|  | put_msg_func_t | put_msg,
|  | void * | user_data )

Initialise a V.18 context.

Initialise a V.18 context.

Parameters

  s | The V.18 context.
  calling_party | TRUE if caller mode, else answerer mode.
  mode | Mode of operation.
  put_msg | A callback routine called to deliver the received text to the application.
  user_data | An opaque pointer for the callback routine.

Returns
  A pointer to the V.18 context, or NULL if there was a problem.

References ASYNC_PARITY_EVEN, ASYNC_PARITY_NONE, async_tx_init(), v18_state_s::calling_party, dtmf_rx_init(), dtmf_tx_init(), fsk_rx_init(), fsk_tx_init(), queue_init(), QUEUE_READ_ATOMIC, and QUEUE_WRITE_ATOMIC.

## ◆ v18_mode_to_str()

const char * v18_mode_to_str | ( | int | mode | ) |

Return a short name for an V.18 mode.

Parameters

  mode | The 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

  s | The V.18 context.
  msg | The string to be added.
  len | The 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.

References queue_write().

## ◆ v18_release()

int v18_release | ( | v18_state_t * | s | ) |

Release a V.18 context.

Release a V.18 context.

Parameters

  s | The V.18 context.

Returns
  0 for OK.