1bc06f734fa1d31055bed56c29104c7c6b0e6eb1
[lcr.git] / sip.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** Linux Call Router                                                         **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** SIP-port header file                                                      **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 #include <sofia-sip/nua.h>
13
14 /* SIP port class */
15 class Psip : public PmISDN
16 {
17         public:
18         Psip(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive, int mode, struct interface *interface);
19         ~Psip();
20         int message_epoint(unsigned int epoint_id, int message, union parameter *param);
21         int message_connect(unsigned int epoint_id, int message, union parameter *param);
22         int message_release(unsigned int epoint_id, int message, union parameter *param);
23         int message_setup(unsigned int epoint_id, int message, union parameter *param);
24         void i_invite(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
25         void i_bye(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
26         void i_cancel(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
27         void r_bye(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
28         void r_cancel(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
29         void r_invite(int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]);
30         void *p_m_s_sip_inst;
31         struct lcr_work p_m_s_delete;
32         nua_handle_t *p_m_s_handle;
33         nua_magic_t *p_m_s_magic;
34         unsigned short p_m_s_rtp_port_local;
35         unsigned short p_m_s_rtp_port_remote;
36         unsigned int p_m_s_rtp_ip_local;
37         unsigned int p_m_s_rtp_ip_remote;
38         struct sockaddr_in p_m_s_rtp_sin_local;
39         struct sockaddr_in p_m_s_rtp_sin_remote;
40         struct sockaddr_in p_m_s_rtcp_sin_local;
41         struct sockaddr_in p_m_s_rtcp_sin_remote;
42         struct lcr_fd p_m_s_rtp_fd;
43         struct lcr_fd p_m_s_rtcp_fd;
44         int p_m_s_rtp_is_connected; /* if RTP session is connected, so we may send frames */
45         int p_m_s_rtp_tx_action;
46         uint16_t p_m_s_rtp_tx_sequence;
47         uint32_t p_m_s_rtp_tx_timestamp;
48         uint32_t p_m_s_rtp_tx_ssrc;
49         struct timeval p_m_s_rtp_tx_last_tv;
50         int rtp_open(void);
51         int rtp_connect(void);
52         void rtp_close(void);
53         int rtp_send_frame(unsigned char *data, unsigned int len, int payload_type);
54         int p_m_s_b_sock; /* SIP bchannel socket */
55         struct lcr_fd p_m_s_b_fd; /* event node */
56         int p_m_s_b_index; /* SIP bchannel socket index to use */
57         int p_m_s_b_active; /* SIP bchannel socket is activated */
58         unsigned char p_m_s_rxdata[160]; /* receive audio buffer */
59         int p_m_s_rxpos; /* position in audio buffer 0..159 */
60         int hunt_bchannel(void);
61         void bchannel_close(void);
62         int bchannel_open(int);
63         void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
64         void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
65         int parse_sdp(sip_t const *sip, unsigned int *ip, unsigned short *port);
66         void rtp_shutdown(void);
67 };
68
69 int sip_init_inst(struct interface *interface);
70 void sip_exit_inst(struct interface *interface);
71 int sip_init(void);
72 void sip_exit(void);
73 void sip_handle(void);