]> sjero.net Git - linphone/blob - linphone/coreapi/linphonecore.h
94d15c258f78182ffccf4240df117b918d24f97f
[linphone] / linphone / coreapi / linphonecore.h
1 /*
2 linphone
3 Copyright (C) 2000  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
43 bool_t payload_type_enabled(struct _PayloadType *pt);
44 void payload_type_set_enable(struct _PayloadType *pt,int value);
45 const char *payload_type_get_description(struct _PayloadType *pt);
46 int payload_type_get_bitrate(PayloadType *pt);
47 const char *payload_type_get_mime(PayloadType *pt);
48 int payload_type_get_rate(PayloadType *pt);
49
50
51 struct _LpConfig;
52
53 typedef struct sip_config
54 {
55         char *contact;
56         char *guessed_contact;
57         int sip_port;
58         MSList *proxies;
59         MSList *deleted_proxies;
60         int inc_timeout;        /*timeout after an un-answered incoming call is rejected*/
61         bool_t use_info;
62         bool_t use_rfc2833;     /*force RFC2833 to be sent*/
63         bool_t guess_hostname;
64         bool_t loopback_only;
65         bool_t ipv6_enabled;
66         bool_t sdp_200_ack;
67         bool_t only_one_codec; /*in SDP answers*/
68         bool_t register_only_when_network_is_up;
69 } sip_config_t;
70
71 typedef struct rtp_config
72 {
73         int audio_rtp_port;
74         int video_rtp_port;
75         int audio_jitt_comp;  /*jitter compensation*/
76         int video_jitt_comp;  /*jitter compensation*/
77         int nortp_timeout;
78 }rtp_config_t;
79
80
81
82 typedef struct net_config
83 {
84         char *nat_address;
85         char *stun_server;
86         char *relay;
87         int download_bw;
88         int upload_bw;
89         int firewall_policy;
90         int mtu;
91         bool_t nat_sdp_only;
92 }net_config_t;
93
94
95 typedef struct sound_config
96 {
97         struct _MSSndCard * ring_sndcard;       /* the playback sndcard currently used */
98         struct _MSSndCard * play_sndcard;       /* the playback sndcard currently used */
99         struct _MSSndCard * capt_sndcard; /* the capture sndcard currently used */
100         const char **cards;
101         int latency;    /* latency in samples of the current used sound device */
102         char rec_lev;
103         char play_lev;
104         char ring_lev;
105         char source;
106         char *local_ring;
107         char *remote_ring;
108         bool_t ec;
109         bool_t ea;
110         bool_t agc;
111 } sound_config_t;
112
113 typedef struct codecs_config
114 {
115         MSList *audio_codecs;  /* list of audio codecs in order of preference*/
116         MSList *video_codecs;   /* for later use*/
117 }codecs_config_t;
118
119 typedef struct video_config{
120         struct _MSWebCam *device;
121         const char **cams;
122         MSVideoSize vsize;
123         bool_t capture;
124         bool_t show_local;
125         bool_t display;
126         bool_t selfview; /*during calls*/
127 }video_config_t;
128
129 typedef struct ui_config
130 {
131         int is_daemon;
132         int is_applet;
133         unsigned int timer_id;  /* the timer id for registration */
134 }ui_config_t;
135
136
137
138 typedef struct autoreplier_config
139 {
140         int enabled;
141         int after_seconds;              /* accept the call after x seconds*/
142         int max_users;                  /* maximum number of user that can call simultaneously */
143         int max_rec_time;       /* the max time of incoming voice recorded */
144         int max_rec_msg;                /* maximum number of recorded messages */
145         const char *message;            /* the path of the file to be played */
146 }autoreplier_config_t;
147
148 struct osip_from;
149
150 /**
151  * Object that represents a SIP address.
152  *
153  * The LinphoneAddress is an opaque object to represents SIP addresses, ie
154  * the content of SIP's 'from' and 'to' headers.
155  * A SIP address is made of display name, username, domain name, port, and various
156  * uri headers (such as tags). It looks like 'Alice <sip:alice@example.net>'.
157  * The LinphoneAddress has methods to extract and manipulate all parts of the address.
158  * When some part of the address (for example the username) is empty, the accessor methods
159  * return NULL.
160  * 
161  * @ingroup linphone_address
162  * @var LinphoneAddress
163  */
164 typedef struct osip_from LinphoneAddress;
165
166 LinphoneAddress * linphone_address_new(const char *uri);
167 LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
168 const char *linphone_address_get_scheme(const LinphoneAddress *u);
169 const char *linphone_address_get_display_name(const LinphoneAddress* u);
170 const char *linphone_address_get_username(const LinphoneAddress *u);
171 const char *linphone_address_get_domain(const LinphoneAddress *u);
172 void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
173 void linphone_address_set_username(LinphoneAddress *uri, const char *username);
174 void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
175 void linphone_address_set_port(LinphoneAddress *uri, const char *port);
176 void linphone_address_set_port_int(LinphoneAddress *uri, int port);
177 /*remove tags, params etc... so that it is displayable to the user*/
178 void linphone_address_clean(LinphoneAddress *uri);
179 char *linphone_address_as_string(const LinphoneAddress *u);
180 char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
181 void linphone_address_destroy(LinphoneAddress *u);
182
183 struct _LinphoneCore;
184 struct _sdp_context;
185 struct _SipSetupContext;
186 struct _LinphoneCall;
187
188 /**
189  * Enum representing the direction of a call.
190  * @ingroup call_logs
191 **/
192 enum _LinphoneCallDir {
193         LinphoneCallOutgoing, /**< outgoing calls*/
194         LinphoneCallIncoming  /**< incoming calls*/
195 };
196
197 /**
198  * Typedef for enum
199  * @ingroup call_logs
200 **/
201 typedef enum _LinphoneCallDir LinphoneCallDir;
202
203 /**
204  * Enum representing the status of a call
205  * @ingroup call_logs
206 **/
207 typedef enum _LinphoneCallStatus { 
208         LinphoneCallSuccess, /**< The call was sucessful*/
209         LinphoneCallAborted, /**< The call was aborted */
210         LinphoneCallMissed /**< The call was missed (unanswered)*/
211 } LinphoneCallStatus;
212
213 /**
214  * Structure representing a call log.
215  *
216  * @ingroup call_logs
217  * 
218 **/
219 typedef struct _LinphoneCallLog{
220         LinphoneCallDir dir; /**< The direction of the call*/
221         LinphoneCallStatus status; /**< The status of the call*/
222         LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
223         LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
224         char start_date[128]; /**<Human readable string containg the start date*/
225         int duration; /**<Duration of the call in seconds*/
226         char *refkey;
227         void *user_pointer;
228         struct _LinphoneCore *lc;
229 } LinphoneCallLog;
230
231
232
233 /*public: */
234 void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
235 void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
236 void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
237 const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
238 char * linphone_call_log_to_str(LinphoneCallLog *cl);
239
240 typedef enum{
241         LinphoneSPWait,
242         LinphoneSPDeny,
243         LinphoneSPAccept
244 }LinphoneSubscribePolicy;
245
246 typedef enum _LinphoneOnlineStatus{
247         LINPHONE_STATUS_UNKNOWN,
248         LINPHONE_STATUS_ONLINE,
249         LINPHONE_STATUS_BUSY,
250         LINPHONE_STATUS_BERIGHTBACK,
251         LINPHONE_STATUS_AWAY,
252         LINPHONE_STATUS_ONTHEPHONE,
253         LINPHONE_STATUS_OUTTOLUNCH,
254         LINPHONE_STATUS_NOT_DISTURB,
255         LINPHONE_STATUS_MOVED,
256         LINPHONE_STATUS_ALT_SERVICE,
257         LINPHONE_STATUS_OFFLINE,
258         LINPHONE_STATUS_PENDING,
259         LINPHONE_STATUS_CLOSED,
260         LINPHONE_STATUS_END
261 }LinphoneOnlineStatus;
262
263 const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
264
265 typedef struct _LinphoneFriend{
266         LinphoneAddress *uri;
267         int in_did;
268         int out_did;
269         int sid;
270         int nid;
271         LinphoneSubscribePolicy pol;
272         LinphoneOnlineStatus status;
273         struct _LinphoneProxyConfig *proxy;
274         struct _LinphoneCore *lc;
275         BuddyInfo *info;
276         char *refkey;
277         bool_t subscribe;
278         bool_t inc_subscribe_pending;
279 }LinphoneFriend;        
280
281 LinphoneFriend * linphone_friend_new();
282 LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
283 int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri);
284 int linphone_friend_set_name(LinphoneFriend *fr, const char *name);
285 int linphone_friend_send_subscribe(LinphoneFriend *fr, bool_t val);
286 int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
287 int linphone_friend_set_proxy(LinphoneFriend *fr, struct _LinphoneProxyConfig *cfg);
288 void linphone_friend_edit(LinphoneFriend *fr);
289 void linphone_friend_done(LinphoneFriend *fr);
290 void linphone_friend_destroy(LinphoneFriend *lf);
291 const LinphoneAddress *linphone_friend_get_uri(const LinphoneFriend *lf);
292 bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf);
293 LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
294 LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
295 BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
296 void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
297 const char *linphone_friend_get_ref_key(const LinphoneFriend *lf);
298 #define linphone_friend_in_list(lf)     ((lf)->lc!=NULL)
299
300 #define linphone_friend_url(lf) ((lf)->url)
301
302 /**
303  * @addtogroup proxies
304  * @{
305 **/
306 /**
307  * The LinphoneProxyConfig object represents a proxy configuration to be used
308  * by the LinphoneCore object.
309  * Its fields must not be used directly in favour of the accessors methods.
310  * Once created and filled properly the LinphoneProxyConfig can be given to
311  * LinphoneCore with linphone_core_add_proxy_config().
312  * This will automatically triggers the registration, if enabled.
313  *
314  * The proxy configuration are persistent to restarts because they are saved
315  * in the configuration file. As a consequence, after linphone_core_new() there
316  * might already be a list of configured proxy that can be examined with
317  * linphone_core_get_proxy_config_list().
318  *
319  * The default proxy (see linphone_core_set_default_proxy() ) is the one of the list
320  * that is used by default for calls.
321 **/
322 typedef struct _LinphoneProxyConfig
323 {
324         struct _LinphoneCore *lc;
325         char *reg_proxy;
326         char *reg_identity;
327         char *reg_route;
328         char *realm;
329         int expires;
330         int reg_time;
331         int rid;
332         char *type;
333         struct _SipSetupContext *ssctx;
334         int auth_failures;
335         char *contact_addr; /* our IP address as seen by the proxy, read from via 's received= parameter*/
336         int contact_port; /*our IP port as seen by the proxy, read from via's rport= parameter */
337         char *dial_prefix;
338         bool_t commit;
339         bool_t reg_sendregister;
340         bool_t registered;
341         bool_t publish;
342         bool_t dial_escape_plus;
343 } LinphoneProxyConfig;
344
345 LinphoneProxyConfig *linphone_proxy_config_new(void);
346 int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
347 void linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
348 void linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
349 void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires);
350 void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val);
351 #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register
352 void linphone_proxy_config_edit(LinphoneProxyConfig *obj);
353 int linphone_proxy_config_done(LinphoneProxyConfig *obj);
354 void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
355 bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
356 const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
357 /** Returns the proxy configured identity as a const char * */
358 #define linphone_proxy_config_get_route(obj)  ((obj)->reg_route)
359 /** Returns the proxy configured identity as a const char * */
360 #define linphone_proxy_config_get_identity(obj) ((obj)->reg_identity)
361 #define linphone_proxy_config_publish_enabled(obj) ((obj)->publish)
362 /** Returns the proxy sip address as const char * */
363 #define linphone_proxy_config_get_addr(obj) ((obj)->reg_proxy)
364 /** Returns the 'expire' time of the registration */
365 #define linphone_proxy_config_get_expires(obj)  ((obj)->expires)
366 /** Returns TRUE if registration is enabled, FALSE otherwise */
367 #define linphone_proxy_config_register_enabled(obj) ((obj)->reg_sendregister)
368 #define linphone_proxy_config_get_core(obj) ((obj)->lc)
369 /* destruction is called automatically when removing the proxy config */
370 void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
371 void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
372 SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
373 SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
374
375 /**
376  * @}
377 **/
378
379 typedef struct _LinphoneAccountCreator{
380         struct _LinphoneCore *lc;
381         struct _SipSetupContext *ssctx;
382         char *username;
383         char *password;
384         char *domain;
385         bool_t succeeded;
386 }LinphoneAccountCreator;
387
388 LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
389 void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
390 void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
391 void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
392 const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
393 const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
394 int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
395 LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
396 void linphone_account_creator_destroy(LinphoneAccountCreator *obj);
397
398 /**
399  * @ingroup authentication
400  * Object holding authentication information.
401  *
402  * @note The object's fields should not be accessed directly. Prefer using
403  * the accessor methods.
404  *
405  * In most case, authentication information consists of a username and password.
406  * Sometimes, a userid is required by proxy, and realm can be useful to discriminate
407  * different SIP domains.
408  *
409  * Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
410  * order to become known and used automatically when needed. 
411  * Use linphone_core_add_auth_info() for that purpose.
412  *
413  * The LinphoneCore object can take the initiative to request authentication information
414  * when needed to the application through the auth_info_requested callback of the
415  * LinphoneCoreVTable structure.
416  *
417  * The application can respond to this information request later using 
418  * linphone_core_add_auth_info(). This will unblock all pending authentication 
419  * transactions and retry them with authentication headers.
420  *
421 **/
422 typedef struct _LinphoneAuthInfo
423 {
424         char *username;
425         char *realm;
426         char *userid;
427         char *passwd;
428         char *ha1;
429         bool_t works;
430         bool_t first_time;
431 }LinphoneAuthInfo;
432
433 LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
434                 const char *passwd, const char *ha1,const char *realm);
435 void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
436 void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
437 void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
438 /* you don't need those function*/
439 void linphone_auth_info_destroy(LinphoneAuthInfo *info);
440 LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos);
441
442 struct _LinphoneChatRoom{
443         struct _LinphoneCore *lc;
444         char  *peer;
445         char *route;
446         LinphoneAddress *peer_url;
447         void * user_data;
448 };
449 typedef struct _LinphoneChatRoom LinphoneChatRoom;
450
451 LinphoneChatRoom * linphone_core_create_chat_room(struct _LinphoneCore *lc, const char *to);
452 void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
453 void linphone_chat_room_destroy(LinphoneChatRoom *cr);
454 void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
455 void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);
456
457 /* describes the different groups of states */
458 typedef enum _gstate_group {
459   GSTATE_GROUP_POWER,
460   GSTATE_GROUP_REG,
461   GSTATE_GROUP_CALL
462 } gstate_group_t;
463
464 typedef enum _gstate {
465   /* states for GSTATE_GROUP_POWER */
466   GSTATE_POWER_OFF = 0,        /* initial state */
467   GSTATE_POWER_STARTUP,
468   GSTATE_POWER_ON,
469   GSTATE_POWER_SHUTDOWN,
470   /* states for GSTATE_GROUP_REG */
471   GSTATE_REG_NONE = 10,       /* initial state */
472   GSTATE_REG_OK,
473   GSTATE_REG_FAILED,
474   /* states for GSTATE_GROUP_CALL */
475   GSTATE_CALL_IDLE = 20,      /* initial state */
476   GSTATE_CALL_OUT_INVITE,
477   GSTATE_CALL_OUT_CONNECTED,
478   GSTATE_CALL_IN_INVITE,
479   GSTATE_CALL_IN_CONNECTED,
480   GSTATE_CALL_END,
481   GSTATE_CALL_ERROR,
482   GSTATE_INVALID
483 } gstate_t;
484
485 struct _LinphoneGeneralState {
486   gstate_t old_state;
487   gstate_t new_state;
488   gstate_group_t group;
489   const char *message;
490 };
491 typedef struct _LinphoneGeneralState LinphoneGeneralState;
492
493 /* private: set a new state */
494 void gstate_new_state(struct _LinphoneCore *lc, gstate_t new_state, const char *message);
495 /*private*/
496 void gstate_initialize(struct _LinphoneCore *lc) ;
497
498 /**
499  * @addtogroup initializing
500  * @{
501 **/
502
503 /** Callback prototype */
504 typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
505 /** Callback prototype */
506 typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, const char *from);
507 /** Callback prototype */
508 typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, const char *from);
509 /** Callback prototype */
510 typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
511 /** Callback prototype */
512 typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
513 /** Callback prototype */
514 typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
515 /** Callback prototype */
516 typedef void (*DisplayQuestionCb)(struct _LinphoneCore *lc, const char *message);
517 /** Callback prototype */
518 typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
519 /** Callback prototype */
520 typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid, const char *url, const char *status, const char *img);
521 /** Callback prototype */
522 typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
523 /** Callback prototype */
524 typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
525 /** Callback prototype */
526 typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
527 /** Callback prototype */
528 typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
529 /** Callback prototype */
530 typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate);
531 /** Callback prototype */
532 typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
533 /** Callback prototype */
534 typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
535 /** Callback prototype */
536 typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
537
538 /**
539  * This structure holds all callbacks that the application should implement.
540  * 
541 **/
542 typedef struct _LinphoneVTable
543 {
544         ShowInterfaceCb show; /**< Notifies the application that it should show up*/
545         InviteReceivedCb inv_recv; /**< Notifies incoming calls */
546         ByeReceivedCb bye_recv; /**< Notify calls terminated by far end*/
547         NotifyReceivedCb notify_recv; /**< Notify received presence events*/
548         NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
549         AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
550         DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
551         DisplayMessageCb display_message;/**< Callback to display a message to the user */
552 #ifdef VINCENT_MAURY_RSVP
553         /* the yes/no dialog box */
554         DisplayMessageCb display_yes_no;
555 #endif
556         DisplayMessageCb display_warning;/** Callback to display a warning to the user */
557         DisplayUrlCb display_url;
558         DisplayQuestionCb display_question;
559         CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
560         TextMessageReceived text_received; /**< A text message has been received */
561         GeneralStateChange general_state; /**< State notification callback */
562         DtmfReceived dtmf_received; /**< A dtmf has been received received */
563         ReferReceived refer_received; /**< A refer was received */
564         BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
565 } LinphoneCoreVTable;
566
567 /**
568  * @}
569 **/
570
571 typedef struct _LCCallbackObj
572 {
573   LinphoneCoreCbFunc _func;
574   void * _user_data;
575 }LCCallbackObj;
576
577
578
579 typedef enum _LinphoneFirewallPolicy{
580         LINPHONE_POLICY_NO_FIREWALL,
581         LINPHONE_POLICY_USE_NAT_ADDRESS,
582         LINPHONE_POLICY_USE_STUN
583 } LinphoneFirewallPolicy;
584
585 typedef enum _LinphoneWaitingState{
586         LinphoneWaitingStart,
587         LinphoneWaitingProgress,
588         LinphoneWaitingFinished
589 } LinphoneWaitingState;
590 typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
591
592
593 typedef struct _LinphoneCore
594 {
595         LinphoneCoreVTable vtable;
596         struct _LpConfig *config;
597         net_config_t net_conf;
598         sip_config_t sip_conf;
599         rtp_config_t rtp_conf;
600         sound_config_t sound_conf;
601         video_config_t video_conf;
602         codecs_config_t codecs_conf;
603         ui_config_t ui_conf;
604         autoreplier_config_t autoreplier_conf;
605         LinphoneProxyConfig *default_proxy;
606         MSList *friends;
607         MSList *auth_info;
608         struct _RingStream *ringstream;
609         LCCallbackObj preview_finished_cb;
610         bool_t preview_finished;
611         struct _LinphoneCall *call;   /* the current call, in the future it will be a list of calls (conferencing)*/
612         int rid; /*registration id*/
613         MSList *queued_calls;   /* used by the autoreplier */
614         MSList *call_logs;
615         MSList *chatrooms;
616         int max_call_logs;
617         int missed_calls;
618         struct _AudioStream *audiostream;  /**/
619         struct _VideoStream *videostream;
620         struct _VideoStream *previewstream;
621         RtpTransport *a_rtp,*a_rtcp;
622         struct _RtpProfile *local_profile;
623         MSList *bl_reqs;
624         MSList *subscribers;    /* unknown subscribers */
625         int minutes_away;
626         LinphoneOnlineStatus presence_mode;
627         LinphoneOnlineStatus prev_mode;
628         char *alt_contact;
629         void *data;
630         ms_mutex_t lock;
631         char *play_file;
632         char *rec_file;
633         time_t prevtime;
634         int dw_audio_bw;
635         int up_audio_bw;
636         int dw_video_bw;
637         int up_video_bw;
638         int audio_bw;
639         int automatic_action;
640         gstate_t gstate_power;
641         gstate_t gstate_reg;
642         gstate_t gstate_call;
643         LinphoneWaitingCallback wait_cb;
644         void *wait_ctx;
645         bool_t use_files;
646         bool_t apply_nat_settings;
647         bool_t ready;
648         bool_t bl_refresh;
649 #ifdef VINCENT_MAURY_RSVP
650         /* QoS parameters*/
651         int rsvp_enable;
652         int rpc_enable;
653 #endif
654 } LinphoneCore;
655
656
657
658 /* THE main API */
659
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);
666
667 LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
668                                                 const char *config_path, const char *factory_config, void* userdata);
669
670 /* function to be periodically called in a main loop */
671 void linphone_core_iterate(LinphoneCore *lc);
672
673 int linphone_core_invite(LinphoneCore *lc, const char *url);
674
675 int linphone_core_refer(LinphoneCore *lc, const char *url);
676
677 bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
678
679 bool_t linphone_core_in_call(const LinphoneCore *lc);
680
681 int linphone_core_accept_call(LinphoneCore *lc, const char *url);
682
683 int linphone_core_terminate_call(LinphoneCore *lc, const char *url);
684
685 void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);
686
687 int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact);
688
689 const char *linphone_core_get_primary_contact(LinphoneCore *lc);
690
691 void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val);
692 bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);
693
694 bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
695 void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);
696
697 LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
698
699 /*0= no bandwidth limit*/
700 void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
701 void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw);
702
703 int linphone_core_get_download_bandwidth(const LinphoneCore *lc);
704 int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
705
706
707 #ifdef VINCENT_MAURY_RSVP
708 /* QoS functions */
709 int linphone_core_set_rpc_mode(LinphoneCore *lc, int on); /* on = 1 (RPC_ENABLE = 1) */
710 int linphone_core_set_rsvp_mode(LinphoneCore *lc, int on); /* on = 1 (RSVP_ENABLE = 1) */
711 int linphone_core_change_qos(LinphoneCore *lc, int answer); /* answer = 1 for yes, 0 for no */
712 #endif
713
714 /* returns a MSList of PayloadType */
715 const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc);
716
717 int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs);
718 /* returns a MSList of PayloadType */
719 const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);
720
721 int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
722
723 bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
724
725 int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
726
727 void linphone_core_clear_proxy_config(LinphoneCore *lc);
728
729 void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
730
731 const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc);
732
733 void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config);
734
735 void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index);
736
737 int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config);
738
739 void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);
740
741 void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);
742
743 const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);
744
745 LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);
746
747 void linphone_core_abort_authentication(LinphoneCore *lc,  LinphoneAuthInfo *info);
748
749 void linphone_core_clear_all_auth_info(LinphoneCore *lc);
750
751 int linphone_core_get_audio_jittcomp(LinphoneCore *lc);
752
753 void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);
754
755 int linphone_core_get_audio_port(const LinphoneCore *lc);
756
757 int linphone_core_get_video_port(const LinphoneCore *lc);
758
759 int linphone_core_get_nortp_timeout(const LinphoneCore *lc);
760
761 void linphone_core_set_audio_port(LinphoneCore *lc, int port);
762
763 void linphone_core_set_video_port(LinphoneCore *lc, int port);
764
765 void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);
766
767 void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);
768
769 bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc);
770
771 void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833);
772
773 bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc);
774
775 int linphone_core_get_sip_port(LinphoneCore *lc);
776
777 void linphone_core_set_sip_port(LinphoneCore *lc,int port);
778
779 void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);
780
781 int linphone_core_get_inc_timeout(LinphoneCore *lc);
782
783 void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
784
785 const char * linphone_core_get_stun_server(const LinphoneCore *lc);
786
787 void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr);
788
789 const char *linphone_core_get_nat_address(const LinphoneCore *lc);
790
791 void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol);
792
793 LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);
794
795 const char * linphone_core_get_relay_addr(const LinphoneCore *lc);
796
797 int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);
798
799 /* sound functions */
800 /* returns a null terminated static array of string describing the sound devices */ 
801 const char**  linphone_core_get_sound_devices(LinphoneCore *lc);
802 bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
803 bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
804 int linphone_core_get_ring_level(LinphoneCore *lc);
805 int linphone_core_get_play_level(LinphoneCore *lc);
806 int linphone_core_get_rec_level(LinphoneCore *lc);
807 void linphone_core_set_ring_level(LinphoneCore *lc, int level);
808 void linphone_core_set_play_level(LinphoneCore *lc, int level);
809 void linphone_core_set_rec_level(LinphoneCore *lc, int level);
810 const char * linphone_core_get_ringer_device(LinphoneCore *lc);
811 const char * linphone_core_get_playback_device(LinphoneCore *lc);
812 const char * linphone_core_get_capture_device(LinphoneCore *lc);
813 int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid);
814 int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid);
815 int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid);
816 char linphone_core_get_sound_source(LinphoneCore *lc);
817 void linphone_core_set_sound_source(LinphoneCore *lc, char source);
818 void linphone_core_set_ring(LinphoneCore *lc, const char *path);
819 const char *linphone_core_get_ring(const LinphoneCore *lc);
820 void linphone_core_set_ringback(LinphoneCore *lc, const char *path);
821 const char * linphone_core_get_ringback(const LinphoneCore *lc);
822 int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
823 void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val);
824 bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc);
825
826 void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
827 bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);
828
829 void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
830 bool_t linphone_core_agc_enabled(const LinphoneCore *lc);
831
832 void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
833
834 void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os);
835
836 LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);
837
838 void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
839 void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr);
840 void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
841 void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
842 /* a list of LinphoneFriend */
843 const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
844 /* notify all friends that have subscribed */
845 void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os);
846 LinphoneFriend *linphone_core_get_friend_by_uri(const LinphoneCore *lc, const char *uri);
847 LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
848
849 /* returns a list of LinphoneCallLog */
850 const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
851 void linphone_core_clear_call_logs(LinphoneCore *lc);
852
853 /* video support */
854 void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled);
855 bool_t linphone_core_video_enabled(LinphoneCore *lc);
856
857 typedef struct MSVideoSizeDef{
858         MSVideoSize vsize;
859         const char *name;
860 }MSVideoSizeDef;
861 /* returns a zero terminated table of MSVideoSizeDef*/
862 const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc);
863 void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize);
864 MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc);
865 void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
866
867 void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
868 bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);
869
870 void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
871 bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
872
873
874 /* returns a null terminated static array of string describing the webcams */ 
875 const char**  linphone_core_get_video_devices(const LinphoneCore *lc);
876 int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
877 const char *linphone_core_get_video_device(const LinphoneCore *lc);
878
879 /*function to be used for eventually setting window decorations (icons, title...)*/
880 unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
881
882
883 /*play/record support: use files instead of soundcard*/
884 void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
885 void linphone_core_set_play_file(LinphoneCore *lc, const char *file);
886 void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
887
888 gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
889 int linphone_core_get_current_call_duration(const LinphoneCore *lc);
890 const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc);
891
892 int linphone_core_get_mtu(const LinphoneCore *lc);
893 void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
894
895 bool_t linphone_core_is_in_main_thread(LinphoneCore *lc);
896
897 void *linphone_core_get_user_data(LinphoneCore *lc);
898
899 /* returns LpConfig object to read/write to the config file: usefull if you wish to extend
900 the config file with your own sections */
901 struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);
902
903 /* attempts to wake up another linphone engine already running.
904 The "show" callback is called for the other linphone, causing gui to show up.
905 call_addr is an optional sip-uri to call immediately after waking up.
906 The method returns 0 if an already running linphone was found*/
907
908 int linphone_core_wake_up_possible_already_running_instance(
909     const char * config_file, const char * call_addr);
910
911 /*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
912 void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
913
914 /*returns the list of registered SipSetup (linphonecore plugins) */
915 const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);
916
917 void linphone_core_destroy(LinphoneCore *lc);
918
919 /*for advanced users:*/
920 void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp);
921
922 /* end of lecacy api */
923
924 /*internal use only */
925 #define linphone_core_lock(lc)  ms_mutex_lock(&(lc)->lock)
926 #define linphone_core_unlock(lc)        ms_mutex_unlock((&lc)->lock)
927 void linphone_core_start_media_streams(LinphoneCore *lc, struct _LinphoneCall *call);
928 void linphone_core_stop_media_streams(LinphoneCore *lc);
929 const char * linphone_core_get_identity(LinphoneCore *lc);
930 const char * linphone_core_get_route(LinphoneCore *lc);
931 bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAddress **real_parsed_url, char **route);
932 void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
933 void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
934 void linphone_core_stop_waiting(LinphoneCore *lc);
935
936
937 #ifdef __cplusplus
938 }
939 #endif
940
941 #endif