3 Copyright (C) 2000 - 2010 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifndef LINPHONECORE_H
20 #define LINPHONECORE_H
22 #include "ortp/ortp.h"
23 #include "ortp/payloadtype.h"
24 #include "mediastreamer2/mscommon.h"
25 #include "mediastreamer2/msvideo.h"
30 #include "linphone/sipsetup.h"
33 #define LINPHONE_IPADDR_SIZE 64
34 #define LINPHONE_HOSTNAME_SIZE 128
43 * Linphone core main object created by function linphone_core_new() .
44 * @ingroup initializing
46 typedef struct _LinphoneCore LinphoneCore;
52 struct _LCSipTransports{
59 typedef struct _LCSipTransports LCSipTransports;
62 * Object that represents a SIP address.
64 * The LinphoneAddress is an opaque object to represents SIP addresses, ie
65 * the content of SIP's 'from' and 'to' headers.
66 * A SIP address is made of display name, username, domain name, port, and various
67 * uri headers (such as tags). It looks like 'Alice <sip:alice@example.net>'.
68 * The LinphoneAddress has methods to extract and manipulate all parts of the address.
69 * When some part of the address (for example the username) is empty, the accessor methods
72 * @ingroup linphone_address
73 * @var LinphoneAddress
75 typedef struct SalAddress LinphoneAddress;
77 #include "linphonefriend.h"
79 #include "linphone/linphonefriend.h"
82 LinphoneAddress * linphone_address_new(const char *uri);
83 LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
84 const char *linphone_address_get_scheme(const LinphoneAddress *u);
85 const char *linphone_address_get_display_name(const LinphoneAddress* u);
86 const char *linphone_address_get_username(const LinphoneAddress *u);
87 const char *linphone_address_get_domain(const LinphoneAddress *u);
89 * Get port number as an integer value.
92 int linphone_address_get_port_int(const LinphoneAddress *u);
94 * Get port number, null if not present.
96 const char* linphone_address_get_port(const LinphoneAddress *u);
97 void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
98 void linphone_address_set_username(LinphoneAddress *uri, const char *username);
99 void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
100 void linphone_address_set_port(LinphoneAddress *uri, const char *port);
101 void linphone_address_set_port_int(LinphoneAddress *uri, int port);
102 /*remove tags, params etc... so that it is displayable to the user*/
103 void linphone_address_clean(LinphoneAddress *uri);
104 char *linphone_address_as_string(const LinphoneAddress *u);
105 char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
106 bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2);
107 void linphone_address_destroy(LinphoneAddress *u);
109 struct _SipSetupContext;
113 * Enum representing the direction of a call.
116 enum _LinphoneCallDir {
117 LinphoneCallOutgoing, /**< outgoing calls*/
118 LinphoneCallIncoming /**< incoming calls*/
125 typedef enum _LinphoneCallDir LinphoneCallDir;
128 * Enum representing the status of a call
131 typedef enum _LinphoneCallStatus {
132 LinphoneCallSuccess, /**< The call was sucessful*/
133 LinphoneCallAborted, /**< The call was aborted */
134 LinphoneCallMissed, /**< The call was missed (unanswered)*/
135 LinphoneCallDeclined /**< The call was declined, either locally or by remote end*/
136 } LinphoneCallStatus;
139 * Structure representing a call log.
144 typedef struct _LinphoneCallLog{
145 LinphoneCallDir dir; /**< The direction of the call*/
146 LinphoneCallStatus status; /**< The status of the call*/
147 LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
148 LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
149 char start_date[128]; /**<Human readable string containg the start date*/
150 int duration; /**<Duration of the call in seconds*/
153 rtp_stats_t local_stats;
154 rtp_stats_t remote_stats;
156 struct _LinphoneCore *lc;
159 enum LinphoneMediaEncryption {
160 LinphoneMediaEncryptionNone,
161 LinphoneMediaEncryptionSRTP,
162 LinphoneMediaEncryptionZRTP
165 typedef enum LinphoneMediaEncryption LinphoneMediaEncryption;
168 void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
169 void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
170 void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
171 const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
172 const rtp_stats_t *linphone_call_log_get_local_stats(const LinphoneCallLog *cl);
173 const rtp_stats_t *linphone_call_log_get_remote_stats(const LinphoneCallLog *cl);
174 char * linphone_call_log_to_str(LinphoneCallLog *cl);
178 * The LinphoneCallParams is an object containing various call related parameters.
179 * It can be used to retrieve parameters from a currently running call or modify the call's characteristics
182 struct _LinphoneCallParams;
183 typedef struct _LinphoneCallParams LinphoneCallParams;
185 LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp);
186 void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled);
187 bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp);
188 LinphoneMediaEncryption linphone_call_params_get_media_encryption(const LinphoneCallParams *cp);
189 void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, LinphoneMediaEncryption e);
190 void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled);
191 bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp);
192 bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp);
193 void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw);
194 void linphone_call_params_destroy(LinphoneCallParams *cp);
197 * Enum describing failure reasons.
198 * @ingroup initializing
200 enum _LinphoneReason{
202 LinphoneReasonNoResponse, /**<No response received from remote*/
203 LinphoneReasonBadCredentials, /**<Authentication failed due to bad or missing credentials*/
204 LinphoneReasonDeclined, /**<The call has been declined*/
207 typedef enum _LinphoneReason LinphoneReason;
209 const char *linphone_reason_to_string(LinphoneReason err);
212 * The LinphoneCall object represents a call issued or received by the LinphoneCore
214 struct _LinphoneCall;
215 typedef struct _LinphoneCall LinphoneCall;
218 * LinphoneCallState enum represents the different state a call can reach into.
219 * The application is notified of state changes through the LinphoneCoreVTable::call_state_changed callback.
220 * @ingroup call_control
222 typedef enum _LinphoneCallState{
223 LinphoneCallIdle, /**<Initial call state */
224 LinphoneCallIncomingReceived, /**<This is a new incoming call */
225 LinphoneCallOutgoingInit, /**<An outgoing call is started */
226 LinphoneCallOutgoingProgress, /**<An outgoing call is in progress */
227 LinphoneCallOutgoingRinging, /**<An outgoing call is ringing at remote end */
228 LinphoneCallOutgoingEarlyMedia, /**<An outgoing call is proposed early media */
229 LinphoneCallConnected, /**<Connected, the call is answered */
230 LinphoneCallStreamsRunning, /**<The media streams are established and running*/
231 LinphoneCallPausing, /**<The call is pausing at the initiative of local end */
232 LinphoneCallPaused, /**< The call is paused, remote end has accepted the pause */
233 LinphoneCallResuming, /**<The call is being resumed by local end*/
234 LinphoneCallRefered, /**<The call is being transfered to another party, resulting in a new outgoing call to follow immediately*/
235 LinphoneCallError, /**<The call encountered an error*/
236 LinphoneCallEnd, /**<The call ended normally*/
237 LinphoneCallPausedByRemote, /**<The call is paused by remote end*/
238 LinphoneCallUpdatedByRemote, /**<The call's parameters are updated, used for example when video is asked by remote */
239 LinphoneCallIncomingEarlyMedia, /**<We are proposing early media to an incoming call */
240 LinphoneCallUpdated, /**<The remote accepted the call update initiated by us */
241 LinphoneCallReleased /**< The call object is no more retained by the core */
244 const char *linphone_call_state_to_string(LinphoneCallState cs);
246 LinphoneCore *linphone_call_get_core(const LinphoneCall *call);
247 LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
248 bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
249 const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
250 const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
251 char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
252 LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call);
253 LinphoneCall * linphone_call_ref(LinphoneCall *call);
254 void linphone_call_unref(LinphoneCall *call);
255 LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call);
256 const char *linphone_call_get_refer_to(const LinphoneCall *call);
257 bool_t linphone_call_has_transfer_pending(const LinphoneCall *call);
258 LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call);
259 int linphone_call_get_duration(const LinphoneCall *call);
260 const LinphoneCallParams * linphone_call_get_current_params(const LinphoneCall *call);
261 void linphone_call_enable_camera(LinphoneCall *lc, bool_t enabled);
262 bool_t linphone_call_camera_enabled(const LinphoneCall *lc);
263 int linphone_call_take_video_snapshot(LinphoneCall *call, const char *file);
264 LinphoneReason linphone_call_get_reason(const LinphoneCall *call);
265 const char *linphone_call_get_remote_user_agent(LinphoneCall *call);
266 float linphone_call_get_play_volume(LinphoneCall *call);
267 float linphone_call_get_record_volume(LinphoneCall *call);
268 float linphone_call_get_current_quality(LinphoneCall *call);
269 float linphone_call_get_average_quality(LinphoneCall *call);
270 const char* linphone_call_get_authentication_token(LinphoneCall *call);
271 bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call);
272 void linphone_call_set_authentication_token_verified(LinphoneCall *call, bool_t verified);
273 void linphone_call_send_vfu_request(LinphoneCall *call);
274 void *linphone_call_get_user_pointer(LinphoneCall *call);
275 void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
277 * Enables or disable echo cancellation for this call
281 * @ingroup media_parameters
283 void linphone_call_enable_echo_cancellation(LinphoneCall *call, bool_t val) ;
285 * Returns TRUE if echo cancellation is enabled.
287 * @ingroup media_parameters
289 bool_t linphone_call_echo_cancellation_enabled(LinphoneCall *lc);
291 * Enables or disable echo limiter for this call
295 * @ingroup media_parameters
297 void linphone_call_enable_echo_limiter(LinphoneCall *call, bool_t val);
299 * Returns TRUE if echo limiter is enabled.
301 * @ingroup media_parameters
303 bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call);
305 /*keep this in sync with mediastreamer2/msvolume.h*/
306 #define LINPHONE_VOLUME_DB_LOWEST (-120) /**< Lowest measured that can be returned.*/
309 * @addtogroup proxies
313 * The LinphoneProxyConfig object represents a proxy configuration to be used
314 * by the LinphoneCore object.
315 * Its fields must not be used directly in favour of the accessors methods.
316 * Once created and filled properly the LinphoneProxyConfig can be given to
317 * LinphoneCore with linphone_core_add_proxy_config().
318 * This will automatically triggers the registration, if enabled.
320 * The proxy configuration are persistent to restarts because they are saved
321 * in the configuration file. As a consequence, after linphone_core_new() there
322 * might already be a list of configured proxy that can be examined with
323 * linphone_core_get_proxy_config_list().
325 * The default proxy (see linphone_core_set_default_proxy() ) is the one of the list
326 * that is used by default for calls.
328 typedef struct _LinphoneProxyConfig LinphoneProxyConfig;
331 * LinphoneRegistrationState describes proxy registration states.
333 typedef enum _LinphoneRegistrationState{
334 LinphoneRegistrationNone, /**<Initial state for registrations */
335 LinphoneRegistrationProgress, /**<Registration is in progress */
336 LinphoneRegistrationOk, /**< Registration is successful */
337 LinphoneRegistrationCleared, /**< Unregistration succeeded */
338 LinphoneRegistrationFailed /**<Registration failed */
339 }LinphoneRegistrationState;
342 * Human readable version of the #LinphoneRegistrationState
345 const char *linphone_registration_state_to_string(LinphoneRegistrationState cs);
348 * True if tunnel support was compiled.
350 bool_t linphone_core_tunnel_available();
353 * Update tunnel using configuration.
355 void linphone_core_update_tunnel(LinphoneCore *lc);
357 LinphoneProxyConfig *linphone_proxy_config_new(void);
358 int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
359 int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
360 int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
361 void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires);
363 * Indicates either or not, REGISTRATION must be issued for this #LinphoneProxyConfig .
364 * <br> In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule.
365 * @param obj object pointer
366 * @param val if true, registration will be engaged
368 void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val);
369 #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register
370 void linphone_proxy_config_edit(LinphoneProxyConfig *obj);
371 int linphone_proxy_config_done(LinphoneProxyConfig *obj);
373 * Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig .
374 * <br> In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule.
375 * @param obj object pointer
376 * @param val if true, publish will be engaged
379 void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
380 void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val);
381 void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix);
383 LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj);
384 bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
385 const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
387 const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj);
388 const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj);
389 bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj);
390 const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj);
391 int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj);
392 bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj);
393 void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
394 struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
396 bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
397 const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);
399 LinphoneReason linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg);
401 /* destruction is called automatically when removing the proxy config */
402 void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
403 void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
404 SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
405 SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
407 * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
409 int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len);
411 * attached a user data to a proxy config
413 void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cr, void * ud);
415 * get user data to a proxy config. return null if any
417 void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr);
423 typedef struct _LinphoneAccountCreator{
424 struct _LinphoneCore *lc;
425 struct _SipSetupContext *ssctx;
430 }LinphoneAccountCreator;
432 LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
433 void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
434 void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
435 void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
436 const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
437 const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
438 int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
439 LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
440 void linphone_account_creator_destroy(LinphoneAccountCreator *obj);
442 struct _LinphoneAuthInfo;
445 * @ingroup authentication
446 * Object holding authentication information.
448 * @note The object's fields should not be accessed directly. Prefer using
449 * the accessor methods.
451 * In most case, authentication information consists of a username and password.
452 * Sometimes, a userid is required by proxy, and realm can be useful to discriminate
453 * different SIP domains.
455 * Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
456 * order to become known and used automatically when needed.
457 * Use linphone_core_add_auth_info() for that purpose.
459 * The LinphoneCore object can take the initiative to request authentication information
460 * when needed to the application through the auth_info_requested callback of the
461 * LinphoneCoreVTable structure.
463 * The application can respond to this information request later using
464 * linphone_core_add_auth_info(). This will unblock all pending authentication
465 * transactions and retry them with authentication headers.
468 typedef struct _LinphoneAuthInfo LinphoneAuthInfo;
470 LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
471 const char *passwd, const char *ha1,const char *realm);
472 void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
473 void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
474 void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
476 const char *linphone_auth_info_get_username(const LinphoneAuthInfo *i);
477 const char *linphone_auth_info_get_passwd(const LinphoneAuthInfo *i);
478 const char *linphone_auth_info_get_userid(const LinphoneAuthInfo *i);
480 /* you don't need those function*/
481 void linphone_auth_info_destroy(LinphoneAuthInfo *info);
482 LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos);
485 struct _LinphoneChatRoom;
487 * @addtogroup chatroom
491 * A chat room is the place where text messages are exchanged.
492 * <br> Can be created by linphone_core_create_chat_room().
494 typedef struct _LinphoneChatRoom LinphoneChatRoom;
496 * Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org
497 * @param lc #LinphoneCore object
498 * @param to destination address for messages
499 * @return #LinphoneChatRoom where messaging can take place.
501 LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to);
504 * @param cr #LinphoneChatRoom object
506 void linphone_chat_room_destroy(LinphoneChatRoom *cr);
510 * get peer address \link linphone_core_create_chat_room() associated to \endlink this #LinphoneChatRoom
511 * @param cr #LinphoneChatRoom object
512 * @return #LinphoneAddress peer address
514 const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr);
516 * send a message to peer member of this chat room.
517 * @param cr #LinphoneChatRoom object
518 * @param msg message to be sent
520 void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
522 void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
523 void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);
531 * @addtogroup initializing
536 * LinphoneGlobalState describes the global state of the LinphoneCore object.
537 * It is notified via the LinphoneCoreVTable::global_state_changed
539 typedef enum _LinphoneGlobalState{
541 LinphoneGlobalStartup,
543 LinphoneGlobalShutdown
544 }LinphoneGlobalState;
546 const char *linphone_global_state_to_string(LinphoneGlobalState gs);
549 /**Call state notification callback prototype*/
550 typedef void (*LinphoneGlobalStateCb)(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
551 /**Call state notification callback prototype*/
552 typedef void (*LinphoneCallStateCb)(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
553 /**Call encryption changed callback prototype*/
554 typedef void (*CallEncryptionChangedCb)(struct _LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
557 * Registration state notification callback prototype
559 typedef void (*LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
560 /** Callback prototype */
561 typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
562 /** Callback prototype */
563 typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
564 /** Callback prototype */
565 typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
566 /** Callback prototype */
567 typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
568 /** Callback prototype */
569 typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
570 /** Callback prototype */
571 typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const char *from, const char *event);
573 * Report status change for a friend previously \link linphone_core_add_friend() added \endlink to #LinphoneCore.
574 * @param lc #LinphoneCore object .
575 * @param lf Updated #LinphoneFriend .
577 typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * lf);
579 * Reports that a new subscription request has been received and wait for a decision.
580 * <br> Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend
581 * @param lc #LinphoneCore object
582 * @param lf #LinphoneFriend corresponding to the subscriber
583 * @param url of the subscriber
586 typedef void (*NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
587 /** Callback prototype */
588 typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
589 /** Callback prototype */
590 typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
594 * @param lc #LinphoneCore object
595 * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room.
596 * @param from #LinphoneAddress from
597 * @param message incoming message
599 typedef void (*TextMessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
600 /** Callback prototype */
601 typedef void (*DtmfReceived)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf);
602 /** Callback prototype */
603 typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
604 /** Callback prototype */
605 typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
608 * This structure holds all callbacks that the application should implement.
611 typedef struct _LinphoneVTable{
612 LinphoneGlobalStateCb global_state_changed; /**<Notifies globlal state changes*/
613 LinphoneRegistrationStateCb registration_state_changed;/**<Notifies registration state changes*/
614 LinphoneCallStateCb call_state_changed;/**<Notifies call state changes*/
615 NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
616 NewSubscribtionRequestCb new_subscription_request; /**< Notify about pending subscription request */
617 AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
618 CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
619 TextMessageReceived text_received; /**< A text message has been received */
620 DtmfReceived dtmf_received; /**< A dtmf has been received received */
621 ReferReceived refer_received; /**< An out of call refer was received */
622 BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
623 NotifyReceivedCb notify_recv; /**< Other notifications*/
624 DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
625 DisplayMessageCb display_message;/**< Callback to display a message to the user */
626 DisplayMessageCb display_warning;/** Callback to display a warning to the user */
627 DisplayUrlCb display_url;
628 ShowInterfaceCb show; /**< Notifies the application that it should show up*/
629 CallEncryptionChangedCb call_encryption_changed; /**<Notifies on change in the encryption of call streams */
630 } LinphoneCoreVTable;
636 typedef struct _LCCallbackObj
638 LinphoneCoreCbFunc _func;
644 typedef enum _LinphoneFirewallPolicy{
645 LinphonePolicyNoFirewall,
646 LinphonePolicyUseNatAddress,
647 LinphonePolicyUseStun
648 } LinphoneFirewallPolicy;
650 typedef enum _LinphoneWaitingState{
651 LinphoneWaitingStart,
652 LinphoneWaitingProgress,
653 LinphoneWaitingFinished
654 } LinphoneWaitingState;
655 typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
660 void linphone_core_enable_logs(FILE *file);
661 void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
662 void linphone_core_disable_logs(void);
663 /*sets the user-agent string in sip messages, must be set before linphone_core_new() or linphone_core_init() */
664 void linphone_core_set_user_agent(const char *ua_name, const char *version);
665 const char *linphone_core_get_version(void);
667 LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
668 const char *config_path, const char *factory_config, void* userdata);
670 /* function to be periodically called in a main loop */
671 void linphone_core_iterate(LinphoneCore *lc);
673 LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);
675 LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url);
677 LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
679 LinphoneCall * linphone_core_invite_with_params(LinphoneCore *lc, const char *url, const LinphoneCallParams *params);
681 LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params);
683 int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to);
685 int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest);
687 bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
689 bool_t linphone_core_in_call(const LinphoneCore *lc);
691 LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc);
693 int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);
695 int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
697 int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri);
699 int linphone_core_terminate_all_calls(LinphoneCore *lc);
701 int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);
703 int linphone_core_pause_all_calls(LinphoneCore *lc);
705 int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call);
707 int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params);
709 LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc);
711 LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address);
713 void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);
715 int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact);
717 const char *linphone_core_get_primary_contact(LinphoneCore *lc);
719 const char * linphone_core_get_identity(LinphoneCore *lc);
721 void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val);
722 bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);
724 bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
725 void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);
727 LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
728 const char * linphone_core_get_identity(LinphoneCore *lc);
729 /*0= no bandwidth limit*/
730 void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
731 void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw);
733 int linphone_core_get_download_bandwidth(const LinphoneCore *lc);
734 int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
736 void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled);
737 bool_t linphone_core_adaptive_rate_control_enabled(const LinphoneCore *lc);
739 * set audio packetization time linphone expect to receive from peer
740 * @ingroup media_parameters
743 void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime);
745 * get audio packetization time linphone expect to receive from peer, 0 means unspecified
746 * @ingroup media_parameters
748 int linphone_core_get_download_ptime(LinphoneCore *lc);
750 void linphone_core_set_upload_ptime(LinphoneCore *lc, int ptime);
752 int linphone_core_get_upload_ptime(LinphoneCore *lc);
754 /* returns a MSList of PayloadType */
755 const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc);
757 int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs);
758 /* returns a MSList of PayloadType */
759 const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);
761 int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
763 bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);
765 int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable);
767 PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) ;
769 const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt);
771 bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
773 int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
775 void linphone_core_clear_proxy_config(LinphoneCore *lc);
777 void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
779 const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc);
781 void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config);
783 void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index);
785 int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config);
787 void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
789 void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
791 const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);
793 const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);
795 void linphone_core_abort_authentication(LinphoneCore *lc, LinphoneAuthInfo *info);
797 void linphone_core_clear_all_auth_info(LinphoneCore *lc);
799 int linphone_core_get_audio_jittcomp(LinphoneCore *lc);
801 void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);
803 int linphone_core_get_audio_port(const LinphoneCore *lc);
805 int linphone_core_get_video_port(const LinphoneCore *lc);
807 int linphone_core_get_nortp_timeout(const LinphoneCore *lc);
809 void linphone_core_set_audio_port(LinphoneCore *lc, int port);
811 void linphone_core_set_video_port(LinphoneCore *lc, int port);
813 void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);
815 void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);
817 bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc);
819 void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833);
821 bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc);
823 void linphone_core_set_sip_port(LinphoneCore *lc, int port);
825 int linphone_core_get_sip_port(LinphoneCore *lc);
827 int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports);
829 int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports);
832 * Give access to the UDP sip socket. Can be useful to configure this socket as persistent I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP)
833 * @param lc #LinphoneCore
834 * @return socket file descriptor
836 ortp_socket_t linphone_core_get_sip_socket(LinphoneCore *lc);
838 void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);
840 int linphone_core_get_inc_timeout(LinphoneCore *lc);
842 void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
844 const char * linphone_core_get_stun_server(const LinphoneCore *lc);
846 void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr);
848 const char *linphone_core_get_nat_address(const LinphoneCore *lc);
850 void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol);
852 LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);
854 const char * linphone_core_get_relay_addr(const LinphoneCore *lc);
856 int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);
858 /* sound functions */
859 /* returns a null terminated static array of string describing the sound devices */
860 const char** linphone_core_get_sound_devices(LinphoneCore *lc);
861 bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
862 bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
863 int linphone_core_get_ring_level(LinphoneCore *lc);
864 int linphone_core_get_play_level(LinphoneCore *lc);
865 int linphone_core_get_rec_level(LinphoneCore *lc);
866 void linphone_core_set_ring_level(LinphoneCore *lc, int level);
867 void linphone_core_set_play_level(LinphoneCore *lc, int level);
869 void linphone_core_set_playback_gain_db(LinphoneCore *lc, float level);
871 float linphone_core_get_playback_gain_db(LinphoneCore *lc);
872 void linphone_core_set_rec_level(LinphoneCore *lc, int level);
873 const char * linphone_core_get_ringer_device(LinphoneCore *lc);
874 const char * linphone_core_get_playback_device(LinphoneCore *lc);
875 const char * linphone_core_get_capture_device(LinphoneCore *lc);
876 int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid);
877 int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid);
878 int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid);
879 char linphone_core_get_sound_source(LinphoneCore *lc);
880 void linphone_core_set_sound_source(LinphoneCore *lc, char source);
881 void linphone_core_set_ring(LinphoneCore *lc, const char *path);
882 const char *linphone_core_get_ring(const LinphoneCore *lc);
883 void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno);
884 void linphone_core_set_root_ca(LinphoneCore *lc, const char *path);
885 void linphone_core_set_ringback(LinphoneCore *lc, const char *path);
886 const char * linphone_core_get_ringback(const LinphoneCore *lc);
888 void linphone_core_set_remote_ringback_tone(LinphoneCore *lc,const char *);
889 const char *linphone_core_get_remote_ringback_tone(const LinphoneCore *lc);
891 int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
892 void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val);
893 bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc);
895 void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
896 bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);
898 void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
899 bool_t linphone_core_agc_enabled(const LinphoneCore *lc);
901 void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
905 * @ingroup media_parameters
907 bool_t linphone_core_is_mic_muted(LinphoneCore *lc);
909 bool_t linphone_core_is_audio_muted(LinphoneCore *lc);
910 bool_t linphone_core_is_rtp_muted(LinphoneCore *lc);
912 bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc);
913 void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, bool_t val);
916 /* returns a list of LinphoneCallLog */
917 const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
918 void linphone_core_clear_call_logs(LinphoneCore *lc);
921 void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled);
922 bool_t linphone_core_video_enabled(LinphoneCore *lc);
924 typedef struct MSVideoSizeDef{
928 /* returns a zero terminated table of MSVideoSizeDef*/
929 const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc);
930 void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize);
931 MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc);
932 void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
934 void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
935 bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);
937 void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
938 bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
941 /* returns a null terminated static array of string describing the webcams */
942 const char** linphone_core_get_video_devices(const LinphoneCore *lc);
943 int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
944 const char *linphone_core_get_video_device(const LinphoneCore *lc);
946 /* Set static picture to be used when "Static picture" is the video device */
947 int linphone_core_set_static_picture(LinphoneCore *lc, const char *path);
949 /* Set and get frame rate for static picture */
950 int linphone_core_set_static_picture_fps(LinphoneCore *lc, float fps);
951 float linphone_core_get_static_picture_fps(LinphoneCore *lc);
953 /*function to be used for eventually setting window decorations (icons, title...)*/
954 unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
955 void linphone_core_set_native_video_window_id(LinphoneCore *lc, unsigned long id);
957 unsigned long linphone_core_get_native_preview_window_id(const LinphoneCore *lc);
958 void linphone_core_set_native_preview_window_id(LinphoneCore *lc, unsigned long id);
960 void linphone_core_use_preview_window(LinphoneCore *lc, bool_t yesno);
961 int linphone_core_get_device_rotation(LinphoneCore *lc );
962 void linphone_core_set_device_rotation(LinphoneCore *lc, int rotation);
964 /*play/record support: use files instead of soundcard*/
965 void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
966 void linphone_core_set_play_file(LinphoneCore *lc, const char *file);
967 void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
969 void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms);
970 void linphone_core_stop_dtmf(LinphoneCore *lc);
972 int linphone_core_get_current_call_duration(const LinphoneCore *lc);
975 int linphone_core_get_mtu(const LinphoneCore *lc);
976 void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
979 * @ingroup network_parameters
980 * This method is called by the application to notify the linphone core library when network is reachable.
981 * Calling this method with true trigger linphone to initiate a registration process for all proxy
982 * configuration with parameter register set to enable.
983 * This method disable the automatic registration mode. It means you must call this method after each network state changes
986 void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value);
988 * @ingroup network_parameters
989 * return network state either as positioned by the application or by linphone
991 bool_t linphone_core_is_network_reachabled(LinphoneCore* lc);
994 * @ingroup network_parameters
995 * enable signaling keep alive. small udp packet sent periodically to keep udp NAT association
997 void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable);
999 * @ingroup network_parameters
1000 * Is signaling keep alive
1002 bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc);
1004 void *linphone_core_get_user_data(LinphoneCore *lc);
1006 /* returns LpConfig object to read/write to the config file: usefull if you wish to extend
1007 the config file with your own sections */
1008 struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);
1010 /*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
1011 void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
1013 /*returns the list of registered SipSetup (linphonecore plugins) */
1014 const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);
1016 void linphone_core_destroy(LinphoneCore *lc);
1018 /*for advanced users:*/
1019 typedef RtpTransport * (*LinphoneRtpTransportFactoryFunc)(void *data, int port);
1020 struct _LinphoneRtpTransportFactories{
1021 LinphoneRtpTransportFactoryFunc audio_rtp_func;
1022 void *audio_rtp_func_data;
1023 LinphoneRtpTransportFactoryFunc audio_rtcp_func;
1024 void *audio_rtcp_func_data;
1025 LinphoneRtpTransportFactoryFunc video_rtp_func;
1026 void *video_rtp_func_data;
1027 LinphoneRtpTransportFactoryFunc video_rtcp_func;
1028 void *video_rtcp_func_data;
1030 typedef struct _LinphoneRtpTransportFactories LinphoneRtpTransportFactories;
1032 void linphone_core_set_rtp_transport_factories(LinphoneCore* lc, LinphoneRtpTransportFactories *factories);
1034 int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, rtp_stats_t *remote);
1036 const MSList *linphone_core_get_calls(LinphoneCore *lc);
1038 LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc);
1040 * force registration refresh to be initiated upon next iterate
1043 void linphone_core_refresh_registers(LinphoneCore* lc);
1045 /* Path to the file storing secrets cache */
1046 void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file);
1049 const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri);
1051 int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call);
1052 int linphone_core_add_all_to_conference(LinphoneCore *lc);
1053 int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call);
1054 bool_t linphone_core_is_in_conference(const LinphoneCore *lc);
1055 int linphone_core_enter_conference(LinphoneCore *lc);
1056 int linphone_core_leave_conference(LinphoneCore *lc);
1057 float linphone_core_get_conference_local_input_volume(LinphoneCore *lc);
1059 int linphone_core_terminate_conference(LinphoneCore *lc);
1060 int linphone_core_get_conference_size(LinphoneCore *lc);
1062 int linphone_core_get_max_calls(LinphoneCore *lc);
1063 void linphone_core_set_max_calls(LinphoneCore *lc, int max);
1065 bool_t linphone_core_sound_resources_locked(LinphoneCore *lc);
1067 bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, LinphoneMediaEncryption menc);
1070 * Choose media encryption policy to be used for RTP packets
1072 int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc);
1073 LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc);
1075 bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc);
1077 * Defines Linphone behaviour when encryption parameters negociation fails on outoing call.
1078 * If set to TRUE call will fail; if set to FALSE will resend an INVITE with encryption disabled
1080 void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m);
1083 * Init call params using LinphoneCore's current configuration
1085 void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params);