pjsua_app_common.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJSUA_APP_COMMON_H__
  19. #define __PJSUA_APP_COMMON_H__
  20. #include <pjsua-lib/pjsua.h>
  21. PJ_BEGIN_DECL
  22. #define current_acc pjsua_acc_get_default()
  23. #define PJSUA_APP_NO_LIMIT_DURATION (int)0x7FFFFFFF
  24. #define PJSUA_APP_MAX_AVI 4
  25. #define PJSUA_APP_NO_NB -2
  26. typedef struct input_result
  27. {
  28. int nb_result;
  29. char *uri_result;
  30. } input_result;
  31. /* Call specific data */
  32. typedef struct app_call_data
  33. {
  34. pj_timer_entry timer;
  35. pj_bool_t ringback_on;
  36. pj_bool_t ring_on;
  37. } app_call_data;
  38. /* Video settings */
  39. typedef struct app_vid
  40. {
  41. unsigned vid_cnt;
  42. int vcapture_dev;
  43. int vrender_dev;
  44. pj_bool_t in_auto_show;
  45. pj_bool_t out_auto_transmit;
  46. } app_vid;
  47. /* Enumeration of CLI frontends */
  48. typedef enum {
  49. CLI_FE_CONSOLE = 1,
  50. CLI_FE_TELNET = 2
  51. } CLI_FE;
  52. /** CLI config **/
  53. typedef struct cli_cfg_t
  54. {
  55. /** Bitmask of CLI_FE **/
  56. int cli_fe;
  57. pj_cli_cfg cfg;
  58. pj_cli_telnet_cfg telnet_cfg;
  59. pj_cli_console_cfg console_cfg;
  60. } cli_cfg_t;
  61. /* Pjsua application data */
  62. typedef struct pjsua_app_config
  63. {
  64. pjsua_config cfg;
  65. pjsua_logging_config log_cfg;
  66. pjsua_media_config media_cfg;
  67. pj_bool_t no_refersub;
  68. pj_bool_t ipv6;
  69. pj_bool_t enable_qos;
  70. pj_bool_t no_mci;
  71. pj_bool_t enable_loam;
  72. pj_bool_t no_tcp;
  73. pj_bool_t no_udp;
  74. pj_bool_t use_tls;
  75. pjsua_transport_config udp_cfg;
  76. pjsua_transport_config rtp_cfg;
  77. pjsip_redirect_op redir_op;
  78. int srtp_keying;
  79. unsigned acc_cnt;
  80. pjsua_acc_config acc_cfg[PJSUA_MAX_ACC];
  81. unsigned buddy_cnt;
  82. pjsua_buddy_config buddy_cfg[PJSUA_MAX_BUDDIES];
  83. app_call_data call_data[PJSUA_MAX_CALLS];
  84. pj_pool_t *pool;
  85. /* Compatibility with older pjsua */
  86. unsigned codec_cnt;
  87. pj_str_t codec_arg[32];
  88. unsigned codec_dis_cnt;
  89. pj_str_t codec_dis[32];
  90. pj_bool_t null_audio;
  91. unsigned wav_count;
  92. pj_str_t wav_files[32];
  93. unsigned tone_count;
  94. pjmedia_tone_desc tones[32];
  95. pjsua_conf_port_id tone_slots[32];
  96. pjsua_player_id wav_id;
  97. pjsua_conf_port_id wav_port;
  98. pj_bool_t auto_play;
  99. pj_bool_t auto_play_hangup;
  100. pj_timer_entry auto_hangup_timer;
  101. pj_bool_t auto_loop;
  102. pj_bool_t auto_conf;
  103. pj_str_t rec_file;
  104. pj_bool_t auto_rec;
  105. pjsua_recorder_id rec_id;
  106. pjsua_conf_port_id rec_port;
  107. unsigned auto_answer;
  108. unsigned duration;
  109. #ifdef STEREO_DEMO
  110. pjmedia_snd_port *snd;
  111. pjmedia_port *sc, *sc_ch1;
  112. pjsua_conf_port_id sc_ch1_slot;
  113. #endif
  114. float mic_level,
  115. speaker_level;
  116. int capture_dev, playback_dev;
  117. unsigned capture_lat, playback_lat;
  118. pj_bool_t no_tones;
  119. int ringback_slot;
  120. int ringback_cnt;
  121. pjmedia_port *ringback_port;
  122. int ring_slot;
  123. int ring_cnt;
  124. pjmedia_port *ring_port;
  125. app_vid vid;
  126. unsigned aud_cnt;
  127. /* AVI to play */
  128. unsigned avi_cnt;
  129. struct {
  130. pj_str_t path;
  131. pjmedia_vid_dev_index dev_id;
  132. pjsua_conf_port_id slot;
  133. } avi[PJSUA_APP_MAX_AVI];
  134. pj_bool_t avi_auto_play;
  135. int avi_def_idx;
  136. /* CLI setting */
  137. pj_bool_t use_cli;
  138. cli_cfg_t cli_cfg;
  139. } pjsua_app_config;
  140. /** Extern variable declaration **/
  141. extern pjsua_call_id current_call;
  142. extern pjsua_app_config app_config;
  143. extern int stdout_refresh;
  144. extern pj_bool_t stdout_refresh_quit;
  145. extern pjsua_call_setting call_opt;
  146. extern pjsua_msg_data msg_data;
  147. extern pj_bool_t app_running;
  148. int my_atoi(const char *cs);
  149. int my_atoi2(const pj_str_t *s);
  150. pj_bool_t find_next_call(void);
  151. pj_bool_t find_prev_call(void);
  152. void send_request(char *cstr_method, const pj_str_t *dst_uri);
  153. void log_call_dump(int call_id);
  154. int write_settings(pjsua_app_config *cfg, char *buf, pj_size_t max);
  155. void app_config_init_video(pjsua_acc_config *acc_cfg);
  156. void arrange_window(pjsua_vid_win_id wid);
  157. /** Defined in pjsua_app_config.c **/
  158. /** This is to load the configuration **/
  159. pj_status_t load_config(int argc, char **argv, pj_str_t *uri_arg);
  160. /** Pjsua app callback **/
  161. /** This callback is called when CLI is started. **/
  162. void cli_on_started(pj_status_t status);
  163. /** This callback is called when "shutdown"/"restart" command is invoked **/
  164. void cli_on_stopped(pj_bool_t restart, int argc, char **argv);
  165. /** This callback is called when "quit"/"restart" command is invoked **/
  166. void legacy_on_stopped(pj_bool_t restart);
  167. /** Pjsua cli method **/
  168. pj_status_t cli_init(void);
  169. pj_status_t cli_main(pj_bool_t wait_telnet_cli);
  170. void cli_destroy(void);
  171. void cli_get_info(char *info, pj_size_t size);
  172. /** Legacy method **/
  173. void legacy_main(void);
  174. #if PJSUA_HAS_VIDEO
  175. void vid_print_dev(int id, const pjmedia_vid_dev_info *vdi, const char *title);
  176. void vid_list_devs(void);
  177. void app_config_show_video(int acc_id, const pjsua_acc_config *acc_cfg);
  178. #endif
  179. #ifdef HAVE_MULTIPART_TEST
  180. /*
  181. * Enable multipart in msg_data and add a dummy body into the
  182. * multipart bodies.
  183. */
  184. void add_multipart(pjsua_msg_data *msg_data);
  185. # define TEST_MULTIPART(msg_data) add_multipart(msg_data)
  186. #else
  187. # define TEST_MULTIPART(msg_data)
  188. #endif
  189. PJ_END_DECL
  190. #endif /* __PJSUA_APP_COMMON_H__ */