Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 1 | /* $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 | */ |
| 19 | #ifndef __PJSUA_APP_COMMON_H__ |
| 20 | #define __PJSUA_APP_COMMON_H__ |
| 21 | |
| 22 | #include <pjsua-lib/pjsua.h> |
| 23 | |
| 24 | PJ_BEGIN_DECL |
| 25 | |
| 26 | #define current_acc pjsua_acc_get_default() |
| 27 | |
| 28 | #define PJSUA_APP_NO_LIMIT_DURATION (int)0x7FFFFFFF |
| 29 | #define PJSUA_APP_MAX_AVI 4 |
| 30 | #define PJSUA_APP_NO_NB -2 |
| 31 | |
| 32 | typedef struct input_result |
| 33 | { |
| 34 | int nb_result; |
| 35 | char *uri_result; |
| 36 | } input_result; |
| 37 | |
| 38 | /* Call specific data */ |
| 39 | typedef struct app_call_data |
| 40 | { |
| 41 | pj_timer_entry timer; |
| 42 | pj_bool_t ringback_on; |
| 43 | pj_bool_t ring_on; |
| 44 | } app_call_data; |
| 45 | |
| 46 | /* Video settings */ |
| 47 | typedef 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 | /* Enumeration of CLI frontends */ |
| 57 | typedef enum { |
| 58 | CLI_FE_CONSOLE = 1, |
| 59 | CLI_FE_TELNET = 2 |
| 60 | } CLI_FE; |
| 61 | |
| 62 | /** CLI config **/ |
| 63 | typedef struct cli_cfg_t |
| 64 | { |
| 65 | /** Bitmask of CLI_FE **/ |
| 66 | int cli_fe; |
| 67 | pj_cli_cfg cfg; |
| 68 | pj_cli_telnet_cfg telnet_cfg; |
| 69 | pj_cli_console_cfg console_cfg; |
| 70 | } cli_cfg_t; |
| 71 | |
| 72 | /* Pjsua application data */ |
| 73 | typedef struct pjsua_app_config |
| 74 | { |
| 75 | pjsua_config cfg; |
| 76 | pjsua_logging_config log_cfg; |
| 77 | pjsua_media_config media_cfg; |
| 78 | pj_bool_t no_refersub; |
| 79 | pj_bool_t ipv6; |
| 80 | pj_bool_t enable_qos; |
| 81 | pj_bool_t no_tcp; |
| 82 | pj_bool_t no_udp; |
| 83 | pj_bool_t use_tls; |
| 84 | pjsua_transport_config udp_cfg; |
| 85 | pjsua_transport_config rtp_cfg; |
| 86 | pjsip_redirect_op redir_op; |
| 87 | |
| 88 | unsigned acc_cnt; |
| 89 | pjsua_acc_config acc_cfg[PJSUA_MAX_ACC]; |
| 90 | |
| 91 | unsigned buddy_cnt; |
| 92 | pjsua_buddy_config buddy_cfg[PJSUA_MAX_BUDDIES]; |
| 93 | |
| 94 | app_call_data call_data[PJSUA_MAX_CALLS]; |
| 95 | |
| 96 | pj_pool_t *pool; |
| 97 | /* Compatibility with older pjsua */ |
| 98 | |
| 99 | unsigned codec_cnt; |
| 100 | pj_str_t codec_arg[32]; |
| 101 | unsigned codec_dis_cnt; |
| 102 | pj_str_t codec_dis[32]; |
| 103 | pj_bool_t null_audio; |
| 104 | unsigned wav_count; |
| 105 | pj_str_t wav_files[32]; |
| 106 | unsigned tone_count; |
| 107 | pjmedia_tone_desc tones[32]; |
| 108 | pjsua_conf_port_id tone_slots[32]; |
| 109 | pjsua_player_id wav_id; |
| 110 | pjsua_conf_port_id wav_port; |
| 111 | pj_bool_t auto_play; |
| 112 | pj_bool_t auto_play_hangup; |
| 113 | pj_timer_entry auto_hangup_timer; |
| 114 | pj_bool_t auto_loop; |
| 115 | pj_bool_t auto_conf; |
| 116 | pj_str_t rec_file; |
| 117 | pj_bool_t auto_rec; |
| 118 | pjsua_recorder_id rec_id; |
| 119 | pjsua_conf_port_id rec_port; |
| 120 | unsigned auto_answer; |
| 121 | unsigned duration; |
| 122 | |
| 123 | #ifdef STEREO_DEMO |
| 124 | pjmedia_snd_port *snd; |
| 125 | pjmedia_port *sc, *sc_ch1; |
| 126 | pjsua_conf_port_id sc_ch1_slot; |
| 127 | #endif |
| 128 | |
| 129 | float mic_level, |
| 130 | speaker_level; |
| 131 | |
| 132 | int capture_dev, playback_dev; |
| 133 | unsigned capture_lat, playback_lat; |
| 134 | |
| 135 | pj_bool_t no_tones; |
| 136 | int ringback_slot; |
| 137 | int ringback_cnt; |
| 138 | pjmedia_port *ringback_port; |
| 139 | int ring_slot; |
| 140 | int ring_cnt; |
| 141 | pjmedia_port *ring_port; |
| 142 | |
| 143 | app_vid vid; |
| 144 | unsigned aud_cnt; |
| 145 | |
| 146 | /* AVI to play */ |
| 147 | unsigned avi_cnt; |
| 148 | struct { |
| 149 | pj_str_t path; |
| 150 | pjmedia_vid_dev_index dev_id; |
| 151 | pjsua_conf_port_id slot; |
| 152 | } avi[PJSUA_APP_MAX_AVI]; |
| 153 | pj_bool_t avi_auto_play; |
| 154 | int avi_def_idx; |
| 155 | |
| 156 | /* CLI setting */ |
| 157 | pj_bool_t use_cli; |
| 158 | cli_cfg_t cli_cfg; |
| 159 | } pjsua_app_config; |
| 160 | |
| 161 | /** Extern variable declaration **/ |
| 162 | extern pjsua_call_id current_call; |
| 163 | extern pjsua_app_config app_config; |
| 164 | extern int stdout_refresh; |
| 165 | extern pj_bool_t stdout_refresh_quit; |
| 166 | extern pjsua_call_setting call_opt; |
| 167 | extern pjsua_msg_data msg_data; |
| 168 | extern pj_bool_t app_running; |
| 169 | |
| 170 | int my_atoi(const char *cs); |
| 171 | pj_bool_t find_next_call(); |
| 172 | pj_bool_t find_prev_call(); |
| 173 | void send_request(char *cstr_method, const pj_str_t *dst_uri); |
| 174 | void log_call_dump(int call_id); |
| 175 | int write_settings(pjsua_app_config *cfg, char *buf, pj_size_t max); |
| 176 | void app_config_init_video(pjsua_acc_config *acc_cfg); |
| 177 | void arrange_window(pjsua_vid_win_id wid); |
| 178 | |
| 179 | /** Defined in pjsua_cli_cmd.c **/ |
| 180 | pj_bool_t is_cli_inited(); |
| 181 | |
| 182 | /** Defined in pjsua_config.c **/ |
| 183 | /** This is to load the configuration **/ |
| 184 | pj_status_t load_config(int argc, char **argv, pj_str_t *uri_arg); |
| 185 | |
| 186 | /** Pjsua app callback **/ |
| 187 | /** This callback is called when CLI is started. **/ |
| 188 | void cli_on_started(pj_status_t status); |
| 189 | |
| 190 | /** This callback is called when "shutdown"/"restart" command is invoked **/ |
| 191 | void cli_on_stopped(pj_bool_t restart, int argc, char **argv); |
| 192 | |
| 193 | /** This callback is called when "quit"/"restart" command is invoked **/ |
| 194 | void legacy_on_stopped(pj_bool_t restart); |
| 195 | |
| 196 | /** Pjsua cli method **/ |
| 197 | pj_status_t cli_init(); |
| 198 | pj_status_t cli_main(pj_bool_t wait_telnet_cli); |
| 199 | void cli_destroy(); |
| 200 | void cli_get_info(char *info, pj_size_t size); |
| 201 | |
| 202 | /** Legacy method **/ |
| 203 | void legacy_main(); |
| 204 | |
| 205 | #if PJSUA_HAS_VIDEO |
| 206 | void vid_print_dev(int id, const pjmedia_vid_dev_info *vdi, const char *title); |
| 207 | void vid_list_devs(); |
| 208 | void app_config_show_video(int acc_id, const pjsua_acc_config *acc_cfg); |
| 209 | #endif |
| 210 | |
| 211 | #ifdef HAVE_MULTIPART_TEST |
| 212 | /* |
| 213 | * Enable multipart in msg_data and add a dummy body into the |
| 214 | * multipart bodies. |
| 215 | */ |
| 216 | void add_multipart(pjsua_msg_data *msg_data); |
| 217 | # define TEST_MULTIPART(msg_data) add_multipart(msg_data) |
| 218 | #else |
| 219 | # define TEST_MULTIPART(msg_data) |
| 220 | #endif |
| 221 | |
| 222 | |
| 223 | PJ_END_DECL |
| 224 | |
| 225 | #endif /* __PJSUA_APP_COMMON_H__ */ |
| 226 | |