summaryrefslogtreecommitdiffstats
path: root/package/tapi_sip/src/sip_client.h
blob: 1c494b6dc333f6d7ba69ed9db03fe17afcd2d2d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __SIP_CLIENT_H__
#define __SIP_CLIENT_H__

#include <tapi-stream.h>
#include <tapi-device.h>

#include <pjsip.h>
#include <pjsip_ua.h>
#include <pjsip_simple.h>
#include <pjlib-util.h>
#include <pjlib.h>

#include <stdlib.h>
#include <sys/socket.h>
#include <stdint.h>

struct stun_client;
struct sip_agent;

struct sip_client_config {
	const char *iface;

	const char *host;
	uint16_t port;
	const char *username;
	const char *password;

	const char *stun_host;
	uint16_t stun_port;
};

struct sip_client {
	const struct sip_client_config *config;

	struct tapi_device *tdev;
	struct stun_client *stun;

	struct sockaddr_storage public_addr;
	struct sockaddr_storage local_addr;

	int sockfd;

	pj_thread_t *sip_thread;
    pj_caching_pool	 cp;
    pj_pool_t		*pool;
    pjsip_endpoint	*sip_endpt;
	pjsip_cred_info cred;
    pj_str_t		 local_contact;
	pj_str_t		server_uri;

	pjsip_regc *regc;

	int (*incoming_call_cb)(struct sip_client *client, struct sip_agent *agent);
};

void sip_client_init(struct sip_client *client, struct tapi_device *dev,
	const struct sip_client_config *config);

struct sip_agent *sip_client_alloc_agent(struct sip_client *client, const char *dst_uri);

#endif