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