private.h 83.8 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

28 29 30 31 32 33
#include "linphone/core.h"
#include "linphone/friend.h"
#include "linphone/friendlist.h"
#include "linphone/tunnel.h"
#include "linphone/core_utils.h"
#include "linphone/conference.h"
34
#include "sal/sal.h"
35
#include "linphone/sipsetup.h"
36
#include "quality_reporting.h"
37
#include "linphone/ringtoneplayer.h"
38 39
#include "vcard_private.h"
#include "carddav.h"
40
#include "linphone/player.h"
aymeric's avatar
aymeric committed
41

42
#include "bctoolbox/port.h"
43
#include "bctoolbox/map.h"
44 45 46
#include "bctoolbox/vfs.h"
#include "belle-sip/belle-sip.h" /*we need this include for all http operations*/

47

48 49
#include <ctype.h>

aymeric's avatar
aymeric committed
50 51 52
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
53
#include "mediastreamer2/ice.h"
54
#include "mediastreamer2/mediastream.h"
Simon Morlat's avatar
Simon Morlat committed
55
#include "mediastreamer2/msconference.h"
Yann Diorcet's avatar
Yann Diorcet committed
56
#ifdef BUILD_UPNP
Yann Diorcet's avatar
Yann Diorcet committed
57
#include "upnp.h"
58
#endif //BUILD_UPNP
aymeric's avatar
aymeric committed
59

Margaux Clerc's avatar
Margaux Clerc committed
60

61
#ifndef LIBLINPHONE_VERSION
aymeric's avatar
aymeric committed
62 63 64
#define LIBLINPHONE_VERSION LINPHONE_VERSION
#endif

65
#ifdef ENABLE_NLS
66 67 68 69 70 71 72 73 74 75 76 77

#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
78
#include <libintl.h>
79

aymeric's avatar
aymeric committed
80
#ifndef _
81
#define _(String) dgettext(GETTEXT_PACKAGE,String)
aymeric's avatar
aymeric committed
82 83
#endif
#else
smorlat's avatar
smorlat committed
84
#ifndef _
aymeric's avatar
aymeric committed
85 86
#define _(something)	(something)
#endif
87 88 89
#ifndef ngettext
#define ngettext(singular, plural, number)	(((number)==1)?(singular):(plural))
#endif
smorlat's avatar
smorlat committed
90
#endif
91
#ifdef __ANDROID__
92 93
#include <jni.h>
#endif
94

95 96 97 98 99 100 101 102 103 104 105 106
#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
107
#endif
108 109 110 111 112
#ifdef _MSC_VER
#if (_MSC_VER >= 1900)
#define LINPHONE_MSC_VER_GREATER_19
#endif
#endif
jehan's avatar
jehan committed
113

Sylvain Berfini's avatar
Sylvain Berfini committed
114 115 116 117 118
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

119 120 121 122 123

#ifdef SQLITE_STORAGE_ENABLED
#include <sqlite3.h>
#endif

Sylvain Berfini's avatar
Sylvain Berfini committed
124 125 126
#ifdef __cplusplus
extern "C" {
#endif
127 128 129 130 131


#define STRING_RESET(field)	if (field) bctbx_free(field); (field) = NULL
#define STRING_SET(field, value)	do{ if (field){bctbx_free(field);field=NULL;}; field=bctbx_strdup(value); }while(0)
#define STRING_TRANSFER(field, newvalue)	do{ if (field){bctbx_free(field);field=NULL;}; field=newvalue; }while(0)
Sylvain Berfini's avatar
Sylvain Berfini committed
132

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

164
	bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/
Simon Morlat's avatar
Simon Morlat committed
165
	bool_t in_conference; /*in conference mode */
jehan's avatar
jehan committed
166
	bool_t low_bandwidth;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
167
	bool_t no_user_consent;/*when set to TRUE an UPDATE request will be used instead of reINVITE*/
168

169
	uint16_t avpf_rr_interval; /*in milliseconds*/
170
	bool_t internal_call_update; /*use mark that call update was requested internally (might be by ice) - unused for the moment*/
171
	bool_t video_multicast_enabled;
172

173
	bool_t audio_multicast_enabled;
174
	bool_t realtimetext_enabled;
175 176
	bool_t update_call_when_ice_completed;
	bool_t encryption_mandatory;
177
};
178

Ghislain MARY's avatar
Ghislain MARY committed
179
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallParams);
180 181


182
struct _LinphoneQualityReporting{
183
	reporting_session_report_t * reports[3]; /**Store information on audio and video media streams (RFC 6035) */
184
	bool_t was_video_running; /*Keep video state since last check in order to detect its (de)activation*/
185
	LinphoneQualityReportingReportSendCb on_report_sent;
186 187
};

