linphonecore.h 34.1 KB
Newer Older
aymeric's avatar
aymeric committed
1 2
/*
linphone
3
Copyright (C) 2000 - 2010 Simon MORLAT (simon.morlat@linphone.org)
aymeric's avatar
aymeric committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
#ifndef LINPHONECORE_H
#define LINPHONECORE_H

#include "ortp/ortp.h"
#include "ortp/payloadtype.h"
#include "mediastreamer2/mscommon.h"
smorlat's avatar
smorlat committed
25
#include "mediastreamer2/msvideo.h"
26 27

#ifdef IN_LINPHONE
smorlat's avatar
smorlat committed
28
#include "sipsetup.h"
29 30 31
#else
#include "linphone/sipsetup.h"
#endif
aymeric's avatar
aymeric committed
32

smorlat's avatar
smorlat committed
33
#define LINPHONE_IPADDR_SIZE 64
smorlat's avatar
smorlat committed
34
#define LINPHONE_HOSTNAME_SIZE 128
smorlat's avatar
smorlat committed
35

aymeric's avatar
aymeric committed
36 37 38 39 40 41
#ifdef __cplusplus
extern "C" {
#endif

struct _MSSndCard;
struct _LinphoneCore;
42
struct SalOp;
aymeric's avatar
aymeric committed
43 44 45

struct _LpConfig;

46

47 48 49 50 51 52 53 54 55
struct _LCSipTransports{
	int udp_port;
	int tcp_port;
	int dtls_port;
	int tls_port;
};

typedef struct _LCSipTransports LCSipTransports;

smorlat's avatar
smorlat committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69
/**
 * Object that represents a SIP address.
 *
 * The LinphoneAddress is an opaque object to represents SIP addresses, ie
 * the content of SIP's 'from' and 'to' headers.
 * A SIP address is made of display name, username, domain name, port, and various
 * uri headers (such as tags). It looks like 'Alice <sip:alice@example.net>'.
 * The LinphoneAddress has methods to extract and manipulate all parts of the address.
 * When some part of the address (for example the username) is empty, the accessor methods
 * return NULL.
 * 
 * @ingroup linphone_address
 * @var LinphoneAddress
 */
70
typedef struct SalAddress LinphoneAddress;
71 72 73 74 75 76 77

LinphoneAddress * linphone_address_new(const char *uri);
LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
const char *linphone_address_get_scheme(const LinphoneAddress *u);
const char *linphone_address_get_display_name(const LinphoneAddress* u);
const char *linphone_address_get_username(const LinphoneAddress *u);
const char *linphone_address_get_domain(const LinphoneAddress *u);
jehan's avatar
jehan committed
78 79 80 81 82 83 84 85 86
/**
 * Get port number as an integer value.
 *
 */
int linphone_address_get_port_int(const LinphoneAddress *u);
/**
 * Get port number, null if not present.
 */
const char* linphone_address_get_port(const LinphoneAddress *u);
87 88 89 90 91
void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
void linphone_address_set_username(LinphoneAddress *uri, const char *username);
void linphone_address_set_domain(LinphoneAddress *uri, const char *host);
void linphone_address_set_port(LinphoneAddress *uri, const char *port);
void linphone_address_set_port_int(LinphoneAddress *uri, int port);
92
/*remove tags, params etc... so that it is displayable to the user*/
93 94 95 96
void linphone_address_clean(LinphoneAddress *uri);
char *linphone_address_as_string(const LinphoneAddress *u);
char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
void linphone_address_destroy(LinphoneAddress *u);
aymeric's avatar
aymeric committed
97

smorlat's avatar
smorlat committed
98
struct _SipSetupContext;
99

aymeric's avatar
aymeric committed
100

smorlat's avatar
smorlat committed
101 102 103 104 105 106 107 108
/**
 * Enum representing the direction of a call.
 * @ingroup call_logs
**/
enum _LinphoneCallDir {
	LinphoneCallOutgoing, /**< outgoing calls*/
	LinphoneCallIncoming  /**< incoming calls*/
};
aymeric's avatar
aymeric committed
109

