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

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

smorlat's avatar
smorlat committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60
/**
 * 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
 */
61
typedef struct SalAddress LinphoneAddress;
62 63 64 65 66 67 68 69 70 71 72 73

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);
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);
74
/*remove tags, params etc... so that it is displayable to the user*/
75 76 77 78
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
79

smorlat's avatar
smorlat committed
80
struct _SipSetupContext;
smorlat's avatar
smorlat committed
81
struct _LinphoneCall;
aymeric's avatar
aymeric committed
82

smorlat's avatar
smorlat committed
83 84 85 86 87 88 89 90
/**
 * Enum representing the direction of a call.
 * @ingroup call_logs
**/
enum _LinphoneCallDir {
	LinphoneCallOutgoing, /**< outgoing calls*/
	LinphoneCallIncoming  /**< incoming calls*/
};
aymeric's avatar
aymeric committed
91

smorlat's avatar
smorlat committed
92 93 94 95 96
/**
 * Typedef for enum
 * @ingroup call_logs
**/
typedef enum _LinphoneCallDir LinphoneCallDir;
aymeric's avatar
aymeric committed
97

smorlat's avatar
smorlat committed
98 99 100 101
/**
 * Enum representing the status of a call
 * @ingroup call_logs
**/
aymeric's avatar
aymeric committed
102
typedef enum _LinphoneCallStatus { 
smorlat's avatar
smorlat committed
103 104 105
	LinphoneCallSuccess, /**< The call was sucessful*/
	LinphoneCallAborted, /**< The call was aborted */
	LinphoneCallMissed /**< The call was missed (unanswered)*/
aymeric's avatar
aymeric committed
106 107
} LinphoneCallStatus;

smorlat's avatar
smorlat committed
108 109 110 111 112 113
/**
 * Structure representing a call log.
 *
 * @ingroup call_logs
 * 
**/
aymeric's avatar
aymeric committed
114
typedef struct _LinphoneCallLog{
smorlat's avatar
smorlat committed
115 116 117 118 119 120
	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*/
121
	char *refkey;
smorlat's avatar
smorlat committed
122
	void *user_pointer;
123
	struct _LinphoneCore *lc;
aymeric's avatar
aymeric committed
124 125
} LinphoneCallLog;

smorlat's avatar
smorlat committed
126

aymeric's avatar
aymeric committed
127 128

/*public: */
smorlat's avatar
smorlat committed
129 130
void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl);
131 132
void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);
const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
aymeric's avatar
aymeric committed
133 134 135 136 137 138 139 140 141
char * linphone_call_log_to_str(LinphoneCallLog *cl);

typedef enum{
	LinphoneSPWait,
	LinphoneSPDeny,
	LinphoneSPAccept
}LinphoneSubscribePolicy;

typedef enum _LinphoneOnlineStatus{
142
	LINPHONE_STATUS_OFFLINE,
aymeric's avatar
aymeric committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
	LINPHONE_STATUS_ONLINE,
	LINPHONE_STATUS_BUSY,
	LINPHONE_STATUS_BERIGHTBACK,
	LINPHONE_STATUS_AWAY,
	LINPHONE_STATUS_ONTHEPHONE,
	LINPHONE_STATUS_OUTTOLUNCH,
	LINPHONE_STATUS_NOT_DISTURB,
	LINPHONE_STATUS_MOVED,
	LINPHONE_STATUS_ALT_SERVICE,
	LINPHONE_STATUS_PENDING,
	LINPHONE_STATUS_END
}LinphoneOnlineStatus;

const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);

158 159 160
struct _LinphoneFriend;

typedef struct _LinphoneFriend LinphoneFriend;
aymeric's avatar
aymeric committed
161 162 163 164 165 166 167 168 169 170

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);
171
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
aymeric's avatar
aymeric committed
172 173 174
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);
175
BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
176 177
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
const char *linphone_friend_get_ref_key(const LinphoneFriend *lf);
178
bool_t linphone_friend_in_list(const LinphoneFriend *lf);
aymeric's avatar
aymeric committed
179 180 181

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

182 183
struct LinphoneProxyConfig;

smorlat's avatar
smorlat committed
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
/**
 * @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.
**/
204
typedef struct _LinphoneProxyConfig LinphoneProxyConfig;
aymeric's avatar
aymeric committed
205 206 207

