source: mediastreamer2/linphone/coreapi/linphonecore.h @ 797:204f2e97bc62

Last change on this file since 797:204f2e97bc62 was 797:204f2e97bc62, checked in by smorlat <smorlat@…>, 4 years ago

Add API docs for liblinphone.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@785 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File size: 34.2 KB
Line 
1/*
2linphone
3Copyright (C) 2000  Simon MORLAT (simon.morlat@linphone.org)
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, 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
37extern "C" {
38#endif
39
40struct _MSSndCard;
41struct _LinphoneCore;
42
43bool_t payload_type_enabled(struct _PayloadType *pt);
44void payload_type_set_enable(struct _PayloadType *pt,int value);
45const char *payload_type_get_description(struct _PayloadType *pt);
46int payload_type_get_bitrate(PayloadType *pt);
47const char *payload_type_get_mime(PayloadType *pt);
48int payload_type_get_rate(PayloadType *pt);
49
50
51struct _LpConfig;
52
53typedef 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
71typedef 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
82typedef 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
95typedef 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
113typedef 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
119typedef 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
129typedef 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
138typedef 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
148struct 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 */
164typedef struct osip_from LinphoneAddress;
165
166LinphoneAddress * linphone_address_new(const char *uri);
167LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
168const char *linphone_address_get_scheme(const LinphoneAddress *u);
169const char *linphone_address_get_display_name(const LinphoneAddress* u);
170const char *linphone_address_get_username(const LinphoneAddress *u);
171const char *linphone_address_get_domain(const LinphoneAddress *u);
172void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
173void linphone_address_set_username(LinphoneAddress *uri, const char *username);
174void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
175void linphone_address_set_port(LinphoneAddress *uri, const char *port);
176void linphone_address_set_port_int(LinphoneAddress *uri, int port);
177/*remove tags, params etc... so that it is displayable to the user*/
178void linphone_address_clean(LinphoneAddress *uri);
179char *linphone_address_as_string(const LinphoneAddress *u);
180char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
181void linphone_address_destroy(LinphoneAddress *u);
182
183struct _LinphoneCore;
184struct _sdp_context;
185struct _SipSetupContext;
186struct _LinphoneCall;
187
188/**
189 * Enum representing the direction of a call.
190 * @ingroup call_logs
191**/
192enum _LinphoneCallDir {
193        LinphoneCallOutgoing, /**< outgoing calls*/
194        LinphoneCallIncoming  /**< incoming calls*/
195};
196
197/**
198 * Typedef for enum
199 * @ingroup call_logs
200**/
201typedef enum _LinphoneCallDir LinphoneCallDir;
202
203/**
204 * Enum representing the status of a call
205 * @ingroup call_logs
206**/
207typedef 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**/
219typedef 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: */
234void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
235void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
236void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
237const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
238char * linphone_call_log_to_str(LinphoneCallLog *cl);
239
240typedef enum{
241        LinphoneSPWait,
242        LinphoneSPDeny,
243        LinphoneSPAccept
244}LinphoneSubscribePolicy;
245
246typedef 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
263const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
264
265typedef 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
281LinphoneFriend * linphone_friend_new();
282LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
283int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri);
284int linphone_friend_set_name(LinphoneFriend *fr, const char *name);
285int linphone_friend_send_subscribe(LinphoneFriend *fr, bool_t val);
286int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
287int linphone_friend_set_proxy(LinphoneFriend *fr, struct _LinphoneProxyConfig *cfg);
288void linphone_friend_edit(LinphoneFriend *fr);
289void linphone_friend_done(LinphoneFriend *fr);
290void linphone_friend_destroy(LinphoneFriend *lf);
291const LinphoneAddress *linphone_friend_get_uri(const LinphoneFriend *lf);
292bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf);
293LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
294LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
295BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
296void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
297const 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**/
322typedef 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        bool_t commit;
338        bool_t reg_sendregister;
339        bool_t registered;
340        bool_t publish;
341} LinphoneProxyConfig;
342
343LinphoneProxyConfig *linphone_proxy_config_new(void);
344int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
345void linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
346void linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
347void linphone_proxy_config_expires(LinphoneProxyConfig *obj, const int expires);
348void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val);
349#define linphone_proxy_config_enableregister linphone_proxy_config_enable_register
350void linphone_proxy_config_edit(LinphoneProxyConfig *obj);
351int linphone_proxy_config_done(LinphoneProxyConfig *obj);
352void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
353bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
354const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
355
356/** Returns the proxy configured identity as a const char * */
357#define linphone_proxy_config_get_route(obj)  ((obj)->reg_route)
358/** Returns the proxy configured identity as a const char * */
359#define linphone_proxy_config_get_identity(obj) ((obj)->reg_identity)
360#define linphone_proxy_config_publish_enabled(obj) ((obj)->publish)
361/** Returns the proxy sip address as const char * */
362#define linphone_proxy_config_get_addr(obj) ((obj)->reg_proxy)
363/** Returns the 'expire' time of the registration */
364#define linphone_proxy_config_get_expires(obj)  ((obj)->expires)
365/** Returns TRUE if registration is enabled, FALSE otherwise */
366#define linphone_proxy_config_register_enabled(obj) ((obj)->reg_sendregister)
367#define linphone_proxy_config_get_core(obj) ((obj)->lc)
368/* destruction is called automatically when removing the proxy config */
369void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
370void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
371SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
372SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
373
374/**
375 * @}
376**/
377
378typedef struct _LinphoneAccountCreator{
379        struct _LinphoneCore *lc;
380        struct _SipSetupContext *ssctx;
381        char *username;
382        char *password;
383        char *domain;
384        bool_t succeeded;
385}LinphoneAccountCreator;
386
387LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
388void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
389void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
390void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
391const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
392const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
393int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
394LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
395void linphone_account_creator_destroy(LinphoneAccountCreator *obj);
396
397/**
398 * @ingroup authentication
399 * Object holding authentication information.
400 *
401 * @note The object's fields should not be accessed directly. Prefer using
402 * the accessor methods.
403 *
404 * In most case, authentication information consists of a username and password.
405 * Sometimes, a userid is required by proxy, and realm can be useful to discriminate
406 * different SIP domains.
407 *
408 * Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
409 * order to become known and used automatically when needed.
410 * Use linphone_core_add_auth_info() for that purpose.
411 *
412 * The LinphoneCore object can take the initiative to request authentication information
413 * when needed to the application through the auth_info_requested callback of the
414 * LinphoneCoreVTable structure.
415 *
416 * The application can respond to this information request later using
417 * linphone_core_add_auth_info(). This will unblock all pending authentication
418 * transactions and retry them with authentication headers.
419 *
420**/
421typedef struct _LinphoneAuthInfo
422{
423        char *username;
424        char *realm;
425        char *userid;
426        char *passwd;
427        char *ha1;
428        bool_t works;
429        bool_t first_time;
430}LinphoneAuthInfo;
431
432LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
433                const char *passwd, const char *ha1,const char *realm);
434void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
435void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
436void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
437/* you don't need those function*/
438void linphone_auth_info_destroy(LinphoneAuthInfo *info);
439LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos);
440
441struct _LinphoneChatRoom{
442        struct _LinphoneCore *lc;
443        char  *peer;
444        char *route;
445        LinphoneAddress *peer_url;
446        void * user_data;
447};
448typedef struct _LinphoneChatRoom LinphoneChatRoom;
449
450LinphoneChatRoom * linphone_core_create_chat_room(struct _LinphoneCore *lc, const char *to);
451void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
452void linphone_chat_room_destroy(LinphoneChatRoom *cr);
453void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
454void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);
455
456/* describes the different groups of states */
457typedef enum _gstate_group {
458  GSTATE_GROUP_POWER,
459  GSTATE_GROUP_REG,
460  GSTATE_GROUP_CALL
461} gstate_group_t;
462
463typedef enum _gstate {
464  /* states for GSTATE_GROUP_POWER */
465  GSTATE_POWER_OFF = 0,        /* initial state */
466  GSTATE_POWER_STARTUP,
467  GSTATE_POWER_ON,
468  GSTATE_POWER_SHUTDOWN,
469  /* states for GSTATE_GROUP_REG */
470  GSTATE_REG_NONE = 10,       /* initial state */
471  GSTATE_REG_OK,
472  GSTATE_REG_FAILED,
473  /* states for GSTATE_GROUP_CALL */
474  GSTATE_CALL_IDLE = 20,      /* initial state */
475  GSTATE_CALL_OUT_INVITE,
476  GSTATE_CALL_OUT_CONNECTED,
477  GSTATE_CALL_IN_INVITE,
478  GSTATE_CALL_IN_CONNECTED,
479  GSTATE_CALL_END,
480  GSTATE_CALL_ERROR,
481  GSTATE_INVALID
482} gstate_t;
483
484struct _LinphoneGeneralState {
485  gstate_t old_state;
486  gstate_t new_state;
487  gstate_group_t group;
488  const char *message;
489};
490typedef struct _LinphoneGeneralState LinphoneGeneralState;
491
492/* private: set a new state */
493void gstate_new_state(struct _LinphoneCore *lc, gstate_t new_state, const char *message);
494/*private*/
495void gstate_initialize(struct _LinphoneCore *lc) ;
496
497/**
498 * @addtogroup initializing
499 * @{
500**/
501
502/** Callback prototype */
503typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
504/** Callback prototype */
505typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, const char *from);
506/** Callback prototype */
507typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, const char *from);
508/** Callback prototype */
509typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
510/** Callback prototype */
511typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
512/** Callback prototype */
513typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
514/** Callback prototype */
515typedef void (*DisplayQuestionCb)(struct _LinphoneCore *lc, const char *message);
516/** Callback prototype */
517typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
518/** Callback prototype */
519typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid, const char *url, const char *status, const char *img);
520/** Callback prototype */
521typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
522/** Callback prototype */
523typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
524/** Callback prototype */
525typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
526/** Callback prototype */
527typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
528/** Callback prototype */
529typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate);
530/** Callback prototype */
531typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
532/** Callback prototype */
533typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
534/** Callback prototype */
535typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
536
537/**
538 * This structure holds all callbacks that the application should implement.
539 *
540**/
541typedef struct _LinphoneVTable
542{
543        ShowInterfaceCb show; /**< Notifies the application that it should show up*/
544        InviteReceivedCb inv_recv; /**< Notifies incoming calls */
545        ByeReceivedCb bye_recv; /**< Notify calls terminated by far end*/
546        NotifyReceivedCb notify_recv; /**< Notify received presence events*/
547        NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
548        AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
549        DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
550        DisplayMessageCb display_message;/**< Callback to display a message to the user */
551#ifdef VINCENT_MAURY_RSVP
552        /* the yes/no dialog box */
553        DisplayMessageCb display_yes_no;
554#endif
555        DisplayMessageCb display_warning;/** Callback to display a warning to the user */
556        DisplayUrlCb display_url;
557        DisplayQuestionCb display_question;
558        CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
559        TextMessageReceived text_received; /**< A text message has been received */
560        GeneralStateChange general_state; /**< State notification callback */
561        DtmfReceived dtmf_received; /**< A dtmf has been received received */
562        ReferReceived refer_received; /**< A refer was received */
563        BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
564} LinphoneCoreVTable;
565
566/**
567 * @}
568**/
569
570typedef struct _LCCallbackObj
571{
572  LinphoneCoreCbFunc _func;
573  void * _user_data;
574}LCCallbackObj;
575
576
577
578typedef enum _LinphoneFirewallPolicy{
579        LINPHONE_POLICY_NO_FIREWALL,
580        LINPHONE_POLICY_USE_NAT_ADDRESS,
581        LINPHONE_POLICY_USE_STUN
582} LinphoneFirewallPolicy;
583
584typedef enum _LinphoneWaitingState{
585        LinphoneWaitingStart,
586        LinphoneWaitingProgress,
587        LinphoneWaitingFinished
588} LinphoneWaitingState;
589typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);
590
591
592typedef struct _LinphoneCore
593{
594        LinphoneCoreVTable vtable;
595        struct _LpConfig *config;
596        net_config_t net_conf;
597        sip_config_t sip_conf;
598        rtp_config_t rtp_conf;
599        sound_config_t sound_conf;
600        video_config_t video_conf;
601        codecs_config_t codecs_conf;
602        ui_config_t ui_conf;
603        autoreplier_config_t autoreplier_conf;
604        LinphoneProxyConfig *default_proxy;
605        MSList *friends;
606        MSList *auth_info;
607        struct _RingStream *ringstream;
608        LCCallbackObj preview_finished_cb;
609        bool_t preview_finished;
610        struct _LinphoneCall *call;   /* the current call, in the future it will be a list of calls (conferencing)*/
611        int rid; /*registration id*/
612        MSList *queued_calls;   /* used by the autoreplier */
613        MSList *call_logs;
614        MSList *chatrooms;
615        int max_call_logs;
616        int missed_calls;
617        struct _AudioStream *audiostream;  /**/
618        struct _VideoStream *videostream;
619        struct _VideoStream *previewstream;
620        RtpTransport *a_rtp,*a_rtcp;
621        struct _RtpProfile *local_profile;
622        MSList *bl_reqs;
623        MSList *subscribers;    /* unknown subscribers */
624        int minutes_away;
625        LinphoneOnlineStatus presence_mode;
626        LinphoneOnlineStatus prev_mode;
627        char *alt_contact;
628        void *data;
629        ms_mutex_t lock;
630        char *play_file;
631        char *rec_file;
632        time_t prevtime;
633        int dw_audio_bw;
634        int up_audio_bw;
635        int dw_video_bw;
636        int up_video_bw;
637        int audio_bw;
638        int automatic_action;
639        gstate_t gstate_power;
640        gstate_t gstate_reg;
641        gstate_t gstate_call;
642        LinphoneWaitingCallback wait_cb;
643        void *wait_ctx;
644        bool_t use_files;
645        bool_t apply_nat_settings;
646        bool_t ready;
647        bool_t bl_refresh;
648#ifdef VINCENT_MAURY_RSVP
649        /* QoS parameters*/
650        int rsvp_enable;
651        int rpc_enable;
652#endif
653} LinphoneCore;
654
655
656
657/* THE main API */
658
659void linphone_core_enable_logs(FILE *file);
660void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
661void linphone_core_disable_logs(void);
662/*sets the user-agent string in sip messages, must be set before linphone_core_new() or linphone_core_init() */
663void linphone_core_set_user_agent(const char *ua_name, const char *version);
664const char *linphone_core_get_version(void);
665
666LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
667                                                const char *config_path, const char *factory_config, void* userdata);
668
669/* function to be periodically called in a main loop */
670void linphone_core_iterate(LinphoneCore *lc);
671
672int linphone_core_invite(LinphoneCore *lc, const char *url);
673
674int linphone_core_refer(LinphoneCore *lc, const char *url);
675
676bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
677
678bool_t linphone_core_in_call(const LinphoneCore *lc);
679
680int linphone_core_accept_call(LinphoneCore *lc, const char *url);
681
682int linphone_core_terminate_call(LinphoneCore *lc, const char *url);
683
684void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);
685
686int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact);
687
688const char *linphone_core_get_primary_contact(LinphoneCore *lc);
689
690void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val);
691bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);
692
693bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
694void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);
695
696LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
697
698/*0= no bandwidth limit*/
699void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
700void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw);
701
702int linphone_core_get_download_bandwidth(const LinphoneCore *lc);
703int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
704
705
706#ifdef VINCENT_MAURY_RSVP
707/* QoS functions */
708int linphone_core_set_rpc_mode(LinphoneCore *lc, int on); /* on = 1 (RPC_ENABLE = 1) */
709int linphone_core_set_rsvp_mode(LinphoneCore *lc, int on); /* on = 1 (RSVP_ENABLE = 1) */
710int linphone_core_change_qos(LinphoneCore *lc, int answer); /* answer = 1 for yes, 0 for no */
711#endif
712
713/* returns a MSList of PayloadType */
714const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc);
715
716int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs);
717/* returns a MSList of PayloadType */
718const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);
719
720int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
721
722bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
723
724int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
725
726void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);
727
728const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc);
729
730void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config);
731
732void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index);
733
734int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config);
735
736void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);
737
738void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);
739
740const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);
741
742LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);
743
744void linphone_core_abort_authentication(LinphoneCore *lc,  LinphoneAuthInfo *info);
745
746void linphone_core_clear_all_auth_info(LinphoneCore *lc);
747
748int linphone_core_get_audio_jittcomp(LinphoneCore *lc);
749
750void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);
751
752int linphone_core_get_audio_port(const LinphoneCore *lc);
753
754int linphone_core_get_video_port(const LinphoneCore *lc);
755
756int linphone_core_get_nortp_timeout(const LinphoneCore *lc);
757
758void linphone_core_set_audio_port(LinphoneCore *lc, int port);
759
760void linphone_core_set_video_port(LinphoneCore *lc, int port);
761
762void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);
763
764void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);
765
766bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc);
767
768void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833);
769
770bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc);
771
772int linphone_core_get_sip_port(LinphoneCore *lc);
773
774void linphone_core_set_sip_port(LinphoneCore *lc,int port);
775
776void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);
777
778int linphone_core_get_inc_timeout(LinphoneCore *lc);
779
780void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
781
782const char * linphone_core_get_stun_server(const LinphoneCore *lc);
783
784void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr);
785
786const char *linphone_core_get_nat_address(const LinphoneCore *lc);
787
788void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol);
789
790LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);
791
792const char * linphone_core_get_relay_addr(const LinphoneCore *lc);
793
794int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);
795
796/* sound functions */
797/* returns a null terminated static array of string describing the sound devices */ 
798const char**  linphone_core_get_sound_devices(LinphoneCore *lc);
799bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
800bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
801int linphone_core_get_ring_level(LinphoneCore *lc);
802int linphone_core_get_play_level(LinphoneCore *lc);
803int linphone_core_get_rec_level(LinphoneCore *lc);
804void linphone_core_set_ring_level(LinphoneCore *lc, int level);
805void linphone_core_set_play_level(LinphoneCore *lc, int level);
806void linphone_core_set_rec_level(LinphoneCore *lc, int level);
807const char * linphone_core_get_ringer_device(LinphoneCore *lc);
808const char * linphone_core_get_playback_device(LinphoneCore *lc);
809const char * linphone_core_get_capture_device(LinphoneCore *lc);
810int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid);
811int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid);
812int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid);
813char linphone_core_get_sound_source(LinphoneCore *lc);
814void linphone_core_set_sound_source(LinphoneCore *lc, char source);
815void linphone_core_set_ring(LinphoneCore *lc, const char *path);
816const char *linphone_core_get_ring(const LinphoneCore *lc);
817void linphone_core_set_ringback(LinphoneCore *lc, const char *path);
818const char * linphone_core_get_ringback(const LinphoneCore *lc);
819int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
820void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val);
821bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc);
822
823void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
824bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);
825
826void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
827bool_t linphone_core_agc_enabled(const LinphoneCore *lc);
828
829void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
830
831void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os);
832
833LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);
834
835void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
836void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr);
837void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
838void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
839/* a list of LinphoneFriend */
840const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
841/* notify all friends that have subscribed */
842void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os);
843LinphoneFriend *linphone_core_get_friend_by_uri(const LinphoneCore *lc, const char *uri);
844LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
845
846/* returns a list of LinphoneCallLog */
847const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
848void linphone_core_clear_call_logs(LinphoneCore *lc);
849
850/* video support */
851void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled);
852bool_t linphone_core_video_enabled(LinphoneCore *lc);
853
854typedef struct MSVideoSizeDef{
855        MSVideoSize vsize;
856        const char *name;
857}MSVideoSizeDef;
858/* returns a zero terminated table of MSVideoSizeDef*/
859const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc);
860void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize);
861MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc);
862void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
863
864void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
865bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);
866
867void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
868bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
869
870
871/* returns a null terminated static array of string describing the webcams */ 
872const char**  linphone_core_get_video_devices(const LinphoneCore *lc);
873int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
874const char *linphone_core_get_video_device(const LinphoneCore *lc);
875
876/*function to be used for eventually setting window decorations (icons, title...)*/
877unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
878
879
880/*play/record support: use files instead of soundcard*/
881void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
882void linphone_core_set_play_file(LinphoneCore *lc, const char *file);
883void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
884
885gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
886int linphone_core_get_current_call_duration(const LinphoneCore *lc);
887const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc);
888
889int linphone_core_get_mtu(const LinphoneCore *lc);
890void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
891
892bool_t linphone_core_is_in_main_thread(LinphoneCore *lc);
893
894void *linphone_core_get_user_data(LinphoneCore *lc);
895
896/* returns LpConfig object to read/write to the config file: usefull if you wish to extend
897the config file with your own sections */
898struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);
899
900/* attempts to wake up another linphone engine already running.
901The "show" callback is called for the other linphone, causing gui to show up.
902call_addr is an optional sip-uri to call immediately after waking up.
903The method returns 0 if an already running linphone was found*/
904
905int linphone_core_wake_up_possible_already_running_instance(
906    const char * config_file, const char * call_addr);
907
908/*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
909void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
910
911/*returns the list of registered SipSetup (linphonecore plugins) */
912const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);
913
914void linphone_core_destroy(LinphoneCore *lc);
915
916/*for advanced users:*/
917void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp);
918
919/* end of lecacy api */
920
921/*internal use only */
922#define linphone_core_lock(lc)  ms_mutex_lock(&(lc)->lock)
923#define linphone_core_unlock(lc)        ms_mutex_unlock((&lc)->lock)
924void linphone_core_start_media_streams(LinphoneCore *lc, struct _LinphoneCall *call);
925void linphone_core_stop_media_streams(LinphoneCore *lc);
926const char * linphone_core_get_identity(LinphoneCore *lc);
927const char * linphone_core_get_route(LinphoneCore *lc);
928bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAddress **real_parsed_url, char **route);
929void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
930void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
931void linphone_core_stop_waiting(LinphoneCore *lc);
932
933
934#ifdef __cplusplus
935}
936#endif
937
938#endif
Note: See TracBrowser for help on using the repository browser.