private.h 58.6 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/***************************************************************************
 *            private.h
 *
 *  Mon Jun 13 14:23:23 2005
 *  Copyright  2005  Simon Morlat
 *  Email simon dot morlat at linphone dot org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
24

aymeric's avatar
aymeric committed
25 26
#ifndef _PRIVATE_H
#define _PRIVATE_H
27

aymeric's avatar
aymeric committed
28
#include "linphonecore.h"
Yann Diorcet's avatar
Yann Diorcet committed
29
#include "linphonefriend.h"
30
#include "friendlist.h"
jehan's avatar
jehan committed
31
#include "linphone_tunnel.h"
Simon Morlat's avatar
Simon Morlat committed
32
#include "linphonecore_utils.h"
33
#include "conference.h"
34
#include "sal/sal.h"
Yann Diorcet's avatar
Yann Diorcet committed
35
#include "sipsetup.h"
36
#include "quality_reporting.h"
37
#include "ringtoneplayer.h"
38
#include "vcard.h"
aymeric's avatar
aymeric committed
39

40 41 42
#include <belle-sip/object.h>
#include <belle-sip/dict.h>

43 44
#include <ctype.h>

aymeric's avatar
aymeric committed
45 46 47
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
48
#include "mediastreamer2/ice.h"
49
#include "mediastreamer2/mediastream.h"
Simon Morlat's avatar
Simon Morlat committed
50
#include "mediastreamer2/msconference.h"
Yann Diorcet's avatar
Yann Diorcet committed
51
#ifdef BUILD_UPNP
Yann Diorcet's avatar
Yann Diorcet committed
52
#include "upnp.h"
53
#endif //BUILD_UPNP
aymeric's avatar
aymeric committed
54

Margaux Clerc's avatar
Margaux Clerc committed
55 56 57 58
#ifdef MSG_STORAGE_ENABLED
#include "sqlite3.h"
#endif

59
#ifndef LIBLINPHONE_VERSION
aymeric's avatar
aymeric committed
60 61 62
#define LIBLINPHONE_VERSION LINPHONE_VERSION
#endif

63
#ifndef PACKAGE_SOUND_DIR
aymeric's avatar
aymeric committed
64 65 66
#define PACKAGE_SOUND_DIR "."
#endif

67 68 69 70
#ifndef PACKAGE_DATA_DIR
#define PACKAGE_DATA_DIR "."
#endif

71
#ifdef ENABLE_NLS
72 73 74 75 76 77 78 79 80 81 82 83

#ifdef _MSC_VER
// prevent libintl.h from re-defining fprintf and vfprintf
#ifndef fprintf
#define fprintf fprintf
#endif
#ifndef vfprintf
#define vfprintf vfprintf
#endif
#define _GL_STDIO_H
#endif

aymeric's avatar
aymeric committed
84
#include <libintl.h>
85

aymeric's avatar
aymeric committed
86
#ifndef _
87
#define _(String) dgettext(GETTEXT_PACKAGE,String)
aymeric's avatar
aymeric committed
88 89
#endif
#else
smorlat's avatar
smorlat committed
90
#ifndef _
aymeric's avatar
aymeric committed
91 92
#define _(something)	(something)
#endif
93 94 95
#ifndef ngettext
#define ngettext(singular, plural, number)	(((number)==1)?(singular):(plural))
#endif
smorlat's avatar
smorlat committed
96
#endif
97 98 99
#ifdef ANDROID
#include <jni.h>
#endif
100

101 102 103 104 105 106 107 108 109 110 111 112
#ifdef _WIN32
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define LINPHONE_WINDOWS_DESKTOP 1
#elif defined(WINAPI_FAMILY_PARTITION)
#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define LINPHONE_WINDOWS_DESKTOP 1
#elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#define LINPHONE_WINDOWS_PHONE 1
#elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define LINPHONE_WINDOWS_UNIVERSAL 1
#endif
#endif
François Grisez's avatar
François Grisez committed
113
#endif
114 115 116 117 118
#ifdef _MSC_VER
#if (_MSC_VER >= 1900)
#define LINPHONE_MSC_VER_GREATER_19
#endif
#endif
jehan's avatar
jehan committed
119

Sylvain Berfini's avatar
Sylvain Berfini committed
120 121 122 123 124 125 126 127 128
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

#ifdef __cplusplus
extern "C" {
#endif

129
struct _LinphoneCallParams{
130 131
	belle_sip_object_t base;
	void *user_data;
132
	LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */
133
	int audio_bw; /* bandwidth limit for audio stream */
134
	LinphoneMediaEncryption media_encryption;
135 136
	PayloadType *audio_codec; /*audio codec currently in use */
	PayloadType *video_codec; /*video codec currently in use */
137
	PayloadType *text_codec; /*text codec currently in use */
138 139
	MSVideoSize sent_vsize; /* Size of the video currently being sent */
	MSVideoSize recv_vsize; /* Size of the video currently being received */
140
	float received_fps,sent_fps;
141 142 143 144
	int down_bw;
	int up_bw;
	int down_ptime;
	int up_ptime;
Simon Morlat's avatar
Simon Morlat committed
145
	char *record_file;
Simon Morlat's avatar
Simon Morlat committed
146
	char *session_name;
147
	SalCustomHeader *custom_headers;
148 149
	SalCustomSdpAttribute *custom_sdp_attributes;
	SalCustomSdpAttribute *custom_sdp_media_attributes[LinphoneStreamTypeUnknown];