LinphoneProxyConfig *linphone_proxy_config_new(void);
int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr);
208 209
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
210
void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires);
aymeric's avatar
aymeric committed
211 212 213 214 215
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);
216 217 218
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);

smorlat's avatar
smorlat committed
219
bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
smorlat's avatar
smorlat committed
220
const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg);
221 222 223 224 225 226 227 228 229

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);

230 231 232
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
233 234
/* destruction is called automatically when removing the proxy config */
void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
smorlat's avatar
smorlat committed
235 236
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
237
SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
smorlat's avatar
smorlat committed
238

smorlat's avatar
smorlat committed
239 240 241 242
/**
 * @}
**/

smorlat's avatar
smorlat committed
243 244 245 246 247 248 249 250 251
typedef struct _LinphoneAccountCreator{
	struct _LinphoneCore *lc;
	struct _SipSetupContext *ssctx;
	char *username;
	char *password;
	char *domain;
	bool_t succeeded;
}LinphoneAccountCreator;

252
LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type);
smorlat's avatar
smorlat committed
253 254 255
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
256 257
const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj);
const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj);
258
int linphone_account_creator_test_existence(LinphoneAccountCreator *obj);
smorlat's avatar
smorlat committed
259 260 261
LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj);
void linphone_account_creator_destroy(LinphoneAccountCreator *obj);

262 263
struct _LinphoneAuthInfo;

smorlat's avatar
smorlat committed
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
/**
 * @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.
 *
**/
288
typedef struct _LinphoneAuthInfo LinphoneAuthInfo;
aymeric's avatar
aymeric committed
289 290 291 292

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);
smorlat's avatar
smorlat committed
293
void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username);
294
void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid);
295 296 297 298 299

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
300 301 302 303
/* 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);

304
struct _LinphoneChatRoom;
aymeric's avatar
aymeric committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
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);

/* describes the different groups of states */
typedef enum _gstate_group {
  GSTATE_GROUP_POWER,
  GSTATE_GROUP_REG,
  GSTATE_GROUP_CALL
} gstate_group_t;

typedef enum _gstate {
  /* states for GSTATE_GROUP_POWER */
  GSTATE_POWER_OFF = 0,        /* initial state */
  GSTATE_POWER_STARTUP,
  GSTATE_POWER_ON,
  GSTATE_POWER_SHUTDOWN,
  /* states for GSTATE_GROUP_REG */
  GSTATE_REG_NONE = 10,       /* initial state */
  GSTATE_REG_OK,
  GSTATE_REG_FAILED,
  /* states for GSTATE_GROUP_CALL */
  GSTATE_CALL_IDLE = 20,      /* initial state */
  GSTATE_CALL_OUT_INVITE,
  GSTATE_CALL_OUT_CONNECTED,
  GSTATE_CALL_IN_INVITE,
  GSTATE_CALL_IN_CONNECTED,
  GSTATE_CALL_END,
smorlat's avatar
smorlat committed
337 338
  GSTATE_CALL_ERROR,
  GSTATE_INVALID
aymeric's avatar
aymeric committed
339 340 341 342 343 344 345 346 347 348 349 350
} gstate_t;

struct _LinphoneGeneralState {
  gstate_t old_state;
  gstate_t new_state;
  gstate_group_t group;
  const char *message;
};
typedef struct _LinphoneGeneralState LinphoneGeneralState;

/* private: set a new state */
void gstate_new_state(struct _LinphoneCore *lc, gstate_t new_state, const char *message);
smorlat's avatar
smorlat committed
351 352
/*private*/
void gstate_initialize(struct _LinphoneCore *lc) ;
aymeric's avatar
aymeric committed
353

smorlat's avatar
smorlat committed
354 355 356 357 358 359
/**
 * @addtogroup initializing
 * @{
**/