smorlat's avatar
smorlat committed
110 111 112 113 114
/**
 * Typedef for enum
 * @ingroup call_logs
**/
typedef enum _LinphoneCallDir LinphoneCallDir;
aymeric's avatar
aymeric committed
115

smorlat's avatar
smorlat committed
116 117 118 119
/**
 * Enum representing the status of a call
 * @ingroup call_logs
**/
aymeric's avatar
aymeric committed
120
typedef enum _LinphoneCallStatus { 
smorlat's avatar
smorlat committed
121 122 123
	LinphoneCallSuccess, /**< The call was sucessful*/
	LinphoneCallAborted, /**< The call was aborted */
	LinphoneCallMissed /**< The call was missed (unanswered)*/
aymeric's avatar
aymeric committed
124 125
} LinphoneCallStatus;

smorlat's avatar
smorlat committed
126 127 128 129 130 131
/**
 * Structure representing a call log.
 *
 * @ingroup call_logs
 * 
**/
aymeric's avatar
aymeric committed
132
typedef struct _LinphoneCallLog{
smorlat's avatar
smorlat committed
133 134 135 136 137 138
	LinphoneCallDir dir; /**< The direction of the call*/
	LinphoneCallStatus status; /**< The status of the call*/
	LinphoneAddress *from; /**<Originator of the call as a LinphoneAddress object*/
	LinphoneAddress *to; /**<Destination of the call as a LinphoneAddress object*/
	char start_date[128]; /**<Human readable string containg the start date*/
	int duration; /**<Duration of the call in seconds*/
139
	char *refkey;
140
	void *user_pointer;
141 142
	rtp_stats_t local_stats;
	rtp_stats_t remote_stats;
143
	struct _LinphoneCore *lc;
aymeric's avatar
aymeric committed
144 145
} LinphoneCallLog;

smorlat's avatar
smorlat committed
146

aymeric's avatar
aymeric committed
147 148

/*public: */
149 150
void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
151 152
void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
153 154
const rtp_stats_t *linphone_call_log_get_local_stats(const LinphoneCallLog *cl);
const rtp_stats_t *linphone_call_log_get_remote_stats(const LinphoneCallLog *cl);
aymeric's avatar
aymeric committed
155 156
char * linphone_call_log_to_str(LinphoneCallLog *cl);

157 158 159 160 161 162 163

/**
 * The LinphoneCall object represents a call issued or received by the LinphoneCore
**/
struct _LinphoneCall;
typedef struct _LinphoneCall LinphoneCall;

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
typedef enum _LinphoneCallState{
	LinphoneCallIdle,
	LinphoneCallIncomingReceived,
	LinphoneCallOutgoingInit,
	LinphoneCallOutgoingProgress,
	LinphoneCallOutgoingRinging,
	LinphoneCallOutgoingEarlyMedia,
	LinphoneCallConnected,
	LinphoneCallStreamsRunning,
	LinphoneCallPausing,
	LinphoneCallPaused,
	LinphoneCallResuming,
	LinphoneCallRefered,
	LinphoneCallError,
	LinphoneCallEnd,
179
	LinphoneCallPausedByRemote
180 181
} LinphoneCallState;

182
const char *linphone_call_state_to_string(LinphoneCallState cs);
183

184 185

LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
186 187 188 189
bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
Simon Morlat's avatar
Simon Morlat committed
190
LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call);
191 192 193
void linphone_call_ref(LinphoneCall *call);
void linphone_call_unref(LinphoneCall *call);
LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call);
Simon Morlat's avatar
Simon Morlat committed
194
const char *linphone_call_get_refer_to(const LinphoneCall *call);
195
bool_t linphone_call_has_transfer_pending(const LinphoneCall *call);
196
int linphone_call_get_duration(const LinphoneCall *call);
Simon Morlat's avatar
Simon Morlat committed
197 198
void *linphone_call_get_user_pointer(LinphoneCall *call);
void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
199

aymeric's avatar
aymeric committed
200 201 202 203 204 205 206
typedef enum{
	LinphoneSPWait,
	LinphoneSPDeny,
	LinphoneSPAccept
}LinphoneSubscribePolicy;

