spandsp  0.0.6
rfc2198_sim.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * rfc2198_sim.h - Simulate the behaviour of RFC2198 (or UDPTL) redundancy.
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2007 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 /*! \file */
27 
28 /*! \page rfc2198_model_page RFC2198 simulation
29 \section rfc2198_model_page_sec_1 What does it do?
30 */
31 
32 #if !defined(_RFC2198_SIM_H_)
33 #define _RFC2198_SIM_H_
34 
35 /*! The definition of an element in the packet queue */
37 {
38  struct rfc2198_sim_queue_element_s *next;
39  struct rfc2198_sim_queue_element_s *prev;
40  int seq_no;
41  double departure_time;
42  double arrival_time;
43  int len;
44  uint8_t pkt[];
46 
47 /*! The model definition for a complete end-to-end path */
48 typedef struct
49 {
50  int redundancy_depth;
51  int next_seq_no;
52  g1050_state_t *g1050;
55  uint8_t tx_pkt[32][1024];
56  int tx_pkt_len[32];
57  int tx_pkt_seq_no[32];
58  int next_pkt;
59  uint8_t rx_pkt[32][1024];
60  int rx_pkt_len[32];
61  int rx_pkt_seq_no[32];
62  int rx_queued_pkts;
64 
65 #ifdef __cplusplus
66 extern "C"
67 {
68 #endif
69 
70 SPAN_DECLARE(rfc2198_sim_state_t *) rfc2198_sim_init(int model,
71  int speed_pattern,
72  int packet_size,
73  int packet_rate,
74  int redundancy_depth);
75 
76 SPAN_DECLARE(int) rfc2198_sim_put(rfc2198_sim_state_t *s,
77  const uint8_t buf[],
78  int len,
79  int seq_no,
80  double departure_time);
81 
82 SPAN_DECLARE(int) rfc2198_sim_get(rfc2198_sim_state_t *s,
83  uint8_t buf[],
84  int max_len,
85  double current_time,
86  int *seq_no,
87  double *departure_time,
88  double *arrival_time);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif
95 /*- End of file ------------------------------------------------------------*/
queue_state_s
Definition: private/queue.h:33
r2_mf_tx_state_s
Definition: private/bell_r2_mf.h:72
QUEUE_WRITE_ATOMIC
#define QUEUE_WRITE_ATOMIC
Definition: queue.h:48
r2_mf_rx_init
r2_mf_rx_state_t * r2_mf_rx_init(r2_mf_rx_state_t *s, int fwd, tone_report_func_t callback, void *user_data)
Initialise an R2 MF receiver context.
Definition: bell_r2_mf.c:807
rfc2198_sim_queue_element_t
struct rfc2198_sim_queue_element_s rfc2198_sim_queue_element_t
r2_mf_rx_state_s
Definition: private/bell_r2_mf.h:85
queue_state_s::len
int len
The length of the data buffer.
Definition: private/queue.h:38
queue_state_s::optr
volatile int optr
The buffer output pointer.
Definition: private/queue.h:42
awgn_state_s
Definition: private/awgn.h:32
queue_write_msg
int queue_write_msg(queue_state_t *s, const uint8_t *buf, int len)
Write a message to a queue.
Definition: queue.c:335
queue_read_byte
int queue_read_byte(queue_state_t *s)
Read a byte from a queue.
Definition: queue.c:188
r2_mf_rx
int r2_mf_rx(r2_mf_rx_state_t *s, const int16_t amp[], int samples)
Process a block of received R2 MF audio samples.
Definition: bell_r2_mf.c:680
r2_mf_rx_get
int r2_mf_rx_get(r2_mf_rx_state_t *s)
Get the current digit from an R2 MF receiver.
Definition: bell_r2_mf.c:801
queue_contents
int queue_contents(queue_state_t *s)
Check the contents of a queue.
Definition: queue.c:63
queue_read
int queue_read(queue_state_t *s, uint8_t *buf, int len)
Read bytes from a queue.
Definition: queue.c:130
g1050_state_t
Definition: g1050.h:248
rfc2198_sim_state_t
Definition: rfc2198_sim.h:48
mf_digit_tones_t
Definition: bell_r2_mf.c:71
queue_init
queue_state_t * queue_init(queue_state_t *s, int len, int flags)
Initialise a queue.
Definition: queue.c:394
rfc2198_sim_queue_element_s
Definition: rfc2198_sim.h:36
rfc2198_sim.h
queue_state_s::iptr
volatile int iptr
The buffer input pointer.
Definition: private/queue.h:40
queue_free_space
int queue_free_space(queue_state_t *s)
Check available free space.
Definition: queue.c:52
g1050.h
tone_gen_descriptor_s
Definition: private/tone_generate.h:42
r2_mf_tx_init
r2_mf_tx_state_t * r2_mf_tx_init(r2_mf_tx_state_t *s, int fwd)
Initialise an R2 MF tone generator context.
Definition: bell_r2_mf.c:394
r2_mf_tx
int r2_mf_tx(r2_mf_tx_state_t *s, int16_t amp[], int samples)
Generate a block of R2 MF tones.
Definition: bell_r2_mf.c:357
spandsp-sim.h
tone_gen_descriptor_init
tone_gen_descriptor_t * tone_gen_descriptor_init(tone_gen_descriptor_t *s, int f1, int l1, int f2, int l2, int d1, int d2, int d3, int d4, int repeat)
Create a tone generator descriptor.
Definition: tone_generate.c:60
queue_write_byte
int queue_write_byte(queue_state_t *s, uint8_t byte)
Write a byte to a queue.
Definition: queue.c:267
queue_write
int queue_write(queue_state_t *s, const uint8_t *buf, int len)
Write bytes to a queue.
Definition: queue.c:214
queue_read_msg
int queue_read_msg(queue_state_t *s, uint8_t *buf, int len)
Read a message from a queue.
Definition: queue.c:309
QUEUE_READ_ATOMIC
#define QUEUE_READ_ATOMIC
Definition: queue.h:45
r2_mf_tx_put
int r2_mf_tx_put(r2_mf_tx_state_t *s, char digit)
Generate a block of R2 MF tones.
Definition: bell_r2_mf.c:374
tone_gen_state_s
Definition: private/tone_generate.h:53
queue_free
int queue_free(queue_state_t *s)
Delete a queue.
Definition: queue.c:415