150 151 152
	LinphonePrivacyMask privacy;
	LinphoneMediaDirection audio_dir;
	LinphoneMediaDirection video_dir;
153
	bool_t has_audio;
154
	bool_t has_video;
155
	bool_t avpf_enabled; /* RTCP feedback messages are enabled */
156
    bool_t implicit_rtcp_fb;
157
	bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/
Simon Morlat's avatar
Simon Morlat committed
158
	bool_t in_conference; /*in conference mode */
159

jehan's avatar
jehan committed
160
	bool_t low_bandwidth;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
161
	bool_t no_user_consent;/*when set to TRUE an UPDATE request will be used instead of reINVITE*/
162
	uint16_t avpf_rr_interval; /*in milliseconds*/
163

164
	bool_t internal_call_update; /*use mark that call update was requested internally (might be by ice) - unused for the moment*/
165 166
	bool_t video_multicast_enabled;
	bool_t audio_multicast_enabled;
167
	bool_t realtimetext_enabled;
168
};
169

170 171 172
BELLE_SIP_DECLARE_VPTR(LinphoneCallParams);


173
struct _LinphoneQualityReporting{
174
	reporting_session_report_t * reports[3]; /**Store information on audio and video media streams (RFC 6035) */
175
	bool_t was_video_running; /*Keep video state since last check in order to detect its (de)activation*/
176
	LinphoneQualityReportingReportSendCb on_report_sent;
177 178
};

179
struct _LinphoneCallLog{
180 181
	belle_sip_object_t base;
	void *user_data;
182 183 184 185 186 187
	struct _LinphoneCore *lc;
	LinphoneCallDir dir; /**< The direction of the call*/
	LinphoneCallStatus status; /**< The status of the call*/
	LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
	LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
	char start_date[128]; /**<Human readable string containing the start date*/
188
	int duration; /**<Duration of the call starting in connected state in seconds*/
189 190 191 192 193
	char *refkey;
	rtp_stats_t local_stats;
	rtp_stats_t remote_stats;
	float quality;
	time_t start_date_time; /**Start date of the call in seconds as expressed in a time_t */
194
	time_t connected_date_time; /**Connecting date of the call in seconds as expressed in a time_t */
195
	char* call_id; /**unique id of a call*/
196
	struct _LinphoneQualityReporting reporting;
197
	bool_t video_enabled;
198
	unsigned int storage_id;
199 200
};

201 202
BELLE_SIP_DECLARE_VPTR(LinphoneCallLog);

203

204 205
typedef struct _CallCallbackObj
{
206 207
	LinphoneCallCbFunc _func;
	void * _user_data;
208
}CallCallbackObj;
209

210 211 212
struct _LinphoneChatMessageCbs {
	belle_sip_object_t base;
	void *user_data;
213 214 215 216
	LinphoneChatMessageCbsMsgStateChangedCb msg_state_changed;
	LinphoneChatMessageCbsFileTransferRecvCb file_transfer_recv; /**< Callback to store file received attached to a #LinphoneChatMessage */
	LinphoneChatMessageCbsFileTransferSendCb file_transfer_send; /**< Callback to collect file chunk to be sent for a #LinphoneChatMessage */
	LinphoneChatMessageCbsFileTransferProgressIndicationCb file_transfer_progress_indication; /**< Callback to indicate file transfer progress */
217 218 219 220
};

BELLE_SIP_DECLARE_VPTR(LinphoneChatMessageCbs);

Simon Morlat's avatar
Simon Morlat committed
221 222 223 224 225
typedef enum _LinphoneChatMessageDir{
	LinphoneChatMessageIncoming,
	LinphoneChatMessageOutgoing
} LinphoneChatMessageDir;

226
struct _LinphoneChatMessage {
227
	belle_sip_object_t base;
228
	LinphoneChatRoom* chat_room;
229
	LinphoneChatMessageCbs *callbacks;
Simon Morlat's avatar
Simon Morlat committed
230 231
	LinphoneChatMessageDir dir;
	char* message;
232
	void* message_state_changed_user_data;
233
	void* message_userdata;
234
	char* appdata;
235
	char* external_body_url;
Simon Morlat's avatar
Simon Morlat committed
236 237
	LinphoneAddress *from;
	LinphoneAddress *to;
238
	time_t time;
239
	SalCustomHeader *custom_headers;
Margaux Clerc's avatar
Margaux Clerc committed
240
	LinphoneChatMessageState state;
Simon Morlat's avatar
Simon Morlat committed
241
	bool_t is_read;
242
	unsigned int storage_id;
243
	SalOp *op;
244 245 246
	LinphoneContent *file_transfer_information; /**< used to store file transfer information when the message is of file transfer type */
	char *content_type; /**< is used to specified the type of message to be sent, used only for file transfer message */
	belle_http_request_t *http_request; /**< keep a reference to the http_request in case of file transfer in order to be able to cancel the transfer */
247
	belle_http_request_listener_t *http_listener; /* our listener, only owned by us*/
248
	char *file_transfer_filepath;
249 250 251 252 253 254 255 256 257

#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
	LinphoneChatMessageStateChangedCb message_state_changed_cb;
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic pop
#endif
258
};
259

260 261
BELLE_SIP_DECLARE_VPTR(LinphoneChatMessage);

262 263 264 265 266 267
typedef struct StunCandidate{
	char addr[64];
	int port;
}StunCandidate;