typedef enum _LinphoneOnlineStatus{
207 208 209 210 211 212 213 214 215 216 217 218
	LinphoneStatusOffline,
	LinphoneStatusOnline,
	LinphoneStatusBusy,
	LinphoneStatusBeRightBack,
	LinphoneStatusAway,
	LinphoneStatusOnThePhone,
	LinphoneStatusOutToLunch,
	LinphoneStatusDoNotDisturb,
	LinphoneStatusMoved,
	LinphoneStatusAltService,
	LinphoneStatusPending,
	LinphoneStatusEnd
aymeric's avatar
aymeric committed
219 220 221 222
}LinphoneOnlineStatus;

const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);

223 224 225
struct _LinphoneFriend;

typedef struct _LinphoneFriend LinphoneFriend;
aymeric's avatar
aymeric committed
226 227 228 229 230 231 232 233 234 235

LinphoneFriend * linphone_friend_new();
LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri);
int linphone_friend_set_name(LinphoneFriend *fr, const char *name);
int linphone_friend_send_subscribe(LinphoneFriend *fr, bool_t val);
int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
void linphone_friend_edit(LinphoneFriend *fr);
void linphone_friend_done(LinphoneFriend *fr);
void linphone_friend_destroy(LinphoneFriend *lf);
236
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
aymeric's avatar
aymeric committed
237 238 239
bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf);
LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
240
BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
241 242
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
const char *linphone_friend_get_ref_key(const LinphoneFriend *lf);
243
bool_t linphone_friend_in_list(const LinphoneFriend *lf);
aymeric's avatar
aymeric committed
244 245 246

#define linphone_friend_url(lf) ((lf)->url)

247

smorlat's avatar
smorlat committed
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
/**
 * @addtogroup proxies
 * @{
**/
/**
 * The LinphoneProxyConfig object represents a proxy configuration to be used
 * by the LinphoneCore object.
 * Its fields must not be used directly in favour of the accessors methods.
 * Once created and filled properly the LinphoneProxyConfig can be given to
 * LinphoneCore with linphone_core_add_proxy_config().
 * This will automatically triggers the registration, if enabled.
 *
 * The proxy configuration are persistent to restarts because they are saved
 * in the configuration file. As a consequence, after linphone_core_new() there
 * might already be a list of configured proxy that can be examined with
 * linphone_core_get_proxy_config_list().
 *
 * The default proxy (see linphone_core_set_default_proxy() ) is the one of the list
 * that is used by default for calls.
**/
268
typedef struct _LinphoneProxyConfig LinphoneProxyConfig;
aymeric's avatar
aymeric committed
269

270 271 272 273 274 275 276 277 278 279 280 281 282
/**
 * LinphoneRegistrationState describes proxy registration states.
**/
typedef enum _LinphoneRegistrationState{
	LinphoneRegistrationNone,
	LinphoneRegistrationProgress,
	LinphoneRegistrationOk,
	LinphoneRegistrationCleared,
	LinphoneRegistrationFailed
}LinphoneRegistrationState;

const char *linphone_registration_state_to_string(LinphoneRegistrationState cs);

aymeric's avatar
aymeric committed
283 284
LinphoneProxyConfig *linphone_proxy_config_new(void);
int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
285 286
int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity);
int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route);
Simon Morlat's avatar
Simon Morlat committed
287
void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires);
aymeric's avatar
aymeric committed
288 289 290 291 292
void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val);
#define linphone_proxy_config_enableregister linphone_proxy_config_enable_register
void linphone_proxy_config_edit(LinphoneProxyConfig *obj);
int linphone_proxy_config_done(LinphoneProxyConfig *obj);
void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
293 294 295
void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val);
void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix);

296
LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj);
smorlat's avatar
smorlat committed
297
bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
smorlat's avatar
smorlat committed
298
const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
299 300 301 302 303 304 305 306 307

const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj);
const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj);
bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj);
const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj);
int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj);
bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj);
struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);

308 309 310
bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);
const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);

aymeric's avatar
aymeric committed
311 312
/* destruction is called automatically when removing the proxy config */
void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
smorlat's avatar
smorlat committed
313 314
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
315
SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
316 317 318 319
/**
 * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
 */
int linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len);
jehan's avatar
jehan committed
320 321 322 323 324 325 326 327
/*
 *  attached a user data to a proxy config
 */