/** Callback prototype */
aymeric's avatar
aymeric committed
360
typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
smorlat's avatar
smorlat committed
361
/** Callback prototype */
aymeric's avatar
aymeric committed
362
typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, const char *from);
smorlat's avatar
smorlat committed
363
/** Callback prototype */
aymeric's avatar
aymeric committed
364
typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, const char *from);
smorlat's avatar
smorlat committed
365
/** Callback prototype */
aymeric's avatar
aymeric committed
366
typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
smorlat's avatar
smorlat committed
367
/** Callback prototype */
aymeric's avatar
aymeric committed
368
typedef void (*DisplayMessageCb)(struct _LinphoneCore *lc, const char *message);
smorlat's avatar
smorlat committed
369
/** Callback prototype */
aymeric's avatar
aymeric committed
370
typedef void (*DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url);
smorlat's avatar
smorlat committed
371
/** Callback prototype */
aymeric's avatar
aymeric committed
372
typedef void (*DisplayQuestionCb)(struct _LinphoneCore *lc, const char *message);
smorlat's avatar
smorlat committed
373
/** Callback prototype */
aymeric's avatar
aymeric committed
374
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
smorlat's avatar
smorlat committed
375
/** Callback prototype */
376
typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid);
smorlat's avatar
smorlat committed
377
/** Callback prototype */
aymeric's avatar
aymeric committed
378
typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
smorlat's avatar
smorlat committed
379
/** Callback prototype */
aymeric's avatar
aymeric committed
380
typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username);
smorlat's avatar
smorlat committed
381
/** Callback prototype */
aymeric's avatar
aymeric committed
382
typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
smorlat's avatar
smorlat committed
383
/** Callback prototype */
aymeric's avatar
aymeric committed
384
typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
smorlat's avatar
smorlat committed
385
/** Callback prototype */
aymeric's avatar
aymeric committed
386
typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate);
smorlat's avatar
smorlat committed
387
/** Callback prototype */
smorlat's avatar
smorlat committed
388
typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
smorlat's avatar
smorlat committed
389
/** Callback prototype */
390
typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
smorlat's avatar
smorlat committed
391
/** Callback prototype */
392
typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
aymeric's avatar
aymeric committed
393

smorlat's avatar
smorlat committed
394 395 396 397
/**
 * This structure holds all callbacks that the application should implement.
 * 
**/
aymeric's avatar
aymeric committed
398 399
typedef struct _LinphoneVTable
{
smorlat's avatar
smorlat committed
400 401 402 403 404 405 406 407 408
	ShowInterfaceCb show; /**< Notifies the application that it should show up*/
	InviteReceivedCb inv_recv; /**< Notifies incoming calls */
	ByeReceivedCb bye_recv; /**< Notify calls terminated by far end*/
	NotifyReceivedCb notify_recv; /**< Notify received presence events*/
	NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
	AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
	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 */
aymeric's avatar
aymeric committed
409 410
	DisplayUrlCb display_url;
	DisplayQuestionCb display_question;
smorlat's avatar
smorlat committed
411 412 413 414 415 416
	CallLogUpdated call_log_updated; /**< Notifies that call log list has been updated */
	TextMessageReceived text_received; /**< A text message has been received */
	GeneralStateChange general_state; /**< State notification callback */
	DtmfReceived dtmf_received; /**< A dtmf has been received received */
	ReferReceived refer_received; /**< A refer was received */
	BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
aymeric's avatar
aymeric committed
417 418
} LinphoneCoreVTable;

smorlat's avatar
smorlat committed
419 420 421 422
/**
 * @}
**/

aymeric's avatar
aymeric committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436
typedef struct _LCCallbackObj
{
  LinphoneCoreCbFunc _func;
  void * _user_data;
}LCCallbackObj;



typedef enum _LinphoneFirewallPolicy{
	LINPHONE_POLICY_NO_FIREWALL,
	LINPHONE_POLICY_USE_NAT_ADDRESS,
	LINPHONE_POLICY_USE_STUN
} LinphoneFirewallPolicy;

smorlat's avatar
smorlat committed
437 438 439 440 441 442 443
typedef enum _LinphoneWaitingState{
	LinphoneWaitingStart,
	LinphoneWaitingProgress,
	LinphoneWaitingFinished
} LinphoneWaitingState;
typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *context, LinphoneWaitingState ws, const char *purpose, float progress);

444
typedef struct _LinphoneCore LinphoneCore;
aymeric's avatar
aymeric committed
445 446 447 448 449 450

/* 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
451 452
/*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
453 454 455
const char *linphone_core_get_version(void);

LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
456
						const char *config_path, const char *factory_config, void* userdata);
aymeric's avatar
aymeric committed
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484

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

int linphone_core_invite(LinphoneCore *lc, const char *url);

int linphone_core_refer(LinphoneCore *lc, const char *url);

bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);

bool_t linphone_core_in_call(const LinphoneCore *lc);

int linphone_core_accept_call(LinphoneCore *lc, const char *url);

int linphone_core_terminate_call(LinphoneCore *lc, const char *url);

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);

485
LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
aymeric's avatar
aymeric committed
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510

/*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);


#ifdef VINCENT_MAURY_RSVP
/* QoS functions */
int linphone_core_set_rpc_mode(LinphoneCore *lc, int on); /* on = 1 (RPC_ENABLE = 1) */
int linphone_core_set_rsvp_mode(LinphoneCore *lc, int on); /* on = 1 (RSVP_ENABLE = 1) */
int linphone_core_change_qos(LinphoneCore *lc, int answer); /* answer = 1 for yes, 0 for no */
#endif

