[ifxmips]
[openwrt.git] / package / tapi_sip / src / sip_client.h
1 #ifndef __SIP_CLIENT_H__
2 #define __SIP_CLIENT_H__
3
4 #include <tapi-stream.h>
5 #include <tapi-device.h>
6
7 #include <pjsip.h>
8 #include <pjsip_ua.h>
9 #include <pjsip_simple.h>
10 #include <pjlib-util.h>
11 #include <pjlib.h>
12
13 #include <stdlib.h>
14 #include <sys/socket.h>
15 #include <stdint.h>
16
17 struct stun_client;
18 struct sip_agent;
19
20 struct sip_client_config {
21         const char *iface;
22
23         const char *host;
24         uint16_t port;
25         const char *username;
26         const char *password;
27
28         const char *stun_host;
29         uint16_t stun_port;
30 };
31
32 struct sip_client {
33         const struct sip_client_config *config;
34
35         struct tapi_device *tdev;
36         struct stun_client *stun;
37
38         struct sockaddr_storage public_addr;
39         struct sockaddr_storage local_addr;
40
41         int sockfd;
42
43         pj_thread_t *sip_thread;
44     pj_caching_pool      cp;
45     pj_pool_t           *pool;
46     pjsip_endpoint      *sip_endpt;
47         pjsip_cred_info cred;
48     pj_str_t             local_contact;
49         pj_str_t                server_uri;
50
51         pjsip_regc *regc;
52
53         int (*incoming_call_cb)(struct sip_client *client, struct sip_agent *agent);
54 };
55
56 void sip_client_init(struct sip_client *client, struct tapi_device *dev,
57         const struct sip_client_config *config);
58
59 struct sip_agent *sip_client_alloc_agent(struct sip_client *client, const char *dst_uri);
60
61 #endif