backup
[lcr.git] / callpbx.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** PBX4Linux                                                                 **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** call header file for pbx calls                                            **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12
13 /* call
14  *
15  * calls connect interfaces together
16  * calls are linked in a chain
17  * interfaces can have 0, 1 or more references to a call
18  * the call can have many references to interfaces
19  * calls receive and send messages
20  */
21
22 #define RECORD_BUFFER_SIZE      16000
23
24 enum { /* relation types */
25         RELATION_TYPE_CALLING,  /* initiator of a call */
26         RELATION_TYPE_SETUP,    /* interface which is to be set up */
27         RELATION_TYPE_CONNECT,  /* interface is connected */
28 };
29
30 enum { /* relation audio state */
31         CHANNEL_STATE_CONNECT,  /* endpoint is connected to the call voice transmission in both dirs */
32         CHANNEL_STATE_HOLD,     /* endpoint is on hold state, no audio */
33 };
34
35 enum { /* states that results from last notification */
36         NOTIFY_STATE_ACTIVE, /* just the normal case, the party is active */
37         NOTIFY_STATE_SUSPEND, /* the party is inactive, because she has parked */
38         NOTIFY_STATE_HOLD, /* the party is inactive, because she holds the line */
39         NOTIFY_STATE_CONFERENCE, /* the parties joined a conference */
40 };
41
42
43 struct call_relation { /* relation to an interface */
44         struct call_relation *next;     /* next node */
45         int type;                       /* type of relation */
46         unsigned long epoint_id;        /* interface to link call to */
47         int channel_state;              /* if audio is available */
48         int rx_state;                   /* current state of what we received from endpoint */
49         int tx_state;                   /* current state of what we sent to endpoint */
50 };
51
52 class CallPBX : public Call
53 {
54         public:
55         CallPBX(class Endpoint *epoint);
56         ~CallPBX();
57         void message_epoint(unsigned long epoint_id, int message, union parameter *param);
58         int handler(void);
59         void release(unsigned long epoint_id, int hold, int location, int cause);
60
61         char c_caller[32];              /* caller number */
62         char c_caller_id[32];           /* caller id to signal */
63         char c_dialed[1024];            /* dial string of (all) number(s) */
64         char c_todial[32];              /* overlap dialing (part not signalled yet) */
65         
66         int c_pid;                      /* pid of call to generate bridge id */
67         int c_updatebridge;             /* bridge must be updated */
68         struct call_relation *c_relation; /* list of endpoints that are related to the call */
69
70         int c_partyline;                /* if set, call is conference room */
71
72         void bridge(void);
73         void bridge_data(unsigned long epoint_from, struct call_relation *relation_from, union parameter *param);
74         void remove_relation(struct call_relation *relation);
75         struct call_relation *add_relation(void);
76         int out_setup(unsigned long epoint_id, int message, union parameter *param, char *newnumber);
77 }; 
78
79 void callpbx_debug(class CallPBX *callpbx, char *function);
80 int callpbx_countrelations(unsigned long call_id);
81 int track_notify(int oldstate, int notify);
82