]> sjero.net Git - linphone/blob - coreapi/linphonecore.h
Merge branch 'master' of git.sv.gnu.org:/srv/git/linphone
[linphone] / coreapi / linphonecore.h
1 /*
2 linphone
3 Copyright (C) 2000 - 2010 Simon MORLAT (simon.morlat@linphone.org)
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19 #ifndef LINPHONECORE_H
20 #define LINPHONECORE_H
21
22 #include "ortp/ortp.h"
23 #include "ortp/payloadtype.h"
24 #include "mediastreamer2/mscommon.h"
25 #include "mediastreamer2/msvideo.h"
26
27 #ifdef IN_LINPHONE
28 #include "sipsetup.h"
29 #else
30 #include "linphone/sipsetup.h"
31 #endif
32
33 #define LINPHONE_IPADDR_SIZE 64
34 #define LINPHONE_HOSTNAME_SIZE 128
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct _MSSndCard;
41 struct _LinphoneCore;
42 struct SalOp;
43
44 struct _LpConfig;
45
46
47 struct _LCSipTransports{
48         int udp_port;
49         int tcp_port;
50         int dtls_port;
51         int tls_port;
52 };
53
54 typedef struct _LCSipTransports LCSipTransports;
55
56 /**
57  * Object that represents a SIP address.
58  *
59  * The LinphoneAddress is an opaque object to represents SIP addresses, ie
60  * the content of SIP's 'from' and 'to' headers.
61  * A SIP address is made of display name, username, domain name, port, and various
62  * uri headers (such as tags). It looks like 'Alice <sip:alice@example.net>'.
63  * The LinphoneAddress has methods to extract and manipulate all parts of the address.
64  * When some part of the address (for example the username) is empty, the accessor methods
65  * return NULL.
66  * 
67  * @ingroup linphone_address
68  * @var LinphoneAddress
69  */
70 typedef struct SalAddress LinphoneAddress;
71
72 LinphoneAddress * linphone_address_new(const char *uri);
73 LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
74 const char *linphone_address_get_scheme(const LinphoneAddress *u);
75 const char *linphone_address_get_display_name(const LinphoneAddress* u);
76 const char *linphone_address_get_username(const LinphoneAddress *u);
77 const char *linphone_address_get_domain(const LinphoneAddress *u);
78 /**
79  * Get port number as an integer value.
80  *
81  */
82 int linphone_address_get_port_int(const LinphoneAddress *u);
83 /**
84  * Get port number, null if not present.
85  */
86 const char* linphone_address_get_port(const LinphoneAddress *u);
87 void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
88 void linphone_address_set_username(LinphoneAddress *uri, const char *username);
89 void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
90 void linphone_address_set_port(LinphoneAddress *uri, const char *port);
91 void linphone_address_set_port_int(LinphoneAddress *uri, int port);
92 /*remove tags, params etc... so that it is displayable to the user*/
93 void linphone_address_clean(LinphoneAddress *uri);
94 char *linphone_address_as_string(const LinphoneAddress *u);
95 char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
96 void linphone_address_destroy(LinphoneAddress *u);
97
98 struct _SipSetupContext;
99
100
101 /**
102  * Enum representing the direction of a call.
103  * @ingroup call_logs
104 **/
105 enum _LinphoneCallDir {
106         LinphoneCallOutgoing, /**< outgoing calls*/
107         LinphoneCallIncoming  /**< incoming calls*/
108 };
109
110 /**
111  * Typedef for enum
112  * @ingroup call_logs
113 **/
114 typedef enum _LinphoneCallDir LinphoneCallDir;
115
116 /**
117  * Enum representing the status of a call
118  * @ingroup call_logs
119 **/
120 typedef enum _LinphoneCallStatus { 
121         LinphoneCallSuccess, /**< The call was sucessful*/
122         LinphoneCallAborted, /**< The call was aborted */
123         LinphoneCallMissed /**< The call was missed (unanswered)*/
124 } LinphoneCallStatus;
125
126 /**
127  * Structure representing a call log.
128  *
129  * @ingroup call_logs
130  * 
131 **/
132 typedef struct _LinphoneCallLog{
133         LinphoneCallDir dir; /**< The direction of the call*/
134         LinphoneCallStatus status; /**< The status of the call*/
135         LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
136         LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
137         char start_date[128]; /**<Human readable string containg the start date*/
138         int duration; /**<Duration of the call in seconds*/
139         char *refkey;
140         void *user_pointer;
141         rtp_stats_t local_stats;
142         rtp_stats_t remote_stats;
143         struct _LinphoneCore *lc;
144 } LinphoneCallLog;
145
146
147
148 /*public: */
149 void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
150 void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
151 void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
152 const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
153 const rtp_stats_t *linphone_call_log_get_local_stats(const LinphoneCallLog *cl);
154 const rtp_stats_t *linphone_call_log_get_remote_stats(const LinphoneCallLog *cl);
155 char * linphone_call_log_to_str(LinphoneCallLog *cl);
156
157
158 /**
159  * The LinphoneCallParams is an object contaning various call related parameters.
160  * It can be used to retrieve parameters from a currently running call or modify the call's characterisitcs 
161  * dynamically.
162 **/
163 struct _LinphoneCallParams;
164 typedef struct _LinphoneCallParams LinphoneCallParams;
165
166 void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled);
167 void linphone_call_params_destroy(LinphoneCallParams *cp);
168
169 /**
170  * Enum describing failure reasons.
171 **/
172 enum _LinphoneError{
173         LinphoneErrorNone,
174         LinphoneErrorNoResponse, /**<No response received from remote*/
175         LinphoneErrorBadCredentials /**<Authentication failed due to bad or missing credentials*/
176 };
177
178 typedef enum _LinphoneError LinphoneError;
179
180 const char *linphone_error_to_string(LinphoneError err);
181
182 /**
183  * The LinphoneCall object represents a call issued or received by the LinphoneCore
184 **/
185 struct _LinphoneCall;
186 typedef struct _LinphoneCall LinphoneCall;
187
188 typedef enum _LinphoneCallState{
189         LinphoneCallIdle,
190         LinphoneCallIncomingReceived,
191         LinphoneCallOutgoingInit,
192         LinphoneCallOutgoingProgress,
193         LinphoneCallOutgoingRinging,
194         LinphoneCallOutgoingEarlyMedia,
195         LinphoneCallConnected,
196         LinphoneCallStreamsRunning,
197         LinphoneCallPausing,
198         LinphoneCallPaused,
199         LinphoneCallResuming,
200         LinphoneCallRefered,
201         LinphoneCallError,
202         LinphoneCallEnd,
203         LinphoneCallPausedByRemote
204 } LinphoneCallState;
205
206 const char *linphone_call_state_to_string(LinphoneCallState cs);
207
208
209 LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
210 bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
211 const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
212 const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
213 char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
214 LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call);
215 void linphone_call_ref(LinphoneCall *call);
216 void linphone_call_unref(LinphoneCall *call);
217 LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call);
218 const char *linphone_call_get_refer_to(const LinphoneCall *call);
219 bool_t linphone_call_has_transfer_pending(const LinphoneCall *call);
220 int linphone_call_get_duration(const LinphoneCall *call);
221 const LinphoneCallParams linphone_call_get_current_params(const LinphoneCall *call);
222 void linphone_call_enable_camera(LinphoneCall *lc, bool_t enabled);
223 bool_t linphone_call_camera_enabled(const LinphoneCall *lc);
224 LinphoneError linphone_call_get_error(const LinphoneCall *call);
225 void *linphone_call_get_user_pointer(LinphoneCall *call);
226 void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
227
228 typedef enum{
229         LinphoneSPWait,
230         LinphoneSPDeny,
231         LinphoneSPAccept
232 }LinphoneSubscribePolicy;
233
234 typedef enum _LinphoneOnlineStatus{
235         LinphoneStatusOffline,
236         LinphoneStatusOnline,
237         LinphoneStatusBusy,
238         LinphoneStatusBeRightBack,
239         LinphoneStatusAway,
240         LinphoneStatusOnThePhone,
241         LinphoneStatusOutToLunch,
242         LinphoneStatusDoNotDisturb,
243         LinphoneStatusMoved,
244         LinphoneStatusAltService,
245         LinphoneStatusPending,
246         LinphoneStatusEnd
247 }LinphoneOnlineStatus;
248
249 const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
250
251 struct _LinphoneFriend;
252
253 typedef struct _LinphoneFriend LinphoneFriend;
254
255 LinphoneFriend * linphone_friend_new();
256 LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
257 int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri);
258 int linphone_friend_set_name(LinphoneFriend *fr, const char *name);
259 int linphone_friend_send_subscribe(LinphoneFriend *fr, bool_t val);
260 int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
261 void linphone_friend_edit(LinphoneFriend *fr);
262 void linphone_friend_done(LinphoneFriend *fr);
263 void linphone_friend_destroy(LinphoneFriend *lf);
264 const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
265 bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf);
266 LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
267 LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
268 BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
269 void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
270 const char *linphone_friend_get_ref_key(const LinphoneFriend *lf);
271 bool_t linphone_friend_in_list(const LinphoneFriend *lf);
272
273 #define linphone_friend_url(lf) ((lf)->url)
274
275
276 /**
277  * @addtogroup proxies
278  * @{
279 **/
280 /**
281  * The LinphoneProxyConfig object represents a proxy configuration to be used
282  * by the LinphoneCore object.
283  * Its fields must not be used directly in favour of the accessors methods.
284  * Once created and filled properly the LinphoneProxyConfig can be given to
285  * LinphoneCore with linphone_core_add_proxy_config().
286  * This will automatically triggers the registration, if enabled.
287  *
288  * The proxy configuration are persistent to restarts because they are saved
289  * in the configuration file. As a consequence, after linphone_core_new() there
290  * might already be a list of configured proxy that can be examined with
291  * linphone_core_get_proxy_config_list().
292  *
293  * The default proxy (see linphone_core_set_default_proxy() ) is the one of the list
294  * that is used by default for calls.
295 **/
296 typedef struct _LinphoneProxyConfig LinphoneProxyConfig;
297
298 /**
299  * LinphoneRegistrationState describes proxy registration states.
300 **/
301 typedef enum _LinphoneRegistrationState{
302         LinphoneRegistrationNone,
303         LinphoneRegistrationProgress,
304         LinphoneRegistrationOk,
305         LinphoneRegistrationCleared,
306         LinphoneRegistrationFailed
307 }LinphoneRegistrationState;
308
309 const char *linphone_registration_state_to_string(LinphoneRegistrationState cs);
310
311 LinphoneProxyConfig *linphone_proxy_config_new(void);
312 int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
313 int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
314 int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
315 void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires);
316 void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val);
317 #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register
318 void linphone_proxy_config_edit(LinphoneProxyConfig *obj);
319 int linphone_proxy_config_done(LinphoneProxyConfig *obj);
320 void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
321 void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val);
322 void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix);
323
324 LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj);
325 bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
326 const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
327
328 const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj);
329 const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj);
330 bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj);
331 const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj);
332 int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj);
333 bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj);
334 struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
335
336 bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
337 const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);
338
339 LinphoneError linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg);
340
341 /* destruction is called automatically when removing the proxy config */
342 void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
343 void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
344 SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
345 SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
346 /**
347  * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
348  */
349 int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len);
350 /*
351  *  attached a user data to a proxy config
352  */
353 void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cr, void * ud);
354 /*
355  *  get user data to a proxy config. return null if any
356  */
357 void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr);
358
359 /**
360  * @}
361 **/
362
363 typedef struct _LinphoneAccountCreator{
364         struct _LinphoneCore *lc;
365         struct _SipSetupContext *ssctx;
366         char *username;
367         char *password;
368         char *domain;
369         bool_t succeeded;
370 }LinphoneAccountCreator;
371
372 LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
373 void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
374 void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
375 void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
376 const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
377 const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
378 int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
379 LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
380 void linphone_account_creator_destroy(LinphoneAccountCreator *obj);
381
382 struct _LinphoneAuthInfo;
383
384 /**
385  * @ingroup authentication
386  * Object holding authentication information.
387  *
388  * @note The object's fields should not be accessed directly. Prefer using
389  * the accessor methods.
390  *
391  * In most case, authentication information consists of a username and password.
392  * Sometimes, a userid is required by proxy, and realm can be useful to discriminate
393  * different SIP domains.
394  *
395  * Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
396  * order to become known and used automatically when needed. 
397  * Use linphone_core_add_auth_info() for that purpose.
398  *
399  * The LinphoneCore object can take the initiative to request authentication information
400  * when needed to the application through the auth_info_requested callback of the
401  * LinphoneCoreVTable structure.
402  *
403  * The application can respond to this information request later using 
404  * linphone_core_add_auth_info(). This will unblock all pending authentication 
405  * transactions and retry them with authentication headers.
406  *
407 **/
408 typedef struct _LinphoneAuthInfo LinphoneAuthInfo;
409
410 LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
411                 const char *passwd, const char *ha1,const char *realm);
412 void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
413 void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
414 void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
415
416 const char *linphone_auth_info_get_username(const LinphoneAuthInfo *i);
417 const char *linphone_auth_info_get_passwd(const LinphoneAuthInfo *i);
418 const char *linphone_auth_info_get_userid(const LinphoneAuthInfo *i);
419
420 /* you don't need those function*/
421 void linphone_auth_info_destroy(LinphoneAuthInfo *info);
422 LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos);
423
424 struct _LinphoneChatRoom;
425 typedef struct _LinphoneChatRoom LinphoneChatRoom;
426
427 LinphoneChatRoom * linphone_core_create_chat_room(struct _LinphoneCore *lc, const char *to);
428 void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
429 void linphone_chat_room_destroy(LinphoneChatRoom *cr);
430 void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
431 void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);
432
433 typedef enum _LinphoneGlobalState{
434         LinphoneGlobalOff,
435         LinphoneGlobalStartup,
436         LinphoneGlobalOn,
437         LinphoneGlobalShutdown
438 }LinphoneGlobalState;
439
440 const char *linphone_global_state_to_string(LinphoneGlobalState gs);
441
442 /**
443  * @addtogroup initializing
444  * @{
445 **/
446
447
448 /**Call state notification callback prototype*/
449 typedef void (*LinphoneGlobalStateCb)(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
450 /**Call state notification callback prototype*/
451 typedef void (*LinphoneCallStateCb)(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
452 /**Registration state notification callback prototype*/
453 typedef void (*LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
454 /** Callback prototype */
455 typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
456 /** Callback prototype */
457 typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
458 /** Callback prototype */
459 typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
460 /** Callback prototype */
461 typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
462 /** Callback prototype */
463 typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
464 /** Callback prototype */
465 typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const char *from, const char *event);
466 /** Callback prototype */
467 typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid);
468 /** Callback prototype */
469 typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
470 /** Callback prototype */
471 typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
472 /** Callback prototype */
473 typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
474 /** Callback prototype */
475 typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
476 /** Callback prototype */
477 typedef void (*DtmfReceived)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf);
478 /** Callback prototype */
479 typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
480 /** Callback prototype */
481 typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
482
483 /**
484  * This structure holds all callbacks that the application should implement.
485  *  None is mandatory.
486 **/
487 typedef struct _LinphoneVTable{
488         LinphoneGlobalStateCb global_state_changed; /**<Notifies globlal state changes*/
489         LinphoneRegistrationStateCb registration_state_changed;/**<Notifies registration state changes*/
490         LinphoneCallStateCb call_state_changed;/**<Notifies call state changes*/
491         NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
492         NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
493         AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
494         CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
495         TextMessageReceived text_received; /**< A text message has been received */
496         DtmfReceived dtmf_received; /**< A dtmf has been received received */
497         ReferReceived refer_received; /**< An out of call refer was received */
498         BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
499         NotifyReceivedCb notify_recv; /**< Other notifications*/
500         DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
501         DisplayMessageCb display_message;/**< Callback to display a message to the user */
502         DisplayMessageCb display_warning;/** Callback to display a warning to the user */
503         DisplayUrlCb display_url;
504         ShowInterfaceCb show; /**< Notifies the application that it should show up*/
505 } LinphoneCoreVTable;
506
507 /**
508  * @}
509 **/
510
511 typedef struct _LCCallbackObj
512 {
513   LinphoneCoreCbFunc _func;
514   void * _user_data;
515 }LCCallbackObj;
516
517
518
519 typedef enum _LinphoneFirewallPolicy{
520         LinphonePolicyNoFirewall,
521         LinphonePolicyUseNatAddress,
522         LinphonePolicyUseStun
523 } LinphoneFirewallPolicy;
524
525 typedef enum _LinphoneWaitingState{
526         LinphoneWaitingStart,
527         LinphoneWaitingProgress,
528         LinphoneWaitingFinished
529 } LinphoneWaitingState;
530 typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
531
532 typedef struct _LinphoneCore LinphoneCore;
533
534 /* THE main API */
535
536 void linphone_core_enable_logs(FILE *file);
537 void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
538 void linphone_core_disable_logs(void);
539 /*sets the user-agent string in sip messages, must be set before linphone_core_new() or linphone_core_init() */
540 void linphone_core_set_user_agent(const char *ua_name, const char *version);
541 const char *linphone_core_get_version(void);
542
543 LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
544                                                 const char *config_path, const char *factory_config, void* userdata);
545
546 /* function to be periodically called in a main loop */
547 void linphone_core_iterate(LinphoneCore *lc);
548
549 LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);
550
551 LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url);
552
553 LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
554
555 LinphoneCall * linphone_core_invite_with_params(LinphoneCore *lc, const char *url, const LinphoneCallParams *params);
556
557 LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params);
558
559 int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to);
560
561 bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
562
563 bool_t linphone_core_in_call(const LinphoneCore *lc);
564
565 LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc);
566
567 int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);
568
569 int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
570
571 int linphone_core_terminate_all_calls(LinphoneCore *lc);
572
573 int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);
574
575 int linphone_core_pause_all_calls(LinphoneCore *lc);
576
577 int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call);
578
579 int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, LinphoneCallParams *params);
580
581 LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc);
582
583 LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address);
584
585 void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);
586
587 int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact);
588
589 const char *linphone_core_get_primary_contact(LinphoneCore *lc);
590
591 void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val);
592 bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);
593
594 bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
595 void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);
596
597 LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
598 const char * linphone_core_get_identity(LinphoneCore *lc);
599 /*0= no bandwidth limit*/
600 void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
601 void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw);
602
603 int linphone_core_get_download_bandwidth(const LinphoneCore *lc);
604 int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
605 /**
606  * set audio packetization time linphone expect to received from peer
607  * @ingroup media_parameters
608  *
609  */
610 void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime);
611 /**
612  * get audio packetization time linphone expect to received from peer, 0 means unspecified
613  * @ingroup media_parameters
614  */
615 int  linphone_core_get_download_ptime(LinphoneCore *lc);
616
617 /* returns a MSList of PayloadType */
618 const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc);
619
620 int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs);
621 /* returns a MSList of PayloadType */
622 const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);
623
624 int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
625
626 bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);
627
628 int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable);
629
630 PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) ;
631
632 const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt);
633
634 bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
635
636 int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
637
638 void linphone_core_clear_proxy_config(LinphoneCore *lc);
639
640 void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
641
642 const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc);
643
644 void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config);
645
646 void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index);
647
648 int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config);
649
650 void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
651
652 void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
653
654 const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);
655
656 const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);
657
658 void linphone_core_abort_authentication(LinphoneCore *lc,  LinphoneAuthInfo *info);
659
660 void linphone_core_clear_all_auth_info(LinphoneCore *lc);
661
662 int linphone_core_get_audio_jittcomp(LinphoneCore *lc);
663
664 void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);
665
666 int linphone_core_get_audio_port(const LinphoneCore *lc);
667
668 int linphone_core_get_video_port(const LinphoneCore *lc);
669
670 int linphone_core_get_nortp_timeout(const LinphoneCore *lc);
671
672 void linphone_core_set_audio_port(LinphoneCore *lc, int port);
673
674 void linphone_core_set_video_port(LinphoneCore *lc, int port);
675
676 void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);
677
678 void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);
679
680 bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc);
681
682 void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833);
683
684 bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc);
685
686 void linphone_core_set_sip_port(LinphoneCore *lc, int port);
687
688 int linphone_core_get_sip_port(LinphoneCore *lc);
689
690 int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports);
691
692 int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports);
693
694 ortp_socket_t linphone_core_get_sip_socket(LinphoneCore *lc);
695
696 void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);
697
698 int linphone_core_get_inc_timeout(LinphoneCore *lc);
699
700 void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
701
702 const char * linphone_core_get_stun_server(const LinphoneCore *lc);
703
704 void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr);
705
706 const char *linphone_core_get_nat_address(const LinphoneCore *lc);
707
708 void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol);
709
710 LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);
711
712 const char * linphone_core_get_relay_addr(const LinphoneCore *lc);
713
714 int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);
715
716 /* sound functions */
717 /* returns a null terminated static array of string describing the sound devices */ 
718 const char**  linphone_core_get_sound_devices(LinphoneCore *lc);
719 bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
720 bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
721 int linphone_core_get_ring_level(LinphoneCore *lc);
722 int linphone_core_get_play_level(LinphoneCore *lc);
723 int linphone_core_get_rec_level(LinphoneCore *lc);
724 void linphone_core_set_ring_level(LinphoneCore *lc, int level);
725 void linphone_core_set_play_level(LinphoneCore *lc, int level);
726
727 void linphone_core_set_playback_gain_db(LinphoneCore *lc, float level);
728
729 float linphone_core_get_playback_gain_db(LinphoneCore *lc);
730 void linphone_core_set_rec_level(LinphoneCore *lc, int level);
731 const char * linphone_core_get_ringer_device(LinphoneCore *lc);
732 const char * linphone_core_get_playback_device(LinphoneCore *lc);
733 const char * linphone_core_get_capture_device(LinphoneCore *lc);
734 int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid);
735 int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid);
736 int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid);
737 char linphone_core_get_sound_source(LinphoneCore *lc);
738 void linphone_core_set_sound_source(LinphoneCore *lc, char source);
739 void linphone_core_set_ring(LinphoneCore *lc, const char *path);
740 const char *linphone_core_get_ring(const LinphoneCore *lc);
741 void linphone_core_set_ringback(LinphoneCore *lc, const char *path);
742 const char * linphone_core_get_ringback(const LinphoneCore *lc);
743 int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
744 void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val);
745 bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc);
746
747 void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
748 bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);
749
750 void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
751 bool_t linphone_core_agc_enabled(const LinphoneCore *lc);
752
753 void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
754 /**
755  * return mic state.
756  *
757  * @ingroup media_parameters
758 **/
759 bool_t linphone_core_is_mic_muted(LinphoneCore *lc);
760
761 bool_t linphone_core_is_audio_muted(LinphoneCore *lc);
762 bool_t linphone_core_is_rtp_muted(LinphoneCore *lc);
763
764 bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc);
765 void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, bool_t val);
766
767 void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os);
768
769 LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);
770
771 void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
772 void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr);
773 void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
774 void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
775 /* a list of LinphoneFriend */
776 const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
777 /* notify all friends that have subscribed */
778 void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os);
779 LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr);
780 LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
781
782 /* returns a list of LinphoneCallLog */
783 const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
784 void linphone_core_clear_call_logs(LinphoneCore *lc);
785
786 /* video support */
787 void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled);
788 bool_t linphone_core_video_enabled(LinphoneCore *lc);
789
790 typedef struct MSVideoSizeDef{
791         MSVideoSize vsize;
792         const char *name;
793 }MSVideoSizeDef;
794 /* returns a zero terminated table of MSVideoSizeDef*/
795 const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc);
796 void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize);
797 MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc);
798 void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
799
800 void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
801 bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);
802
803 void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
804 bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
805
806
807 /* returns a null terminated static array of string describing the webcams */ 
808 const char**  linphone_core_get_video_devices(const LinphoneCore *lc);
809 int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
810 const char *linphone_core_get_video_device(const LinphoneCore *lc);
811
812 /* Set static picture to be used when "Static picture" is the video device */
813 int linphone_core_set_static_picture(LinphoneCore *lc, const char *path);
814
815 /* Set and get frame rate for static picture */
816 int linphone_core_set_static_picture_fps(LinphoneCore *lc, float fps);
817 float linphone_core_get_static_picture_fps(LinphoneCore *lc);
818
819 /*function to be used for eventually setting window decorations (icons, title...)*/
820 unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
821
822
823 /*play/record support: use files instead of soundcard*/
824 void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
825 void linphone_core_set_play_file(LinphoneCore *lc, const char *file);
826 void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
827
828 void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms);
829 void linphone_core_stop_dtmf(LinphoneCore *lc);
830
831
832 int linphone_core_get_current_call_duration(const LinphoneCore *lc);
833
834
835 int linphone_core_get_mtu(const LinphoneCore *lc);
836 void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
837
838 /**
839  * This method is called by the application to notify the linphone core library when network is reachable.
840  * Calling this method with true trigger linphone to initiate a registration process for all proxy
841  * configuration with parameter register set to enable.
842  * This method disable the automatic registration mode. It means you must call this method after each network state changes
843  *
844  */
845 void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value);
846 /**
847  * return network state either as positioned by the application or by linphone
848  */
849 bool_t linphone_core_is_network_reachabled(LinphoneCore* lc);
850
851
852 void *linphone_core_get_user_data(LinphoneCore *lc);
853
854 /* returns LpConfig object to read/write to the config file: usefull if you wish to extend
855 the config file with your own sections */
856 struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);
857
858 /* attempts to wake up another linphone engine already running.
859 The "show" callback is called for the other linphone, causing gui to show up.
860 call_addr is an optional sip-uri to call immediately after waking up.
861 The method returns 0 if an already running linphone was found*/
862
863 int linphone_core_wake_up_possible_already_running_instance(
864     const char * config_file, const char * call_addr);
865
866 /*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
867 void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
868
869 /*returns the list of registered SipSetup (linphonecore plugins) */
870 const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);
871
872 void linphone_core_destroy(LinphoneCore *lc);
873
874 /*for advanced users:*/
875 void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp);
876
877 int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, rtp_stats_t *remote);
878
879 const MSList *linphone_core_get_calls(LinphoneCore *lc);
880
881 LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc);
882
883 #ifdef __cplusplus
884 }
885 #endif
886
887
888
889 #endif