188
struct _LinphoneCallLog{
189 190
	belle_sip_object_t base;
	void *user_data;
191 192 193 194 195 196
	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*/
197
	int duration; /**<Duration of the call starting in connected state in seconds*/
198 199 200 201 202
	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 */
203
	time_t connected_date_time; /**Connecting date of the call in seconds as expressed in a time_t */
204
	char* call_id; /**unique id of a call*/
205
	struct _LinphoneQualityReporting reporting;
206 207
	unsigned int storage_id;
	LinphoneErrorInfo *error_info;
208
	bool_t video_enabled;
209
	bool_t was_conference; /**<That call was a call with a conference server */
210 211
};

Ghislain MARY's avatar
Ghislain MARY committed
212
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallLog);
213

214

215 216
typedef struct _CallCallbackObj
{
217 218
	LinphoneCallCbFunc _func;
	void * _user_data;
219
}CallCallbackObj;
220

221 222 223
struct _LinphoneChatMessageCbs {
	belle_sip_object_t base;
	void *user_data;
224 225 226 227
	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 */
228 229
};

Ghislain MARY's avatar
Ghislain MARY committed
230
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs);
231

Simon Morlat's avatar
Simon Morlat committed
232 233 234 235 236
typedef enum _LinphoneChatMessageDir{
	LinphoneChatMessageIncoming,
	LinphoneChatMessageOutgoing
} LinphoneChatMessageDir;

237
struct _LinphoneChatMessage {
238
	belle_sip_object_t base;
239
	LinphoneChatRoom* chat_room;
240
	LinphoneChatMessageCbs *callbacks;
241
	LinphoneErrorInfo *ei;
Simon Morlat's avatar
Simon Morlat committed
242 243
	LinphoneChatMessageDir dir;
	char* message;
244
	void* message_state_changed_user_data;
245
	void* message_userdata;
246
	char* appdata;
247
	char* external_body_url;
Simon Morlat's avatar
Simon Morlat committed
248 249
	LinphoneAddress *from;
	LinphoneAddress *to;
250
	time_t time;
251
	SalCustomHeader *custom_headers;
Margaux Clerc's avatar
Margaux Clerc committed
252
	LinphoneChatMessageState state;
Simon Morlat's avatar
Simon Morlat committed
253
	bool_t is_read;
254
	unsigned int storage_id;
Ghislain MARY's avatar
Ghislain MARY committed
255
	char *message_id;
256
	SalOp *op;
257 258
	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 */
259
	bool_t to_be_stored;
260
	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 */
261
	belle_http_request_listener_t *http_listener; /* our listener, only owned by us*/
262
	char *file_transfer_filepath;
263
	unsigned long bg_task_id;
264
	bool_t is_secured;
265

266
#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
267 268
#pragma GCC diagnostic push
#endif
269
#if defined(__clang__) || defined(__GNUC__)
270
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
271 272 273 274
#endif
#ifdef _MSC_VER
#pragma deprecated(message_state_changed_cb)
#endif
275
	LinphoneChatMessageStateChangedCb message_state_changed_cb;
276
#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
277 278
#pragma GCC diagnostic pop
#endif
279
};
280

Ghislain MARY's avatar
Ghislain MARY committed
281
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessage);
282

283 284 285 286 287 288
typedef struct StunCandidate{
	char addr[64];
	int port;
}StunCandidate;


289
typedef struct _PortConfig{
290
	char multicast_ip[LINPHONE_IPADDR_SIZE];
291
	char multicast_bind_ip[LINPHONE_IPADDR_SIZE];
292 293 294 295
	int rtp_port;
	int rtcp_port;
}PortConfig;

296 297 298 299 300 301 302 303 304 305 306 307 308
struct _LinphoneCallCbs {
	belle_sip_object_t base;
	void *user_data;
	LinphoneCallCbsDtmfReceivedCb dtmf_received_cb;
	LinphoneCallCbsEncryptionChangedCb encryption_changed_cb;
	LinphoneCallCbsInfoMessageReceivedCb info_message_received_cb;
	LinphoneCallCbsStateChangedCb state_changed_cb;
	LinphoneCallCbsStatsUpdatedCb stats_updated_cb;
	LinphoneCallCbsTransferStateChangedCb transfer_state_changed_cb;
};

LinphoneCallCbs * _linphone_call_cbs_new(void);