void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cr, void * ud);
/*
 *  get user data to a proxy config. return null if any
 */
void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr);
smorlat's avatar
smorlat committed
328

smorlat's avatar
smorlat committed
329 330 331 332
/**
 * @}
**/

333 334 335 336 337 338 339 340 341
typedef struct _LinphoneAccountCreator{
	struct _LinphoneCore *lc;
	struct _SipSetupContext *ssctx;
	char *username;
	char *password;
	char *domain;
	bool_t succeeded;
}LinphoneAccountCreator;

342
LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
343 344 345
void linphone_account_creator_set_username(LinphoneAccountCreator *obj, const char *username);
void linphone_account_creator_set_password(LinphoneAccountCreator *obj, const char *password);
void linphone_account_creator_set_domain(LinphoneAccountCreator *obj, const char *domain);
smorlat's avatar
smorlat committed
346 347
const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
348
int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
349 350 351
LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
void linphone_account_creator_destroy(LinphoneAccountCreator *obj);

352 353
struct _LinphoneAuthInfo;

smorlat's avatar
smorlat committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
/**
 * @ingroup authentication
 * Object holding authentication information.
 *
 * @note The object's fields should not be accessed directly. Prefer using
 * the accessor methods.
 *
 * In most case, authentication information consists of a username and password.
 * Sometimes, a userid is required by proxy, and realm can be useful to discriminate
 * different SIP domains.
 *
 * Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in
 * order to become known and used automatically when needed. 
 * Use linphone_core_add_auth_info() for that purpose.
 *
 * The LinphoneCore object can take the initiative to request authentication information
 * when needed to the application through the auth_info_requested callback of the
 * LinphoneCoreVTable structure.
 *
 * The application can respond to this information request later using 
 * linphone_core_add_auth_info(). This will unblock all pending authentication 
 * transactions and retry them with authentication headers.
 *
**/
378
typedef struct _LinphoneAuthInfo LinphoneAuthInfo;
aymeric's avatar
aymeric committed
379 380 381 382

LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
		const char *passwd, const char *ha1,const char *realm);
void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd);
383
void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
384
void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
385 386 387 388 389

const char *linphone_auth_info_get_username(const LinphoneAuthInfo *i);
const char *linphone_auth_info_get_passwd(const LinphoneAuthInfo *i);
const char *linphone_auth_info_get_userid(const LinphoneAuthInfo *i);

aymeric's avatar
aymeric committed
390 391 392 393
/* you don't need those function*/
void linphone_auth_info_destroy(LinphoneAuthInfo *info);
LinphoneAuthInfo * linphone_auth_info_new_from_config_file(struct _LpConfig *config, int pos);

394
struct _LinphoneChatRoom;
aymeric's avatar
aymeric committed
395 396 397 398 399 400 401 402
typedef struct _LinphoneChatRoom LinphoneChatRoom;

LinphoneChatRoom * linphone_core_create_chat_room(struct _LinphoneCore *lc, const char *to);
void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg);
void linphone_chat_room_destroy(LinphoneChatRoom *cr);
void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud);
void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr);

403 404 405 406 407 408 409
typedef enum _LinphoneGlobalState{
	LinphoneGlobalOff,
	LinphoneGlobalStartup,
	LinphoneGlobalOn,
	LinphoneGlobalShutdown
}LinphoneGlobalState;

410
const char *linphone_global_state_to_string(LinphoneGlobalState gs);
aymeric's avatar
aymeric committed
411

smorlat's avatar
smorlat committed
412 413 414 415 416
/**
 * @addtogroup initializing
 * @{
**/

417 418 419 420 421 422

