1 /***************************************************************************
2 * private.h
3 *
4 * Mon Jun 13 14:23:23 2005
5 * Copyright 2005 Simon Morlat
6 * Email simon dot morlat at linphone dot org
7 ****************************************************************************/
8
9 /*
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24
25 #ifndef _PRIVATE_H
26 #define _PRIVATE_H
27
28 #include "linphone/core.h"
29 #include "linphone/friend.h"
30 #include "linphone/friendlist.h"
31 #include "linphone/tunnel.h"
32 #include "linphone/core_utils.h"
33 #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 #include "vcard_private.h"
39 #include "carddav.h"
40 #include "linphone/player.h"
41
42 #include "bctoolbox/port.h"
43 #include "bctoolbox/map.h"
44 #include "bctoolbox/vfs.h"
45 #include "belle-sip/belle-sip.h" /*we need this include for all http operations*/
46
47
48 #include <ctype.h>
49
50 #ifdef HAVE_CONFIG_H
51 #include "config.h"
52 #endif
53 #include "mediastreamer2/ice.h"
54 #include "mediastreamer2/mediastream.h"
55 #include "mediastreamer2/msconference.h"
56 #ifdef BUILD_UPNP
57 #include "upnp.h"
58 #endif //BUILD_UPNP
59
60
61 #ifndef LIBLINPHONE_VERSION
62 #define LIBLINPHONE_VERSION LINPHONE_VERSION
63 #endif
64
65 #ifdef ENABLE_NLS
66
67 #ifdef _MSC_VER
68 // prevent libintl.h from re-defining fprintf and vfprintf
69 #ifndef fprintf
70 #define fprintf fprintf
71 #endif
72 #ifndef vfprintf
73 #define vfprintf vfprintf
74 #endif
75 #define _GL_STDIO_H
76 #endif
77
78 #include <libintl.h>
79
80 #ifndef _
81 #define _(String) dgettext(GETTEXT_PACKAGE,String)
82 #endif
83 #else
84 #ifndef _
85 #define _(something) (something)
86 #endif
87 #ifndef ngettext
88 #define ngettext(singular, plural, number) (((number)==1)?(singular):(plural))
89 #endif
90 #endif
91 #ifdef __ANDROID__
92 #include <jni.h>
93 #endif
94
95 #ifdef _WIN32
96 #if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
97 #define LINPHONE_WINDOWS_DESKTOP 1
98 #elif defined(WINAPI_FAMILY_PARTITION)
99 #if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
100 #define LINPHONE_WINDOWS_DESKTOP 1
101 #elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
102 #define LINPHONE_WINDOWS_PHONE 1
103 #elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
104 #define LINPHONE_WINDOWS_UNIVERSAL 1
105 #endif
106 #endif
107 #endif
108 #ifdef _MSC_VER
109 #if (_MSC_VER >= 1900)
110 #define LINPHONE_MSC_VER_GREATER_19
111 #endif
112 #endif
113
114 #include <libxml/xmlreader.h>
115 #include <libxml/xmlwriter.h>
116 #include <libxml/xpath.h>
117 #include <libxml/xpathInternals.h>
118
119
120 #ifdef SQLITE_STORAGE_ENABLED
121 #include <sqlite3.h>
122 #endif
123
124 #ifdef __cplusplus
125 extern "C" {
126 #endif
127
128
129 #define STRING_RESET(field) if (field) bctbx_free(field); (field) = NULL
130 #define STRING_SET(field, value) do{ if (field){bctbx_free(field);field=NULL;}; field=bctbx_strdup(value); }while(0)
131 #define STRING_TRANSFER(field, newvalue) do{ if (field){bctbx_free(field);field=NULL;}; field=newvalue; }while(0)
132
133 struct _LinphoneCallParams{
134 belle_sip_object_t base;
135 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 PayloadType *audio_codec; /*audio codec currently in use */
140 PayloadType *video_codec; /*video codec currently in use */
141 PayloadType *text_codec; /*text codec currently in use */
142 MSVideoSize sent_vsize; /* DEPRECATED: Size of the video currently being sent */
143 MSVideoSize recv_vsize; /* DEPRECATED: Size of the video currently being received */
144 LinphoneVideoDefinition *sent_vdef; /* Definition of the video currently being sent */
145 LinphoneVideoDefinition *recv_vdef; /* Definition of the video currrently being received */
146 float received_fps,sent_fps;
147 int down_bw;
148 int up_bw;
149 int down_ptime;
150 int up_ptime;
151 char *record_file;
152 char *session_name;
153 SalCustomHeader *custom_headers;
154 SalCustomSdpAttribute *custom_sdp_attributes;
155 SalCustomSdpAttribute *custom_sdp_media_attributes[LinphoneStreamTypeUnknown];
156 LinphonePrivacyMask privacy;
157 LinphoneMediaDirection audio_dir;
158 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)*/
165 bool_t in_conference; /*in conference mode */
166 bool_t low_bandwidth;
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 bool_t update_call_when_ice_completed;
176 bool_t encryption_mandatory;
177 };
178
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 belle_sip_object_t base;
190 void *user_data;
191 struct _LinphoneCore *lc;
192 LinphoneCallDir dir; /**< The direction of the call*/
193 LinphoneCallStatus status; /**< The status of the call*/
194 LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
195 LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
196 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 char *refkey;
199 rtp_stats_t local_stats;
200 rtp_stats_t remote_stats;
201 float quality;
202 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 unsigned int storage_id;
207 LinphoneErrorInfo *error_info;
208 bool_t video_enabled;
209 bool_t was_conference; /**<That call was a call with a conference server */
210 };
211
212 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallLog);
213
214
215 typedef struct _CallCallbackObj
216 {
217 LinphoneCallCbFunc _func;
218 void * _user_data;
219 }CallCallbackObj;
220
221 struct _LinphoneChatMessageCbs {
222 belle_sip_object_t base;
223 void *user_data;
224 LinphoneChatMessageCbsMsgStateChangedCb msg_state_changed;
225 LinphoneChatMessageCbsFileTransferRecvCb file_transfer_recv; /**< Callback to store file received attached to a #LinphoneChatMessage */
226 LinphoneChatMessageCbsFileTransferSendCb file_transfer_send; /**< Callback to collect file chunk to be sent for a #LinphoneChatMessage */
227 LinphoneChatMessageCbsFileTransferProgressIndicationCb file_transfer_progress_indication; /**< Callback to indicate file transfer progress */
228 };
229
230 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs);
231
232 typedef enum _LinphoneChatMessageDir{
233 LinphoneChatMessageIncoming,
234 LinphoneChatMessageOutgoing
235 } LinphoneChatMessageDir;
236
237 struct _LinphoneChatMessage {
238 belle_sip_object_t base;
239 LinphoneChatRoom* chat_room;
240 LinphoneChatMessageCbs *callbacks;
241 LinphoneErrorInfo *ei;
242 LinphoneChatMessageDir dir;
243 char* message;
244 void* message_state_changed_user_data;
245 void* message_userdata;
246 char* appdata;
247 char* external_body_url;
248 LinphoneAddress *from;
249 LinphoneAddress *to;
250 time_t time;
251 SalCustomHeader *custom_headers;
252 LinphoneChatMessageState state;
253 bool_t is_read;
254 unsigned int storage_id;
255 char *message_id;
256 SalOp *op;
257 LinphoneContent *file_transfer_information; /**< used to store file transfer information when the message is of file transfer type */
258 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 #pragma GCC diagnostic push
268 #endif
269 #if defined(__clang__) || defined(__GNUC__)
270 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
271 #endif
272 #ifdef _MSC_VER
273 #pragma deprecated(message_state_changed_cb)
274 #endif
275 LinphoneChatMessageStateChangedCb message_state_changed_cb;
276 #if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
277 #pragma GCC diagnostic pop
278 #endif
279 };
280
281 /*
282 *Gets a Message with a given message id and direction.
283 */
284 LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_room_find_message_with_dir(LinphoneChatRoom *cr, const char *message_id,LinphoneChatMessageDir dir);
285
286 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessage);
287
288 typedef struct StunCandidate{
289 char addr[64];
290 int port;
291 }StunCandidate;
292
293
294 typedef struct _PortConfig{
295 char multicast_ip[LINPHONE_IPADDR_SIZE];
296 char multicast_bind_ip[LINPHONE_IPADDR_SIZE];
297 int rtp_port;
298 int rtcp_port;
299 }PortConfig;
300
301 struct _LinphoneCallCbs {
302 belle_sip_object_t base;
303 void *user_data;
304 LinphoneCallCbsDtmfReceivedCb dtmf_received_cb;
305 LinphoneCallCbsEncryptionChangedCb encryption_changed_cb;
306 LinphoneCallCbsInfoMessageReceivedCb info_message_received_cb;
307 LinphoneCallCbsStateChangedCb state_changed_cb;
308 LinphoneCallCbsStatsUpdatedCb stats_updated_cb;
309 LinphoneCallCbsTransferStateChangedCb transfer_state_changed_cb;
310 LinphoneCallCbsAckProcessingCb ack_processing;
311 };
312
313 LinphoneCallCbs * _linphone_call_cbs_new(void);
314
315 struct _LinphoneCall{
316 belle_sip_object_t base;
317 void *user_data;
318 struct _LinphoneCore *core;
319 LinphoneErrorInfo *ei;
320 int af; /*the address family to prefer for RTP path, guessed from signaling path*/
321 LinphoneCallDir dir;
322 SalMediaDescription *biggestdesc; /*media description with all already proposed streams, used to remember the mapping of streams*/
323 SalMediaDescription *localdesc;
324 SalMediaDescription *resultdesc;
325 struct _RtpProfile *audio_profile;
326 struct _RtpProfile *video_profile;
327 struct _RtpProfile *text_profile;
328 struct _RtpProfile *rtp_io_audio_profile;
329 struct _RtpProfile *rtp_io_video_profile;
330 struct _LinphoneCallLog *log;
331 LinphoneAddress *me; /*Either from or to based on call dir*/
332 LinphoneAddress *diversion_address;
333 SalOp *op;
334 SalOp *ping_op;
335 char media_localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local media ipaddress for this call */
336 LinphoneCallState state;
337 LinphoneCallState prevstate;
338 LinphoneCallState transfer_state; /*idle if no transfer*/
339 LinphoneProxyConfig *dest_proxy;
340 int main_audio_stream_index, main_video_stream_index, main_text_stream_index;
341 PortConfig media_ports[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
342 MSMediaStreamSessions sessions[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; /*the rtp, srtp, zrtp contexts for each stream*/
343 StunCandidate ac, vc, tc; /*audio video text ip/port discovered by STUN*/
344 struct _AudioStream *audiostream; /**/
345 struct _VideoStream *videostream;
346 struct _TextStream *textstream;
347 void *video_window_id;
348 MSAudioEndpoint *endpoint; /*used for conferencing*/
349 char *refer_to;
350 LinphoneCallParams *params;
351 LinphoneCallParams *current_params;
352 LinphoneCallParams *remote_params;
353 int up_bw; /*upload bandwidth setting at the time the call is started. Used to detect if it changes during a call */
354 int audio_bw; /*upload bandwidth used by audio */
355 OrtpEvQueue *audiostream_app_evq;
356 char *auth_token;
357 OrtpEvQueue *videostream_app_evq;
358 OrtpEvQueue *textstream_app_evq;
359 CallCallbackObj nextVideoFrameDecoded;
360 LinphoneCallStats *audio_stats;
361 LinphoneCallStats *video_stats;
362 LinphoneCallStats *text_stats;
363 #ifdef BUILD_UPNP
364 UpnpSession *upnp_session;
365 #endif //BUILD_UPNP
366 IceSession *ice_session;
367 int ping_time;
368 unsigned int remote_session_id;
369 unsigned int remote_session_ver;
370 LinphoneCall *referer; /*when this call is the result of a transfer, referer is set to the original call that caused the transfer*/
371 LinphoneCall *transfer_target;/*if this call received a transfer request, then transfer_target points to the new call created to the refer target */
372 int localdesc_changed;/*not a boolean, contains a mask representing changes*/
373 LinphonePlayer *player;
374 unsigned long bg_task_id; /*used to prevent device to suspend app while a call is received in background*/
375 unsigned int nb_media_starts;
376
377 char *dtmf_sequence; /*DTMF sequence needed to be sent using #dtmfs_timer*/
378 belle_sip_source_t *dtmfs_timer; /*DTMF timer needed to send a DTMF sequence*/
379
380 char *dtls_certificate_fingerprint; /**> This fingerprint is computed during stream init and is stored in call to be used when making local media description */
381 char *onhold_file; /*set if a on-hold file is to be played*/
382 LinphoneChatRoom *chat_room;
383 LinphoneConference *conf_ref; /**> Point on the associated conference if this call is part of a conference. NULL instead. */
384 bool_t refer_pending;
385 bool_t expect_media_in_ack;
386 bool_t audio_muted;
387 bool_t camera_enabled;
388
389 bool_t all_muted; /*this flag is set during early medias*/
390 bool_t playing_ringbacktone;
391 bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/
392 bool_t auth_token_verified;
393
394 bool_t defer_update;
395 bool_t was_automatically_paused;
396 bool_t ping_replied;
397 bool_t record_active;
398
399 bool_t paused_by_app;
400 bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */
401 bool_t defer_notify_incoming;
402 bool_t need_localip_refresh;
403
404 bool_t reinvite_on_cancel_response_requested;
405 bool_t non_op_error; /*set when the LinphoneErrorInfo was set at higher level than sal*/
406
407 bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */
408 LinphoneCallCbs *current_cbs; /* The current LinphoneCallCbs object used to call a callback */
409 LinphoneNatPolicy *nat_policy; /*nat policy for this call, either from proxy nor from core*/
410 };
411
412 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCall);
413
414
415 void linphone_call_notify_state_changed(LinphoneCall *call, LinphoneCallState cstate, const char *message);
416 void linphone_call_notify_dtmf_received(LinphoneCall *call, int dtmf);
417 void linphone_call_notify_encryption_changed(LinphoneCall *call, bool_t on, const char *authentication_token);
418 void linphone_call_notify_transfer_state_changed(LinphoneCall *call, LinphoneCallState cstate);
419 void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallStats *stats);
420 void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg);
421 void linphone_call_notify_ack_processing(LinphoneCall *call, void *msg, bool_t is_received);
422
423 LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
424 LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op);
425 void _linphone_call_set_new_params(LinphoneCall *call, const LinphoneCallParams *params);
426 void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message);
427 void linphone_call_set_contact_op(LinphoneCall* call);
428 void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, SalMediaDescription *md);
429 void linphone_call_set_symmetric_rtp(LinphoneCall *call, bool_t val);
430 /* private: */
431 LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress * to);
432 void linphone_call_log_completed(LinphoneCall *call);
433 void linphone_call_set_transfer_state(LinphoneCall* call, LinphoneCallState state);
434 LinphonePlayer *linphone_call_build_player(LinphoneCall*call);
435 void linphone_call_refresh_sockets(LinphoneCall *call);
436 void linphone_call_replace_op(LinphoneCall *call, SalOp *op);
437 void linphone_call_reinvite_to_recover_from_connection_loss(LinphoneCall *call);
438
439 LinphoneCallParams * linphone_call_params_new(void);
440 SalMediaProto get_proto_from_call_params(const LinphoneCallParams *params);
441 SalStreamDir get_audio_dir_from_call_params(const LinphoneCallParams *params);
442 SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params);
443 void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch);
444 void linphone_call_params_set_custom_sdp_attributes(LinphoneCallParams *params, const SalCustomSdpAttribute *csa);
445 void linphone_call_params_set_custom_sdp_media_attributes(LinphoneCallParams *params, LinphoneStreamType type, const SalCustomSdpAttribute *csa);
446
447 void linphone_auth_info_write_config(LinphoneConfig *config, LinphoneAuthInfo *obj, int pos);
448 LinphoneAuthInfo * linphone_auth_info_new_from_config_file(LpConfig *config, int pos);
449 void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
450 const LinphoneAuthInfo *_linphone_core_find_tls_auth_info(LinphoneCore *lc);
451 const LinphoneAuthInfo *_linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *domain, bool_t ignore_realm);
452
453 void linphone_core_update_proxy_register(LinphoneCore *lc);
454 int linphone_call_abort(LinphoneCall *call, const char *error);
455 const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc);
456
457 int linphone_proxy_config_send_publish(LinphoneProxyConfig *cfg, LinphonePresenceModel *presence);
458 void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState rstate, const char *message);
459 void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig *obj);
460 void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc);
461 void _linphone_proxy_config_release(LinphoneProxyConfig *cfg);
462 void _linphone_proxy_config_unpublish(LinphoneProxyConfig *obj);
463 void linphone_proxy_config_notify_publish_state_changed(LinphoneProxyConfig *cfg, LinphonePublishState state);
464 LinphoneEvent *linphone_proxy_config_create_publish(LinphoneProxyConfig *cfg, const char *event, int expires);
465 /*
466 * returns service route as defined in as defined by rfc3608, might be a list instead of just one.
467 * Can be NULL
468 * */
469 const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg);
470
471 void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
472 void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
473 void linphone_friend_list_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state);
474 void _linphone_friend_list_release(LinphoneFriendList *list);
475 /*get rls either from list or core if any*/
476 const LinphoneAddress * _linphone_friend_list_get_rls_address(const LinphoneFriendList *list);
477
478 LINPHONE_PUBLIC void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
479 void linphone_friend_close_subscriptions(LinphoneFriend *lf);
480 void _linphone_friend_release(LinphoneFriend *lf);
481 LINPHONE_PUBLIC void linphone_friend_update_subscribes(LinphoneFriend *fr, bool_t only_when_registered);
482 void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
483 void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc);
484 void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);
485 void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op);
486 const char * linphone_friend_phone_number_to_sip_uri(LinphoneFriend *lf, const char *phone_number);
487 const char * linphone_friend_sip_uri_to_phone_number(LinphoneFriend *lf, const char *uri);
488 void linphone_friend_clear_presence_models(LinphoneFriend *lf);
489 LinphoneFriend *linphone_friend_list_find_friend_by_inc_subscribe(const LinphoneFriendList *list, SalOp *op);
490 LinphoneFriend *linphone_friend_list_find_friend_by_out_subscribe(const LinphoneFriendList *list, SalOp *op);
491 LinphoneFriend *linphone_core_find_friend_by_out_subscribe(const LinphoneCore *lc, SalOp *op);
492 LinphoneFriend *linphone_core_find_friend_by_inc_subscribe(const LinphoneCore *lc, SalOp *op);
493 MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf);
494 bool_t linphone_core_should_subscribe_friends_only_when_registered(const LinphoneCore *lc);
495 void linphone_core_update_friends_subscriptions(LinphoneCore *lc);
496 void _linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered);
497 void linphone_core_friends_storage_init(LinphoneCore *lc);
498 void linphone_core_friends_storage_close(LinphoneCore *lc);
499 void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf);
500 void linphone_core_remove_friend_from_db(LinphoneCore *lc, LinphoneFriend *lf);
501 void linphone_core_store_friends_list_in_db(LinphoneCore *lc, LinphoneFriendList *list);
502 void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendList *list);
503 LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list);
504 LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc);
505 LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize);
506
507 int linphone_parse_host_port(const char *input, char *host, size_t hostlen, int *port);
508 int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen, int default_port);
509
510 bool_t host_has_ipv6_network(void);
511 bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret);
512
get_min_bandwidth(int dbw,int ubw)513 static MS2_INLINE int get_min_bandwidth(int dbw, int ubw){
514 if (dbw<=0) return ubw;
515 if (ubw<=0) return dbw;
516 return MIN(dbw,ubw);
517 }
518
bandwidth_is_greater(int bw1,int bw2)519 static MS2_INLINE bool_t bandwidth_is_greater(int bw1, int bw2){
520 if (bw1<=0) return TRUE;
521 else if (bw2<=0) return FALSE;
522 else return bw1>=bw2;
523 }
524
get_remaining_bandwidth_for_video(int total,int audio)525 static MS2_INLINE int get_remaining_bandwidth_for_video(int total, int audio){
526 int ret = total-audio-10;
527 if (ret < 0) ret = 0;
528 return ret;
529 }
530
set_string(char ** dest,const char * src,bool_t lowercase)531 static MS2_INLINE void set_string(char **dest, const char *src, bool_t lowercase){
532 if (*dest){
533 ms_free(*dest);
534 *dest=NULL;
535 }
536 if (src) {
537 *dest=ms_strdup(src);
538 if (lowercase) {
539 char *cur = *dest;
540 for (; *cur; cur++) *cur = tolower(*cur);
541 }
542 }
543 }
544
545 #define PAYLOAD_TYPE_ENABLED PAYLOAD_TYPE_USER_FLAG_0
546 #define PAYLOAD_TYPE_BITRATE_OVERRIDE PAYLOAD_TYPE_USER_FLAG_3
547 #define PAYLOAD_TYPE_FROZEN_NUMBER PAYLOAD_TYPE_USER_FLAG_4
548
549 void linphone_process_authentication(LinphoneCore* lc, SalOp *op);
550 void linphone_authentication_ok(LinphoneCore *lc, SalOp *op);
551 void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from);
552 void linphone_core_send_presence(LinphoneCore *lc, LinphonePresenceModel *presence);
553 void linphone_notify_parse_presence(const char *content_type, const char *content_subtype, const char *body, SalPresenceModel **result);
554 void linphone_notify_convert_presence_to_xml(SalOp *op, SalPresenceModel *presence, const char *contact, char **content);
555 void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model);
556 void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, SalOp *op);
557 void linphone_core_soundcard_hint_check(LinphoneCore* lc);
558
559
560 void linphone_subscription_answered(LinphoneCore *lc, SalOp *op);
561 void linphone_subscription_closed(LinphoneCore *lc, SalOp *op);
562
563 void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc);
564 void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt, int maxbw);
565
566 LINPHONE_PUBLIC int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
567 void linphone_core_resolve_stun_server(LinphoneCore *lc);
568 LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc);
569 void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params);
570 int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call);
571 LINPHONE_PUBLIC void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable);
572 LINPHONE_PUBLIC void linphone_core_enable_short_turn_refresh(LinphoneCore *lc, bool_t enable);
573 void linphone_call_update_ice_state_in_call_stats(LinphoneCall *call);
574 LINPHONE_PUBLIC void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev);
575 void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result);
576 void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session, bool_t use_nortpproxy);
577 void linphone_call_update_local_media_description_from_ice_or_upnp(LinphoneCall *call);
578 void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md, bool_t is_offer);
579 void linphone_call_clear_unused_ice_candidates(LinphoneCall *call, const SalMediaDescription *md);
580 bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md);
581
582 void linphone_core_send_initial_subscribes(LinphoneCore *lc);
583 void linphone_core_write_friends_config(LinphoneCore* lc);
584 void linphone_friend_write_to_config_file(LinphoneConfig *config, LinphoneFriend *lf, int index);
585 LinphoneFriend * linphone_friend_new_from_config_file(struct _LinphoneCore *lc, int index);
586
587 void linphone_proxy_config_update(LinphoneProxyConfig *cfg);
588 LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri);
589 const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to);
590 int linphone_core_get_local_ip_for(int type, const char *dest, char *result);
591 LINPHONE_PUBLIC void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result);
592
593 LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index);
594 void linphone_proxy_config_write_to_config_file(LinphoneConfig* config,LinphoneProxyConfig *obj, int index);
595
596 LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
597 void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call);
598
599 void linphone_call_init_stats(LinphoneCallStats *stats, int type);
600 void linphone_call_fix_call_parameters(LinphoneCall *call, SalMediaDescription *rmd);
601 void linphone_call_init_audio_stream(LinphoneCall *call);
602 void linphone_call_init_video_stream(LinphoneCall *call);
603 void linphone_call_init_text_stream(LinphoneCall *call);
604 void linphone_call_init_media_streams(LinphoneCall *call);
605 void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState target_state);
606 void linphone_call_start_media_streams_for_ice_gathering(LinphoneCall *call);
607 void linphone_call_stop_media_streams(LinphoneCall *call);
608 void linphone_call_delete_ice_session(LinphoneCall *call);
609 void linphone_call_delete_upnp_session(LinphoneCall *call);
610 void linphone_call_stop_media_streams_for_ice_gathering(LinphoneCall *call);
611 void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md);
612 void linphone_call_update_remote_session_id_and_ver(LinphoneCall *call);
613 int _linphone_core_apply_transports(LinphoneCore *lc);
614 const char * linphone_core_get_identity(LinphoneCore *lc);
615
616 void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
617 void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
618 void linphone_core_stop_waiting(LinphoneCore *lc);
619
620 int linphone_call_proceed_with_invite_if_ready(LinphoneCall *call, LinphoneProxyConfig *dest_proxy);
621 int linphone_call_start_invite(LinphoneCall *call, const LinphoneAddress *destination/* = NULL if to be taken from the call log */);
622 int linphone_call_restart_invite(LinphoneCall *call);
623 /*
624 * param automatic_offering aims is to take into account previous answer for video in case of automatic re-invite.
625 * Purpose is to avoid to re-ask video previously declined */
626 int linphone_call_start_update(LinphoneCall *call);
627 int linphone_call_start_accept_update(LinphoneCall *call, LinphoneCallState next_state, const char *state_info);
628 void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
629 bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md);
630 extern SalCallbacks linphone_sal_callbacks;
631 LINPHONE_PUBLIC bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
632 LINPHONE_PUBLIC bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc);
633
634 void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun, void *data, const char *task_description);
635
636 typedef enum _LinphoneProxyConfigAddressComparisonResult{
637 LinphoneProxyConfigAddressDifferent,
638 LinphoneProxyConfigAddressEqual,
639 LinphoneProxyConfigAddressWeakEqual
640 } LinphoneProxyConfigAddressComparisonResult;
641
642 LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b);
643 LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_config_changed(const LinphoneProxyConfig* obj);
644 /**
645 * unregister without moving the register_enable flag
646 */
647 void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj);
648 void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
649
650 /*chat*/
651 void linphone_chat_room_release(LinphoneChatRoom *cr);
652 void linphone_chat_room_add_weak_message(LinphoneChatRoom *cr, LinphoneChatMessage *cm);
653 void linphone_chat_message_destroy(LinphoneChatMessage* msg);
654 void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
655 void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state);
656 void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured);
657 void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *cm, LinphoneReason reason);
658 void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm);
659 int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
660 void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
661 LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
662 LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
663 void linphone_chat_room_add_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
664 void linphone_chat_room_remove_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
665 /**/
666
667 struct _LinphoneProxyConfig
668 {
669 belle_sip_object_t base;
670 void *user_data;
671 struct _LinphoneCore *lc;
672 LinphoneErrorInfo *ei;
673 char *reg_proxy;
674 char *reg_identity;
675 LinphoneAddress* identity_address;
676 char *reg_route;
677 char *quality_reporting_collector;
678 char *realm;
679 char *contact_params;
680 char *contact_uri_params;
681 int expires;
682 int publish_expires;
683 SalOp *op;
684 SalCustomHeader *sent_headers;
685 char *type;
686 struct _SipSetupContext *ssctx;
687 int auth_failures;
688 char *dial_prefix;
689 LinphoneRegistrationState state;
690 LinphoneAVPFMode avpf_mode;
691 LinphoneNatPolicy *nat_policy;
692
693 bool_t commit;
694 bool_t reg_sendregister;
695 bool_t publish;
696 bool_t dial_escape_plus;
697
698 bool_t send_publish;
699 bool_t quality_reporting_enabled;
700 uint8_t avpf_rr_interval;
701 uint8_t quality_reporting_interval;
702
703 time_t deletion_date;
704 LinphonePrivacyMask privacy;
705 /*use to check if server config has changed between edit() and done()*/
706 LinphoneAddress *saved_proxy;
707 LinphoneAddress *saved_identity;
708 bool_t register_changed;
709 bool_t unused[3];
710 /*---*/
711 LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/
712 LinphoneEvent *presence_publish_event;
713 unsigned long long previous_publish_config_hash[2];
714
715 char *refkey;
716 char *sip_etag; /*publish context*/
717 };
718
719 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneProxyConfig);
720
721 struct _LinphoneAuthInfo
722 {
723 belle_sip_object_t base;
724 char *username;
725 char *realm;
726 char *userid;
727 char *passwd;
728 char *ha1;
729 char *domain;
730 char *tls_cert;
731 char *tls_key;
732 char *tls_cert_path;
733 char *tls_key_path;
734 };
735
736 typedef enum _LinphoneIsComposingState {
737 LinphoneIsComposingIdle,
738 LinphoneIsComposingActive
739 } LinphoneIsComposingState;
740
741 struct _LinphoneChatRoom{
742 belle_sip_object_t base;
743 void *user_data;
744 struct _LinphoneCore *lc;
745 char *peer;
746 LinphoneAddress *peer_url;
747 MSList *messages_hist;
748 MSList *transient_messages;
749 bctbx_list_t *weak_messages;
750 int unread_count;
751 LinphoneIsComposingState remote_is_composing;
752 LinphoneIsComposingState is_composing;
753 belle_sip_source_t *remote_composing_refresh_timer;
754 belle_sip_source_t *composing_idle_timer;
755 belle_sip_source_t *composing_refresh_timer;
756 LinphoneCall *call;
757 LinphoneChatMessage *pending_message;
758 MSList *received_rtt_characters;
759 };
760
761 typedef struct _LinphoneChatMessageCharacter {
762 uint32_t value;
763 bool_t has_been_read;
764 } LinphoneChatMessageCharacter;
765
766 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoom);
767
768
769 typedef struct _LinphoneFriendPresence {
770 char *uri_or_tel;
771 LinphonePresenceModel *presence;
772 } LinphoneFriendPresence;
773
774 typedef struct _LinphoneFriendPhoneNumberSipUri {
775 char *number;
776 char *uri;
777 } LinphoneFriendPhoneNumberSipUri;
778
779 struct _LinphoneFriend{
780 belle_sip_object_t base;
781 void *user_data;
782 LinphoneAddress *uri;
783 MSList *insubs; /*list of SalOp. There can be multiple instances of a same Friend that subscribe to our presence*/
784 SalOp *outsub;
785 LinphoneSubscribePolicy pol;
786 MSList *presence_models; /* list of LinphoneFriendPresence. It associates SIP URIs and phone numbers with their respective presence models. */
787 MSList *phone_number_sip_uri_map; /* list of LinphoneFriendPhoneNumberSipUri. It associates phone numbers with their corresponding SIP URIs. */
788 struct _LinphoneCore *lc;
789 BuddyInfo *info;
790 char *refkey;
791 bool_t subscribe;
792 bool_t subscribe_active;
793 bool_t inc_subscribe_pending;
794 bool_t commit;
795 bool_t initial_subscribes_sent; /*used to know if initial subscribe message was sent or not*/
796 bool_t presence_received;
797 LinphoneVcard *vcard;
798 unsigned int storage_id;
799 LinphoneFriendList *friend_list;
800 LinphoneSubscriptionState out_sub_state;
801 };
802
803 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriend);
804
805 struct _LinphoneFriendListCbs {
806 belle_sip_object_t base;
807 void *user_data;
808 LinphoneFriendListCbsContactCreatedCb contact_created_cb;
809 LinphoneFriendListCbsContactDeletedCb contact_deleted_cb;
810 LinphoneFriendListCbsContactUpdatedCb contact_updated_cb;
811 LinphoneFriendListCbsSyncStateChangedCb sync_state_changed_cb;
812 };
813
814 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriendListCbs);
815
816 struct _LinphoneFriendList {
817 belle_sip_object_t base;
818 void *user_data;
819 LinphoneCore *lc;
820 LinphoneEvent *event;
821 char *display_name;
822 char *rls_uri; /*this field is take in sync with rls_addr*/
823 LinphoneAddress *rls_addr;
824 MSList *friends;
825 bctbx_map_t *friends_map;
826 bctbx_map_t *friends_map_uri;
827 unsigned char *content_digest;
828 int expected_notification_version;
829 unsigned int storage_id;
830 char *uri;
831 MSList *dirty_friends_to_update;
832 int revision;
833 LinphoneFriendListCbs *cbs;
834 bool_t enable_subscriptions;
835 };
836
837 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneFriendList);
838
839
840
841 typedef struct sip_config
842 {
843 char *contact;
844 char *guessed_contact;
845 MSList *proxies;
846 MSList *deleted_proxies;
847 int inc_timeout; /*timeout after an un-answered incoming call is rejected*/
848 int in_call_timeout; /*timeout after a call is hangup */
849 int delayed_timeout; /*timeout after a delayed call is resumed */
850 unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/
851 LinphoneSipTransports transports;
852 bool_t guess_hostname;
853 bool_t loopback_only;
854 bool_t ipv6_enabled;
855 bool_t sdp_200_ack;
856 bool_t register_only_when_network_is_up;
857 bool_t register_only_when_upnp_is_ok;
858 bool_t ping_with_options;
859 bool_t auto_net_state_mon;
860 bool_t tcp_tls_keepalive;
861 bool_t vfu_with_info; /*use to enable vfu request using sip info*/
862 bool_t save_auth_info; // if true, auth infos will be write in the config file when they are added to the list
863 } sip_config_t;
864
865 typedef struct rtp_config
866 {
867 int audio_rtp_min_port;
868 int audio_rtp_max_port;
869 int video_rtp_min_port;
870 int video_rtp_max_port;
871 int audio_jitt_comp; /*jitter compensation*/
872 int video_jitt_comp; /*jitter compensation*/
873 int nortp_timeout;
874 int disable_upnp;
875 MSCryptoSuite *srtp_suites;
876 LinphoneAVPFMode avpf_mode;
877 bool_t rtp_no_xmit_on_audio_mute;
878 /* stop rtp xmit when audio muted */
879 bool_t audio_adaptive_jitt_comp_enabled;
880 bool_t video_adaptive_jitt_comp_enabled;
881 bool_t pad;
882 char* audio_multicast_addr;
883 bool_t audio_multicast_enabled;
884 int audio_multicast_ttl;
885 char* video_multicast_addr;
886 int video_multicast_ttl;
887 bool_t video_multicast_enabled;
888 int text_rtp_min_port;
889 int text_rtp_max_port;
890 }rtp_config_t;
891
892
893
894 typedef struct net_config
895 {
896 char *nat_address; /* may be IP or host name */
897 char *nat_address_ip; /* ip translated from nat_address */
898 struct addrinfo *stun_addrinfo;
899 int download_bw;
900 int upload_bw;
901 int mtu;
902 OrtpNetworkSimulatorParams netsim_params;
903 bool_t nat_sdp_only;
904 }net_config_t;
905
906
907 typedef struct sound_config
908 {
909 struct _MSSndCard * ring_sndcard; /* the playback sndcard currently used */
910 struct _MSSndCard * play_sndcard; /* the playback sndcard currently used */
911 struct _MSSndCard * capt_sndcard; /* the capture sndcard currently used */
912 struct _MSSndCard * lsd_card; /* dummy playback card for Linphone Sound Daemon extension */
913 const char **cards;
914 int latency; /* latency in samples of the current used sound device */
915 float soft_play_lev; /*playback gain in db.*/
916 float soft_mic_lev; /*mic gain in db.*/
917 char rec_lev;
918 char play_lev;
919 char ring_lev;
920 char source;
921 char *local_ring;
922 char *remote_ring;
923 char *ringback_tone;
924 bool_t ec;
925 bool_t ea;
926 bool_t agc;
927 } sound_config_t;
928
929 typedef struct codecs_config
930 {
931 MSList *audio_codecs; /* list of audio codecs in order of preference*/
932 MSList *video_codecs;
933 MSList *text_codecs;
934 int dyn_pt;
935 int telephone_event_pt;
936 }codecs_config_t;
937
938 typedef struct video_config{
939 struct _MSWebCam *device;
940 const char **cams;
941 MSVideoSize vsize;
942 MSVideoSize preview_vsize; /*is 0,0 if no forced preview size is set, in which case vsize field above is used.*/
943 LinphoneVideoDefinition *vdef;
944 LinphoneVideoDefinition *preview_vdef;
945 float fps;
946 bool_t capture;
947 bool_t show_local;
948 bool_t display;
949 bool_t selfview; /*during calls*/
950 bool_t reuse_preview_source;
951 }video_config_t;
952
953 typedef struct text_config{
954 bool_t enabled;
955 }text_config_t;
956
957 typedef struct ui_config
958 {
959 int is_daemon;
960 int is_applet;
961 unsigned int timer_id; /* the timer id for registration */
962 }ui_config_t;
963
964
965
966 typedef struct autoreplier_config
967 {
968 int enabled;
969 int after_seconds; /* accept the call after x seconds*/
970 int max_users; /* maximum number of user that can call simultaneously */
971 int max_rec_time; /* the max time of incoming voice recorded */
972 int max_rec_msg; /* maximum number of recorded messages */
973 const char *message; /* the path of the file to be played */
974 }autoreplier_config_t;
975
976
977 typedef struct _LinphoneToneDescription{
978 LinphoneReason reason; /*the call error code*/
979 LinphoneToneID toneid; /*A tone type to play when this error arrives. This is played using tone generator*/
980 char *audiofile; /*An override audio file to play instead, when this error arrives*/
981 /*Note that some tones are not affected to any error, in which case it is affected LinphoneReasonNone*/
982 }LinphoneToneDescription;
983
984 LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile);
985 void linphone_tone_description_destroy(LinphoneToneDescription *obj);
986 LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *lc, LinphoneReason reason);
987 void linphone_core_play_call_error_tone(LinphoneCore *lc, LinphoneReason reason);
988 void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
989 LINPHONE_PUBLIC const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
990 int _linphone_call_accept_update(LinphoneCall *call, const LinphoneCallParams *params, LinphoneCallState next_state, const char *state_info);
991
992 typedef struct _LinphoneTaskList{
993 MSList *hooks;
994 }LinphoneTaskList;
995
996 void linphone_task_list_init(LinphoneTaskList *t);
997 void linphone_task_list_add(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data);
998 void linphone_task_list_remove(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data);
999 void linphone_task_list_run(LinphoneTaskList *t);
1000 void linphone_task_list_free(LinphoneTaskList *t);
1001
1002
1003 struct _LinphoneCoreCbs {
1004 belle_sip_object_t base;
1005 LinphoneCoreVTable *vtable;
1006 bool_t autorelease;
1007 };
1008
1009 LinphoneCoreCbs * _linphone_core_cbs_new(void);
1010 void _linphone_core_cbs_set_v_table(LinphoneCoreCbs *cbs, LinphoneCoreVTable *vtable, bool_t autorelease);
1011
1012 typedef struct _LCCallbackObj {
1013 LinphoneCoreCbFunc _func;
1014 void *_user_data;
1015 } LCCallbackObj;
1016
1017 struct _LinphoneCore
1018 {
1019 belle_sip_object_t base;
1020 MSFactory* factory;
1021 MSList* vtable_refs;
1022 int vtable_notify_recursion;
1023 Sal *sal;
1024 LinphoneGlobalState state;
1025 struct _LpConfig *config;
1026 MSList *default_audio_codecs;
1027 MSList *default_video_codecs;
1028 MSList *default_text_codecs;
1029 net_config_t net_conf;
1030 sip_config_t sip_conf;
1031 rtp_config_t rtp_conf;
1032 sound_config_t sound_conf;
1033 video_config_t video_conf;
1034 text_config_t text_conf;
1035 codecs_config_t codecs_conf;
1036 ui_config_t ui_conf;
1037 autoreplier_config_t autoreplier_conf;
1038 LinphoneProxyConfig *default_proxy;
1039 MSList *friends_lists;
1040 MSList *auth_info;
1041 struct _RingStream *ringstream;
1042 time_t dmfs_playing_start_time;
1043 LCCallbackObj preview_finished_cb;
1044 LinphoneCall *current_call; /* the current call */
1045 MSList *calls; /* all the processed calls */
1046 MSList *queued_calls; /* used by the autoreplier */
1047 MSList *call_logs;
1048 MSList *chatrooms;
1049 int max_call_logs;
1050 int missed_calls;
1051 VideoPreview *previewstream;
1052 struct _MSEventQueue *msevq;
1053 LinphoneRtpTransportFactories *rtptf;
1054 MSList *bl_reqs;
1055 MSList *subscribers; /* unknown subscribers */
1056 int minutes_away;
1057 LinphonePresenceModel *presence_model;
1058 void *data;
1059 char *play_file;
1060 char *rec_file;
1061 uint64_t prevtime_ms;
1062 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*/
1063 LinphoneCoreWaitingCallback wait_cb;
1064 void *wait_ctx;
1065 void *video_window_id;
1066 void *preview_window_id;
1067 time_t netup_time; /*time when network went reachable */
1068 struct _EcCalibrator *ecc;
1069 struct _EchoTester *ect;
1070 LinphoneTaskList hooks; /*tasks periodically executed in linphone_core_iterate()*/
1071 LinphoneConference *conf_ctx;
1072 char* zrtp_secrets_cache; /**< zrtp cache filename */
1073 char* user_certificates_path;
1074 LinphoneVideoPolicy video_policy;
1075 time_t network_last_check;
1076 LinphoneNatPolicy *nat_policy;
1077 LinphoneImNotifPolicy *im_notif_policy;
1078
1079 bool_t use_files;
1080 bool_t apply_nat_settings;
1081 bool_t initial_subscribes_sent;
1082 bool_t bl_refresh;
1083
1084 bool_t preview_finished;
1085 bool_t auto_net_state_mon;
1086 bool_t sip_network_reachable;
1087 bool_t media_network_reachable;
1088
1089 bool_t network_reachable_to_be_notified; /*set to true when state must be notified in next iterate*/
1090 bool_t use_preview_window;
1091 bool_t network_last_status;
1092 bool_t ringstream_autorelease;
1093
1094 bool_t vtables_running;
1095 bool_t send_call_stats_periodical_updates;
1096 bool_t forced_ice_relay;
1097 bool_t short_turn_refresh;
1098
1099 char localip[LINPHONE_IPADDR_SIZE];
1100 int device_rotation;
1101 int max_calls;
1102 LinphoneTunnel *tunnel;
1103 char* device_id;
1104 char *chat_db_file;
1105 char *logs_db_file;
1106 char *friends_db_file;
1107 #ifdef SQLITE_STORAGE_ENABLED
1108 sqlite3 *zrtp_cache_db; /**< zrtp sqlite cache, used by both zrtp and lime */
1109 sqlite3 *db;
1110 sqlite3 *logs_db;
1111 sqlite3 *friends_db;
1112 bool_t debug_storage;
1113 #endif
1114 #ifdef BUILD_UPNP
1115 UpnpContext *upnp;
1116 #endif //BUILD_UPNP
1117 belle_http_provider_t *http_provider;
1118 belle_tls_crypto_config_t *http_crypto_config;
1119 belle_http_request_listener_t *provisioning_http_listener;
1120 #ifdef ENABLE_UPDATE_CHECK
1121 belle_http_request_listener_t *update_check_http_listener;
1122 char *update_check_current_version;
1123 #endif
1124 MSList *tones;
1125 LinphoneReason chat_deny_code;
1126 char *file_transfer_server;
1127 const char **supported_formats;
1128 LinphoneContent *log_collection_upload_information;
1129 LinphoneCoreCbs *current_cbs; // the latest LinphoneCoreCbs object to call a callback, see linphone_core_get_current_cbs()
1130 LinphoneRingtonePlayer *ringtoneplayer;
1131 #ifdef __ANDROID__
1132 jobject wifi_lock;
1133 jclass wifi_lock_class;
1134 jmethodID wifi_lock_acquire_id;
1135 jmethodID wifi_lock_release_id;
1136 jobject multicast_lock;
1137 jclass multicast_lock_class;
1138 jmethodID multicast_lock_acquire_id;
1139 jmethodID multicast_lock_release_id;
1140 #endif
1141 LinphoneVcardContext *vcard_context;
1142
1143 /*for tests only*/
1144 bool_t zrtp_not_available_simulation;
1145
1146 /* string for TLS auth instead of path to files */
1147 char *tls_cert;
1148 char *tls_key;
1149
1150 LinphoneAddress *default_rls_addr; /*default resource list server*/
1151 LinphoneImEncryptionEngine *im_encryption_engine;
1152 struct _LinphoneAccountCreatorService *default_ac_service;
1153 MSBandwidthController *bw_controller;
1154 };
1155
1156
1157 struct _LinphoneEvent{
1158 belle_sip_object_t base;
1159 LinphoneErrorInfo *ei;
1160 LinphoneSubscriptionDir dir;
1161 LinphoneCore *lc;
1162 SalOp *op;
1163 SalCustomHeader *send_custom_headers;
1164 LinphoneSubscriptionState subscription_state;
1165 LinphonePublishState publish_state;
1166 void *userdata;
1167 char *name;
1168 int expires;
1169 bool_t terminating;
1170 bool_t is_out_of_dialog_op; /*used for out of dialog notify*/
1171 bool_t internal;
1172 bool_t oneshot;
1173 };
1174
1175 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneEvent);
1176
1177 LinphoneTunnel *linphone_core_tunnel_new(LinphoneCore *lc);
1178 void linphone_tunnel_configure(LinphoneTunnel *tunnel);
1179 void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler);
1180
1181 /**
1182 * Check if we do not have exceed the number of simultaneous call
1183 *
1184 * @ingroup call_control
1185 **/
1186 bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
1187
1188 int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call);
1189 int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call);
1190 int linphone_core_get_calls_nb(const LinphoneCore *lc);
1191
1192 void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
1193 void linphone_call_update_biggest_desc(LinphoneCall *call, SalMediaDescription *md);
1194 void linphone_call_make_local_media_description(LinphoneCall *call);
1195 void linphone_call_make_local_media_description_with_params(LinphoneCore *lc, LinphoneCall *call, LinphoneCallParams *params);
1196 void linphone_call_increment_local_media_description(LinphoneCall *call);
1197 void linphone_call_fill_media_multicast_addr(LinphoneCall *call);
1198 void linphone_call_update_streams(LinphoneCall *call, SalMediaDescription *new_md, LinphoneCallState target_state);
1199
1200 bool_t linphone_core_is_payload_type_usable_for_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit);
1201
1202 #define linphone_core_ready(lc) ((lc)->state==LinphoneGlobalOn || (lc)->state==LinphoneGlobalShutdown)
1203 void _linphone_core_configure_resolver(void);
1204
1205 void linphone_core_initialize_supported_content_types(LinphoneCore *lc);
1206
1207 struct _EcCalibrator{
1208 MSFactory *factory;
1209 ms_thread_t thread;
1210 MSSndCard *play_card,*capt_card;
1211 MSFilter *sndread,*det,*rec;
1212 MSFilter *play, *gen, *sndwrite;
1213 MSFilter *read_resampler,*write_resampler;
1214 MSTicker *ticker;
1215 LinphoneEcCalibrationCallback cb;
1216 void *cb_data;
1217 LinphoneEcCalibrationAudioInit audio_init_cb;
1218 LinphoneEcCalibrationAudioUninit audio_uninit_cb;
1219 int64_t acc;
1220 int delay;
1221 unsigned int rate;
1222 LinphoneEcCalibratorStatus status;
1223 bool_t freq1,freq2,freq3;
1224 bool_t play_cool_tones;
1225 };
1226
1227 typedef struct _EcCalibrator EcCalibrator;
1228
1229 LinphoneEcCalibratorStatus ec_calibrator_get_status(EcCalibrator *ecc);
1230
1231 void ec_calibrator_destroy(EcCalibrator *ecc);
1232
1233 struct _EchoTester {
1234 MSFactory *factory;
1235 MSFilter *in,*out;
1236 MSSndCard *capture_card;
1237 MSSndCard *playback_card;
1238 MSTicker *ticker;
1239 unsigned int rate;
1240 };
1241
1242 typedef struct _EchoTester EchoTester;
1243
1244 void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed);
1245 void linphone_call_set_broken(LinphoneCall *call);
1246 void linphone_call_repair_if_broken(LinphoneCall *call);
1247 void linphone_core_repair_calls(LinphoneCore *lc);
1248 int linphone_core_preempt_sound_resources(LinphoneCore *lc);
1249 int _linphone_call_pause(LinphoneCall *call);
1250
1251 /*conferencing subsystem*/
1252 void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t muted);
1253 bool_t linphone_core_sound_resources_available(LinphoneCore *lc);
1254 void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall);
1255 LINPHONE_PUBLIC unsigned int linphone_core_get_audio_features(LinphoneCore *lc);
1256
1257 void _linphone_core_codec_config_write(LinphoneCore *lc);
1258
1259 #define HOLD_OFF (0)
1260 #define HOLD_ON (1)
1261
1262 #ifndef NB_MAX_CALLS
1263 #define NB_MAX_CALLS (10)
1264 #endif
1265
1266 #define LINPHONE_MAX_CALL_HISTORY_UNLIMITED (-1)
1267 #ifndef LINPHONE_MAX_CALL_HISTORY_SIZE
1268 #ifdef SQLITE_STORAGE_ENABLED
1269 #define LINPHONE_MAX_CALL_HISTORY_SIZE LINPHONE_MAX_CALL_HISTORY_UNLIMITED
1270 #else
1271 #define LINPHONE_MAX_CALL_HISTORY_SIZE 30
1272 #endif
1273 #endif
1274
1275 LINPHONE_PUBLIC bctbx_list_t * call_logs_read_from_config_file(LinphoneCore *lc);
1276 void call_logs_write_to_config_file(LinphoneCore *lc);
1277 void linphone_core_call_log_storage_init(LinphoneCore *lc);
1278 void linphone_core_call_log_storage_close(LinphoneCore *lc);
1279 void linphone_core_store_call_log(LinphoneCore *lc, LinphoneCallLog *log);
1280 LINPHONE_PUBLIC const MSList *linphone_core_get_call_history(LinphoneCore *lc);
1281 LINPHONE_PUBLIC void linphone_core_delete_call_history(LinphoneCore *lc);
1282 LINPHONE_PUBLIC void linphone_core_delete_call_log(LinphoneCore *lc, LinphoneCallLog *log);
1283 LINPHONE_PUBLIC int linphone_core_get_call_history_size(LinphoneCore *lc);
1284
1285 int linphone_core_get_edge_bw(LinphoneCore *lc);
1286 int linphone_core_get_edge_ptime(LinphoneCore *lc);
1287
1288 int linphone_upnp_init(LinphoneCore *lc);
1289 void linphone_upnp_destroy(LinphoneCore *lc);
1290
1291 #ifdef SQLITE_STORAGE_ENABLED
1292 int _linphone_sqlite3_open(const char *db_file, sqlite3 **db);
1293 sqlite3 * linphone_message_storage_init(void);
1294 void linphone_message_storage_init_chat_rooms(LinphoneCore *lc);
1295 #endif
1296 void linphone_chat_message_store_update(LinphoneChatMessage *msg);
1297 void linphone_chat_message_store_state(LinphoneChatMessage *msg);
1298 void linphone_chat_message_store_appdata(LinphoneChatMessage* msg);
1299 void linphone_core_message_storage_init(LinphoneCore *lc);
1300 void linphone_core_message_storage_close(LinphoneCore *lc);
1301 void linphone_core_message_storage_set_debug(LinphoneCore *lc, bool_t debug);
1302
1303 void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID id);
1304 bool_t linphone_core_tone_indications_enabled(LinphoneCore*lc);
1305 const char *linphone_core_create_uuid(LinphoneCore *lc);
1306 void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact);
1307 void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy);
1308 void linphone_call_create_op(LinphoneCall *call);
1309 int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer);
1310 void linphone_core_notify_info_message(LinphoneCore* lc,SalOp *op, SalBodyHandler *body);
1311 LinphoneContent * linphone_content_new(void);
1312 LinphoneContent * linphone_content_copy(const LinphoneContent *ref);
1313 SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content);
1314 SalReason linphone_reason_to_sal(LinphoneReason reason);
1315 LinphoneReason linphone_reason_from_sal(SalReason reason);
1316 void linphone_error_info_to_sal(const LinphoneErrorInfo* ei, SalErrorInfo* sei);
1317 LinphoneEvent *linphone_event_new(LinphoneCore *lc, LinphoneSubscriptionDir dir, const char *name, int expires);
1318 LinphoneEvent *linphone_event_new_with_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name);
1319 void linphone_event_unpublish(LinphoneEvent *lev);
1320 /**
1321 * Useful for out of dialog notify
1322 * */
1323 LinphoneEvent *linphone_event_new_with_out_of_dialog_op(LinphoneCore *lc, SalOp *op, LinphoneSubscriptionDir dir, const char *name);
1324 void linphone_event_set_internal(LinphoneEvent *lev, bool_t internal);
1325 bool_t linphone_event_is_internal(LinphoneEvent *lev);
1326 void linphone_event_set_state(LinphoneEvent *lev, LinphoneSubscriptionState state);
1327 void linphone_event_set_publish_state(LinphoneEvent *lev, LinphonePublishState state);
1328 LinphoneSubscriptionState linphone_subscription_state_from_sal(SalSubscribeStatus ss);
1329 LinphoneContent *linphone_content_from_sal_body_handler(SalBodyHandler *ref);
1330 void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc);
1331 void linphone_core_register_offer_answer_providers(LinphoneCore *lc);
1332
1333
1334 struct _LinphoneContent {
1335 belle_sip_object_t base;
1336 void *user_data;
1337 SalBodyHandler *body_handler;
1338 char *name; /**< used by RCS File transfer messages to store the original filename of the file to be downloaded from server */
1339 char *key; /**< used by RCS File transfer messages to store the key to encrypt file if needed */
1340 size_t keyLength; /**< Length of key in bytes */
1341 void *cryptoContext; /**< crypto context used to encrypt file for RCS file transfer */
1342 bool_t owned_fields;
1343 };
1344
1345 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneContent);
1346
1347 struct _LinphoneBuffer {
1348 belle_sip_object_t base;
1349 void *user_data;
1350 uint8_t *content; /**< A pointer to the buffer content */
1351 size_t size; /**< The size of the buffer content */
1352 };
1353
1354 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneBuffer);
1355
1356 struct _LinphoneNatPolicy {
1357 belle_sip_object_t base;
1358 void *user_data;
1359 LinphoneCore *lc;
1360 belle_sip_resolver_context_t *stun_resolver_context;
1361 struct addrinfo *stun_addrinfo;
1362 char *stun_server;
1363 char *stun_server_username;
1364 char *ref;
1365 bool_t stun_enabled;
1366 bool_t turn_enabled;
1367 bool_t ice_enabled;
1368 bool_t upnp_enabled;
1369 };
1370
1371 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneNatPolicy);
1372
1373 void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy);
1374
1375 struct _LinphoneImNotifPolicy {
1376 belle_sip_object_t base;
1377 void *user_data;
1378 LinphoneCore *lc;
1379 bool_t send_is_composing;
1380 bool_t recv_is_composing;
1381 bool_t send_imdn_delivered;
1382 bool_t recv_imdn_delivered;
1383 bool_t send_imdn_displayed;
1384 bool_t recv_imdn_displayed;
1385 };
1386
1387 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneImNotifPolicy);
1388
1389 void linphone_core_create_im_notif_policy(LinphoneCore *lc);
1390
1391
1392 /*****************************************************************************
1393 * XML-RPC interface *
1394 ****************************************************************************/
1395
1396 typedef struct _LinphoneXmlRpcArg {
1397 LinphoneXmlRpcArgType type;
1398 union {
1399 int i;
1400 char *s;
1401 } data;
1402 } LinphoneXmlRpcArg;
1403
1404 struct _LinphoneXmlRpcRequestCbs {
1405 belle_sip_object_t base;
1406 void *user_data;
1407 LinphoneXmlRpcRequestCbsResponseCb response;
1408 };
1409
1410 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcRequestCbs);
1411
1412 struct _LinphoneXmlRpcRequest {
1413 belle_sip_object_t base;
1414 void *user_data;
1415 LinphoneXmlRpcRequestCbs *callbacks;
1416 belle_sip_list_t *arg_list;
1417 char *content; /**< The string representation of the XML-RPC request */
1418 char *method;
1419 LinphoneXmlRpcStatus status;
1420 LinphoneXmlRpcArg response;
1421 };
1422
1423 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcRequest);
1424
1425 struct _LinphoneXmlRpcSession {
1426 belle_sip_object_t base;
1427 void *user_data;
1428 LinphoneCore *core;
1429 char *url;
1430 bool_t released;
1431 };
1432
1433 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcSession);
1434
1435
1436 /*****************************************************************************
1437 * Account creator interface *
1438 ****************************************************************************/
1439
1440 struct _LinphoneAccountCreatorService {
1441 belle_sip_object_t base;
1442 void *user_data;
1443
1444 LinphoneAccountCreatorRequestFunc account_creator_service_constructor_cb; /**< Constructor */
1445 LinphoneAccountCreatorRequestFunc account_creator_service_destructor_cb; /**< Destructor */
1446
1447 LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */
1448 LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */
1449
1450 LinphoneAccountCreatorRequestFunc activate_account_request_cb; /**< Request to activate account */
1451 LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */
1452
1453 LinphoneAccountCreatorRequestFunc link_account_request_cb; /**< Request to link account with an alias */
1454 LinphoneAccountCreatorRequestFunc activate_alias_request_cb; /**< Request to activate the link of alias */
1455 LinphoneAccountCreatorRequestFunc is_alias_used_request_cb; /**< Request to know if alias is used */
1456 LinphoneAccountCreatorRequestFunc is_account_linked_request_cb; /**< Request to know if account is linked with an alias */
1457
1458 LinphoneAccountCreatorRequestFunc recover_account_request_cb; /**< Request to recover account */
1459 LinphoneAccountCreatorRequestFunc update_account_request_cb; /**< Request to update account */
1460 };
1461
1462 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreatorService);
1463
1464 struct _LinphoneAccountCreatorCbs {
1465 belle_sip_object_t base;
1466 void *user_data;
1467
1468 LinphoneAccountCreatorCbsStatusCb create_account_response_cb; /**< Response of create_account request */
1469 LinphoneAccountCreatorCbsStatusCb is_account_exist_response_cb; /**< Response of is_account_exist request */
1470
1471 LinphoneAccountCreatorCbsStatusCb activate_account_response_cb; /**< Response of activate_account request */
1472 LinphoneAccountCreatorCbsStatusCb is_account_activated_response_cb; /**< Response of is_account_activated request */
1473
1474 LinphoneAccountCreatorCbsStatusCb link_account_response_cb; /**< Response of link_account request */
1475 LinphoneAccountCreatorCbsStatusCb activate_alias_response_cb; /**< Response of activation alias */
1476 LinphoneAccountCreatorCbsStatusCb is_alias_used_response_cb; /**< Response of is_alias_used request */
1477 LinphoneAccountCreatorCbsStatusCb is_account_linked_response_cb; /**< Response of is_account_linked request */
1478
1479 LinphoneAccountCreatorCbsStatusCb recover_account_response_cb; /**< Response of recover_account request */
1480 LinphoneAccountCreatorCbsStatusCb update_account_response_cb; /**< Response of update_account request */
1481 };
1482
1483 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreatorCbs);
1484
1485 struct _LinphoneAccountCreator {
1486 belle_sip_object_t base;
1487 void *user_data;
1488 LinphoneCore *core;
1489
1490 /* AccountCreator */
1491 LinphoneAccountCreatorService *service; /**< Account creator service */
1492 LinphoneAccountCreatorCbs *cbs; /**< Account creator cbs */
1493 LinphoneXmlRpcSession *xmlrpc_session; /**< XML-RPC session */
1494 LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */
1495
1496 /* User */
1497 char *username; /**< Username */
1498 char *display_name; /**< Display name */
1499 /* Password */
1500 char *password; /**< Plain text password */
1501 char *ha1; /**< Hash password */
1502 /* Phone Number(Alias) */
1503 char *phone_number; /**< User phone number*/
1504 char *phone_country_code; /**< User phone number country code */
1505 /* Email(Alias) */
1506 char *email; /**< User email */
1507 /* Misc */
1508 char *language; /**< User language */
1509 char *activation_code; /**< Account validation code */
1510 char *domain; /**< Domain */
1511 LinphoneTransportType transport; /**< Transport used */
1512
1513 /* Deprecated */
1514 char *route;
1515 };
1516
1517 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreator);
1518
1519 /**
1520 * Account creator custom to set Linphone default values
1521 * @param[in] creator LinphoneAccountCreator object
1522 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1523 **/
1524 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_constructor_linphone(LinphoneAccountCreator *creator);
1525
1526 /**
1527 * Send an XML-RPC request to test the existence of a Linphone account.
1528 * @param[in] creator LinphoneAccountCreator object
1529 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1530 **/
1531 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_exist_linphone(LinphoneAccountCreator *creator);
1532
1533 /**
1534 * Send an XML-RPC request to create a Linphone account.
1535 * @param[in] creator LinphoneAccountCreator object
1536 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1537 **/
1538 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_account_linphone(LinphoneAccountCreator *creator);
1539
1540 /**
1541 * Send an XML-RPC request to activate a Linphone account with phone number.
1542 * @param[in] creator LinphoneAccountCreator object
1543 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1544 **/
1545 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_account_linphone(LinphoneAccountCreator *creator);
1546
1547 /**
1548 * Send an XML-RPC request to activate a Linphone account with email.
1549 * @param[in] creator LinphoneAccountCreator object
1550 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1551 **/
1552 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_email_account_linphone(LinphoneAccountCreator *creator);
1553
1554 /**
1555 * Send an XML-RPC request to test the validation of a Linphone account.
1556 * @param[in] creator LinphoneAccountCreator object
1557 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1558 **/
1559 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated_linphone(LinphoneAccountCreator *creator);
1560
1561 /**
1562 * Send an XML-RPC request to test the existence a phone number with a Linphone account.
1563 * @param[in] creator LinphoneAccountCreator object
1564 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1565 **/
1566 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used_linphone(LinphoneAccountCreator *creator);
1567
1568 /**
1569 * Send an XML-RPC request to link a phone number with a Linphone account.
1570 * @param[in] creator LinphoneAccountCreator object
1571 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1572 **/
1573 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_account_linphone(LinphoneAccountCreator *creator);
1574
1575 /**
1576 * Send an XML-RPC request to activate the link of a phone number with a Linphone account.
1577 * @param[in] creator LinphoneAccountCreator object
1578 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1579 **/
1580 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link_linphone(LinphoneAccountCreator *creator);
1581
1582 /**
1583 * Send an XML-RPC request to a Linphone account with the phone number.
1584 * @param[in] creator LinphoneAccountCreator object
1585 * @return LinphoneAccountCreatorStatusRequestOk if the request has been sent, LinphoneAccountCreatorStatusRequestFailed otherwise
1586 **/
1587 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account_linphone(LinphoneAccountCreator *creator);
1588
1589 /**
1590 * Send an XML-RPC request to ask if an account is linked with a phone number
1591 * @param[in] creator LinphoneAccountCreator object
1592 * @return if this account is linked with a phone number
1593 **/
1594 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked_linphone(LinphoneAccountCreator *creator);
1595
1596 /**
1597 * Send an XML-RPC request to ask if an account is linked with a phone number
1598 * @param[in] creator LinphoneAccountCreator object
1599 * @param[in] new_pwd const char * : new password for the account creator
1600 * @return LinphoneAccountCreatorStatusRequestOk if everything is OK, or a specific error otherwise.
1601 **/
1602 LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(LinphoneAccountCreator *creator);
1603
1604
1605 /*****************************************************************************
1606 * CardDAV interface *
1607 ****************************************************************************/
1608
1609 struct _LinphoneCardDavContext {
1610 LinphoneFriendList *friend_list;
1611 int ctag;
1612 void *user_data;
1613 LinphoneCardDavContactCreatedCb contact_created_cb;
1614 LinphoneCardDavContactUpdatedCb contact_updated_cb;
1615 LinphoneCardDavContactRemovedCb contact_removed_cb;
1616 LinphoneCardDavSynchronizationDoneCb sync_done_cb;
1617 LinphoneAuthInfo *auth_info;
1618 };
1619
1620 struct _LinphoneCardDavQuery {
1621 LinphoneCardDavContext *context;
1622 char *url;
1623 const char *method;
1624 char *body;
1625 const char *depth;
1626 const char *ifmatch;
1627 belle_http_request_listener_t *http_request_listener;
1628 void *user_data;
1629 LinphoneCardDavQueryType type;
1630 };
1631
1632 struct _LinphoneCardDavResponse {
1633 char *etag;
1634 char *url;
1635 char *vcard;
1636 };
1637
1638 /*****************************************************************************
1639 * REMOTE PROVISIONING FUNCTIONS *
1640 ****************************************************************************/
1641
1642 void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState state, const char *message);
1643 int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri);
1644 LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path);
1645
1646 /*****************************************************************************
1647 * Player interface *
1648 ****************************************************************************/
1649
1650 struct _LinphonePlayerCbs {
1651 belle_sip_object_t base;
1652 void *user_data;
1653 LinphonePlayerCbsEofReachedCb eof;
1654 };
1655
1656 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphonePlayerCbs);
1657
1658 LinphonePlayerCbs *linphone_player_cbs_new(void);
1659
1660 struct _LinphonePlayer{
1661 belle_sip_object_t base;
1662 void *user_data;
1663 int (*open)(LinphonePlayer* player, const char *filename);
1664 int (*start)(LinphonePlayer* player);
1665 int (*pause)(LinphonePlayer* player);
1666 int (*seek)(LinphonePlayer* player, int time_ms);
1667 MSPlayerState (*get_state)(LinphonePlayer* player);
1668 int (*get_duration)(LinphonePlayer *player);
1669 int (*get_position)(LinphonePlayer *player);
1670 void (*close)(LinphonePlayer* player);
1671 void (*destroy)(LinphonePlayer *player);
1672 void *impl;
1673 LinphonePlayerCbs *callbacks;
1674 };
1675
1676 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphonePlayer);
1677
1678 LinphonePlayer * linphone_player_new(void);
1679 void _linphone_player_destroy(LinphonePlayer *player);
1680
1681
1682 /*****************************************************************************
1683 * XML UTILITY FUNCTIONS *
1684 ****************************************************************************/
1685
1686 #define XMLPARSING_BUFFER_LEN 2048
1687 #define MAX_XPATH_LENGTH 256
1688
1689 typedef struct _xmlparsing_context {
1690 xmlDoc *doc;
1691 xmlXPathContextPtr xpath_ctx;
1692 char errorBuffer[XMLPARSING_BUFFER_LEN];
1693 char warningBuffer[XMLPARSING_BUFFER_LEN];
1694 } xmlparsing_context_t;
1695
1696 xmlparsing_context_t * linphone_xmlparsing_context_new(void);
1697 void linphone_xmlparsing_context_destroy(xmlparsing_context_t *ctx);
1698 void linphone_xmlparsing_genericxml_error(void *ctx, const char *fmt, ...);
1699 int linphone_create_xml_xpath_context(xmlparsing_context_t *xml_ctx);
1700 void linphone_xml_xpath_context_set_node(xmlparsing_context_t *xml_ctx, xmlNodePtr node);
1701 char * linphone_get_xml_text_content(xmlparsing_context_t *xml_ctx, const char *xpath_expression);
1702 const char * linphone_get_xml_attribute_text_content(xmlparsing_context_t *xml_ctx, const char *xpath_expression, const char *attribute_name);
1703 void linphone_free_xml_text_content(const char *text);
1704 xmlXPathObjectPtr linphone_get_xml_xpath_object_for_node_list(xmlparsing_context_t *xml_ctx, const char *xpath_expression);
1705 void linphone_xml_xpath_context_init_carddav_ns(xmlparsing_context_t *xml_ctx);
1706
1707 /*****************************************************************************
1708 * OTHER UTILITY FUNCTIONS *
1709 ****************************************************************************/
1710 char * linphone_timestamp_to_rfc3339_string(time_t timestamp);
1711
1712
1713 void linphone_error_info_from_sal_op(LinphoneErrorInfo *ei, const SalOp *op);
1714
payload_type_set_enable(OrtpPayloadType * pt,int value)1715 static MS2_INLINE void payload_type_set_enable(OrtpPayloadType *pt,int value)
1716 {
1717 if ((value)!=0) payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); \
1718 else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED);
1719 }
1720
payload_type_enabled(const OrtpPayloadType * pt)1721 static MS2_INLINE bool_t payload_type_enabled(const OrtpPayloadType *pt) {
1722 return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0);
1723 }
1724
1725 bool_t is_payload_type_number_available(const MSList *l, int number, const OrtpPayloadType *ignore);
1726 int get_audio_payload_bandwidth(const LinphoneCore *lc, const PayloadType *pt, int maxbw);
1727 LinphonePayloadType *linphone_payload_type_new(LinphoneCore *lc, OrtpPayloadType *ortp_pt);
1728 bool_t _linphone_core_check_payload_type_usability(const LinphoneCore *lc, const OrtpPayloadType *pt);
1729 OrtpPayloadType *linphone_payload_type_get_ortp_pt(const LinphonePayloadType *pt);
1730
1731
1732 const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc);
1733 MsZrtpCryptoTypesCount linphone_core_get_zrtp_key_agreement_suites(LinphoneCore *lc, MSZrtpKeyAgreement keyAgreements[MS_MAX_ZRTP_CRYPTO_TYPES]);
1734 MsZrtpCryptoTypesCount linphone_core_get_zrtp_cipher_suites(LinphoneCore *lc, MSZrtpCipher ciphers[MS_MAX_ZRTP_CRYPTO_TYPES]);
1735 MsZrtpCryptoTypesCount linphone_core_get_zrtp_hash_suites(LinphoneCore *lc, MSZrtpHash hashes[MS_MAX_ZRTP_CRYPTO_TYPES]);
1736 MsZrtpCryptoTypesCount linphone_core_get_zrtp_auth_suites(LinphoneCore *lc, MSZrtpAuthTag authTags[MS_MAX_ZRTP_CRYPTO_TYPES]);
1737 MsZrtpCryptoTypesCount linphone_core_get_zrtp_sas_suites(LinphoneCore *lc, MSZrtpSasType sasTypes[MS_MAX_ZRTP_CRYPTO_TYPES]);
1738
1739 struct _LinphoneImEncryptionEngineCbs {
1740 belle_sip_object_t base;
1741 void *user_data;
1742 LinphoneImEncryptionEngineCbsIncomingMessageCb process_incoming_message;
1743 LinphoneImEncryptionEngineCbsOutgoingMessageCb process_outgoing_message;
1744 LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer;
1745 LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb generate_file_transfer_key;
1746 LinphoneImEncryptionEngineCbsDownloadingFileCb process_downlading_file;
1747 LinphoneImEncryptionEngineCbsUploadingFileCb process_uploading_file;
1748 };
1749
1750 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneImEncryptionEngineCbs);
1751
1752 LinphoneImEncryptionEngineCbs * linphone_im_encryption_engine_cbs_new(void);
1753
1754 struct _LinphoneImEncryptionEngine {
1755 belle_sip_object_t base;
1756 void *user_data;
1757 LinphoneCore *lc;
1758 LinphoneImEncryptionEngineCbs *callbacks;
1759 };
1760
1761 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneImEncryptionEngine);
1762
1763 struct _LinphoneRange {
1764 belle_sip_object_t base;
1765 void *user_data;
1766 int min;
1767 int max;
1768 };
1769
1770 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneRange);
1771
1772 LinphoneRange *linphone_range_new(void);
1773
1774 struct _LinphoneTransports {
1775 belle_sip_object_t base;
1776 void *user_data;
1777 int udp_port; /**< SIP/UDP port */
1778 int tcp_port; /**< SIP/TCP port */
1779 int dtls_port; /**< SIP/DTLS port */
1780 int tls_port; /**< SIP/TLS port */
1781 };
1782
1783 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneTransports);
1784
1785 LINPHONE_PUBLIC LinphoneTransports *linphone_transports_new(void);
1786
1787 struct _LinphoneVideoActivationPolicy {
1788 belle_sip_object_t base;
1789 void *user_data;
1790 bool_t automatically_initiate; /**<Whether video shall be automatically proposed for outgoing calls.*/
1791 bool_t automatically_accept; /**<Whether video shall be automatically accepted for incoming calls*/
1792 };
1793
1794 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneVideoActivationPolicy);
1795
1796 LINPHONE_PUBLIC LinphoneVideoActivationPolicy *linphone_video_activation_policy_new(void);
1797
1798 /**
1799 * The LinphoneCallStats objects carries various statistic informations regarding quality of audio or video streams.
1800 *
1801 * To receive these informations periodically and as soon as they are computed, the application is invited to place a #LinphoneCoreCallStatsUpdatedCb callback in the LinphoneCoreVTable structure
1802 * it passes for instantiating the LinphoneCore object (see linphone_core_new() ).
1803 *
1804 * At any time, the application can access last computed statistics using linphone_call_get_audio_stats() or linphone_call_get_video_stats().
1805 **/
1806 struct _LinphoneCallStats {
1807 belle_sip_object_t base;
1808 void *user_data;
1809 LinphoneStreamType type; /**< Type of the stream which the stats refer to */
1810 jitter_stats_t jitter_stats; /**<jitter buffer statistics, see oRTP documentation for details */
1811 mblk_t *received_rtcp; /**<Last RTCP packet received, as a mblk_t structure. See oRTP documentation for details how to extract information from it*/
1812 mblk_t *sent_rtcp;/**<Last RTCP packet sent, as a mblk_t structure. See oRTP documentation for details how to extract information from it*/
1813 float round_trip_delay; /**<Round trip propagation time in seconds if known, -1 if unknown.*/
1814 LinphoneIceState ice_state; /**< State of ICE processing. */
1815 LinphoneUpnpState upnp_state; /**< State of uPnP processing. */
1816 float download_bandwidth; /**<Download bandwidth measurement of received stream, expressed in kbit/s, including IP/UDP/RTP headers*/
1817 float upload_bandwidth; /**<Download bandwidth measurement of sent stream, expressed in kbit/s, including IP/UDP/RTP headers*/
1818 float local_late_rate; /**<percentage of packet received too late over last second*/
1819 float local_loss_rate; /**<percentage of lost packet over last second*/
1820 int updated; /**< Tell which RTCP packet has been updated (received_rtcp or sent_rtcp). Can be either LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE or LINPHONE_CALL_STATS_SENT_RTCP_UPDATE */
1821 float rtcp_download_bandwidth; /**<RTCP download bandwidth measurement of received stream, expressed in kbit/s, including IP/UDP/RTP headers*/
1822 float rtcp_upload_bandwidth; /**<RTCP download bandwidth measurement of sent stream, expressed in kbit/s, including IP/UDP/RTP headers*/
1823 rtp_stats_t rtp_stats; /**< RTP stats */
1824 int rtp_remote_family; /**< Ip adress family of the remote destination */
1825 int clockrate; /*RTP clockrate of the stream, provided here for easily converting timestamp units expressed in RTCP packets in milliseconds*/
1826 bool_t rtcp_received_via_mux; /*private flag, for non-regression test only*/
1827 };
1828
1829 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallStats);
1830
1831 LinphoneCallStats *linphone_call_stats_new(void);
1832
1833 /** Belle Sip-based objects need unique ids
1834 */
1835
1836 BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000)
1837 BELLE_SIP_TYPE_ID(LinphoneAccountCreator),
1838 BELLE_SIP_TYPE_ID(LinphoneAccountCreatorCbs),
1839 BELLE_SIP_TYPE_ID(LinphoneAccountCreatorService),
1840 BELLE_SIP_TYPE_ID(LinphoneBuffer),
1841 BELLE_SIP_TYPE_ID(LinphoneContactProvider),
1842 BELLE_SIP_TYPE_ID(LinphoneContactSearch),
1843 BELLE_SIP_TYPE_ID(LinphoneCall),
1844 BELLE_SIP_TYPE_ID(LinphoneCallCbs),
1845 BELLE_SIP_TYPE_ID(LinphoneCallLog),
1846 BELLE_SIP_TYPE_ID(LinphoneCallParams),
1847 BELLE_SIP_TYPE_ID(LinphoneChatMessage),
1848 BELLE_SIP_TYPE_ID(LinphoneChatMessageCbs),
1849 BELLE_SIP_TYPE_ID(LinphoneChatRoom),
1850 BELLE_SIP_TYPE_ID(LinphoneContent),
1851 BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngine),
1852 BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngineCbs),
1853 BELLE_SIP_TYPE_ID(LinphoneImNotifPolicy),
1854 BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider),
1855 BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch),
1856 BELLE_SIP_TYPE_ID(LinphoneProxyConfig),
1857 BELLE_SIP_TYPE_ID(LinphoneFriend),
1858 BELLE_SIP_TYPE_ID(LinphoneFriendList),
1859 BELLE_SIP_TYPE_ID(LinphoneXmlRpcRequest),
1860 BELLE_SIP_TYPE_ID(LinphoneXmlRpcRequestCbs),
1861 BELLE_SIP_TYPE_ID(LinphoneXmlRpcSession),
1862 BELLE_SIP_TYPE_ID(LinphoneTunnel),
1863 BELLE_SIP_TYPE_ID(LinphoneTunnelConfig),
1864 BELLE_SIP_TYPE_ID(LinphoneFriendListCbs),
1865 BELLE_SIP_TYPE_ID(LinphoneEvent),
1866 BELLE_SIP_TYPE_ID(LinphoneNatPolicy),
1867 BELLE_SIP_TYPE_ID(LinphoneCore),
1868 BELLE_SIP_TYPE_ID(LinphoneCoreCbs),
1869 BELLE_SIP_TYPE_ID(LinphoneFactory),
1870 BELLE_SIP_TYPE_ID(LinphoneAuthInfo),
1871 BELLE_SIP_TYPE_ID(LinphoneVcard),
1872 BELLE_SIP_TYPE_ID(LinphoneConfig),
1873 BELLE_SIP_TYPE_ID(LinphonePresenceModel),
1874 BELLE_SIP_TYPE_ID(LinphonePresenceService),
1875 BELLE_SIP_TYPE_ID(LinphonePresencePerson),
1876 BELLE_SIP_TYPE_ID(LinphonePresenceActivity),
1877 BELLE_SIP_TYPE_ID(LinphonePresenceNote),
1878 BELLE_SIP_TYPE_ID(LinphoneErrorInfo),
1879 BELLE_SIP_TYPE_ID(LinphoneConferenceParams),
1880 BELLE_SIP_TYPE_ID(LinphoneConference),
1881 BELLE_SIP_TYPE_ID(LinphoneInfoMessage),
1882 BELLE_SIP_TYPE_ID(LinphonePayloadType),
1883 BELLE_SIP_TYPE_ID(LinphoneRange),
1884 BELLE_SIP_TYPE_ID(LinphoneVideoDefinition),
1885 BELLE_SIP_TYPE_ID(LinphoneTransports),
1886 BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy),
1887 BELLE_SIP_TYPE_ID(LinphoneCallStats),
1888 BELLE_SIP_TYPE_ID(LinphonePlayer),
1889 BELLE_SIP_TYPE_ID(LinphonePlayerCbs)
1890 BELLE_SIP_DECLARE_TYPES_END
1891
1892
1893
1894 void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
1895 void linphone_core_notify_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
1896 void linphone_core_notify_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
1897 void linphone_core_notify_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
1898 void linphone_core_notify_show_interface(LinphoneCore *lc);
1899 void linphone_core_notify_display_status(LinphoneCore *lc, const char *message);
1900 void linphone_core_notify_display_message(LinphoneCore *lc, const char *message);
1901 void linphone_core_notify_display_warning(LinphoneCore *lc, const char *message);
1902 void linphone_core_notify_display_url(LinphoneCore *lc, const char *message, const char *url);
1903 void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
1904 void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
1905 void linphone_core_notify_authentication_requested(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method);
1906 void linphone_core_notify_call_log_updated(LinphoneCore *lc, LinphoneCallLog *newcl);
1907 void linphone_core_notify_text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
1908 void linphone_core_notify_message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
1909 void linphone_core_notify_message_received_unable_decrypt(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
1910 void linphone_core_notify_file_transfer_recv(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size);
1911 void linphone_core_notify_file_transfer_send(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, char* buff, size_t* size);
1912 void linphone_core_notify_file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total);
1913 void linphone_core_notify_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room);
1914 void linphone_core_notify_dtmf_received(LinphoneCore* lc, LinphoneCall *call, int dtmf);
1915 /*
1916 * return true if at least a registered vtable has a cb for dtmf received*/
1917 bool_t linphone_core_dtmf_received_has_listener(const LinphoneCore* lc);
1918 void linphone_core_notify_refer_received(LinphoneCore *lc, const char *refer_to);
1919 void linphone_core_notify_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf);
1920 void linphone_core_notify_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state);
1921 void linphone_core_notify_call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats);
1922 void linphone_core_notify_info_received(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
1923 void linphone_core_notify_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
1924 void linphone_core_notify_network_reachable(LinphoneCore *lc, bool_t reachable);
1925
1926 void linphone_core_notify_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, const LinphoneContent *body);
1927 void linphone_core_notify_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state);
1928 void linphone_core_notify_publish_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphonePublishState state);
1929 void linphone_core_notify_log_collection_upload_state_changed(LinphoneCore *lc, LinphoneCoreLogCollectionUploadState state, const char *info);
1930 void linphone_core_notify_log_collection_upload_progress_indication(LinphoneCore *lc, size_t offset, size_t total);
1931 void linphone_core_notify_friend_list_created(LinphoneCore *lc, LinphoneFriendList *list);
1932 void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendList *list);
1933 void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call);
1934 void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url);
1935
1936 void set_mic_gain_db(AudioStream *st, float gain);
1937 void set_playback_gain_db(AudioStream *st, float gain);
1938
1939 LinphoneMediaDirection media_direction_from_sal_stream_dir(SalStreamDir dir);
1940 SalStreamDir sal_dir_from_call_params_dir(LinphoneMediaDirection cpdir);
1941
1942 /*****************************************************************************
1943 * LINPHONE CONTENT PRIVATE ACCESSORS *
1944 ****************************************************************************/
1945 /**
1946 * Get the key associated with a RCS file transfer message if encrypted
1947 * @param[in] content LinphoneContent object.
1948 * @return The key to encrypt/decrypt the file associated to this content.
1949 */
1950 LINPHONE_PUBLIC const char *linphone_content_get_key(const LinphoneContent *content);
1951
1952 /**
1953 * Get the size of key associated with a RCS file transfer message if encrypted
1954 * @param[in] content LinphoneContent object.
1955 * @return The key size in bytes
1956 */
1957 size_t linphone_content_get_key_size(const LinphoneContent *content);
1958
1959 /**
1960 * Set the key associated with a RCS file transfer message if encrypted
1961 * @param[in] content LinphoneContent object.
1962 * @param[in] key The key to be used to encrypt/decrypt file associated to this content.
1963 * @param[in] keyLength The lengh of the key.
1964 */
1965 void linphone_content_set_key(LinphoneContent *content, const char *key, const size_t keyLength);
1966
1967 /**
1968 * Get the address of the crypto context associated with a RCS file transfer message if encrypted
1969 * @param[in] content LinphoneContent object.
1970 * @return The address of the pointer to the crypto context. Crypto context is managed(alloc/free)
1971 * by the encryption/decryption functions, so we give the address to store/retrieve the pointer
1972 */
1973 void ** linphone_content_get_cryptoContext_address(LinphoneContent *content);
1974
1975 #ifdef __ANDROID__
1976 void linphone_core_wifi_lock_acquire(LinphoneCore *lc);
1977 void linphone_core_wifi_lock_release(LinphoneCore *lc);
1978 void linphone_core_multicast_lock_acquire(LinphoneCore *lc);
1979 void linphone_core_multicast_lock_release(LinphoneCore *lc);
1980 #endif
1981
1982 struct _VTableReference{
1983 LinphoneCoreCbs *cbs;
1984 bool_t valid;
1985 bool_t autorelease;
1986 bool_t internal;
1987 };
1988
1989 typedef struct _VTableReference VTableReference;
1990
1991 void v_table_reference_destroy(VTableReference *ref);
1992
1993 LINPHONE_PUBLIC void _linphone_core_add_callbacks(LinphoneCore *lc, LinphoneCoreCbs *vtable, bool_t internal);
1994
1995 #ifdef VIDEO_ENABLED
1996 LINPHONE_PUBLIC MSWebCam *linphone_call_get_video_device(const LinphoneCall *call);
1997 MSWebCam *get_nowebcam_device(MSFactory *f);
1998 #endif
1999 LinphoneLimeState linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc);
2000
2001 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneTunnelConfig);
2002
2003 int linphone_core_get_default_proxy_config_index(LinphoneCore *lc);
2004
2005 char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ;
2006
2007 #define LINPHONE_SQLITE3_VFS "sqlite3bctbx_vfs"
2008
2009 void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite);
2010
2011 bool_t linphone_call_state_is_early(LinphoneCallState state);
2012
2013 struct _LinphoneErrorInfo{
2014 belle_sip_object_t base;
2015 LinphoneReason reason;
2016 char *protocol; /* */
2017 int protocol_code; /*from SIP response*/
2018 char *phrase; /*from SIP response*/
2019 char *warnings; /*from SIP response*/
2020 char *full_string; /*concatenation of status_string + warnings*/
2021 struct _LinphoneErrorInfo *sub_ei;
2022 };
2023 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneErrorInfo);
2024
2025 void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log);
2026 void linphone_core_report_early_failed_call(LinphoneCore *lc, LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress *to, LinphoneErrorInfo *ei);
2027
2028 struct _LinphoneVideoDefinition {
2029 belle_sip_object_t base;
2030 void *user_data;
2031 unsigned int width; /**< The width of the video */
2032 unsigned int height; /**< The height of the video */
2033 char *name; /** The name of the video definition */
2034 };
2035
2036 BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneVideoDefinition);
2037
2038 LinphoneVideoDefinition * linphone_video_definition_new(unsigned int width, unsigned int height, const char *name);
2039
2040 LinphoneVideoDefinition * linphone_factory_find_supported_video_definition(const LinphoneFactory *factory, unsigned int width, unsigned int height);
2041 LinphoneVideoDefinition * linphone_factory_find_supported_video_definition_by_name(const LinphoneFactory *factory, const char *name);
2042
2043 const char* _linphone_config_load_from_xml_string(LpConfig *lpc, const char *buffer);
2044 LinphoneNatPolicy * linphone_config_create_nat_policy_from_section(const LinphoneConfig *config, const char* section);
2045
2046
2047 #ifdef __cplusplus
2048 }
2049 #endif
2050
2051 #endif /* _PRIVATE_H */
2052