309
struct _LinphoneCall{
310 311
	belle_sip_object_t base;
	void *user_data;
smorlat's avatar
smorlat committed
312
	struct _LinphoneCore *core;
313
	LinphoneErrorInfo *ei;
314
	int af; /*the address family to prefer for RTP path, guessed from signaling path*/
315 316
	LinphoneCallDir dir;
	SalMediaDescription *biggestdesc; /*media description with all already proposed streams, used to remember the mapping of streams*/
317 318
	SalMediaDescription *localdesc;
	SalMediaDescription *resultdesc;
Simon Morlat's avatar
Simon Morlat committed
319 320
	struct _RtpProfile *audio_profile;
	struct _RtpProfile *video_profile;
321
	struct _RtpProfile *text_profile;
322 323
	struct _RtpProfile *rtp_io_audio_profile;
	struct _RtpProfile *rtp_io_video_profile;
smorlat's avatar
smorlat committed
324
	struct _LinphoneCallLog *log;
325
	LinphoneAddress *me; /*Either from or to based on call dir*/
326
	LinphoneAddress *diversion_address;
327
	SalOp *op;
328
	SalOp *ping_op;
329
	char media_localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local media ipaddress for this call */
330 331
	LinphoneCallState state;
	LinphoneCallState prevstate;
332
	LinphoneCallState transfer_state; /*idle if no transfer*/
333
	LinphoneProxyConfig *dest_proxy;
334 335 336 337
	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*/
338 339
	struct _AudioStream *audiostream;  /**/
	struct _VideoStream *videostream;
340
	struct _TextStream *textstream;
341
	void *video_window_id;
Simon Morlat's avatar
Simon Morlat committed
342
	MSAudioEndpoint *endpoint; /*used for conferencing*/
Simon Morlat's avatar
Simon Morlat committed
343
	char *refer_to;
344 345 346
	LinphoneCallParams *params;
	LinphoneCallParams *current_params;
	LinphoneCallParams *remote_params;
347
	int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
348
	int audio_bw;	/*upload bandwidth used by audio */
349 350 351
	OrtpEvQueue *audiostream_app_evq;
	char *auth_token;
	OrtpEvQueue *videostream_app_evq;
352
	OrtpEvQueue *textstream_app_evq;
353
	CallCallbackObj nextVideoFrameDecoded;
354 355 356
	LinphoneCallStats *audio_stats;
	LinphoneCallStats *video_stats;
	LinphoneCallStats *text_stats;
Yann Diorcet's avatar
Yann Diorcet committed
357 358 359
#ifdef BUILD_UPNP
	UpnpSession *upnp_session;
#endif //BUILD_UPNP
360 361
	IceSession *ice_session;
	int ping_time;
362 363
	unsigned int remote_session_id;
	unsigned int remote_session_ver;
364
	LinphoneCall *referer; /*when this call is the result of a transfer, referer is set to the original call that caused the transfer*/
365
	LinphoneCall *transfer_target;/*if this call received a transfer request, then transfer_target points to the new call created to the refer target */
366
	int localdesc_changed;/*not a boolean, contains a mask representing changes*/
367
	LinphonePlayer *player;
Simon Morlat's avatar
Simon Morlat committed
368
	unsigned long bg_task_id; /*used to prevent device to suspend app while a call is received in background*/
369
	unsigned int nb_media_starts;
370

371 372 373
	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*/

374
	char *dtls_certificate_fingerprint; /**> This fingerprint is computed during stream init and is stored in call to be used when making local media description */
375
	char *onhold_file; /*set if a on-hold file is to be played*/
376
	LinphoneChatRoom *chat_room;
377
	LinphoneConference *conf_ref; /**> Point on the associated conference if this call is part of a conference. NULL instead. */
378
	bool_t refer_pending;
379
	bool_t expect_media_in_ack;
380
	bool_t audio_muted;
381
	bool_t camera_enabled;
382

383
	bool_t all_muted; /*this flag is set during early medias*/
384
	bool_t playing_ringbacktone;
385
	bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/
Simon Morlat's avatar
Simon Morlat committed
386
	bool_t auth_token_verified;
387

388
	bool_t defer_update;
389
	bool_t was_automatically_paused;
390
	bool_t ping_replied;
Simon Morlat's avatar
Simon Morlat committed
391
	bool_t record_active;
392

393
	bool_t paused_by_app;
394
	bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */
395
	bool_t defer_notify_incoming;
396
	bool_t need_localip_refresh;
397

398
	bool_t reinvite_on_cancel_response_requested;
399
	bool_t non_op_error; /*set when the LinphoneErrorInfo was set at higher level than sal*/
400 401 402

	bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */
	LinphoneCallCbs *current_cbs; /* The current LinphoneCallCbs object used to call a callback */
403
	LinphoneNatPolicy *nat_policy; /*nat policy for this call, either from proxy nor from core*/
404
};
smorlat's avatar
smorlat committed
405

Ghislain MARY's avatar
Ghislain MARY committed
406
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCall);
407

408

409 410 411 412 413 414 415
void linphone_call_notify_state_changed(LinphoneCall *call, LinphoneCallState cstate, const char *message);
void linphone_call_notify_dtmf_received(LinphoneCall *call, int dtmf);
void linphone_call_notify_encryption_changed(LinphoneCall *call, bool_t on, const char *authentication_token);
void linphone_call_notify_transfer_state_changed(LinphoneCall *call, LinphoneCallState cstate);
void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallStats *stats);
void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg);

Simon Morlat's avatar
Simon Morlat committed
416
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
417
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op);
418
void _linphone_call_set_new_params(LinphoneCall *call, const LinphoneCallParams *params);
419
void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message);
420
void linphone_call_set_contact_op(LinphoneCall* call);
421
void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, SalMediaDescription *md);
422
void linphone_call_set_symmetric_rtp(LinphoneCall *call, bool_t val);
smorlat's avatar
smorlat committed
423
/* private: */
424
LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress * to);
425
void linphone_call_log_completed(LinphoneCall *call);
426
void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state);
427
LinphonePlayer *linphone_call_build_player(LinphoneCall*call);
428
void linphone_call_refresh_sockets(LinphoneCall *call);
429
void linphone_call_replace_op(LinphoneCall *call, SalOp *op);
430
void linphone_call_reinvite_to_recover_from_connection_loss(LinphoneCall *call);
smorlat's avatar
smorlat committed
431

432 433
LinphoneCallParams * linphone_call_params_new(void);
SalMediaProto get_proto_from_call_params(const LinphoneCallParams *params);
434 435
SalStreamDir get_audio_dir_from_call_params(const LinphoneCallParams *params);
SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params);
436
void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch);
437 438
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);
439

440 441
void linphone_auth_info_write_config(LinphoneConfig *config, LinphoneAuthInfo *obj, int pos);
LinphoneAuthInfo * linphone_auth_info_new_from_config_file(LpConfig *config, int pos);
442
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
443
const LinphoneAuthInfo *_linphone_core_find_tls_auth_info(LinphoneCore *lc);
444
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
445 446

void linphone_core_update_proxy_register(LinphoneCore *lc);
447
int linphone_call_abort(LinphoneCall *call, const char *error);
448
const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
aymeric's avatar
aymeric committed
449

450
int linphone_proxy_config_send_publish(LinphoneProxyConfig *cfg, LinphonePresenceModel *presence);
451
void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState rstate, const char *message);
452
void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj);
453
void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc);
454
void _linphone_proxy_config_release(LinphoneProxyConfig *cfg);
455
void _linphone_proxy_config_unpublish(LinphoneProxyConfig *obj);
456
void linphone_proxy_config_notify_publish_state_changed(LinphoneProxyConfig *cfg, LinphonePublishState state);
457

458 459 460 461 462
/*
 * 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);
463

464
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
465
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
466
void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state);
467
void _linphone_friend_list_release(LinphoneFriendList *list);
468 469
/*get rls either from list or core if any*/
const LinphoneAddress * _linphone_friend_list_get_rls_address(const LinphoneFriendList *list);
470

471
void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
472
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
473
void _linphone_friend_release(LinphoneFriend *lf);
474
void linphone_friend_update_subscribes(LinphoneFriend *fr, bool_t only_when_registered);
475
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
476
void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc);
477 478
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op);
479 480
const char * linphone_friend_phone_number_to_sip_uri(LinphoneFriend *lf, const char *phone_number);
const char * linphone_friend_sip_uri_to_phone_number(LinphoneFriend *lf, const char *uri);
481
void linphone_friend_clear_presence_models(LinphoneFriend *lf);
482 483
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);
484
LinphoneFriend *linphone_core_find_friend_by_out_subscribe(const LinphoneCore *lc, SalOp *op);
485
LinphoneFriend *linphone_core_find_friend_by_inc_subscribe(const LinphoneCore *lc, SalOp *op);
486
MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf);
487
bool_t linphone_core_should_subscribe_friends_only_when_registered(const LinphoneCore *lc);
488 489
void linphone_core_update_friends_subscriptions(LinphoneCore *lc);
void _linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered);
490 491 492 493
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);
494 495
void linphone_core_store_friends_list_in_db(LinphoneCore *lc, LinphoneFriendList *list);
void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendList *list);
496 497 498
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list);
LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize);
499