/**Call state notification callback prototype*/
typedef void (*LinphoneGlobalStateCb)(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message);
/**Call state notification callback prototype*/
typedef void (*LinphoneCallStateCb)(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message);
/**Registration state notification callback prototype*/
423
typedef void (*LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
smorlat's avatar
smorlat committed
424
/** Callback prototype */
aymeric's avatar
aymeric committed
425
typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
smorlat's avatar
smorlat committed
426
/** Callback prototype */
aymeric's avatar
aymeric committed
427
typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
smorlat's avatar
smorlat committed
428
/** Callback prototype */
aymeric's avatar
aymeric committed
429
typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
smorlat's avatar
smorlat committed
430
/** Callback prototype */
aymeric's avatar
aymeric committed
431
typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
smorlat's avatar
smorlat committed
432
/** Callback prototype */
aymeric's avatar
aymeric committed
433
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
smorlat's avatar
smorlat committed
434
/** Callback prototype */
435
typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const char *from, const char *event);
436 437
/** Callback prototype */
typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid);
smorlat's avatar
smorlat committed
438
/** Callback prototype */
aymeric's avatar
aymeric committed
439
typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
smorlat's avatar
smorlat committed
440
/** Callback prototype */
aymeric's avatar
aymeric committed
441
typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
smorlat's avatar
smorlat committed
442
/** Callback prototype */
aymeric's avatar
aymeric committed
443
typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
smorlat's avatar
smorlat committed
444
/** Callback prototype */
aymeric's avatar
aymeric committed
445
typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
smorlat's avatar
smorlat committed
446
/** Callback prototype */
447
typedef void (*DtmfReceived)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf);
smorlat's avatar
smorlat committed
448
/** Callback prototype */
449
typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
smorlat's avatar
smorlat committed
450
/** Callback prototype */
451
typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
aymeric's avatar
aymeric committed
452

smorlat's avatar
smorlat committed
453 454
/**
 * This structure holds all callbacks that the application should implement.
455
 *  None is mandatory.
smorlat's avatar
smorlat committed
456
**/
457 458 459 460
typedef struct _LinphoneVTable{
	LinphoneGlobalStateCb global_state_changed; /**<Notifies globlal state changes*/
	LinphoneRegistrationStateCb registration_state_changed;/**<Notifies registration state changes*/
	LinphoneCallStateCb call_state_changed;/**<Notifies call state changes*/
461
	NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
smorlat's avatar
smorlat committed
462 463 464 465 466
	NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
	AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
	CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
	TextMessageReceived text_received; /**< A text message has been received */
	DtmfReceived dtmf_received; /**< A dtmf has been received received */
Simon Morlat's avatar
Simon Morlat committed
467
	ReferReceived refer_received; /**< An out of call refer was received */
smorlat's avatar
smorlat committed
468
	BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
469
	NotifyReceivedCb notify_recv; /**< Other notifications*/
Simon Morlat's avatar
Simon Morlat committed
470 471 472 473 474
	DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
	DisplayMessageCb display_message;/**< Callback to display a message to the user */
	DisplayMessageCb display_warning;/** Callback to display a warning to the user */
	DisplayUrlCb display_url;
	ShowInterfaceCb show; /**< Notifies the application that it should show up*/
aymeric's avatar
aymeric committed
475 476
} LinphoneCoreVTable;

smorlat's avatar
smorlat committed
477 478 479 480
/**
 * @}
**/

aymeric's avatar
aymeric committed
481 482 483 484 485 486 487 488 489
typedef struct _LCCallbackObj
{
  LinphoneCoreCbFunc _func;
  void * _user_data;
}LCCallbackObj;



typedef enum _LinphoneFirewallPolicy{
490 491 492
	LinphonePolicyNoFirewall,
	LinphonePolicyUseNatAddress,
	LinphonePolicyUseStun
aymeric's avatar
aymeric committed
493 494
} LinphoneFirewallPolicy;

495 496 497 498 499 500 501
typedef enum _LinphoneWaitingState{
	LinphoneWaitingStart,
	LinphoneWaitingProgress,
	LinphoneWaitingFinished
} LinphoneWaitingState;
typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);

502
typedef struct _LinphoneCore LinphoneCore;
aymeric's avatar
aymeric committed
503 504 505 506 507 508

/* THE main API */

void linphone_core_enable_logs(FILE *file);
void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
void linphone_core_disable_logs(void);
smorlat's avatar
smorlat committed
509 510
/*sets the user-agent string in sip messages, must be set before linphone_core_new() or linphone_core_init() */
void linphone_core_set_user_agent(const char *ua_name, const char *version);
aymeric's avatar
aymeric committed
511 512 513
const char *linphone_core_get_version(void);

LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
514
						const char *config_path, const char *factory_config, void* userdata);
aymeric's avatar
aymeric committed
515 516 517 518

/* function to be periodically called in a main loop */
void linphone_core_iterate(LinphoneCore *lc);

519 520
LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);

521
LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url);
aymeric's avatar
aymeric committed
522

523
LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
524

525
int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to);
aymeric's avatar
aymeric committed
526 527 528 529 530

bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);

bool_t linphone_core_in_call(const LinphoneCore *lc);

531
LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc);
532

533 534 535
int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);

int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
536

537
int linphone_core_terminate_all_calls(LinphoneCore *lc);
aymeric's avatar
aymeric committed
538

539 540
int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);

541 542
int linphone_core_pause_all_calls(LinphoneCore *lc);

543
int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call);
aymeric's avatar
aymeric committed
544

545
LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address);
aymeric's avatar
aymeric committed
546 547 548 549 550 551 552 553 554 555 556 557 558

void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);

int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact);

const char *linphone_core_get_primary_contact(LinphoneCore *lc);

void linphone_core_set_guess_hostname(LinphoneCore *lc, bool_t val);
bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);

bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);

559
LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
jehan's avatar
jehan committed
560
const char * linphone_core_get_identity(LinphoneCore *lc);
aymeric's avatar
aymeric committed
561 562 563 564 565 566
/*0= no bandwidth limit*/
void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw);

int linphone_core_get_download_bandwidth(const LinphoneCore *lc);
int linphone_core_get_upload_bandwidth(const LinphoneCore *lc);
jehan's avatar
jehan committed
567 568 569 570 571 572 573 574 575 576 577
/**
 * set audio packetization time linphone expect to received from peer
 * @ingroup media_parameters
 *
 */
void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime);
/**
 * get audio packetization time linphone expect to received from peer, 0 means unspecified
 * @ingroup media_parameters
 */
int  linphone_core_get_download_ptime(LinphoneCore *lc);
aymeric's avatar
aymeric committed
578 579 580 581 582 583 584 585 586 587

/* returns a MSList of PayloadType */
const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc);

int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs);
/* returns a MSList of PayloadType */
const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc);

int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);

588 589 590 591
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);

int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable);

jehan's avatar
jehan committed
592 593
PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) ;

594 595
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt);

aymeric's avatar
aymeric committed
596 597 598 599
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);

int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);

600 601
void linphone_core_clear_proxy_config(LinphoneCore *lc);

aymeric's avatar
aymeric committed
602 603 604 605 606 607 608 609 610 611
void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config);

const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc);

void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config);

void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index);

int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config);

612
void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
aymeric's avatar
aymeric committed
613

614
void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info);
aymeric's avatar
aymeric committed
615

smorlat's avatar
smorlat committed
616 617
const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);

618
const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);
smorlat's avatar
smorlat committed
619

aymeric's avatar
aymeric committed
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
void linphone_core_abort_authentication(LinphoneCore *lc,  LinphoneAuthInfo *info);

void linphone_core_clear_all_auth_info(LinphoneCore *lc);

int linphone_core_get_audio_jittcomp(LinphoneCore *lc);

void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value);

int linphone_core_get_audio_port(const LinphoneCore *lc);

int linphone_core_get_video_port(const LinphoneCore *lc);

int linphone_core_get_nortp_timeout(const LinphoneCore *lc);

void linphone_core_set_audio_port(LinphoneCore *lc, int port);

void linphone_core_set_video_port(LinphoneCore *lc, int port);

void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);

void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);

bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc);

644 645 646 647
void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833);

bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc);

648 649
void linphone_core_set_sip_port(LinphoneCore *lc, int port);

aymeric's avatar
aymeric committed
650 651
int linphone_core_get_sip_port(LinphoneCore *lc);

652 653 654
int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports);

int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports);
aymeric's avatar
aymeric committed
655

656 657
ortp_socket_t linphone_core_get_sip_socket(LinphoneCore *lc);

aymeric's avatar
aymeric committed
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);

int linphone_core_get_inc_timeout(LinphoneCore *lc);

void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);

const char * linphone_core_get_stun_server(const LinphoneCore *lc);