268
typedef struct _PortConfig{
269
	char multicast_ip[LINPHONE_IPADDR_SIZE];
270 271 272 273
	int rtp_port;
	int rtcp_port;
}PortConfig;

274
struct _LinphoneCall{
275 276
	belle_sip_object_t base;
	void *user_data;
smorlat's avatar
smorlat committed
277
	struct _LinphoneCore *core;
278
	SalErrorInfo non_op_error;
279
	int af; /*the address family to prefer for RTP path, guessed from signaling path*/
280 281
	LinphoneCallDir dir;
	SalMediaDescription *biggestdesc; /*media description with all already proposed streams, used to remember the mapping of streams*/
282 283
	SalMediaDescription *localdesc;
	SalMediaDescription *resultdesc;
Simon Morlat's avatar
Simon Morlat committed
284 285
	struct _RtpProfile *audio_profile;
	struct _RtpProfile *video_profile;
286
	struct _RtpProfile *text_profile;
287 288
	struct _RtpProfile *rtp_io_audio_profile;
	struct _RtpProfile *rtp_io_video_profile;
smorlat's avatar
smorlat committed
289
	struct _LinphoneCallLog *log;
290
	LinphoneAddress *me; /*Either from or to based on call dir*/
291
	SalOp *op;
292
	SalOp *ping_op;
293
	char media_localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local media ipaddress for this call */
294 295
	LinphoneCallState state;
	LinphoneCallState prevstate;
296
	LinphoneCallState transfer_state; /*idle if no transfer*/
297
	LinphoneProxyConfig *dest_proxy;
298 299 300 301
	int main_audio_stream_index, main_video_stream_index, main_text_stream_index;
	PortConfig media_ports[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
	MSMediaStreamSessions sessions[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; /*the rtp, srtp, zrtp contexts for each stream*/
	StunCandidate ac, vc, tc; /*audio video text ip/port discovered by STUN*/
302 303
	struct _AudioStream *audiostream;  /**/
	struct _VideoStream *videostream;
304
	struct _TextStream *textstream;
305
	void *video_window_id;
Simon Morlat's avatar
Simon Morlat committed
306
	MSAudioEndpoint *endpoint; /*used for conferencing*/
Simon Morlat's avatar
Simon Morlat committed
307
	char *refer_to;
308 309 310
	LinphoneCallParams *params;
	LinphoneCallParams *current_params;
	LinphoneCallParams *remote_params;
311
	int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
312
	int audio_bw;	/*upload bandwidth used by audio */
313 314 315
	OrtpEvQueue *audiostream_app_evq;
	char *auth_token;
	OrtpEvQueue *videostream_app_evq;
316
	OrtpEvQueue *textstream_app_evq;
317
	CallCallbackObj nextVideoFrameDecoded;
318
	LinphoneCallStats stats[3]; /* audio, video, text */
Yann Diorcet's avatar
Yann Diorcet committed
319 320 321
#ifdef BUILD_UPNP
	UpnpSession *upnp_session;
#endif //BUILD_UPNP
322 323
	IceSession *ice_session;
	int ping_time;
324 325
	unsigned int remote_session_id;
	unsigned int remote_session_ver;
326
	LinphoneCall *referer; /*when this call is the result of a transfer, referer is set to the original call that caused the transfer*/
327
	LinphoneCall *transfer_target;/*if this call received a transfer request, then transfer_target points to the new call created to the refer target */
328
	int localdesc_changed;/*not a boolean, contains a mask representing changes*/
329
	LinphonePlayer *player;
Simon Morlat's avatar
Simon Morlat committed
330
	unsigned long bg_task_id; /*used to prevent device to suspend app while a call is received in background*/
331
	unsigned int nb_media_starts;
332

333 334 335
	char *dtmf_sequence; /*DTMF sequence needed to be sent using #dtmfs_timer*/
	belle_sip_source_t *dtmfs_timer; /*DTMF timer needed to send a DTMF sequence*/

336
	char *dtls_certificate_fingerprint; /**> This fingerprint is computed during stream init and is stored in call to be used when making local media description */
337
	char *onhold_file; /*set if a on-hold file is to be played*/
338
	LinphoneChatRoom *chat_room;
339
	bool_t refer_pending;
340
	bool_t expect_media_in_ack;
341
	bool_t audio_muted;
342
	bool_t camera_enabled;
343

344
	bool_t all_muted; /*this flag is set during early medias*/
345
	bool_t playing_ringbacktone;
346
	bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/
Simon Morlat's avatar
Simon Morlat committed
347
	bool_t auth_token_verified;
348

349
	bool_t defer_update;
350
	bool_t was_automatically_paused;
351
	bool_t ping_replied;
Simon Morlat's avatar
Simon Morlat committed
352
	bool_t record_active;
353

354
	bool_t paused_by_app;
355
	bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */
356 357
	
	LinphoneConference *conf_ref; /**> Point on the associated conference if this call is part of a conference. NULL instead. */
358
};
smorlat's avatar
smorlat committed
359

360 361
BELLE_SIP_DECLARE_VPTR(LinphoneCall);

362

Simon Morlat's avatar
Simon Morlat committed
363
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
364
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op);
365
void linphone_call_set_new_params(LinphoneCall *call, const LinphoneCallParams *params);
366
void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message);
367
void linphone_call_set_contact_op(LinphoneCall* call);
368
void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, SalMediaDescription *md);
smorlat's avatar
smorlat committed
369
/* private: */
370
LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *local, LinphoneAddress * remote);
371
void linphone_call_log_completed(LinphoneCall *call);
smorlat's avatar
smorlat committed
372
void linphone_call_log_destroy(LinphoneCallLog *cl);
373
void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state);
374
LinphonePlayer *linphone_call_build_player(LinphoneCall*call);
375
void linphone_call_refresh_sockets(LinphoneCall *call);
smorlat's avatar
smorlat committed
376

