spandsp 3.0.0
private/v18.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/v18.h - V.18 text telephony for the deaf.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004-2009 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#if !defined(_SPANDSP_PRIVATE_V18_H_)
27#define _SPANDSP_PRIVATE_V18_H_
28
29enum
30{
31 GOERTZEL_TONE_SET_390HZ = 0,
32 GOERTZEL_TONE_SET_980HZ = 1,
33 GOERTZEL_TONE_SET_1180HZ = 2,
34 GOERTZEL_TONE_SET_1270HZ = 3,
35 GOERTZEL_TONE_SET_1300HZ = 4,
36 GOERTZEL_TONE_SET_1400HZ = 5,
37 GOERTZEL_TONE_SET_1650HZ = 6,
38 GOERTZEL_TONE_SET_1800HZ = 7,
39 GOERTZEL_TONE_SET_2225HZ = 8,
40 GOERTZEL_TONE_SET_ENTRIES = 9
41};
42
43enum
44{
45 V18_TX_STATE_ORIGINATING_1 = 1,
46 V18_TX_STATE_ORIGINATING_2 = 2,
47 V18_TX_STATE_ORIGINATING_3 = 3,
48 V18_TX_STATE_ORIGINATING_42 = 42,
49
50 V18_TX_STATE_ANSWERING_1 = 101,
51 V18_TX_STATE_ANSWERING_2 = 102,
52 V18_TX_STATE_ANSWERING_3 = 103,
53 V18_TX_STATE_ANSWERING_42 = 142
54};
55
56enum
57{
58 V18_RX_STATE_ORIGINATING_1 = 1,
59 V18_RX_STATE_ORIGINATING_2 = 2,
60 V18_RX_STATE_ORIGINATING_3 = 3,
61 V18_RX_STATE_ORIGINATING_42 = 42,
62
63 V18_RX_STATE_ANSWERING_1 = 101,
64 V18_RX_STATE_ANSWERING_2 = 102,
65 V18_RX_STATE_ANSWERING_3 = 103,
66 V18_RX_STATE_ANSWERING_42 = 142
67};
68
70{
71 /*! \brief True if we are the calling modem */
73 int initial_mode;
74 int nation;
75 span_put_msg_func_t put_msg;
76 void *put_msg_user_data;
77 span_modem_status_func_t status_handler;
78 void *status_handler_user_data;
79 bool repeat_shifts;
80 bool autobauding;
81 /* The stored message is used during probing. See V.18/5.2.12.1 */
82 char stored_message[81];
83 int current_mode;
84 int tx_state;
85 int rx_state;
86 union
87 {
88 queue_state_t queue;
89 uint8_t buf[QUEUE_STATE_T_SIZE(128)];
90 } queue;
91 tone_gen_descriptor_t alert_tone_desc;
92 tone_gen_state_t alert_tone_gen;
94 dtmf_tx_state_t dtmf_tx;
95 async_tx_state_t async_tx;
96 int baudot_tx_shift;
97 int tx_signal_on;
98 bool tx_draining;
99 uint8_t next_byte;
100
102 dtmf_rx_state_t dtmf_rx;
103 modem_connect_tones_rx_state_t answer_tone_rx;
104
105#if defined(SPANDSP_USE_FIXED_POINTx)
106 /*! Minimum acceptable tone level for detection. */
107 int32_t threshold;
108 /*! The accumlating total energy on the same period over which the Goertzels work. */
109 int32_t energy;
110#else
111 /*! Minimum acceptable tone level for detection. */
113 /*! The accumlating total energy on the same period over which the Goertzels work. */
114 float energy;
115#endif
116 goertzel_state_t tone_set[GOERTZEL_TONE_SET_ENTRIES];
117 /*! The current sample number within a tone processing block. */
119 /*! Tone state duration */
120 span_sample_timer_t tone_duration;
121 span_sample_timer_t target_tone_duration;
122 int in_tone;
123
124 int baudot_rx_shift;
125 uint8_t rx_msg[256 + 1];
126 int rx_msg_len;
127 span_sample_timer_t msg_in_progress_timer;
128
129 span_sample_timer_t rx_suppression_timer;
130 span_sample_timer_t tx_suppression_timer;
131
132 span_sample_timer_t ta_interval;
133 span_sample_timer_t tc_interval;
134 span_sample_timer_t te_interval;
135 span_sample_timer_t tm_interval;
136 span_sample_timer_t tr_interval;
137 span_sample_timer_t tt_interval;
138
139 span_sample_timer_t ta_timer; // 3s automoding timer
140 span_sample_timer_t tc_timer; // 6s probing timer
141 span_sample_timer_t te_timer; // 2.7s probing timer
142 span_sample_timer_t tm_timer; // 3s probing timer
143 span_sample_timer_t tr_timer; // 2s
144 span_sample_timer_t tt_timer; // 3s return to probing timer
145
146 int txp_cnt;
147
148 /*! \brief Error and flow logging control */
150};
151
152#endif
153/*- End of file ------------------------------------------------------------*/
void(* span_modem_status_func_t)(void *user_data, int status)
Definition async.h:131
struct async_tx_state_s async_tx_state_t
Definition async.h:139
void(* span_put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:107
int dtmf_tx(dtmf_tx_state_t *s, int16_t amp[], int max_samples)
Generate a buffer of DTMF tones.
Definition dtmf.c:551
int dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples)
Process a block of received DTMF audio samples.
Definition dtmf.c:132
int fsk_tx(fsk_tx_state_t *s, int16_t amp[], int len)
Generate a block of FSK modem audio samples.
Definition fsk.c:162
int fsk_rx(fsk_rx_state_t *s, const int16_t *amp, int len)
Process a block of received FSK modem audio samples.
Definition fsk.c:396
struct fsk_rx_state_s fsk_rx_state_t
Definition fsk.h:146
struct fsk_tx_state_s fsk_tx_state_t
Definition fsk.h:137
struct logging_state_s logging_state_t
Definition logging.h:72
struct modem_connect_tones_rx_state_s modem_connect_tones_rx_state_t
Definition modem_connect_tones.h:105
struct queue_state_s queue_state_t
Definition queue.h:54
Definition private/v18.h:70
float threshold
Definition private/v18.h:112
float energy
Definition private/v18.h:114
logging_state_t logging
Error and flow logging control.
Definition private/v18.h:149
int current_goertzel_sample
Definition private/v18.h:118
span_sample_timer_t tone_duration
Definition private/v18.h:120
bool calling_party
True if we are the calling modem.
Definition private/v18.h:72
struct tone_gen_descriptor_s tone_gen_descriptor_t
Definition tone_generate.h:51
struct tone_gen_state_s tone_gen_state_t
Definition tone_generate.h:57