blob: 37740c3a51bcbeecc11fa180800e39486f38625a [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
3 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
22/* Include all PJSIP core headers. */
23#include <pjsip.h>
24
25/* Include all PJMEDIA headers. */
26#include <pjmedia.h>
27
28/* Include all PJSIP-UA headers */
29#include <pjsip_ua.h>
30
31/* Include all PJLIB-UTIL headers. */
32#include <pjlib-util.h>
33
34/* Include all PJLIB headers. */
35#include <pjlib.h>
36
37
Benny Prijono1a01ad32006-02-07 21:13:28 +000038PJ_BEGIN_DECL
39
Benny Prijono268ca612006-02-07 12:34:11 +000040/* PJSUA application variables. */
Benny Prijono95196582006-02-09 00:13:40 +000041struct pjsua
Benny Prijono268ca612006-02-07 12:34:11 +000042{
43 /* Control: */
44
Benny Prijono95196582006-02-09 00:13:40 +000045 pj_caching_pool cp; /**< Global pool factory. */
46 pjsip_endpoint *endpt; /**< Global endpoint. */
47 pj_pool_t *pool; /**< pjsua's private pool. */
48 pjsip_module mod; /**< pjsua's PJSIP module. */
Benny Prijono268ca612006-02-07 12:34:11 +000049
50
Benny Prijono95196582006-02-09 00:13:40 +000051 /* Media: */
52
53 pjmedia_endpt *med_endpt; /**< Media endpoint. */
54 pj_bool_t null_audio;
55 pjmedia_sock_info med_skinfo;
56
Benny Prijono268ca612006-02-07 12:34:11 +000057 /* User info: */
Benny Prijonoccf95622006-02-07 18:48:01 +000058
Benny Prijono268ca612006-02-07 12:34:11 +000059 pj_str_t local_uri; /**< Uri in From: header. */
60 pj_str_t contact_uri; /**< Uri in Contact: header. */
61
Benny Prijonoccf95622006-02-07 18:48:01 +000062 /* Proxy URLs: */
63
64 pj_str_t proxy;
65 pj_str_t outbound_proxy;
Benny Prijono95196582006-02-09 00:13:40 +000066 pjsip_route_hdr route_set;
67
Benny Prijonoccf95622006-02-07 18:48:01 +000068
69 /* Registration: */
70
71 pj_str_t registrar_uri;
72 pjsip_regc *regc;
73 pj_int32_t reg_timeout;
74 pj_timer_entry regc_timer;
75
76
77 /* Authentication credentials: */
78
79 int cred_count;
80 pjsip_cred_info cred_info[4];
81
82
Benny Prijono268ca612006-02-07 12:34:11 +000083 /* Threading: */
84
85 int thread_cnt; /**< Thread count. */
86 pj_thread_t *threads[8]; /**< Thread instances. */
87 pj_bool_t quit_flag; /**< To signal thread to quit. */
88
89 /* Transport (UDP): */
90
91 pj_uint16_t sip_port; /**< SIP signaling port. */
92 pj_sock_t sip_sock; /**< SIP UDP socket. */
93 pj_sockaddr_in sip_sock_name; /**< Public/STUN UDP socket addr. */
Benny Prijono268ca612006-02-07 12:34:11 +000094
95
96
97 /* STUN: */
98
99 pj_str_t stun_srv1;
100 int stun_port1;
101 pj_str_t stun_srv2;
102 int stun_port2;
103
104
105 /* Misc: */
106
107 int log_level; /**< Logging verbosity. */
108 int app_log_level; /**< stdout log verbosity. */
109 unsigned log_decor; /**< Log decoration. */
Benny Prijonoccf95622006-02-07 18:48:01 +0000110 char *log_filename; /**< Log filename. */
Benny Prijono268ca612006-02-07 12:34:11 +0000111
Benny Prijono1a01ad32006-02-07 21:13:28 +0000112};
Benny Prijono268ca612006-02-07 12:34:11 +0000113
Benny Prijono95196582006-02-09 00:13:40 +0000114
115/** PJSUA instance. */
116extern struct pjsua pjsua;
117
118
119/**
120 * Structure to be attached to all dialog.
121 * Given a dialog "dlg", application can retrieve this structure
122 * by accessing dlg->mod_data[pjsua.mod.id].
123 */
124struct pjsua_inv_data
125{
126 pjmedia_session *session;
127};
128
Benny Prijono268ca612006-02-07 12:34:11 +0000129
130/*****************************************************************************
131 * PJSUA API.
132 */
133
134/**
135 * Initialize pjsua settings with default parameters.
136 */
137void pjsua_default(void);
138
139
140/**
141 * Display error message for the specified error code.
142 */
143void pjsua_perror(const char *title, pj_status_t status);
144
145
146/**
Benny Prijonoccf95622006-02-07 18:48:01 +0000147 * Initialize pjsua application. Application can call this before parsing
148 * application settings.
149 *
150 * This will initialize all libraries, create endpoint instance, and register
151 * pjsip modules. Transport will NOT be created however.
152 *
153 * Application may register module after calling this function.
Benny Prijono268ca612006-02-07 12:34:11 +0000154 */
155pj_status_t pjsua_init(void);
156
157
158/**
Benny Prijonoccf95622006-02-07 18:48:01 +0000159 * Start pjsua stack. Application calls this after pjsua settings has been
160 * configured.
161 *
162 * This will start the transport, worker threads (if any), and registration
163 * process, if registration is configured.
164 */
165pj_status_t pjsua_start(void);
166
167
168/**
Benny Prijono268ca612006-02-07 12:34:11 +0000169 * Destroy pjsua.
170 */
171pj_status_t pjsua_destroy(void);
172
173
174/**
175 * Make outgoing call.
176 */
177pj_status_t pjsua_invite(const char *cstr_dest_uri,
178 pjsip_inv_session **p_inv);
179
180
181/*****************************************************************************
Benny Prijonoccf95622006-02-07 18:48:01 +0000182 * PJSUA Client Registration API.
183 */
184
185/**
186 * Initialize client registration session.
187 *
188 * @param app_callback Optional callback
189 */
190pj_status_t pjsua_regc_init(void);
191
192/**
193 * Update registration or perform unregistration. If renew argument is zero,
194 * this will start unregistration process.
195 */
196void pjsua_regc_update(pj_bool_t renew);
197
198
199/*****************************************************************************
Benny Prijono268ca612006-02-07 12:34:11 +0000200 * User Interface API.
201 * The UI API specifies functions that will be called by pjsua upon
202 * occurence of various events.
203 */
204
205/**
206 * Notify UI when invite state has changed.
207 */
Benny Prijonoccf95622006-02-07 18:48:01 +0000208void pjsua_ui_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e);
Benny Prijono268ca612006-02-07 12:34:11 +0000209
210
Benny Prijono1a01ad32006-02-07 21:13:28 +0000211PJ_END_DECL
212
Benny Prijono268ca612006-02-07 12:34:11 +0000213#endif /* __PJSUA_H__ */