/* 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);

511 512 513 514 515 516
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);

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

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

aymeric's avatar
aymeric committed
517 518 519 520
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);

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

smorlat's avatar
smorlat committed
521 522
void linphone_core_clear_proxy_config(LinphoneCore *lc);

aymeric's avatar
aymeric committed
523 524 525 526 527 528 529 530 531 532 533 534 535 536
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);

void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);

void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info);

smorlat's avatar
smorlat committed
537 538 539 540
const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc);

LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username);

aymeric's avatar
aymeric committed
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
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);

565 566 567 568
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);

aymeric's avatar
aymeric committed
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
int linphone_core_get_sip_port(LinphoneCore *lc);

void linphone_core_set_sip_port(LinphoneCore *lc,int port);

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
596 597
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
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
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);
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);
613 614 615
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
616
int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata);
617 618
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
619

smorlat's avatar
smorlat committed
620 621 622
void linphone_core_enable_echo_limiter(LinphoneCore *lc, bool_t val);
bool_t linphone_core_echo_limiter_enabled(const LinphoneCore *lc);

623 624 625
void linphone_core_enable_agc(LinphoneCore *lc, bool_t val);
bool_t linphone_core_agc_enabled(const LinphoneCore *lc);

smorlat's avatar
smorlat committed
626 627
void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted);

aymeric's avatar
aymeric committed
628 629 630 631
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
632
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
aymeric's avatar
aymeric committed
633 634 635 636
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 */
637
const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
aymeric's avatar
aymeric committed
638 639
/* notify all friends that have subscribed */
void linphone_core_notify_all_friends(LinphoneCore *lc, LinphoneOnlineStatus os);
640
LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr);
641
LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
aymeric's avatar
aymeric committed
642 643

/* returns a list of LinphoneCallLog */
smorlat's avatar
smorlat committed
644
const MSList * linphone_core_get_call_logs(LinphoneCore *lc);
645
void linphone_core_clear_call_logs(LinphoneCore *lc);
aymeric's avatar
aymeric committed
646 647 648 649 650

/* 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
651 652 653 654 655 656 657 658 659
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
660 661 662 663

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
664 665
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
666 667 668 669 670 671 672


/* 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);

673 674
/*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
675 676 677 678 679 680 681


/*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);

smorlat's avatar
smorlat committed
682 683
gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
int linphone_core_get_current_call_duration(const LinphoneCore *lc);
684
const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc);
smorlat's avatar
smorlat committed
685

aymeric's avatar
aymeric committed
686 687 688 689 690 691 692 693 694
int linphone_core_get_mtu(const LinphoneCore *lc);
void linphone_core_set_mtu(LinphoneCore *lc, int mtu);

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
695 696
/* attempts to wake up another linphone engine already running.
The "show" callback is called for the other linphone, causing gui to show up.
697
call_addr is an optional sip-uri to call immediately after waking up.
smorlat's avatar
smorlat committed
698
The method returns 0 if an already running linphone was found*/
699

700 701
int linphone_core_wake_up_possible_already_running_instance(
    const char * config_file, const char * call_addr);
smorlat's avatar
smorlat committed
702

smorlat's avatar
smorlat committed
703
/*set a callback for some blocking operations, it takes you informed of the progress of the operation*/
704
void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallback cb, void *user_context);
smorlat's avatar
smorlat committed
705

smorlat's avatar
smorlat committed
706 707 708
/*returns the list of registered SipSetup (linphonecore plugins) */
const MSList * linphone_core_get_sip_setups(LinphoneCore *lc);

aymeric's avatar
aymeric committed
709 710
void linphone_core_destroy(LinphoneCore *lc);

smorlat's avatar
smorlat committed
711 712 713
/*for advanced users:*/
void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp);

aymeric's avatar
aymeric committed
714 715 716 717 718
#ifdef __cplusplus
}
#endif

#endif