377 378
LinphoneCallParams * linphone_call_params_new(void);
SalMediaProto get_proto_from_call_params(const LinphoneCallParams *params);
379 380
SalStreamDir get_audio_dir_from_call_params(const LinphoneCallParams *params);
SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params);
381
void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch);
382 383
void linphone_call_params_set_custom_sdp_attributes(LinphoneCallParams *params, const SalCustomSdpAttribute *csa);
void linphone_call_params_set_custom_sdp_media_attributes(LinphoneCallParams *params, LinphoneStreamType type, const SalCustomSdpAttribute *csa);
384

aymeric's avatar
aymeric committed
385
void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);
386
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
387
const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain, bool_t ignore_realm);
aymeric's avatar
aymeric committed
388 389

void linphone_core_update_proxy_register(LinphoneCore *lc);
390
int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *error);
391
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
aymeric's avatar
aymeric committed
392

393
int linphone_proxy_config_send_publish(LinphoneProxyConfig *cfg, LinphonePresenceModel *presence);
394
void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState rstate, const char *message);
395
void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj);
396
void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc);
397
void _linphone_proxy_config_release(LinphoneProxyConfig *cfg);
398 399 400 401 402
/*
 * returns service route as defined in as defined by rfc3608, might be a list instead of just one.
 * Can be NULL
 * */
const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg);
403

404
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
405
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
406
void _linphone_friend_list_release(LinphoneFriendList *list);
407
void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
408
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
409
void _linphone_friend_release(LinphoneFriend *lf);
410
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered);
411
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
412 413
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op);
414 415
LinphoneFriend *linphone_friend_list_find_friend_by_inc_subscribe(const LinphoneFriendList *list, SalOp *op);
LinphoneFriend *linphone_friend_list_find_friend_by_out_subscribe(const LinphoneFriendList *list, SalOp *op);
416
MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf);
417 418
bool_t linphone_core_should_subscribe_friends_only_when_registered(const LinphoneCore *lc);
void linphone_core_update_friends_subscriptions(LinphoneCore *lc, LinphoneProxyConfig *cfg, bool_t only_when_registered);
419 420 421 422
void linphone_core_friends_storage_init(LinphoneCore *lc);
void linphone_core_friends_storage_close(LinphoneCore *lc);
void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf);
void linphone_core_remove_friend_from_db(LinphoneCore *lc, LinphoneFriend *lf);
423
MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc);
424
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf);
425

426
int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen, int default_port);
Simon Morlat's avatar
Simon Morlat committed
427

428
bool_t host_has_ipv6_network(void);
aymeric's avatar
aymeric committed
429 430
bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret);

431
static MS2_INLINE int get_min_bandwidth(int dbw, int ubw){
Simon Morlat's avatar
Simon Morlat committed
432 433
	if (dbw<=0) return ubw;
	if (ubw<=0) return dbw;
aymeric's avatar
aymeric committed
434 435 436
	return MIN(dbw,ubw);
}

437
static MS2_INLINE bool_t bandwidth_is_greater(int bw1, int bw2){
438 439
	if (bw1<=0) return TRUE;
	else if (bw2<=0) return FALSE;
aymeric's avatar
aymeric committed
440 441 442
	else return bw1>=bw2;
}

443
static MS2_INLINE int get_remaining_bandwidth_for_video(int total, int audio){
444 445 446
	int ret = total-audio-10;
	if (ret < 0) ret = 0;
	return ret;
447 448
}

449
static MS2_INLINE void set_string(char **dest, const char *src, bool_t lowercase){
450 451 452 453
	if (*dest){
		ms_free(*dest);
		*dest=NULL;
	}
454
	if (src) {
455
		*dest=ms_strdup(src);
456 457 458 459 460
		if (lowercase) {
			char *cur = *dest;
			for (; *cur; cur++) *cur = tolower(*cur);
		}
	}
461 462
}

aymeric's avatar
aymeric committed
463
#define PAYLOAD_TYPE_ENABLED	PAYLOAD_TYPE_USER_FLAG_0
464
#define PAYLOAD_TYPE_BITRATE_OVERRIDE PAYLOAD_TYPE_USER_FLAG_3
465
#define PAYLOAD_TYPE_FROZEN_NUMBER	PAYLOAD_TYPE_USER_FLAG_4
aymeric's avatar
aymeric committed
466

467 468
void linphone_process_authentication(LinphoneCore* lc, SalOp *op);
void linphone_authentication_ok(LinphoneCore *lc, SalOp *op);
469
void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from);
470
void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence);
471
void linphone_notify_parse_presence(const char *content_type, const char *content_subtype, const char *body, SalPresenceModel **result);
472
void linphone_notify_convert_presence_to_xml(SalOp *op, SalPresenceModel *presence, const char *contact, char **content);
473
void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model);
474
void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, SalOp *op);
475 476
void linphone_core_soundcard_hint_check(LinphoneCore* lc);

aymeric's avatar
aymeric committed
477