500
int linphone_parse_host_port(const char *input, char *host, size_t hostlen, int *port);
501
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
502

503
bool_t host_has_ipv6_network(void);
aymeric's avatar
aymeric committed
504 505
bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret);

506
static MS2_INLINE int get_min_bandwidth(int dbw, int ubw){
Simon Morlat's avatar
Simon Morlat committed
507 508
	if (dbw<=0) return ubw;
	if (ubw<=0) return dbw;
aymeric's avatar
aymeric committed
509 510 511
	return MIN(dbw,ubw);
}

512
static MS2_INLINE bool_t bandwidth_is_greater(int bw1, int bw2){
513 514
	if (bw1<=0) return TRUE;
	else if (bw2<=0) return FALSE;
aymeric's avatar
aymeric committed
515 516 517
	else return bw1>=bw2;
}

518
static MS2_INLINE int get_remaining_bandwidth_for_video(int total, int audio){
519 520 521
	int ret = total-audio-10;
	if (ret < 0) ret = 0;
	return ret;
522 523
}

524
static MS2_INLINE void set_string(char **dest, const char *src, bool_t lowercase){
525 526 527 528
	if (*dest){
		ms_free(*dest);
		*dest=NULL;
	}
529
	if (src) {
530
		*dest=ms_strdup(src);
531 532 533 534 535
		if (lowercase) {
			char *cur = *dest;
			for (; *cur; cur++) *cur = tolower(*cur);
		}
	}
536 537
}

aymeric's avatar
aymeric committed
538
#define PAYLOAD_TYPE_ENABLED	PAYLOAD_TYPE_USER_FLAG_0
539
#define PAYLOAD_TYPE_BITRATE_OVERRIDE PAYLOAD_TYPE_USER_FLAG_3
540
#define PAYLOAD_TYPE_FROZEN_NUMBER	PAYLOAD_TYPE_USER_FLAG_4
aymeric's avatar
aymeric committed
541

542 543
void linphone_process_authentication(LinphoneCore* lc, SalOp *op);
void linphone_authentication_ok(LinphoneCore *lc, SalOp *op);
544
void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from);
545
void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence);
546
void linphone_notify_parse_presence(const char *content_type, const char *content_subtype, const char *body, SalPresenceModel **result);
547
void linphone_notify_convert_presence_to_xml(SalOp *op, SalPresenceModel *presence, const char *contact, char **content);
548
void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model);
549
void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, SalOp *op);
550 551
void linphone_core_soundcard_hint_check(LinphoneCore* lc);

aymeric's avatar
aymeric committed
552

553 554
void linphone_subscription_answered(LinphoneCore *lc, SalOp *op);
void linphone_subscription_closed(LinphoneCore *lc, SalOp *op);
aymeric's avatar
aymeric committed
555

556
void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc);
557
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt, int maxbw);
558

559
LINPHONE_PUBLIC int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
560
void linphone_core_resolve_stun_server(LinphoneCore *lc);
561
LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc);
562
void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params);
563
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call);
564
LINPHONE_PUBLIC void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable);
565
LINPHONE_PUBLIC void linphone_core_enable_short_turn_refresh(LinphoneCore *lc, bool_t enable);
566
void linphone_call_update_ice_state_in_call_stats(LinphoneCall *call);
567
LINPHONE_PUBLIC void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev);
Simon Morlat's avatar
Simon Morlat committed
568
void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result);
569
void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session, bool_t use_nortpproxy);
570
void linphone_call_update_local_media_description_from_ice_or_upnp(LinphoneCall *call);
Simon Morlat's avatar
Simon Morlat committed
571
void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md, bool_t is_offer);
572
void linphone_call_clear_unused_ice_candidates(LinphoneCall *call, const SalMediaDescription *md);
573
bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md);
aymeric's avatar
aymeric committed
574

575
void linphone_core_send_initial_subscribes(LinphoneCore *lc);
576
void linphone_core_write_friends_config(LinphoneCore* lc);
577
void linphone_friend_write_to_config_file(LinphoneConfig *config, LinphoneFriend *lf, int index);
smorlat's avatar
smorlat committed
578 579
LinphoneFriend * linphone_friend_new_from_config_file(struct _LinphoneCore *lc, int index);

580
void linphone_proxy_config_update(LinphoneProxyConfig *cfg);
Simon Morlat's avatar
Simon Morlat committed
581
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri);
582
const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to);
583
int linphone_core_get_local_ip_for(int type, const char *dest, char *result);
584
LINPHONE_PUBLIC void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result);
585

