Added chan_lcr support for Asterisk 1.8.
[lcr.git] / bchannel.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** Linux Call Router                                                         **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** mISDN channel handlin for remote application                              **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 /* this test produces a test tone to test gaps in audio stream */
13 //#define SEAMLESS_TEST
14
15 #define QUEUE_BUFFER_SIZE               8192 /* must be the power of two */
16 #define QUEUE_BUFFER_MAX                4096 /* half of size */
17
18 struct bchannel {
19         struct bchannel *next;
20         struct chan_call *call;         /* link to call process */
21         unsigned int handle;            /* handle for stack id */
22         int b_sock;                     /* socket for b-channel */
23         struct lcr_fd lcr_fd;           /* socket register */
24         int b_mode;                     /* dsp, raw, dsphdlc */
25         int b_state;
26         int b_txdata;
27         int b_delay;
28         int b_tx_dejitter;
29         int b_tx_gain, b_rx_gain;
30         char b_pipeline[256];
31         unsigned int b_conf;
32         int b_echo;
33         int b_tone;
34         int b_rxoff;
35         // int b_txmix;
36         int b_dtmf;
37         int b_bf_len;
38         unsigned char b_bf_key[128];
39         int nodsp_queue;                /* enables nodsp_queue_buffer */
40         unsigned char nodsp_queue_buffer[QUEUE_BUFFER_SIZE];
41                                         /* buffer for seamless transmission */
42         unsigned int nodsp_queue_in, nodsp_queue_out;
43                                         /* in and out pointers */
44         int queue_sent;                 /* data for mISDN was not confrmed yet */
45 #ifdef SEAMLESS_TEST
46         int test;
47 #endif
48 };
49
50
51 extern struct bchannel *bchannel_first;
52 extern pid_t bchannel_pid;
53
54 int bchannel_initialize(void);
55 void bchannel_deinitialize(void);
56 void bchannel_destroy(struct bchannel *bchannel);
57 int bchannel_create(struct bchannel *channel, int mode, int queue);
58 void bchannel_activate(struct bchannel *channel, int activate);
59 void bchannel_transmit(struct bchannel *channel, unsigned char *data, int len);
60 void bchannel_join(struct bchannel *channel, unsigned short id);
61 void bchannel_dtmf(struct bchannel *channel, int on);
62 void bchannel_blowfish(struct bchannel *bchannel, unsigned char *key, int len);
63 void bchannel_pipeline(struct bchannel *bchannel, char *pipeline);
64 void bchannel_gain(struct bchannel *bchannel, int gain, int tx);
65 struct bchannel *find_bchannel_handle(unsigned int handle);
66 //struct bchannel *find_bchannel_ref(unsigned int ref);
67 struct bchannel *alloc_bchannel(unsigned int handle);
68 void free_bchannel(struct bchannel *channel);
69