478 479
void linphone_subscription_answered(LinphoneCore *lc, SalOp *op);
void linphone_subscription_closed(LinphoneCore *lc, SalOp *op);
aymeric's avatar
aymeric committed
480

481
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc);
482
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt, int maxbw);
483

484
LINPHONE_PUBLIC int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
485
void linphone_core_resolve_stun_server(LinphoneCore *lc);
486
LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc);
487
void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params);
488
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call);
489
void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call);
Simon Morlat's avatar
Simon Morlat committed
490
void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev);
Simon Morlat's avatar
Simon Morlat committed
491
void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result);
492 493 494
void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session);
void linphone_call_update_local_media_description_from_ice_or_upnp(LinphoneCall *call);
void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md);
495
void linphone_call_clear_unused_ice_candidates(LinphoneCall *call, const SalMediaDescription *md);
496
bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md);
aymeric's avatar
aymeric committed
497

498
void linphone_core_send_initial_subscribes(LinphoneCore *lc);
499
void linphone_core_write_friends_config(LinphoneCore* lc);
smorlat's avatar
smorlat committed
500 501 502
void linphone_friend_write_to_config_file(struct _LpConfig *config, LinphoneFriend *lf, int index);
LinphoneFriend * linphone_friend_new_from_config_file(struct _LinphoneCore *lc, int index);

503
void linphone_proxy_config_update(LinphoneProxyConfig *cfg);
Simon Morlat's avatar
Simon Morlat committed
504
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri);
505
const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to);
506
int linphone_core_get_local_ip_for(int type, const char *dest, char *result);
507
void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result);
508

jehan's avatar
jehan committed
509
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index);
smorlat's avatar
smorlat committed
510 511
void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index);

512
void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
513
void linphone_core_is_composing_received(LinphoneCore *lc, SalOp *op, const SalIsComposing *is_composing);
Sylvain Berfini's avatar
Sylvain Berfini committed
514
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call);
515

516
void linphone_call_init_stats(LinphoneCallStats *stats, int type);
517
void linphone_call_fix_call_parameters(LinphoneCall *call, SalMediaDescription *rmd);
518 519
void linphone_call_init_audio_stream(LinphoneCall *call);
void linphone_call_init_video_stream(LinphoneCall *call);
520
void linphone_call_init_text_stream(LinphoneCall *call);
521
void linphone_call_init_media_streams(LinphoneCall *call);
522
void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState target_state);
523
void linphone_call_start_media_streams_for_ice_gathering(LinphoneCall *call);
524
void linphone_call_stop_media_streams(LinphoneCall *call);
525
void linphone_call_delete_ice_session(LinphoneCall *call);
Yann Diorcet's avatar
Yann Diorcet committed
526
void linphone_call_delete_upnp_session(LinphoneCall *call);
527
void linphone_call_stop_media_streams_for_ice_gathering(LinphoneCall *call);
528
void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md);
529
void linphone_call_update_remote_session_id_and_ver(LinphoneCall *call);
530
int _linphone_core_apply_transports(LinphoneCore *lc);
531
const char * linphone_core_get_identity(LinphoneCore *lc);
532

533 534 535 536
void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
void linphone_core_stop_waiting(LinphoneCore *lc);

537
int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy);
538
int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, const LinphoneAddress* destination/* = NULL if to be taken from the call log */);
Simon Morlat's avatar
Simon Morlat committed
539
int linphone_core_restart_invite(LinphoneCore *lc, LinphoneCall *call);
540 541 542
/*
 * param automatic_offering aims is to take into account previous answer for video in case of automatic re-invite.
 *  Purpose is to avoid to re-ask video previously declined */
543
int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call);
544
int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState next_state, const char *state_info);
545
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
546
bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md);
547
extern SalCallbacks linphone_sal_callbacks;
548
bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
549
bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc);
550

551 552
void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun, void *data, const char *task_description);

553 554 555 556 557 558 559 560
typedef enum _LinphoneProxyConfigAddressComparisonResult{
	LinphoneProxyConfigAddressDifferent,
	LinphoneProxyConfigAddressEqual,
	LinphoneProxyConfigAddressWeakEqual
} LinphoneProxyConfigAddressComparisonResult;

LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b);
LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj);
561 562 563
/**
 * unregister without moving the register_enable flag
 */
564
void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj);
565
void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
566

567
/*chat*/
568
void linphone_chat_room_release(LinphoneChatRoom *cr);
569
void linphone_chat_message_destroy(LinphoneChatMessage* msg);
570
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
571
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state);
572
int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
573 574
void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
575
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
576
/**/
577

578 579
struct _LinphoneProxyConfig
{
580 581
	belle_sip_object_t base;
	void *user_data;
582 583 584
	struct _LinphoneCore *lc;
	char *reg_proxy;
	char *reg_identity;
585
	LinphoneAddress* identity_address;
586
	char *reg_route;
587
	char *quality_reporting_collector;
588
	char *realm;
589
	char *contact_params;
590
	char *contact_uri_params;
591
	int expires;
592
	int publish_expires;
593
	SalOp *op;
594
	SalCustomHeader *sent_headers;
595 596 597 598
	char *type;
	struct _SipSetupContext *ssctx;
	int auth_failures;
	char *dial_prefix;
599
	LinphoneRegistrationState state;
Simon Morlat's avatar
Simon Morlat committed
600
	SalOp *publish_op;
601
	LinphoneAVPFMode avpf_mode;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
602

603 604 605 606
	bool_t commit;
	bool_t reg_sendregister;
	bool_t publish;
	bool_t dial_escape_plus;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
607

608
	bool_t send_publish;
609
	bool_t quality_reporting_enabled;
610
	uint8_t avpf_rr_interval;
611
	uint8_t quality_reporting_interval;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
612

613
	time_t deletion_date;
614
	LinphonePrivacyMask privacy;
615 616 617 618
	/*use to check if server config has changed  between edit() and done()*/
	LinphoneAddress *saved_proxy;
	LinphoneAddress *saved_identity;
	/*---*/
619
	LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/
620

621 622
};

