mncc: Use stdint.h from C++, copy newer version of OpenBSC's mncc.h
[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 extern int any_sip_interface;
15
16 /* SIP port class */
17 class Psip : public Port
18 {
19         public:
20         Psip(int type, char *portname, struct port_settings *settings, struct interface *interface);
21         ~Psip();
22         int message_epoint(unsigned int epoint_id, int message, union parameter *param);
23         int message_connect(unsigned int epoint_id, int message, union parameter *param);
24         int message_release(unsigned int epoint_id, int message, union parameter *param);
25         int message_setup(unsigned int epoint_id, int message, union parameter *param);
26         int message_notify(unsigned int epoint_id, int message, union parameter *param);
27         int message_information(unsigned int epoint_id, int message, union parameter *param);
28         int message_dtmf(unsigned int epoint_id, int message, union parameter *param);
29         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[]);
30         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[]);
31         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[]);
32         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[]);
33         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[]);
34         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[]);
35         void *p_s_sip_inst;
36         struct lcr_work p_s_delete;
37         nua_handle_t *p_s_handle;
38         nua_magic_t *p_s_magic;
39         int p_s_rtp_bridge; /* bridge RTP instead of having a local RTP peer */
40         unsigned short p_s_rtp_port_local;
41         unsigned short p_s_rtp_port_remote;
42         unsigned int p_s_rtp_ip_local;
43         unsigned int p_s_rtp_ip_remote;
44         struct sockaddr_in p_s_rtp_sin_local;
45         struct sockaddr_in p_s_rtp_sin_remote;
46         struct sockaddr_in p_s_rtcp_sin_local;
47         struct sockaddr_in p_s_rtcp_sin_remote;
48         struct lcr_fd p_s_rtp_fd;
49         struct lcr_fd p_s_rtcp_fd;
50         int p_s_rtp_is_connected; /* if RTP session is connected, so we may send frames */
51         int p_s_rtp_tx_action;
52         uint16_t p_s_rtp_tx_sequence;
53         uint32_t p_s_rtp_tx_timestamp;
54         uint32_t p_s_rtp_tx_ssrc;
55         struct timeval p_s_rtp_tx_last_tv;
56         int rtp_open(void);
57         int rtp_connect(void);
58         void rtp_close(void);
59         int rtp_send_frame(unsigned char *data, unsigned int len, uint8_t payload_type);
60         int p_s_b_sock; /* SIP bchannel socket */
61         struct lcr_fd p_s_b_fd; /* event node */
62         int p_s_b_index; /* SIP bchannel socket index to use */
63         int p_s_b_active; /* SIP bchannel socket is activated */
64         unsigned char p_s_rxdata[160]; /* receive audio buffer */
65         int p_s_rxpos; /* position in audio buffer 0..159 */
66         int bridge_rx(unsigned char *data, int len);
67         int parse_sdp(sip_t const *sip, unsigned int *ip, unsigned short *port, uint8_t *payload_types, int *media_types, int *payloads, int max_payloads);
68         void rtp_shutdown(void);
69
70         /* audio */
71         struct lcr_timer p_s_loadtimer;         /* timer for audio transmission */
72         virtual void update_load(void);
73         void load_tx(void);
74         unsigned int p_s_next_tv_sec;           /* time stamp of next expected tx_load call, (to sync audio data) */
75         unsigned int p_s_next_tv_usec;
76         void set_tone(const char *dir, const char *name);
77 };
78
79 int sip_init_inst(struct interface *interface);
80 void sip_exit_inst(struct interface *interface);
81 int sip_init(void);
82 void sip_exit(void);
83 void sip_handle(void);