jehan's avatar
jehan committed
586
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index);
587
void linphone_proxy_config_write_to_config_file(LinphoneConfig* config,LinphoneProxyConfig *obj, int index);
smorlat's avatar
smorlat committed
588

589
LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
Sylvain Berfini's avatar
Sylvain Berfini committed
590
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call);
591

592
void linphone_call_init_stats(LinphoneCallStats *stats, int type);
593
void linphone_call_fix_call_parameters(LinphoneCall *call, SalMediaDescription *rmd);
594 595
void linphone_call_init_audio_stream(LinphoneCall *call);
void linphone_call_init_video_stream(LinphoneCall *call);
596
void linphone_call_init_text_stream(LinphoneCall *call);
597
void linphone_call_init_media_streams(LinphoneCall *call);
598
void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState target_state);
599
void linphone_call_start_media_streams_for_ice_gathering(LinphoneCall *call);
600
void linphone_call_stop_media_streams(LinphoneCall *call);
601
void linphone_call_delete_ice_session(LinphoneCall *call);
Yann Diorcet's avatar
Yann Diorcet committed
602
void linphone_call_delete_upnp_session(LinphoneCall *call);
603
void linphone_call_stop_media_streams_for_ice_gathering(LinphoneCall *call);
604
void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md);
605
void linphone_call_update_remote_session_id_and_ver(LinphoneCall *call);
606
int _linphone_core_apply_transports(LinphoneCore *lc);
607
const char * linphone_core_get_identity(LinphoneCore *lc);
608

609 610 611 612
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);

613 614 615
int linphone_call_proceed_with_invite_if_ready(LinphoneCall *call, LinphoneProxyConfig *dest_proxy);
int linphone_call_start_invite(LinphoneCall *call, const LinphoneAddress *destination/* = NULL if to be taken from the call log */);
int linphone_call_restart_invite(LinphoneCall *call);
616 617 618
/*
 * 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 */
619 620
int linphone_call_start_update(LinphoneCall *call);
int linphone_call_start_accept_update(LinphoneCall *call, LinphoneCallState next_state, const char *state_info);
621
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
622
bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md);
623
extern SalCallbacks linphone_sal_callbacks;
Ghislain MARY's avatar
Ghislain MARY committed
624
LINPHONE_PUBLIC bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
625
LINPHONE_PUBLIC bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc);
626

627 628
void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun, void *data, const char *task_description);

629 630 631 632 633 634 635 636
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);
637 638 639
/**
 * unregister without moving the register_enable flag
 */
640
void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj);
641
void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
642

643
/*chat*/
644
void linphone_chat_room_release(LinphoneChatRoom *cr);
645
void linphone_chat_room_add_weak_message(LinphoneChatRoom *cr, LinphoneChatMessage *cm);
646
void linphone_chat_message_destroy(LinphoneChatMessage* msg);
647
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
648
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state);
649
void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured);
650
void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *cm, LinphoneReason reason);
Ghislain MARY's avatar
Ghislain MARY committed
651
void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm);
652
int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
653
void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
654
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
655
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
656 657
void linphone_chat_room_add_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
void linphone_chat_room_remove_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
658
/**/
659

660 661
struct _LinphoneProxyConfig
{
662 663
	belle_sip_object_t base;
	void *user_data;
664
	struct _LinphoneCore *lc;
665
	LinphoneErrorInfo *ei;
666 667
	char *reg_proxy;
	char *reg_identity;
668
	LinphoneAddress* identity_address;
669
	char *reg_route;
670
	char *quality_reporting_collector;
671
	char *realm;
672
	char *contact_params;
673
	char *contact_uri_params;
674
	int expires;
675
	int publish_expires;
676
	SalOp *op;
677
	SalCustomHeader *sent_headers;
678 679 680 681
	char *type;
	struct _SipSetupContext *ssctx;
	int auth_failures;
	char *dial_prefix;
682
	LinphoneRegistrationState state;
683
	LinphoneAVPFMode avpf_mode;
684
	LinphoneNatPolicy *nat_policy;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
685

686 687 688 689
	bool_t commit;
	bool_t reg_sendregister;
	bool_t publish;
	bool_t dial_escape_plus;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
690

691
	bool_t send_publish;
692
	bool_t quality_reporting_enabled;
693
	uint8_t avpf_rr_interval;
694
	uint8_t quality_reporting_interval;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
695

696
	time_t deletion_date;
697
	LinphonePrivacyMask privacy;
698 699 700
	/*use to check if server config has changed  between edit() and done()*/
	LinphoneAddress *saved_proxy;
	LinphoneAddress *saved_identity;
701
	bool_t register_changed;
702
	bool_t unused[3];
703
	/*---*/
704
	LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/
705 706
	LinphoneEvent *long_term_event;
	unsigned long long previous_publish_config_hash[2];
707

708
	char *refkey;
709
	char *sip_etag; /*publish context*/
710 711
};