623 624
BELLE_SIP_DECLARE_VPTR(LinphoneProxyConfig);

625
struct _LinphoneAuthInfo
626 627 628 629 630 631
{
	char *username;
	char *realm;
	char *userid;
	char *passwd;
	char *ha1;
632
	char *domain;
633 634
};

635 636 637 638 639
typedef enum _LinphoneIsComposingState {
	LinphoneIsComposingIdle,
	LinphoneIsComposingActive
} LinphoneIsComposingState;

640
struct _LinphoneChatRoom{
641 642
	belle_sip_object_t base;
	void *user_data;
643 644 645
	struct _LinphoneCore *lc;
	char  *peer;
	LinphoneAddress *peer_url;
Margaux Clerc's avatar
Margaux Clerc committed
646
	MSList *messages_hist;
647
	MSList *transient_messages;
648
	int unread_count;
649 650 651 652 653
	LinphoneIsComposingState remote_is_composing;
	LinphoneIsComposingState is_composing;
	belle_sip_source_t *remote_composing_refresh_timer;
	belle_sip_source_t *composing_idle_timer;
	belle_sip_source_t *composing_refresh_timer;
654 655
	LinphoneCall *call;
	LinphoneChatMessage *pending_message;
656
	MSList *received_rtt_characters;
657 658
};

659 660 661 662 663
typedef struct _LinphoneChatMessageCharacter {
	uint32_t value;
	bool_t has_been_read;
} LinphoneChatMessageCharacter;

664
BELLE_SIP_DECLARE_VPTR(LinphoneChatRoom);
665

666

667
struct _LinphoneFriend{
668 669
	belle_sip_object_t base;
	void *user_data;
670
	LinphoneAddress *uri;
671
	MSList *insubs; /*list of SalOp. There can be multiple instances of a same Friend that subscribe to our presence*/
672 673
	SalOp *outsub;
	LinphoneSubscribePolicy pol;
674
	LinphonePresenceModel *presence;
675 676 677
	struct _LinphoneCore *lc;
	BuddyInfo *info;
	char *refkey;
Simon Morlat's avatar
Simon Morlat committed
678
	bool_t in_list;
679
	bool_t subscribe;
680
	bool_t subscribe_active;
681
	bool_t inc_subscribe_pending;
682
	bool_t commit;
683
	bool_t initial_subscribes_sent; /*used to know if initial subscribe message was sent or not*/
684
	bool_t presence_received;
685
	LinphoneVCard *vcard;
686
	unsigned int storage_id;
687
};
688

689 690
BELLE_SIP_DECLARE_VPTR(LinphoneFriend);

jehan's avatar
jehan committed
691

692 693 694
struct _LinphoneFriendList {
	belle_sip_object_t base;
	void *user_data;
695
	LinphoneCore *lc;
696
	LinphoneEvent *event;
697 698 699
	char *display_name;
	char *rls_uri;
	MSList *friends;
700
	unsigned char *content_digest;
701
	int expected_notification_version;
702 703 704 705 706
};

BELLE_SIP_DECLARE_VPTR(LinphoneFriendList);


707 708 709 710 711 712 713
typedef struct sip_config
{
	char *contact;
	char *guessed_contact;
	MSList *proxies;
	MSList *deleted_proxies;
	int inc_timeout;	/*timeout after an un-answered incoming call is rejected*/
Yann Diorcet's avatar
Yann Diorcet committed
714
	int in_call_timeout;	/*timeout after a call is hangup */
715
	int delayed_timeout; 	/*timeout after a delayed call is resumed */
716 717
	unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/
	LCSipTransports transports;
718 719 720 721 722
	bool_t guess_hostname;
	bool_t loopback_only;
	bool_t ipv6_enabled;
	bool_t sdp_200_ack;
	bool_t register_only_when_network_is_up;
723
	bool_t register_only_when_upnp_is_ok;
724
	bool_t ping_with_options;
725
	bool_t auto_net_state_mon;
726
	bool_t tcp_tls_keepalive;
727
	bool_t vfu_with_info; /*use to enable vfu request using sip info*/
728
	bool_t save_auth_info; // if true, auth infos will be write in the config file when they are added to the list
729 730 731 732
} sip_config_t;

typedef struct rtp_config
{
733 734 735 736
	int audio_rtp_min_port;
	int audio_rtp_max_port;
	int video_rtp_min_port;
	int video_rtp_max_port;
737 738 739
	int audio_jitt_comp;  /*jitter compensation*/
	int video_jitt_comp;  /*jitter compensation*/
	int nortp_timeout;
740
	int disable_upnp;
741
	MSCryptoSuite *srtp_suites;
742
	LinphoneAVPFMode avpf_mode;
743
	bool_t rtp_no_xmit_on_audio_mute;
744
							  /* stop rtp xmit when audio muted */
745 746
	bool_t audio_adaptive_jitt_comp_enabled;
	bool_t video_adaptive_jitt_comp_enabled;
747
	bool_t pad;
jehan's avatar
jehan committed
748 749 750 751 752 753
	char* audio_multicast_addr;
	bool_t audio_multicast_enabled;
	int audio_multicast_ttl;
	char* video_multicast_addr;
	int video_multicast_ttl;
	bool_t video_multicast_enabled;
754 755
	int text_rtp_min_port;
	int text_rtp_max_port;
756 757 758 759 760 761
}rtp_config_t;