void linphone_core_set_nat_address(LinphoneCore *lc, const char *addr);

const char *linphone_core_get_nat_address(const LinphoneCore *lc);

void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol);

LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc);

const char * linphone_core_get_relay_addr(const LinphoneCore *lc);

int linphone_core_set_relay_addr(LinphoneCore *lc, const char *addr);

/* sound functions */
/* returns a null terminated static array of string describing the sound devices */ 
const char**  linphone_core_get_sound_devices(LinphoneCore *lc);
smorlat's avatar
smorlat committed
681 682
bool_t linphone_core_sound_device_can_capture(LinphoneCore *lc, const char *device);
bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, const char *device);
aymeric's avatar
aymeric committed
683 684 685 686 687
int linphone_core_get_ring_level(LinphoneCore *lc);
int linphone_core_get_play_level(LinphoneCore *lc);
int linphone_core_get_rec_level(LinphoneCore *lc);
void linphone_core_set_ring_level(LinphoneCore *lc, int level);
void linphone_core_set_play_level(LinphoneCore *lc, int level);
688 689 690 691

void linphone_core_set_playback_gain_db(LinphoneCore *lc, float level);

float linphone_core_get_playback_gain_db(LinphoneCore *lc);
aymeric's avatar
aymeric committed
692 693 694 695 696 697 698 699 700 701
void linphone_core_set_rec_level(LinphoneCore *lc, int level);
const char * linphone_core_get_ringer_device(LinphoneCore *lc);
const char * linphone_core_get_playback_device(LinphoneCore *lc);
const char * linphone_core_get_capture_device(LinphoneCore *lc);
int linphone_core_set_ringer_device(LinphoneCore *lc, const char * devid);
int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid);
int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid);
char linphone_core_get_sound_source(LinphoneCore *lc);
void linphone_core_set_sound_source(LinphoneCore *lc, char source);
void linphone_core_set_ring(LinphoneCore *lc, const char *path);
702 703 704
const char *linphone_core_get_ring(const LinphoneCore *lc);
void linphone_core_set_ringback(LinphoneCore *lc, const char *path);
const char * linphone_core_get_ringback(const LinphoneCore *lc);
aymeric's avatar
aymeric committed
705
int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
706 707
void linphone_core_enable_echo_cancellation(LinphoneCore *lc, bool_t val);
bool_t linphone_core_echo_cancellation_enabled(LinphoneCore *lc);
aymeric's avatar
aymeric committed
708

smorlat's avatar
smorlat committed
709 710 711
void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);

712 713 714
void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
bool_t linphone_core_agc_enabled(const LinphoneCore *lc);

smorlat's avatar
smorlat committed
715
void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);
716 717 718 719 720 721
/**
 * return mic state.
 *
 * @ingroup media_parameters
**/
bool_t linphone_core_is_mic_muted(LinphoneCore *lc);
smorlat's avatar
smorlat committed
722

Simon Morlat's avatar
Simon Morlat committed
723 724 725 726 727 728
bool_t linphone_core_is_audio_muted(LinphoneCore *lc);
bool_t linphone_core_is_rtp_muted(LinphoneCore *lc);

bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc);
void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, bool_t val);

aymeric's avatar
aymeric committed
729 730 731 732
void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os);

LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);

smorlat's avatar
smorlat committed
733
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
aymeric's avatar
aymeric committed
734 735 736 737
void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr);
void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
/* a list of LinphoneFriend */
738
const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
aymeric's avatar
aymeric committed
739 740
/* notify all friends that have subscribed */
void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os);
741
LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr);
742
LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
aymeric's avatar
aymeric committed
743 744

/* returns a list of LinphoneCallLog */
745
const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
746
void linphone_core_clear_call_logs(LinphoneCore *lc);
aymeric's avatar
aymeric committed
747 748 749 750 751

/* video support */
void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled);
bool_t linphone_core_video_enabled(LinphoneCore *lc);