Ghislain MARY's avatar
Ghislain MARY committed
712
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneProxyConfig);
713

714
struct _LinphoneAuthInfo
715
{
716
	belle_sip_object_t base;
717 718 719 720 721
	char *username;
	char *realm;
	char *userid;
	char *passwd;
	char *ha1;
722
	char *domain;
723 724 725 726
	char *tls_cert;
	char *tls_key;
	char *tls_cert_path;
	char *tls_key_path;
727 728
};

729 730 731 732 733
typedef enum _LinphoneIsComposingState {
	LinphoneIsComposingIdle,
	LinphoneIsComposingActive
} LinphoneIsComposingState;

734
struct _LinphoneChatRoom{
735 736
	belle_sip_object_t base;
	void *user_data;
737 738 739
	struct _LinphoneCore *lc;
	char  *peer;
	LinphoneAddress *peer_url;
Margaux Clerc's avatar
Margaux Clerc committed
740
	MSList *messages_hist;
741
	MSList *transient_messages;
742
	bctbx_list_t *weak_messages;
743
	int unread_count;
744 745 746 747 748
	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;
749 750
	LinphoneCall *call;
	LinphoneChatMessage *pending_message;
751
	MSList *received_rtt_characters;
752 753
};

754 755 756 757 758
typedef struct _LinphoneChatMessageCharacter {
	uint32_t value;
	bool_t has_been_read;
} LinphoneChatMessageCharacter;

Ghislain MARY's avatar
Ghislain MARY committed
759
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoom);
760

761

762 763 764 765 766 767 768 769 770 771
typedef struct _LinphoneFriendPresence {
	char *uri_or_tel;
	LinphonePresenceModel *presence;
} LinphoneFriendPresence;

typedef struct _LinphoneFriendPhoneNumberSipUri {
	char *number;
	char *uri;
} LinphoneFriendPhoneNumberSipUri;

772
struct _LinphoneFriend{
773 774
	belle_sip_object_t base;
	void *user_data;
775
	LinphoneAddress *uri;
776
	MSList *insubs; /*list of SalOp. There can be multiple instances of a same Friend that subscribe to our presence*/
777 778
	SalOp *outsub;
	LinphoneSubscribePolicy pol;
779 780
	MSList *presence_models; /* list of LinphoneFriendPresence. It associates SIP URIs and phone numbers with their respective presence models. */
	MSList *phone_number_sip_uri_map; /* list of LinphoneFriendPhoneNumberSipUri. It associates phone numbers with their corresponding SIP URIs. */
781 782 783 784
	struct _LinphoneCore *lc;
	BuddyInfo *info;
	char *refkey;
	bool_t subscribe;
785
	bool_t subscribe_active;
786
	bool_t inc_subscribe_pending;
787
	bool_t commit;
788
	bool_t initial_subscribes_sent; /*used to know if initial subscribe message was sent or not*/
789
	bool_t presence_received;
790
	LinphoneVcard *vcard;
791
	unsigned int storage_id;
792
	LinphoneFriendList *friend_list;
793
	LinphoneSubscriptionState out_sub_state;
794
};
795

Ghislain MARY's avatar
Ghislain MARY committed
796
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriend);
797

798 799 800
struct _LinphoneFriendListCbs {
	belle_sip_object_t base;
	void *user_data;
801 802 803 804
	LinphoneFriendListCbsContactCreatedCb contact_created_cb;
	LinphoneFriendListCbsContactDeletedCb contact_deleted_cb;
	LinphoneFriendListCbsContactUpdatedCb contact_updated_cb;
	LinphoneFriendListCbsSyncStateChangedCb sync_state_changed_cb;
805 806
};

Ghislain MARY's avatar
Ghislain MARY committed
807
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriendListCbs);
jehan's avatar
jehan committed
808

809 810 811
struct _LinphoneFriendList {
	belle_sip_object_t base;
	void *user_data;
812
	LinphoneCore *lc;
813
	LinphoneEvent *event;
814
	char *display_name;
815 816
	char *rls_uri; /*this field is take in sync with rls_addr*/
	LinphoneAddress *rls_addr;
817
	MSList *friends;
818
	bctbx_map_t *friends_map;
819
	bctbx_map_t *friends_map_uri;
820
	unsigned char *content_digest;
821
	int expected_notification_version;
822 823 824 825 826
	unsigned int storage_id;
	char *uri;
	MSList *dirty_friends_to_update;
	int revision;
	LinphoneFriendListCbs *cbs;
827
	bool_t enable_subscriptions;
828 829
};

