| 1 | /* |
|---|
| 2 | linphone |
|---|
| 3 | Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) |
|---|
| 4 | |
|---|
| 5 | This program is free software; you can redistribute it and/or |
|---|
| 6 | modify it under the terms of the GNU General Public License |
|---|
| 7 | as published by the Free Software Foundation; either version 2 |
|---|
| 8 | of the License, or (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 LINPHONECORE_H |
|---|
| 20 | #define LINPHONECORE_H |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | #include <osipparser2/osip_message.h> |
|---|
| 24 | #include "ortp/ortp.h" |
|---|
| 25 | #include "ortp/payloadtype.h" |
|---|
| 26 | #include "mediastreamer2/mscommon.h" |
|---|
| 27 | #include "mediastreamer2/msvideo.h" |
|---|
| 28 | |
|---|
| 29 | #ifdef IN_LINPHONE |
|---|
| 30 | #include "sipsetup.h" |
|---|
| 31 | #else |
|---|
| 32 | #include "linphone/sipsetup.h" |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #define LINPHONE_IPADDR_SIZE 64 |
|---|
| 36 | #define LINPHONE_HOSTNAME_SIZE 128 |
|---|
| 37 | |
|---|
| 38 | #ifdef __cplusplus |
|---|
| 39 | extern "C" { |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | struct _MSSndCard; |
|---|
| 43 | struct _LinphoneCore; |
|---|
| 44 | |
|---|
| 45 | bool_t payload_type_enabled(struct _PayloadType *pt); |
|---|
| 46 | void payload_type_set_enable(struct _PayloadType *pt,int value); |
|---|
| 47 | const char *payload_type_get_description(struct _PayloadType *pt); |
|---|
| 48 | int payload_type_get_bitrate(PayloadType *pt); |
|---|
| 49 | const char *payload_type_get_mime(PayloadType *pt); |
|---|
| 50 | int payload_type_get_rate(PayloadType *pt); |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | struct _LpConfig; |
|---|
| 54 | |
|---|
| 55 | typedef struct sip_config |
|---|
| 56 | { |
|---|
| 57 | char *contact; |
|---|
| 58 | char *guessed_contact; |
|---|
| 59 | int sip_port; |
|---|
| 60 | MSList *proxies; |
|---|
| 61 | MSList *deleted_proxies; |
|---|
| 62 | int inc_timeout; /*timeout after an un-answered incoming call is rejected*/ |
|---|
| 63 | bool_t use_info; |
|---|
| 64 | bool_t guess_hostname; |
|---|
| 65 | bool_t loopback_only; |
|---|
| 66 | bool_t ipv6_enabled; |
|---|
| 67 | bool_t sdp_200_ack; |
|---|
| 68 | bool_t only_one_codec; /*in SDP answers*/ |
|---|
| 69 | } sip_config_t; |
|---|
| 70 | |
|---|
| 71 | typedef struct rtp_config |
|---|
| 72 | { |
|---|
| 73 | int audio_rtp_port; |
|---|
| 74 | int video_rtp_port; |
|---|
| 75 | int audio_jitt_comp; /*jitter compensation*/ |
|---|
| 76 | int video_jitt_comp; /*jitter compensation*/ |
|---|
| 77 | int nortp_timeout; |
|---|
| 78 | }rtp_config_t; |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | typedef struct net_config |
|---|
| 83 | { |
|---|
| 84 | char *nat_address; |
|---|
| 85 | char *stun_server; |
|---|
| 86 | char *relay; |
|---|
| 87 | int download_bw; |
|---|
| 88 | int upload_bw; |
|---|
| 89 | int firewall_policy; |
|---|
| 90 | int mtu; |
|---|
| 91 | bool_t nat_sdp_only; |
|---|
| 92 | }net_config_t; |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | typedef struct sound_config |
|---|
| 96 | { |
|---|
| 97 | struct _MSSndCard * ring_sndcard; /* the playback sndcard currently used */ |
|---|
| 98 | struct _MSSndCard * play_sndcard; /* the playback sndcard currently used */ |
|---|
| 99 | struct _MSSndCard * capt_sndcard; /* the capture sndcard currently used */ |
|---|
| 100 | const char **cards; |
|---|
| 101 | int latency; /* latency in samples of the current used sound device */ |
|---|
| 102 | char rec_lev; |
|---|
| 103 | char play_lev; |
|---|
| 104 | char ring_lev; |
|---|
| 105 | char source; |
|---|
| 106 | char pad; |
|---|
| 107 | char *local_ring; |
|---|
| 108 | char *remote_ring; |
|---|
| 109 | bool_t ec; |
|---|
| 110 | } sound_config_t; |
|---|
| 111 | |
|---|
| 112 | typedef struct codecs_config |
|---|
| 113 | { |
|---|
| 114 | MSList *audio_codecs; /* list of audio codecs in order of preference*/ |
|---|
| 115 | MSList *video_codecs; /* for later use*/ |
|---|
| 116 | }codecs_config_t; |
|---|
| 117 | |
|---|
| 118 | typedef struct video_config{ |
|---|
| 119 | struct _MSWebCam *device; |
|---|
| 120 | const char **cams; |
|---|
| 121 | MSVideoSize vsize; |
|---|
| 122 | bool_t capture; |
|---|
| 123 | bool_t show_local; |
|---|
| 124 | bool_t display; |
|---|
| 125 | bool_t selfview; /*during calls*/ |
|---|
| 126 | }video_config_t; |
|---|
| 127 | |
|---|
| 128 | typedef struct ui_config |
|---|
| 129 | { |
|---|
| 130 | int is_daemon; |
|---|
| 131 | int is_applet; |
|---|
| 132 | unsigned int timer_id; /* the timer id for registration */ |
|---|
| 133 | }ui_config_t; |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | typedef struct autoreplier_config |
|---|
| 138 | { |
|---|
| 139 | int enabled; |
|---|
| 140 | int after_seconds; /* accept the call after x seconds*/ |
|---|
| 141 | int max_users; /* maximum number of user that can call simultaneously */ |
|---|
| 142 | int max_rec_time; /* the max time of incoming voice recorded */ |
|---|
| 143 | int max_rec_msg; /* maximum number of recorded messages */ |
|---|
| 144 | const char *message; /* the path of the file to be played */ |
|---|
| 145 | }autoreplier_config_t; |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | struct _LinphoneCore; |
|---|
| 149 | struct _sdp_context; |
|---|
| 150 | struct _SipSetupContext; |
|---|
| 151 | |
|---|
| 152 | typedef struct _StreamParams |
|---|
| 153 | { |
|---|
| 154 | int initialized; |
|---|
| 155 | int line; |
|---|
| 156 | int localport; |
|---|
| 157 | int remoteport; |
|---|
| 158 | int remotertcpport; |
|---|
| 159 | int pt; |
|---|
| 160 | char *relay_session_id; |
|---|
| 161 | int natd_port; |
|---|
| 162 | char remoteaddr[LINPHONE_HOSTNAME_SIZE]; |
|---|
| 163 | char natd_addr[LINPHONE_HOSTNAME_SIZE]; |
|---|
| 164 | } StreamParams; |
|---|
| 165 | |
|---|
| 166 | typedef enum _LCState{ |
|---|
| 167 | LCStateInit, |
|---|
| 168 | LCStateRinging, |
|---|
| 169 | LCStateAVRunning |
|---|
| 170 | }LCState; |
|---|
| 171 | |
|---|
| 172 | typedef enum _LinphoneCallDir {LinphoneCallOutgoing, LinphoneCallIncoming} LinphoneCallDir; |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | typedef struct _LinphoneCall |
|---|
| 176 | { |
|---|
| 177 | struct _LinphoneCore *core; |
|---|
| 178 | StreamParams audio_params; |
|---|
| 179 | StreamParams video_params; |
|---|
| 180 | LinphoneCallDir dir; |
|---|
| 181 | struct _RtpProfile *profile; /*points to the local_profile or to the remote "guessed" profile*/ |
|---|
| 182 | struct _LinphoneCallLog *log; |
|---|
| 183 | int cid; /*call id */ |
|---|
| 184 | int did; /*dialog id */ |
|---|
| 185 | int tid; /*last transaction id*/ |
|---|
| 186 | struct _sdp_context *sdpctx; |
|---|
| 187 | time_t start_time; |
|---|
| 188 | LCState state; |
|---|
| 189 | bool_t auth_pending; |
|---|
| 190 | } LinphoneCall; |
|---|
| 191 | |
|---|
| 192 | LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const osip_from_t *from, const osip_to_t *to); |
|---|
| 193 | LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const char *from, const char *to, int cid, int did , int tid); |
|---|
| 194 | #define linphone_call_set_state(lcall,st) (lcall)->state=(st) |
|---|
| 195 | void linphone_call_destroy(struct _LinphoneCall *obj); |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | typedef enum _LinphoneCallStatus { |
|---|
| 199 | LinphoneCallSuccess, |
|---|
| 200 | LinphoneCallAborted, |
|---|
| 201 | LinphoneCallMissed |
|---|
| 202 | } LinphoneCallStatus; |
|---|
| 203 | |
|---|
| 204 | typedef struct _LinphoneCallLog{ |
|---|
| 205 | LinphoneCallDir dir; |
|---|
| 206 | LinphoneCallStatus status; |
|---|
| 207 | char *from; |
|---|
| 208 | char *to; |
|---|
| 209 | char start_date[128]; |
|---|
| 210 | int duration; |
|---|
| 211 | |
|---|
| 212 | } LinphoneCallLog; |
|---|
| 213 | |
|---|
| 214 | /* private: */ |
|---|
| 215 | LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *local, char * remote); |
|---|
| 216 | void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call); |
|---|
| 217 | void linphone_call_log_destroy(LinphoneCallLog *cl); |
|---|
| 218 | |
|---|
| 219 | /*public: */ |
|---|
| 220 | char * linphone_call_log_to_str(LinphoneCallLog *cl); |
|---|
| 221 | |
|---|
| 222 | typedef enum{ |
|---|
| 223 | LinphoneSPWait, |
|---|
| 224 | LinphoneSPDeny, |
|---|
| 225 | LinphoneSPAccept |
|---|
| 226 | }LinphoneSubscribePolicy; |
|---|
| 227 | |
|---|
| 228 | typedef enum _LinphoneOnlineStatus{ |
|---|
| 229 | LINPHONE_STATUS_UNKNOWN, |
|---|
| 230 | LINPHONE_STATUS_ONLINE, |
|---|
| 231 | LINPHONE_STATUS_BUSY, |
|---|
| 232 | LINPHONE_STATUS_BERIGHTBACK, |
|---|
| 233 | LINPHONE_STATUS_AWAY, |
|---|
| 234 | LINPHONE_STATUS_ONTHEPHONE, |
|---|
| 235 | LINPHONE_STATUS_OUTTOLUNCH, |
|---|
| 236 | LINPHONE_STATUS_NOT_DISTURB, |
|---|
| 237 | LINPHONE_STATUS_MOVED, |
|---|
| 238 | LINPHONE_STATUS_ALT_SERVICE, |
|---|
| 239 | LINPHONE_STATUS_OFFLINE, |
|---|
| 240 | LINPHONE_STATUS_PENDING, |
|---|
| 241 | LINPHONE_STATUS_CLOSED, |
|---|
| 242 | LINPHONE_STATUS_END |
|---|
| 243 | }LinphoneOnlineStatus; |
|---|
| 244 | |
|---|
| 245 | const char *linphone_online_status_to_string(LinphoneOnlineStatus ss); |
|---|
| 246 | |
|---|
| 247 | typedef struct _LinphoneFriend{ |
|---|
| 248 | osip_from_t *url; |
|---|
| 249 | int in_did; |
|---|
| 250 | int out_did; |
|---|
| 251 | int sid; |
|---|
| 252 | int nid; |
|---|
| 253 | LinphoneSubscribePolicy pol; |
|---|
| 254 | LinphoneOnlineStatus status; |
|---|
| 255 | struct _LinphoneProxyConfig *proxy; |
|---|
| 256 | struct _LinphoneCore *lc; |
|---|
| 257 | bool_t subscribe; |
|---|
| 258 | bool_t inc_subscribe_pending; |
|---|
| 259 | }LinphoneFriend; |
|---|
| 260 | |
|---|
| 261 | LinphoneFriend * linphone_friend_new(); |
|---|
| 262 | LinphoneFriend *linphone_friend_new_with_addr(const char *addr); |
|---|
| 263 | int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri); |
|---|
| 264 | int linphone_friend_set_name(LinphoneFriend *fr, const char *name); |
|---|
| 265 | int linphone_friend_send_subscribe(LinphoneFriend *fr, bool_t val); |
|---|
| 266 | int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol); |
|---|
| 267 | int linphone_friend_set_proxy(LinphoneFriend *fr, struct _LinphoneProxyConfig *cfg); |
|---|
| 268 | void linphone_friend_edit(LinphoneFriend *fr); |
|---|
| 269 | void linphone_friend_done(LinphoneFriend *fr); |
|---|
| 270 | void linphone_friend_destroy(LinphoneFriend *lf); |
|---|
| 271 | /* memory returned by those 3 functions must be freed */ |
|---|
| 272 | char *linphone_friend_get_name(LinphoneFriend *lf); |
|---|
| 273 | char *linphone_friend_get_addr(LinphoneFriend *lf); |
|---|
| 274 | char *linphone_friend_get_url(LinphoneFriend *lf); /* name <sip address> */ |
|---|
| 275 | bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf); |
|---|
| 276 | LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf); |
|---|
| 277 | LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); |
|---|
| 278 | |
|---|
| 279 | #define linphone_friend_url(lf) ((lf)->url) |
|---|
| 280 | |
|---|
| 281 | void linphone_friend_write_to_config_file(struct _LpConfig *config, LinphoneFriend *lf, int index); |
|---|
| 282 | LinphoneFriend * linphone_friend_new_from_config_file(struct _LinphoneCore *lc, int index); |
|---|
| 283 | |
|---|
| 284 | typedef struct _LinphoneProxyConfig |
|---|
| 285 | { |
|---|
| 286 | struct _LinphoneCore *lc; |
|---|
| 287 | char *reg_proxy; |
|---|
| 288 | char *reg_identity; |
|---|
| 289 | char *reg_route; |
|---|
| 290 | char *realm; |
|---|
| 291 | int expires; |
|---|
| 292 | int reg_time; |
|---|
| 293 | int rid; |
|---|
| 294 | char *type; |
|---|
| 295 | struct _SipSetupContext *ssctx; |
|---|
| 296 | bool_t frozen; |
|---|
| 297 | bool_t reg_sendregister; |
|---|
| 298 | bool_t auth_pending; |
|---|
| 299 | bool_t registered; |
|---|
| 300 | bool_t publish; |
|---|
| 301 | } LinphoneProxyConfig; |
|---|
| 302 | |
|---|
| 303 | LinphoneProxyConfig *linphone_proxy_config_new(void); |
|---|
| 304 | int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr); |
|---|
| 305 | void linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity); |
|---|
| 306 | void linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route); |
|---|
| 307 | void linphone_proxy_config_expires(LinphoneProxyConfig *obj, const int expires); |
|---|
| 308 | void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val); |
|---|
| 309 | #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register |
|---|
| 310 | void linphone_proxy_config_edit(LinphoneProxyConfig *obj); |
|---|
| 311 | int linphone_proxy_config_done(LinphoneProxyConfig *obj); |
|---|
| 312 | void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); |
|---|
| 313 | bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); |
|---|
| 314 | #define linphone_proxy_config_get_route(obj) ((obj)->reg_route) |
|---|
| 315 | #define linphone_proxy_config_get_identity(obj) ((obj)->reg_identity) |
|---|
| 316 | #define linphone_proxy_config_publish_enabled(obj) ((obj)->publish) |
|---|
| 317 | #define linphone_proxy_config_get_addr(obj) ((obj)->reg_proxy) |
|---|
| 318 | #define linphone_proxy_config_get_expires(obj) ((obj)->expires) |
|---|
| 319 | #define linphone_proxy_config_register_enabled(obj) ((obj)->reg_sendregister) |
|---|
| 320 | |
|---|
| 321 | /* destruction is called automatically when removing the proxy config */ |
|---|
| 322 | void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); |
|---|
| 323 | LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(struct _LpConfig *config, int index); |
|---|
| 324 | void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index); |
|---|
| 325 | void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); |
|---|
| 326 | SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | typedef struct _LinphoneAuthInfo |
|---|
| 330 | { |
|---|
| 331 | char *username; |
|---|
| 332 | char *realm; |
|---|
| 333 | char *userid; |
|---|
| 334 | char *passwd; |
|---|
| 335 | char *ha1; |
|---|
| 336 | bool_t works; |
|---|
| 337 | bool_t first_time; |
|---|
| 338 | }LinphoneAuthInfo; |
|---|
| 339 | |
|---|
| 340 | LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, |
|---|
| 341 | const char *passwd, const char *ha1,const char *realm); |
|---|
| 342 | void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd); |
|---|
| 343 | void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username); |
|---|
| 344 | /* you don't need those function*/ |
|---|
| 345 | void linphone_auth_info_destroy(LinphoneAuthInfo *info); |
|---|
| 346 | LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos); |
|---|
| 347 | |
|---|
| 348 | struct _LinphoneChatRoom{ |
|---|
| 349 | struct _LinphoneCore *lc; |
|---|
| 350 | char *peer; |
|---|
| 351 | char *route; |
|---|
| 352 | osip_from_t *peer_url; |
|---|
| 353 | void * user_data; |
|---|
| 354 | }; |
|---|
| 355 | typedef struct _LinphoneChatRoom LinphoneChatRoom; |
|---|
| 356 | |
|---|
| 357 | LinphoneChatRoom * linphone_core_create_chat_room(struct _LinphoneCore *lc, const char *to); |
|---|
| 358 | void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); |
|---|
| 359 | void linphone_chat_room_destroy(LinphoneChatRoom *cr); |
|---|
| 360 | void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud); |
|---|
| 361 | void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr); |
|---|
| 362 | |
|---|
| 363 | /* describes the different groups of states */ |
|---|
| 364 | typedef enum _gstate_group { |
|---|
| 365 | GSTATE_GROUP_POWER, |
|---|
| 366 | GSTATE_GROUP_REG, |
|---|
| 367 | GSTATE_GROUP_CALL |
|---|
| 368 | } gstate_group_t; |
|---|
| 369 | |
|---|
| 370 | typedef enum _gstate { |
|---|
| 371 | /* states for GSTATE_GROUP_POWER */ |
|---|
| 372 | GSTATE_POWER_OFF = 0, /* initial state */ |
|---|
| 373 | GSTATE_POWER_STARTUP, |
|---|
| 374 | GSTATE_POWER_ON, |
|---|
| 375 | GSTATE_POWER_SHUTDOWN, |
|---|
| 376 | /* states for GSTATE_GROUP_REG */ |
|---|
| 377 | GSTATE_REG_NONE = 10, /* initial state */ |
|---|
| 378 | GSTATE_REG_OK, |
|---|
| 379 | GSTATE_REG_FAILED, |
|---|
| 380 | /* states for GSTATE_GROUP_CALL */ |
|---|
| 381 | GSTATE_CALL_IDLE = 20, /* initial state */ |
|---|
| 382 | GSTATE_CALL_OUT_INVITE, |
|---|
| 383 | GSTATE_CALL_OUT_CONNECTED, |
|---|
| 384 | GSTATE_CALL_IN_INVITE, |
|---|
| 385 | GSTATE_CALL_IN_CONNECTED, |
|---|
| 386 | GSTATE_CALL_END, |
|---|
| 387 | GSTATE_CALL_ERROR, |
|---|
| 388 | GSTATE_INVALID |
|---|
| 389 | } gstate_t; |
|---|
| 390 | |
|---|
| 391 | struct _LinphoneGeneralState { |
|---|
| 392 | gstate_t old_state; |
|---|
| 393 | gstate_t new_state; |
|---|
| 394 | gstate_group_t group; |
|---|
| 395 | const char *message; |
|---|
| 396 | }; |
|---|
| 397 | typedef struct _LinphoneGeneralState LinphoneGeneralState; |
|---|
| 398 | |
|---|
| 399 | /* private: set a new state */ |
|---|
| 400 | void gstate_new_state(struct _LinphoneCore *lc, gstate_t new_state, const char *message); |
|---|
| 401 | /*private*/ |
|---|
| 402 | void gstate_initialize(struct _LinphoneCore *lc) ; |
|---|
| 403 | |
|---|
| 404 | typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc); |
|---|
| 405 | typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, const char *from); |
|---|
| 406 | typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, const char *from); |
|---|
| 407 | typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message); |
|---|
| 408 | typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message); |
|---|
| 409 | typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url); |
|---|
| 410 | typedef void (*DisplayQuestionCb)(struct _LinphoneCore *lc, const char *message); |
|---|
| 411 | typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data); |
|---|
| 412 | typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid, const char *url, const char *status, const char *img); |
|---|
| 413 | typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url); |
|---|
| 414 | typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username); |
|---|
| 415 | typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl); |
|---|
| 416 | typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message); |
|---|
| 417 | typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate); |
|---|
| 418 | typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf); |
|---|
| 419 | |
|---|
| 420 | typedef struct _LinphoneVTable |
|---|
| 421 | { |
|---|
| 422 | ShowInterfaceCb show; |
|---|
| 423 | InviteReceivedCb inv_recv; |
|---|
| 424 | ByeReceivedCb bye_recv; |
|---|
| 425 | NotifyReceivedCb notify_recv; |
|---|
| 426 | NewUnknownSubscriberCb new_unknown_subscriber; |
|---|
| 427 | AuthInfoRequested auth_info_requested; |
|---|
| 428 | DisplayStatusCb display_status; |
|---|
| 429 | DisplayMessageCb display_message; |
|---|
| 430 | #ifdef VINCENT_MAURY_RSVP |
|---|
| 431 | /* the yes/no dialog box */ |
|---|
| 432 | DisplayMessageCb display_yes_no; |
|---|
| 433 | #endif |
|---|
| 434 | DisplayMessageCb display_warning; |
|---|
| 435 | DisplayUrlCb display_url; |
|---|
| 436 | DisplayQuestionCb display_question; |
|---|
| 437 | CallLogUpdated call_log_updated; |
|---|
| 438 | TextMessageReceived text_received; |
|---|
| 439 | GeneralStateChange general_state; |
|---|
| 440 | DtmfReceived dtmf_received; |
|---|
| 441 | } LinphoneCoreVTable; |
|---|
| 442 | |
|---|
| 443 | typedef struct _LCCallbackObj |
|---|
| 444 | { |
|---|
| 445 | LinphoneCoreCbFunc _func; |
|---|
| 446 | void * _user_data; |
|---|
| 447 | }LCCallbackObj; |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | typedef enum _LinphoneFirewallPolicy{ |
|---|
| 452 | LINPHONE_POLICY_NO_FIREWALL, |
|---|
| 453 | LINPHONE_POLICY_USE_NAT_ADDRESS, |
|---|
| 454 | LINPHONE_POLICY_USE_STUN |
|---|
| 455 | } LinphoneFirewallPolicy; |
|---|
| 456 | |
|---|
| 457 | typedef struct _LinphoneCore |
|---|
| 458 | { |
|---|
| 459 | LinphoneCoreVTable vtable; |
|---|
| 460 | struct _LpConfig *config; |
|---|
| 461 | net_config_t net_conf; |
|---|
| 462 | sip_config_t sip_conf; |
|---|
| 463 | rtp_config_t rtp_conf; |
|---|
| 464 | sound_config_t sound_conf; |
|---|
| 465 | video_config_t video_conf; |
|---|
| 466 | codecs_config_t codecs_conf; |
|---|
| 467 | ui_config_t ui_conf; |
|---|
| 468 | autoreplier_config_t autoreplier_conf; |
|---|
| 469 | LinphoneProxyConfig *default_proxy; |
|---|
| 470 | MSList *friends; |
|---|
| 471 | MSList *auth_info; |
|---|
| 472 | struct _RingStream *ringstream; |
|---|
| 473 | LCCallbackObj preview_finished_cb; |
|---|
| 474 | bool_t preview_finished; |
|---|
| 475 | LinphoneCall *call; /* the current call, in the future it will be a list of calls (conferencing)*/ |
|---|
| 476 | int rid; /*registration id*/ |
|---|
| 477 | MSList *queued_calls; /* used by the autoreplier */ |
|---|
| 478 | MSList *call_logs; |
|---|
| 479 | MSList *chatrooms; |
|---|
| 480 | int max_call_logs; |
|---|
| 481 | int missed_calls; |
|---|
| 482 | struct _AudioStream *audiostream; /**/ |
|---|
| 483 | struct _VideoStream *videostream; |
|---|
| 484 | struct _VideoStream *previewstream; |
|---|
| 485 | struct _RtpProfile *local_profile; |
|---|
| 486 | MSList *subscribers; /* unknown subscribers */ |
|---|
| 487 | int minutes_away; |
|---|
| 488 | LinphoneOnlineStatus presence_mode; |
|---|
| 489 | LinphoneOnlineStatus prev_mode; |
|---|
| 490 | char *alt_contact; |
|---|
| 491 | void *data; |
|---|
| 492 | ms_mutex_t lock; |
|---|
| 493 | char *play_file; |
|---|
| 494 | char *rec_file; |
|---|
| 495 | time_t prevtime; |
|---|
| 496 | int dw_audio_bw; |
|---|
| 497 | int up_audio_bw; |
|---|
| 498 | int dw_video_bw; |
|---|
| 499 | int up_video_bw; |
|---|
| 500 | int audio_bw; |
|---|
| 501 | int automatic_action; |
|---|
| 502 | gstate_t gstate_power; |
|---|
| 503 | gstate_t gstate_reg; |
|---|
| 504 | gstate_t gstate_call; |
|---|
| 505 | bool_t use_files; |
|---|
| 506 | bool_t apply_nat_settings; |
|---|
| 507 | bool_t ready; |
|---|
| 508 | #ifdef VINCENT_MAURY_RSVP |
|---|
| 509 | /* QoS parameters*/ |
|---|
| 510 | int rsvp_enable; |
|---|
| 511 | int rpc_enable; |
|---|
| 512 | #endif |
|---|
| 513 | } LinphoneCore; |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | /* THE main API */ |
|---|
| 518 | |
|---|
| 519 | void linphone_core_enable_logs(FILE *file); |
|---|
| 520 | void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc); |
|---|
| 521 | void linphone_core_disable_logs(void); |
|---|
| 522 | |
|---|
| 523 | const char *linphone_core_get_version(void); |
|---|
| 524 | |
|---|
| 525 | LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, |
|---|
| 526 | const char *config_path, void* userdata); |
|---|
| 527 | |
|---|
| 528 | void linphone_core_init(LinphoneCore *lc, const LinphoneCoreVTable *vtable, |
|---|
| 529 | const char *config_path, void * userdata); |
|---|
| 530 | |
|---|
| 531 | /* function to be periodically called in a main loop */ |
|---|
| 532 | void linphone_core_iterate(LinphoneCore *lc); |
|---|
| 533 | |
|---|
| 534 | int linphone_core_invite(LinphoneCore *lc, const char *url); |
|---|
| 535 | |
|---|
| 536 | int linphone_core_refer(LinphoneCore *lc, const char *url); |
|---|
| 537 | |
|---|
| 538 | bool_t linphone_core_inc_invite_pending(LinphoneCore*lc); |
|---|
| 539 | |
|---|
| 540 | bool_t linphone_core_in_call(const LinphoneCore *lc); |
|---|
| 541 | |
|---|
| 542 | int linphone_core_accept_call(LinphoneCore *lc, const char *url); |
|---|
| 543 | |
|---|
| 544 | int linphone_core_terminate_call(LinphoneCore *lc, const char *url); |
|---|
| 545 | |
|---|
| 546 | void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf); |
|---|
| 547 | |
|---|
| 548 | int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact); |
|---|
| 549 | |
|---|
| 550 | const char *linphone_core_get_primary_contact(LinphoneCore *lc); |
|---|
| 551 | |
|---|
| 552 | void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val); |
|---|
| 553 | bool_t linphone_core_get_guess_hostname(LinphoneCore *lc); |
|---|
| 554 | |
|---|
| 555 | bool_t linphone_core_ipv6_enabled(LinphoneCore *lc); |
|---|
| 556 | void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val); |
|---|
| 557 | |
|---|
| 558 | osip_from_t *linphone_core_get_primary_contact_parsed(LinphoneCore *lc); |
|---|
| 559 | |
|---|
| 560 | /*0= no bandwidth limit*/ |
|---|
| 561 | void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw); |
|---|
| 562 | void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw); |
|---|
| 563 | |
|---|
| 564 | int linphone_core_get_download_bandwidth(const LinphoneCore *lc); |
|---|
| 565 | int linphone_core_get_upload_bandwidth(const LinphoneCore *lc); |
|---|
| 566 | |
|---|
| 567 | |
|---|
| 568 | #ifdef VINCENT_MAURY_RSVP |
|---|
| 569 | /* QoS functions */ |
|---|
| 570 | int linphone_core_set_rpc_mode(LinphoneCore *lc, int on); /* on = 1 (RPC_ENABLE = 1) */ |
|---|
| 571 | int linphone_core_set_rsvp_mode(LinphoneCore *lc, int on); /* on = 1 (RSVP_ENABLE = 1) */ |
|---|
| 572 | int linphone_core_change_qos(LinphoneCore *lc, int answer); /* answer = 1 for yes, 0 for no */ |
|---|
| 573 | #endif |
|---|
| 574 | |
|---|
| 575 | /* returns a MSList of PayloadType */ |
|---|
| 576 | const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc); |
|---|
| 577 | |
|---|
| 578 | int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs); |
|---|
| 579 | /* returns a MSList of PayloadType */ |
|---|
| 580 | const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc); |
|---|
| 581 | |
|---|
| 582 | int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs); |
|---|
| 583 | |
|---|
| 584 | bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt); |
|---|
| 585 | |
|---|
| 586 | int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); |
|---|
| 587 | |
|---|
| 588 | void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); |
|---|
| 589 | |
|---|
| 590 | const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc); |
|---|
| 591 | |
|---|
| 592 | void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config); |
|---|
| 593 | |
|---|
| 594 | void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index); |
|---|
| 595 | |
|---|
| 596 | int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); |
|---|
| 597 | |
|---|
| 598 | void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info); |
|---|
| 599 | |
|---|
| 600 | void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info); |
|---|
| 601 | |
|---|
| 602 | void linphone_core_abort_authentication(LinphoneCore *lc, LinphoneAuthInfo *info); |
|---|
| 603 | |
|---|
| 604 | void linphone_core_clear_all_auth_info(LinphoneCore *lc); |
|---|
| 605 | |
|---|
| 606 | int linphone_core_get_audio_jittcomp(LinphoneCore *lc); |
|---|
| 607 | |
|---|
| 608 | void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value); |
|---|
| 609 | |
|---|
| 610 | int linphone_core_get_audio_port(const LinphoneCore *lc); |
|---|
| 611 | |
|---|
| 612 | int linphone_core_get_video_port(const LinphoneCore *lc); |
|---|
| 613 | |
|---|
| 614 | int linphone_core_get_nortp_timeout(const LinphoneCore *lc); |
|---|
| 615 | |
|---|
| 616 | void linphone_core_set_audio_port(LinphoneCore *lc, int port); |
|---|
| 617 | |
|---|
| 618 | void linphone_core_set_video_port(LinphoneCore *lc, int port); |
|---|
| 619 | |
|---|
| 620 | void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port); |
|---|
| 621 | |
|---|
| 622 | void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info); |
|---|
| 623 | |
|---|
| 624 | bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc); |
|---|
| 625 | |
|---|
| 626 | int linphone_core_get_sip_port(LinphoneCore *lc); |
|---|
| 627 | |
|---|
| 628 | void linphone_core_set_sip_port(LinphoneCore *lc,int port); |
|---|
| 629 | |
|---|
| 630 | void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds); |
|---|
| 631 | |
|---|
| 632 | int linphone_core_get_inc_timeout(LinphoneCore *lc); |
|---|
| 633 | |
|---|
| 634 | void linphone_core_set_stun_server(LinphoneCore *lc, const char *server); |
|---|
| 635 | |
|---|
| 636 | const char * linphone_core_get_stun_server(const LinphoneCore *lc); |
|---|
| 637 | |
|---|
| 638 | void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr); |
|---|
| 639 | |
|---|
| 640 | const char *linphone_core_get_nat_address(const LinphoneCore *lc); |
|---|
| 641 | |
|---|
| 642 | void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol); |
|---|
| 643 | |
|---|
| 644 | LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc); |
|---|
| 645 | |
|---|
| 646 | const char * linphone_core_get_relay_addr(const LinphoneCore *lc); |
|---|
| 647 | |
|---|
| 648 | int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr); |
|---|
| 649 | |
|---|
| 650 | /* sound functions */ |
|---|
| 651 | /* returns a null terminated static array of string describing the sound devices */ |
|---|
| 652 | const char** linphone_core_get_sound_devices(LinphoneCore *lc); |
|---|
| 653 | bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device); |
|---|
| 654 | bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device); |
|---|
| 655 | int linphone_core_get_ring_level(LinphoneCore *lc); |
|---|
| 656 | int linphone_core_get_play_level(LinphoneCore *lc); |
|---|
| 657 | int linphone_core_get_rec_level(LinphoneCore *lc); |
|---|
| 658 | void linphone_core_set_ring_level(LinphoneCore *lc, int level); |
|---|
| 659 | void linphone_core_set_play_level(LinphoneCore *lc, int level); |
|---|
| 660 | void linphone_core_set_rec_level(LinphoneCore *lc, int level); |
|---|
| 661 | const char * linphone_core_get_ringer_device(LinphoneCore *lc); |
|---|
| 662 | const char * linphone_core_get_playback_device(LinphoneCore *lc); |
|---|
| 663 | const char * linphone_core_get_capture_device(LinphoneCore *lc); |
|---|
| 664 | int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid); |
|---|
| 665 | int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid); |
|---|
| 666 | int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid); |
|---|
| 667 | char linphone_core_get_sound_source(LinphoneCore *lc); |
|---|
| 668 | void linphone_core_set_sound_source(LinphoneCore *lc, char source); |
|---|
| 669 | void linphone_core_set_ring(LinphoneCore *lc, const char *path); |
|---|
| 670 | const char *linphone_core_get_ring(const LinphoneCore *lc); |
|---|
| 671 | void linphone_core_set_ringback(LinphoneCore *lc, const char *path); |
|---|
| 672 | const char * linphone_core_get_ringback(const LinphoneCore *lc); |
|---|
| 673 | int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata); |
|---|
| 674 | void linphone_core_enable_echo_cancelation(LinphoneCore *lc, bool_t val); |
|---|
| 675 | bool_t linphone_core_echo_cancelation_enabled(LinphoneCore *lc); |
|---|
| 676 | |
|---|
| 677 | void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os); |
|---|
| 678 | |
|---|
| 679 | LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); |
|---|
| 680 | |
|---|
| 681 | void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); |
|---|
| 682 | void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr); |
|---|
| 683 | void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); |
|---|
| 684 | void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf); |
|---|
| 685 | /* a list of LinphoneFriend */ |
|---|
| 686 | const MSList * linphone_core_get_friend_list(LinphoneCore *lc); |
|---|
| 687 | /* notify all friends that have subscribed */ |
|---|
| 688 | void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os); |
|---|
| 689 | |
|---|
| 690 | /* returns a list of LinphoneCallLog */ |
|---|
| 691 | MSList * linphone_core_get_call_logs(LinphoneCore *lc); |
|---|
| 692 | |
|---|
| 693 | /* video support */ |
|---|
| 694 | void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); |
|---|
| 695 | bool_t linphone_core_video_enabled(LinphoneCore *lc); |
|---|
| 696 | |
|---|
| 697 | typedef struct MSVideoSizeDef{ |
|---|
| 698 | MSVideoSize vsize; |
|---|
| 699 | const char *name; |
|---|
| 700 | }MSVideoSizeDef; |
|---|
| 701 | /* returns a zero terminated table of MSVideoSizeDef*/ |
|---|
| 702 | const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc); |
|---|
| 703 | void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize); |
|---|
| 704 | MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc); |
|---|
| 705 | void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name); |
|---|
| 706 | |
|---|
| 707 | void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val); |
|---|
| 708 | bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc); |
|---|
| 709 | |
|---|
| 710 | void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val); |
|---|
| 711 | bool_t linphone_core_self_view_enabled(const LinphoneCore *lc); |
|---|
| 712 | |
|---|
| 713 | |
|---|
| 714 | /* returns a null terminated static array of string describing the webcams */ |
|---|
| 715 | const char** linphone_core_get_video_devices(const LinphoneCore *lc); |
|---|
| 716 | int linphone_core_set_video_device(LinphoneCore *lc, const char *id); |
|---|
| 717 | const char *linphone_core_get_video_device(const LinphoneCore *lc); |
|---|
| 718 | |
|---|
| 719 | /*function to be used for eventually setting window decorations (icons, title...)*/ |
|---|
| 720 | unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc); |
|---|
| 721 | |
|---|
| 722 | |
|---|
| 723 | /*play/record support: use files instead of soundcard*/ |
|---|
| 724 | void linphone_core_use_files(LinphoneCore *lc, bool_t yesno); |
|---|
| 725 | void linphone_core_set_play_file(LinphoneCore *lc, const char *file); |
|---|
| 726 | void linphone_core_set_record_file(LinphoneCore *lc, const char *file); |
|---|
| 727 | |
|---|
| 728 | gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group); |
|---|
| 729 | int linphone_core_get_current_call_duration(const LinphoneCore *lc); |
|---|
| 730 | |
|---|
| 731 | int linphone_core_get_mtu(const LinphoneCore *lc); |
|---|
| 732 | void linphone_core_set_mtu(LinphoneCore *lc, int mtu); |
|---|
| 733 | |
|---|
| 734 | bool_t linphone_core_is_in_main_thread(LinphoneCore *lc); |
|---|
| 735 | |
|---|
| 736 | void *linphone_core_get_user_data(LinphoneCore *lc); |
|---|
| 737 | |
|---|
| 738 | /* returns LpConfig object to read/write to the config file: usefull if you wish to extend |
|---|
| 739 | the config file with your own sections */ |
|---|
| 740 | struct _LpConfig *linphone_core_get_config(LinphoneCore *lc); |
|---|
| 741 | |
|---|
| 742 | /* attempts to wake up another linphone engine already running. |
|---|
| 743 | The "show" callback is called for the other linphone, causing gui to show up. |
|---|
| 744 | The method returns 0 if an already running linphone was found*/ |
|---|
| 745 | int linphone_core_wake_up_possible_already_running_instance(const char *config_file); |
|---|
| 746 | |
|---|
| 747 | void linphone_core_uninit(LinphoneCore *lc); |
|---|
| 748 | void linphone_core_destroy(LinphoneCore *lc); |
|---|
| 749 | |
|---|
| 750 | /* end of lecacy api */ |
|---|
| 751 | |
|---|
| 752 | /*internal use only */ |
|---|
| 753 | #define linphone_core_lock(lc) ms_mutex_lock(&(lc)->lock) |
|---|
| 754 | #define linphone_core_unlock(lc) ms_mutex_unlock((&lc)->lock) |
|---|
| 755 | void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call); |
|---|
| 756 | void linphone_core_stop_media_streams(LinphoneCore *lc); |
|---|
| 757 | const char * linphone_core_get_identity(LinphoneCore *lc); |
|---|
| 758 | const char * linphone_core_get_route(LinphoneCore *lc); |
|---|
| 759 | bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, char **real_url, osip_to_t **real_parsed_url, char **route); |
|---|
| 760 | |
|---|
| 761 | #ifdef __cplusplus |
|---|
| 762 | } |
|---|
| 763 | #endif |
|---|
| 764 | |
|---|
| 765 | #endif |
|---|