smorlat's avatar
smorlat committed
752 753 754 755 756 757 758 759 760
typedef struct MSVideoSizeDef{
	MSVideoSize vsize;
	const char *name;
}MSVideoSizeDef;
/* returns a zero terminated table of MSVideoSizeDef*/
const MSVideoSizeDef *linphone_core_get_supported_video_sizes(LinphoneCore *lc);
void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize);
MSVideoSize linphone_core_get_preferred_video_size(LinphoneCore *lc);
void linphone_core_set_preferred_video_size_by_name(LinphoneCore *lc, const char *name);
aymeric's avatar
aymeric committed
761 762 763 764

void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);

smorlat's avatar
smorlat committed
765 766
void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);
bool_t linphone_core_self_view_enabled(const LinphoneCore *lc);
aymeric's avatar
aymeric committed
767 768 769 770 771 772 773


/* returns a null terminated static array of string describing the webcams */ 
const char**  linphone_core_get_video_devices(const LinphoneCore *lc);
int linphone_core_set_video_device(LinphoneCore *lc, const char *id);
const char *linphone_core_get_video_device(const LinphoneCore *lc);

774 775 776
/* Set static picture to be used when "Static picture" is the video device */
int linphone_core_set_static_picture(LinphoneCore *lc, const char *path);

777 778 779 780
/* Set and get frame rate for static picture */
int linphone_core_set_static_picture_fps(LinphoneCore *lc, float fps);
float linphone_core_get_static_picture_fps(LinphoneCore *lc);

781 782
/*function to be used for eventually setting window decorations (icons, title...)*/
unsigned long linphone_core_get_native_video_window_id(const LinphoneCore *lc);
smorlat's avatar
smorlat committed
783 784 785 786 787 788 789


/*play/record support: use files instead of soundcard*/
void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
void linphone_core_set_play_file(LinphoneCore *lc, const char *file);
void linphone_core_set_record_file(LinphoneCore *lc, const char *file);

790 791 792
void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms);
void linphone_core_stop_dtmf(LinphoneCore *lc);

793

smorlat's avatar
smorlat committed
794
int linphone_core_get_current_call_duration(const LinphoneCore *lc);
jehan's avatar
jehan committed
795

smorlat's avatar
smorlat committed
796

aymeric's avatar
aymeric committed
797 798
int linphone_core_get_mtu(const LinphoneCore *lc);
void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
799

800 801 802
/**
 * This method is called by the application to notify the linphone core library when network is reachable.
 * Calling this method with true trigger linphone to initiate a registration process for all proxy
803 804
 * configuration with parameter register set to enable.
 * This method disable the automatic registration mode. It means you must call this method after each network state changes
805 806 807
 *
 */
void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value);
808 809 810 811
/**
 * return network state either as positioned by the application or by linphone
 */
bool_t linphone_core_is_network_reachabled(LinphoneCore* lc);
812

aymeric's avatar
aymeric committed
813 814 815 816 817 818 819

void *linphone_core_get_user_data(LinphoneCore *lc);

/* returns LpConfig object to read/write to the config file: usefull if you wish to extend
the config file with your own sections */
struct _LpConfig *linphone_core_get_config(LinphoneCore *lc);

smorlat's avatar
smorlat committed
820 821
/* attempts to wake up another linphone engine already running.
The "show" callback is called for the other linphone, causing gui to show up.
822
call_addr is an optional sip-uri to call immediately after waking up.
smorlat's avatar
smorlat committed
823
The method returns 0 if an already running linphone was found*/
824

825 826
int linphone_core_wake_up_possible_already_running_instance(
    const char * config_file, const char * call_addr);
smorlat's avatar
smorlat committed
827

828
/*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
829
void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
830

smorlat's avatar
smorlat committed
831 832 833
/*returns the list of registered SipSetup (linphonecore plugins) */
const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);

aymeric's avatar
aymeric committed
834 835
void linphone_core_destroy(LinphoneCore *lc);

836 837 838
/*for advanced users:*/
void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp);

839 840
int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, rtp_stats_t *remote);

Simon Morlat's avatar
Simon Morlat committed
841 842
const MSList *linphone_core_get_calls(LinphoneCore *lc);

843 844
LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc);

aymeric's avatar
aymeric committed
845 846 847 848
#ifdef __cplusplus
}
#endif

Simon Morlat's avatar
Simon Morlat committed
849

850

aymeric's avatar
aymeric committed
851
#endif