Merge branch 'master' of ssh://jolly@www.mISDN.org/var/git/lcr
[lcr.git] / joinpbx.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** Linux Call Router                                                         **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** join header file for pbx joins                                            **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12
13 /* join
14  *
15  * joins connect interfaces together
16  * joins are linked in a chain
17  * interfaces can have 0, 1 or more references to a join
18  * the join can have many references to interfaces
19  * joins receive and send messages
20  */
21
22 #define RECORD_BUFFER_SIZE      16000
23
24 enum { /* relation types */
25         RELATION_TYPE_CALLING,  /* initiator of a join */
26         RELATION_TYPE_SETUP,    /* interface which is to be set up */
27         RELATION_TYPE_CONNECT,  /* interface is connected */
28 };
29
30 enum { /* states that results from last notification */
31         NOTIFY_STATE_ACTIVE, /* just the normal case, the party is active */
32         NOTIFY_STATE_SUSPEND, /* the party is inactive, because she has parked */
33         NOTIFY_STATE_HOLD, /* the party is inactive, because she holds the line */
34         NOTIFY_STATE_CONFERENCE, /* the parties joined a conference */
35 };
36
37
38 struct join_relation { /* relation to an interface */
39         struct join_relation *next;     /* next node */
40         int type;                       /* type of relation */
41         unsigned int epoint_id; /* interface to link join to */
42         int channel_state;              /* if audio is available */
43         int rx_state;                   /* current state of what we received from endpoint */
44         int tx_state;                   /* current state of what we sent to endpoint */
45 };
46
47 class JoinPBX : public Join
48 {
49         public:
50         JoinPBX(class Endpoint *epoint);
51         ~JoinPBX();
52         void message_epoint(unsigned int epoint_id, int message, union parameter *param);
53         int handler(void);
54         int release(struct join_relation *relation, int location, int cause);
55
56         char j_caller[32];              /* caller number */
57         char j_caller_id[32];           /* caller id to signal */
58         char j_dialed[1024];            /* dial string of (all) number(s) */
59         char j_todial[32];              /* overlap dialing (part not signalled yet) */
60         int j_multicause, j_multilocation;
61         
62         int j_pid;                      /* pid of join to generate bridge id */
63         int j_updatebridge;             /* bridge must be updated */
64         struct join_relation *j_relation; /* list of endpoints that are related to the join */
65
66         int j_partyline;                /* if set, join is conference room */
67         int j_partyline_jingle;         /* also play jingle on join/leave */
68
69         void bridge(void);
70         void bridge_data(unsigned int epoint_from, struct join_relation *relation_from, union parameter *param);
71         void remove_relation(struct join_relation *relation);
72         struct join_relation *add_relation(void);
73         int out_setup(unsigned int epoint_id, int message, union parameter *param, char *newnumber, char *newkeypad);
74         void play_jingle(int in);
75 }; 
76
77 void joinpbx_debug(class JoinPBX *joinpbx, const char *function);
78 int joinpbx_countrelations(unsigned int join_id);
79 int track_notify(int oldstate, int notify);
80