typedef struct net_config
{
762 763
	char *nat_address; /* may be IP or host name */
	char *nat_address_ip; /* ip translated from nat_address */
764
	char *stun_server;
765
	struct addrinfo *stun_addrinfo;
766
	SalResolverContext * stun_res;
767 768 769
	int download_bw;
	int upload_bw;
	int mtu;
770
	OrtpNetworkSimulatorParams netsim_params;
771 772 773 774 775 776 777 778 779
	bool_t nat_sdp_only;
}net_config_t;


typedef struct sound_config
{
	struct _MSSndCard * ring_sndcard;	/* the playback sndcard currently used */
	struct _MSSndCard * play_sndcard;	/* the playback sndcard currently used */
	struct _MSSndCard * capt_sndcard; /* the capture sndcard currently used */
780
	struct _MSSndCard * lsd_card; /* dummy playback card for Linphone Sound Daemon extension */
781 782
	const char **cards;
	int latency;	/* latency in samples of the current used sound device */
783
	float soft_play_lev; /*playback gain in db.*/
784
	float soft_mic_lev; /*mic gain in db.*/
785 786 787 788 789 790
	char rec_lev;
	char play_lev;
	char ring_lev;
	char source;
	char *local_ring;
	char *remote_ring;
791
	char *ringback_tone;
792 793 794 795 796 797 798 799
	bool_t ec;
	bool_t ea;
	bool_t agc;
} sound_config_t;

typedef struct codecs_config
{
	MSList *audio_codecs;  /* list of audio codecs in order of preference*/
800
	MSList *video_codecs;
801
	MSList *text_codecs;
802 803
	int dyn_pt;
	int telephone_event_pt;
804 805 806 807 808 809
}codecs_config_t;

typedef struct video_config{
	struct _MSWebCam *device;
	const char **cams;
	MSVideoSize vsize;
810
	MSVideoSize preview_vsize; /*is 0,0 if no forced preview size is set, in which case vsize field above is used.*/
811
	float fps;
812 813 814 815
	bool_t capture;
	bool_t show_local;
	bool_t display;
	bool_t selfview; /*during calls*/
816
	bool_t reuse_preview_source;
817 818
}video_config_t;

819 820 821 822
typedef struct text_config{
	bool_t enabled;
}text_config_t;

823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
typedef struct ui_config
{
	int is_daemon;
	int is_applet;
	unsigned int timer_id;  /* the timer id for registration */
}ui_config_t;



typedef struct autoreplier_config
{
	int enabled;
	int after_seconds;		/* accept the call after x seconds*/
	int max_users;			/* maximum number of user that can call simultaneously */
	int max_rec_time;  	/* the max time of incoming voice recorded */
	int max_rec_msg;		/* maximum number of recorded messages */
	const char *message;		/* the path of the file to be played */
}autoreplier_config_t;

842 843 844 845 846 847 848 849 850 851 852

typedef struct _LinphoneToneDescription{
	LinphoneReason reason;
	LinphoneToneID toneid;
	char *audiofile;
}LinphoneToneDescription;

LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile);
void linphone_tone_description_destroy(LinphoneToneDescription *obj);
LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *lc, LinphoneReason reason);
void linphone_core_play_call_error_tone(LinphoneCore *lc, LinphoneReason reason);
853 854
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
855
int _linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params, LinphoneCallState next_state, const char *state_info);
856

857 858 859 860 861 862 863 864 865 866
typedef struct _LinphoneTaskList{
	MSList *hooks;
}LinphoneTaskList;

void linphone_task_list_init(LinphoneTaskList *t);
void linphone_task_list_add(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data);
void linphone_task_list_remove(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data);
void linphone_task_list_run(LinphoneTaskList *t);
void linphone_task_list_free(LinphoneTaskList *t);