Ghislain MARY's avatar
Ghislain MARY committed
830
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriendList);
831 832


833

834 835 836 837 838 839 840
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
841
	int in_call_timeout;	/*timeout after a call is hangup */
842
	int delayed_timeout; 	/*timeout after a delayed call is resumed */
843
	unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/
844
	LinphoneSipTransports transports;
845 846 847 848 849
	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;
850
	bool_t register_only_when_upnp_is_ok;
851
	bool_t ping_with_options;
852
	bool_t auto_net_state_mon;
853
	bool_t tcp_tls_keepalive;
854
	bool_t vfu_with_info; /*use to enable vfu request using sip info*/
855
	bool_t save_auth_info; // if true, auth infos will be write in the config file when they are added to the list
856 857 858 859
} sip_config_t;

typedef struct rtp_config
{
860 861 862 863
	int audio_rtp_min_port;
	int audio_rtp_max_port;
	int video_rtp_min_port;
	int video_rtp_max_port;
864 865 866
	int audio_jitt_comp;  /*jitter compensation*/
	int video_jitt_comp;  /*jitter compensation*/
	int nortp_timeout;
867
	int disable_upnp;
868
	MSCryptoSuite *srtp_suites;
869
	LinphoneAVPFMode avpf_mode;
870
	bool_t rtp_no_xmit_on_audio_mute;
871
							  /* stop rtp xmit when audio muted */
872 873
	bool_t audio_adaptive_jitt_comp_enabled;
	bool_t video_adaptive_jitt_comp_enabled;
874
	bool_t pad;
jehan's avatar
jehan committed
875 876 877 878 879 880
	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;
881 882
	int text_rtp_min_port;
	int text_rtp_max_port;
883 884 885 886 887 888
}rtp_config_t;



typedef struct net_config
{
889 890
	char *nat_address; /* may be IP or host name */
	char *nat_address_ip; /* ip translated from nat_address */
891
	struct addrinfo *stun_addrinfo;
892 893 894
	int download_bw;
	int upload_bw;
	int mtu;
895
	OrtpNetworkSimulatorParams netsim_params;
896 897 898 899 900 901 902 903 904
	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 */
905
	struct _MSSndCard * lsd_card; /* dummy playback card for Linphone Sound Daemon extension */
906 907
	const char **cards;
	int latency;	/* latency in samples of the current used sound device */
908
	float soft_play_lev; /*playback gain in db.*/
909
	float soft_mic_lev; /*mic gain in db.*/
910 911 912 913 914 915
	char rec_lev;
	char play_lev;
	char ring_lev;
	char source;
	char *local_ring;
	char *remote_ring;
916
	char *ringback_tone;
917 918 919 920 921 922 923 924
	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*/
925
	MSList *video_codecs;
926
	MSList *text_codecs;
927 928
	int dyn_pt;
	int telephone_event_pt;
929 930 931 932 933 934
}codecs_config_t;

typedef struct video_config{
	struct _MSWebCam *device;
	const char **cams;
	MSVideoSize vsize;
935
	MSVideoSize preview_vsize; /*is 0,0 if no forced preview size is set, in which case vsize field above is used.*/
936 937
	LinphoneVideoDefinition *vdef;
	LinphoneVideoDefinition *preview_vdef;
938
	float fps;
939 940 941 942
	bool_t capture;
	bool_t show_local;
	bool_t display;
	bool_t selfview; /*during calls*/
943
	bool_t reuse_preview_source;
944 945
}video_config_t;

946 947 948 949
typedef struct text_config{
	bool_t enabled;
}text_config_t;

950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
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;

969 970

typedef struct _LinphoneToneDescription{
971 972 973 974
	LinphoneReason reason; /*the call error code*/
	LinphoneToneID toneid; /*A tone type to play when this error arrives. This is played using tone generator*/
	char *audiofile; /*An override audio file to play instead, when this error arrives*/
	/*Note that some tones are not affected to any error, in which case it is affected LinphoneReasonNone*/
975 976 977 978 979 980
}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);
981
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
Ghislain MARY's avatar
Ghislain MARY committed
982
LINPHONE_PUBLIC const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
983
int _linphone_call_accept_update(LinphoneCall *call, const LinphoneCallParams *params, LinphoneCallState next_state, const char *state_info);
984

985 986 987 988 989 990 991 992 993 994
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