summaryrefslogtreecommitdiffstats
path: root/src/ss5/dsp.h
blob: aa58deacdfb47ad5430acc2c33158164f4469419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
struct ss5_endpoint;

typedef struct dsp {
	void *priv;
	double samplerate;

	/* tone generation */
	mf_mod_t *mf_mod;		/* MF modulator */
	char tone;			/* current digit playing or 0 */
	uint32_t tone_mask;		/* bit-mask of which MF tones to play */
	int tone_duration;		/* counter of samples for length of tone */
	char dial_string[33];		/* stores digits when dialing number sequence */
	int dial_length;		/* length of dial string, or 0 */
	int dial_index;			/* current position at dial string */
	int digit_pause;		/* flag that states if pause is played after digit */

	/* tone detection */
	mf_demod_t *mf_demod;		/* MF demodulator */
	double ms_per_sample;		/* how many milliseconds between two samples */
	double detect_interval;		/* counts milliseconds */
	int interrupt_duration;		/* number of milliseconds until interruption is detected */
	int interrupt_count;		/* counter for interrupt condition */
	int split_duration;		/* number of milliseconds until split (mute) condition meats */
	int split_count;		/* counter for split condition */
	int sig_detect_duration_AB;	/* signaling tone duration in milliseconds (TONE A/B) */
	int sig_detect_duration_C;	/* signaling tone duration in milliseconds (TONE C) */
	int mf_detect_duration;		/* MF tone duration in milliseconds */
	int detect_count;		/* counter for tone detection */
	char detect_tone;		/* current tone detected or ' ' for no tone */
} dsp_t;


int dsp_init_inst(dsp_t *dsp, void *priv, double samplerate, double sense_db);
void dsp_cleanup_inst(dsp_t *dsp);
void set_sig_detect_duration(dsp_t *dsp, double duration_AB, double duration_C);
void set_tone(dsp_t *dsp, char tone, double duration);
void set_dial_string(dsp_t *dsp, const char *dial);
void audio_clock(struct ss5_endpoint *ss5_ep_sunset, struct ss5_endpoint *ss5_ep_sunrise, int len);
void down_audio(struct osmo_cc_session_codec *codec, uint16_t __attribute__((unused)) sequence_number, uint32_t __attribute__((unused)) timestamp, uint8_t *data, int len);
void encode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len);
void decode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len);

void receive_digit(void *priv, char digit, double dbm);
void dialing_complete(void *priv);