# Initializing liblinphone

## Data Structures
struct | _LinphoneVTable
## Typedefs
typedef struct _LinphoneCore | LinphoneCore
typedef enum _LinphoneGlobalState | LinphoneGlobalState
typedef void(* | LinphoneGlobalStateCb )(struct _LinphoneCore *lc, LinphoneGlobalState gstate, const char *message)
typedef void(* | LinphoneCallStateCb )(struct _LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message)
typedef void(* | LinphoneRegistrationStateCb )(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message)
typedef void(* | ShowInterfaceCb )(struct _LinphoneCore *lc)
typedef void(* | DisplayStatusCb )(struct _LinphoneCore *lc, const char *message)
typedef void(* | DisplayMessageCb )(struct _LinphoneCore *lc, const char *message)
typedef void(* | DisplayUrlCb )(struct _LinphoneCore *lc, const char *message, const char *url)
typedef void(* | LinphoneCoreCbFunc )(struct _LinphoneCore *lc, void *user_data)
typedef void(* | NotifyReceivedCb )(struct _LinphoneCore *lc, LinphoneCall *call, const char *from, const char *event)
typedef void(* | NotifyPresenceReceivedCb )(struct _LinphoneCore *lc, LinphoneFriend *lf)
typedef void(* | NewSubscribtionRequestCb )(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url)
typedef void(* | AuthInfoRequested )(struct _LinphoneCore *lc, const char *realm, const char *username)
typedef void(* | CallLogUpdated )(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl)
typedef void(* | TextMessageReceived )(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message)
typedef void(* | DtmfReceived )(struct _LinphoneCore *lc, LinphoneCall *call, int dtmf)
typedef void(* | ReferReceived )(struct _LinphoneCore *lc, const char *refer_to)
typedef void(* | BuddyInfoUpdated )(struct _LinphoneCore *lc, LinphoneFriend *lf)
typedef struct _LinphoneVTable | LinphoneCoreVTable
## Enumerations
enum | _LinphoneReason { , LinphoneReasonNoResponse, LinphoneReasonBadCredentials, LinphoneReasonDeclined }
enum | _LinphoneGlobalState
## Functions
LinphoneCore * | linphone_core_new (const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config_path, void *userdata)
void | linphone_core_iterate (LinphoneCore *lc)
void * | linphone_core_get_user_data (LinphoneCore *lc)
void | linphone_core_destroy (LinphoneCore *lc)

## Typedef Documentation

typedef struct _LinphoneCore LinphoneCore

Linphone core main object created by function linphone_core_new() .

typedef enum _LinphoneGlobalState LinphoneGlobalState

LinphoneGlobalState describes the global state of the LinphoneCore object. It is notified via the LinphoneCoreVTable::global_state_changed

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)

Call state notification callback prototype

typedef void(* LinphoneRegistrationStateCb)(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message)

Registration state notification callback prototype

typedef void(* ShowInterfaceCb)(struct _LinphoneCore *lc)

Callback prototype

typedef void(* DisplayStatusCb)(struct _LinphoneCore *lc, const char *message)

Callback prototype

typedef void(* DisplayMessageCb)(struct _LinphoneCore *lc, const char *message)

Callback prototype

typedef void(* DisplayUrlCb)(struct _LinphoneCore *lc, const char *message, const char *url)

Callback prototype

typedef void(* LinphoneCoreCbFunc)(struct _LinphoneCore *lc, void *user_data)

Callback prototype

typedef void(* NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const char *from, const char *event)

Callback prototype

typedef void(* NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend *lf)

Report status change for a friend previously added to LinphoneCore.

Parameters:

  | lc | LinphoneCore object .
  | lf | Updated LinphoneFriend .

typedef void(* NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url)

Reports that a new subscription request has been received and wait for a decision.
Status on this subscription request is notified by changing policy for this friend

Parameters:

  | lc | LinphoneCore object
  | lf | LinphoneFriend corresponding to the subscriber
  | url | of the subscriber Callback prototype

typedef void(* AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username)

Callback prototype

typedef void(* CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl)

Callback prototype

typedef void(* TextMessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message)

Callback prototype

Parameters:

  | lc | LinphoneCore object
  | room | LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
  | from | LinphoneAddress from
  | message | incoming message

typedef void(* DtmfReceived)(struct _LinphoneCore *lc, LinphoneCall *call, int dtmf)

Callback prototype

typedef void(* ReferReceived)(struct _LinphoneCore *lc, const char *refer_to)

Callback prototype

typedef void(* BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf)

Callback prototype

typedef struct _LinphoneVTable LinphoneCoreVTable

This structure holds all callbacks that the application should implement. None is mandatory.

## Enumeration Type Documentation

enum _LinphoneReason

Enum describing failure reasons.

Enumerator:

  LinphoneReasonNoResponse | No response received from remote
  LinphoneReasonBadCredentials | Authentication failed due to bad or missing credentials
  LinphoneReasonDeclined | The call has been declined

enum _LinphoneGlobalState

LinphoneGlobalState describes the global state of the LinphoneCore object. It is notified via the LinphoneCoreVTable::global_state_changed

## Function Documentation

LinphoneCore* linphone_core_new | ( | const LinphoneCoreVTable * | vtable,
|  | const char * | config_path,
|  | const char * | factory_config_path,
|  | void * | userdata |
| ) |  |  |

Instanciates a LinphoneCore object.

The LinphoneCore object is the primary handle for doing all phone actions. It should be unique within your application.

Parameters:

  | vtable | a LinphoneCoreVTable structure holding your application callbacks
  | config_path | a path to a config file. If it does not exists it will be created. The config file is used to store all settings, call logs, friends, proxies... so that all these settings become persistent over the life of the LinphoneCore object. It is allowed to set a NULL config file. In that case LinphoneCore will not store any settings.
  | factory_config_path | a path to a read-only config file that can be used to to store hard-coded preference such as proxy settings or internal preferences. The settings in this factory file always override the one in the normal config file. It is OPTIONAL, use NULL if unneeded.
  | userdata | an opaque user pointer that can be retrieved at any time (for example in callbacks) using linphone_core_get_user_data().

void linphone_core_iterate | ( | LinphoneCore * | lc | ) |

Main loop function. It is crucial that your application call it periodically.

linphone_core_iterate() performs various backgrounds tasks:

- receiving of SIP messages
- handles timers and timeout
- performs registration to proxies
- authentication retries The application MUST call this function periodically, in its main loop. Be careful that this function must be called from the same thread as other liblinphone methods. If it is not the case make sure all liblinphone calls are serialized with a mutex.

void* linphone_core_get_user_data | ( | LinphoneCore * | lc | ) |

Retrieves the user pointer that was given to linphone_core_new()

void linphone_core_destroy | ( | LinphoneCore * | lc | ) |

Destroys a LinphoneCore