blob: 42646e8dfdf36a699fd5fa245307f71a5bc97369 [file] [log] [blame]
Benny Prijono8e4a1132013-04-03 22:41:23 +00001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
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 */
Riza Sulistyobc9c6772013-04-05 03:02:19 +000019#ifndef __PJSUA_COMMON_H__
20#define __PJSUA_COMMON_H__
Benny Prijono8e4a1132013-04-03 22:41:23 +000021
22#include <pjsua-lib/pjsua.h>
23
24PJ_BEGIN_DECL
25
26#define current_acc pjsua_acc_get_default()
27
28#define NO_LIMIT_DURATION (int)0x7FFFFFFF
29#define MAX_AVI 4
30#define NO_NB -2
31
32typedef struct input_result
33{
34 int nb_result;
35 char *uri_result;
36} input_result;
37
38/* Call specific data */
Riza Sulistyobc9c6772013-04-05 03:02:19 +000039typedef struct app_call_data
Benny Prijono8e4a1132013-04-03 22:41:23 +000040{
41 pj_timer_entry timer;
42 pj_bool_t ringback_on;
43 pj_bool_t ring_on;
Riza Sulistyobc9c6772013-04-05 03:02:19 +000044} app_call_data;
Benny Prijono8e4a1132013-04-03 22:41:23 +000045
46/* Video settings */
47typedef struct app_vid
48{
49 unsigned vid_cnt;
50 int vcapture_dev;
51 int vrender_dev;
52 pj_bool_t in_auto_show;
53 pj_bool_t out_auto_transmit;
54} app_vid;
55
56/* Pjsua application data */
57typedef struct pjsua_app_config
58{
59 pjsua_config cfg;
60 pjsua_logging_config log_cfg;
61 pjsua_media_config media_cfg;
62 pj_bool_t no_refersub;
63 pj_bool_t ipv6;
64 pj_bool_t enable_qos;
65 pj_bool_t no_tcp;
66 pj_bool_t no_udp;
67 pj_bool_t use_tls;
68 pjsua_transport_config udp_cfg;
69 pjsua_transport_config rtp_cfg;
70 pjsip_redirect_op redir_op;
71
72 unsigned acc_cnt;
73 pjsua_acc_config acc_cfg[PJSUA_MAX_ACC];
74
75 unsigned buddy_cnt;
76 pjsua_buddy_config buddy_cfg[PJSUA_MAX_BUDDIES];
77
Riza Sulistyobc9c6772013-04-05 03:02:19 +000078 app_call_data call_data[PJSUA_MAX_CALLS];
Benny Prijono8e4a1132013-04-03 22:41:23 +000079
80 pj_pool_t *pool;
81 /* Compatibility with older pjsua */
82
83 unsigned codec_cnt;
84 pj_str_t codec_arg[32];
85 unsigned codec_dis_cnt;
86 pj_str_t codec_dis[32];
87 pj_bool_t null_audio;
88 unsigned wav_count;
89 pj_str_t wav_files[32];
90 unsigned tone_count;
91 pjmedia_tone_desc tones[32];
92 pjsua_conf_port_id tone_slots[32];
93 pjsua_player_id wav_id;
94 pjsua_conf_port_id wav_port;
95 pj_bool_t auto_play;
96 pj_bool_t auto_play_hangup;
97 pj_timer_entry auto_hangup_timer;
98 pj_bool_t auto_loop;
99 pj_bool_t auto_conf;
100 pj_str_t rec_file;
101 pj_bool_t auto_rec;
102 pjsua_recorder_id rec_id;
103 pjsua_conf_port_id rec_port;
104 unsigned auto_answer;
105 unsigned duration;
106
107#ifdef STEREO_DEMO
108 pjmedia_snd_port *snd;
109 pjmedia_port *sc, *sc_ch1;
110 pjsua_conf_port_id sc_ch1_slot;
111#endif
112
113 float mic_level,
114 speaker_level;
115
116 int capture_dev, playback_dev;
117 unsigned capture_lat, playback_lat;
118
119 pj_bool_t no_tones;
120 int ringback_slot;
121 int ringback_cnt;
122 pjmedia_port *ringback_port;
123 int ring_slot;
124 int ring_cnt;
125 pjmedia_port *ring_port;
126
127 app_vid vid;
128 unsigned aud_cnt;
129
130 /* AVI to play */
131 unsigned avi_cnt;
132 struct {
133 pj_str_t path;
134 pjmedia_vid_dev_index dev_id;
135 pjsua_conf_port_id slot;
136 } avi[MAX_AVI];
137 pj_bool_t avi_auto_play;
138 int avi_def_idx;
139
140 /* CLI setting */
141 pj_bool_t use_cli;
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000142 int cli_telnet_port;
143 pj_bool_t disable_cli_console;
Benny Prijono8e4a1132013-04-03 22:41:23 +0000144} pjsua_app_config;
145
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000146/** CLI callback **/
147/** This specifies the callback called when cli quit is called. **/
148typedef void (*pj_cli_on_quit)(pj_bool_t is_restarting);
149/** This callback is called when the cli is completely destroyed **/
150typedef void (*pj_cli_on_destroy)(void);
151/** This callback is called when pjsua restart command is invode by cli **/
152typedef void (*pj_cli_on_restart_pjsua)(void);
153
Benny Prijono8e4a1132013-04-03 22:41:23 +0000154/** Extern variable declaration **/
155extern pjsua_call_id current_call;
156extern pjsua_app_config app_config;
157extern int stdout_refresh;
158extern pj_bool_t stdout_refresh_quit;
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000159extern pjsua_call_setting call_opt;
160extern pjsua_msg_data msg_data;
Benny Prijono8e4a1132013-04-03 22:41:23 +0000161
162PJ_DECL(int) my_atoi(const char *cs);
163PJ_DECL(pj_bool_t) find_next_call();
164PJ_DECL(pj_bool_t) find_prev_call();
165PJ_DECL(void) send_request(char *cstr_method, const pj_str_t *dst_uri);
166PJ_DECL(void) log_call_dump(int call_id);
167PJ_DECL(int) write_settings(pjsua_app_config *cfg, char *buf, pj_size_t max);
168PJ_DECL(void) app_config_init_video(pjsua_acc_config *acc_cfg);
169PJ_DECL(void) arrange_window(pjsua_vid_win_id wid);
170
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000171/** Defined in pjsua_cli_cmd.c **/
172PJ_DECL(pj_bool_t) is_cli_inited();
173
174/** Defined in pjsua_app.c **/
175PJ_DECL(pj_status_t) app_init(pj_cli_telnet_on_started on_started_cb,
176 pj_cli_on_quit on_quit_cb,
177 pj_cli_on_destroy on_destroy_cb,
178 pj_cli_on_restart_pjsua on_restart_pjsua_cb);
179PJ_DECL(void) setup_signal_handler(void);
180
181/** Defined in pjsua_config.c **/
182/** This is to store the app runtime/startup options **/
183PJ_DECL(void) add_startup_config(int argc, char *argv[]);
184/** This is to store the app reload options **/
185PJ_DECL(void) add_reload_config(unsigned idx, pj_str_t *option);
186/** This is to load the configuration **/
187PJ_DECL(pj_status_t) load_config(pjsua_app_config *app_config,
188 pj_str_t *uri_arg,
189 pj_bool_t app_running);
190
Benny Prijono8e4a1132013-04-03 22:41:23 +0000191#if PJSUA_HAS_VIDEO
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000192PJ_DECL(void) vid_print_dev(int id, const pjmedia_vid_dev_info *vdi,
193 const char *title);
Benny Prijono8e4a1132013-04-03 22:41:23 +0000194PJ_DECL(void) vid_list_devs();
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000195PJ_DECL(void) app_config_show_video(int acc_id,
196 const pjsua_acc_config *acc_cfg);
Benny Prijono8e4a1132013-04-03 22:41:23 +0000197#endif
198
199#ifdef HAVE_MULTIPART_TEST
200 /*
201 * Enable multipart in msg_data and add a dummy body into the
202 * multipart bodies.
203 */
204 PJ_DECL(void) add_multipart(pjsua_msg_data *msg_data);
205# define TEST_MULTIPART(msg_data) add_multipart(msg_data)
206#else
207# define TEST_MULTIPART(msg_data)
208#endif
209
Riza Sulistyobc9c6772013-04-05 03:02:19 +0000210
211PJ_END_DECL
212
Benny Prijono8e4a1132013-04-03 22:41:23 +0000213#endif /* __PJSUA_CMD_H__ */
214