867 868
struct _LinphoneCore
{
Simon Morlat's avatar
Simon Morlat committed
869
	MSList* vtable_refs;
870
	Sal *sal;
Simon Morlat's avatar
Simon Morlat committed
871
	LinphoneGlobalState state;
872
	struct _LpConfig *config;
873 874
	MSList *default_audio_codecs;
	MSList *default_video_codecs;
875
	MSList *default_text_codecs;
876 877 878 879 880
	net_config_t net_conf;
	sip_config_t sip_conf;
	rtp_config_t rtp_conf;
	sound_config_t sound_conf;
	video_config_t video_conf;
881
	text_config_t text_conf;
882 883 884 885
	codecs_config_t codecs_conf;
	ui_config_t ui_conf;
	autoreplier_config_t autoreplier_conf;
	LinphoneProxyConfig *default_proxy;
886
	LinphoneFriendList *friendlist;
887 888
	MSList *auth_info;
	struct _RingStream *ringstream;
889
	time_t dmfs_playing_start_time;
890
	LCCallbackObj preview_finished_cb;
891 892
	LinphoneCall *current_call;   /* the current call */
	MSList *calls;				/* all the processed calls */
893 894 895 896 897
	MSList *queued_calls;	/* used by the autoreplier */
	MSList *call_logs;
	MSList *chatrooms;
	int max_call_logs;
	int missed_calls;
898
	VideoPreview *previewstream;
899
	struct _MSEventQueue *msevq;
Guillaume Beraudo's avatar
Guillaume Beraudo committed
900
	LinphoneRtpTransportFactories *rtptf;
901 902 903
	MSList *bl_reqs;
	MSList *subscribers;	/* unknown subscribers */
	int minutes_away;
904
	LinphonePresenceModel *presence_model;
905 906 907
	void *data;
	char *play_file;
	char *rec_file;
908
	uint64_t prevtime_ms;
909
	int audio_bw; /*IP bw consumed by audio codec, set as soon as used codec is known, its purpose is to know the remaining bw for video*/
910
	LinphoneCoreWaitingCallback wait_cb;
911
	void *wait_ctx;
912 913
	void *video_window_id;
	void *preview_window_id;
914
	time_t netup_time; /*time when network went reachable */
Simon Morlat's avatar
Simon Morlat committed
915
	struct _EcCalibrator *ecc;
916
	LinphoneTaskList hooks; /*tasks periodically executed in linphone_core_iterate()*/
917
	LinphoneConference *conf_ctx;
Simon Morlat's avatar
Simon Morlat committed
918
	char* zrtp_secrets_cache;
johan's avatar
johan committed
919
	char* user_certificates_path;
920
	LinphoneVideoPolicy video_policy;
Simon Morlat's avatar
Simon Morlat committed
921
	time_t network_last_check;
922

923 924
	bool_t use_files;
	bool_t apply_nat_settings;
925
	bool_t initial_subscribes_sent;
926
	bool_t bl_refresh;
927

928
	bool_t preview_finished;
929
	bool_t auto_net_state_mon;
930
	bool_t network_reachable;
931
	bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/
932

933
	bool_t use_preview_window;
Yann Diorcet's avatar
Yann Diorcet committed
934
	bool_t network_last_status;
935
	bool_t ringstream_autorelease;
Simon Morlat's avatar
Simon Morlat committed
936
	bool_t vtables_running;
937
	char localip[LINPHONE_IPADDR_SIZE];
938
	int device_rotation;
939
	int max_calls;
940
	LinphoneTunnel *tunnel;
jehan's avatar
jehan committed
941
	char* device_id;
942
	MSList *last_recv_msg_ids;
Simon Morlat's avatar
Simon Morlat committed
943
	char *chat_db_file;
Margaux Clerc's avatar
Margaux Clerc committed
944 945
#ifdef MSG_STORAGE_ENABLED
	sqlite3 *db;
946
	bool_t debug_storage;
947 948 949 950
#endif
	char *logs_db_file;
#ifdef CALL_LOGS_STORAGE_ENABLED
	sqlite3 *logs_db;
951 952 953 954
#endif
	char *friends_db_file;
#ifdef FRIENDS_SQL_STORAGE_ENABLED
	sqlite3 *friends_db;
Margaux Clerc's avatar
Margaux Clerc committed
955
#endif
Yann Diorcet's avatar
Yann Diorcet committed
956
#ifdef BUILD_UPNP
Yann Diorcet's avatar
Yann Diorcet committed
957
	UpnpContext *upnp;
Yann Diorcet's avatar
Yann Diorcet committed
958
#endif //BUILD_UPNP
959
	belle_http_provider_t *http_provider;
960
	belle_tls_verify_policy_t *http_verify_policy;
Simon Morlat's avatar
Simon Morlat committed
961
	belle_http_request_listener_t *provisioning_http_listener;
962
	MSList *tones;
963
	LinphoneReason chat_deny_code;
964
	char *file_transfer_server;
Simon Morlat's avatar
Simon Morlat committed
965
	const char **supported_formats;
966
	LinphoneContent *log_collection_upload_information;
967
	LinphoneCoreVTable *current_vtable; // the latest vtable to call a callback, see linphone_core_get_current_vtable
968
	LinphoneRingtonePlayer *ringtoneplayer;
969 970
#ifdef ANDROID
	jobject wifi_lock;
971
	jclass wifi_lock_class;
972 973
	jmethodID wifi_lock_acquire_id;
	jmethodID wifi_lock_release_id;
974
	jobject multicast_lock;
975
	jclass multicast_lock_class;
976 977
	jmethodID multicast_lock_acquire_id;
	jmethodID multicast_lock_release_id;
978
#endif
979 980
};

981 982 983 984 985

struct _LinphoneEvent{
	LinphoneSubscriptionDir dir;
	LinphoneCore *lc;
	SalOp *op;
986
	SalCustomHeader *send_custom_headers;
987 988 989 990 991
	LinphoneSubscriptionState subscription_state;
	LinphonePublishState publish_state;
	void *userdata;
	int refcnt;
	char *name;
992
	int expires;
993
	bool_t terminating;
994
	bool_t is_out_of_dialog_op; /*used for out of dialog notify*/
995
	bool_t internal;
996 997 998
};


999 1000
LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
void linphone_tunnel_destroy(LinphoneTunnel *tunnel);
1001 1002
void linphone_tunnel_configure(LinphoneTunnel *tunnel);
void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler);
Yann Diorcet's avatar
Yann Diorcet committed
1003

1004 1005 1006 1007 1008
bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call);
int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call);
int linphone_core_get_calls_nb(const LinphoneCore *lc);