/* linphone Copyright (C) 2000 - 2010 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" #include "mediastreamer2/msvideo.h" #ifdef IN_LINPHONE #include "sipsetup.h" #else #include "linphone/sipsetup.h" #endif #define LINPHONE_IPADDR_SIZE 64 #define LINPHONE_HOSTNAME_SIZE 128 #ifdef __cplusplus extern "C" { #endif struct _MSSndCard; struct _LinphoneCore; /** * Linphone core main object created by function linphone_core_new() . * @ingroup initializing */ typedef struct _LinphoneCore LinphoneCore; struct SalOp; struct _LpConfig; struct _LCSipTransports{ int udp_port; int tcp_port; int dtls_port; int tls_port; }; typedef struct _LCSipTransports LCSipTransports; /** * 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 '. * 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 */ typedef struct SalAddress LinphoneAddress; #ifdef IN_LINPHONE #include "linphonefriend.h" #else #include "linphone/linphonefriend.h" #endif 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); /** * 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); 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); /*remove tags, params etc... so that it is displayable to the user*/ void linphone_address_clean(LinphoneAddress *uri); char *linphone_address_as_string(const LinphoneAddress *u); char *linphone_address_as_string_uri_only(const LinphoneAddress *u); bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2); void linphone_address_destroy(LinphoneAddress *u); struct _SipSetupContext; /** * Enum representing the direction of a call. * @ingroup call_logs **/ enum _LinphoneCallDir { LinphoneCallOutgoing, /**< outgoing calls*/ LinphoneCallIncoming /**< incoming calls*/ }; /** * Typedef for enum * @ingroup call_logs **/ typedef enum _LinphoneCallDir LinphoneCallDir; /** * Enum representing the status of a call * @ingroup call_logs **/ typedef enum _LinphoneCallStatus { LinphoneCallSuccess, /**< The call was sucessful*/ LinphoneCallAborted, /**< The call was aborted */ LinphoneCallMissed, /**< The call was missed (unanswered)*/ LinphoneCallDeclined /**< The call was declined, either locally or by remote end*/ } LinphoneCallStatus; /** * Structure representing a call log. * * @ingroup call_logs * **/ typedef struct _LinphoneCallLog{ LinphoneCallDir dir; /**< The direction of the call*/ LinphoneCallStatus status; /**< The status of the call*/ LinphoneAddress *from; /** In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. * @param obj object pointer * @param val if true, registration will be engaged */ 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); /** * Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig . *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. * @param obj object pointer * @param val if true, publish will be engaged * */ void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); 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); LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg); 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); void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj); const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj); void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params); struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg); const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg); LinphoneReason linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg); /* destruction is called automatically when removing the proxy config */ void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg); SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg); /** * 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); /* * 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); /** * @} **/ typedef struct _LinphoneAccountCreator{ struct _LinphoneCore *lc; struct _SipSetupContext *ssctx; char *username; char *password; char *domain; char *route; char *email; int suscribe; bool_t succeeded; }LinphoneAccountCreator; LinphoneAccountCreator *linphone_account_creator_new(struct _LinphoneCore *core, const char *type); 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); void linphone_account_creator_set_route(LinphoneAccountCreator *obj, const char *route); void linphone_account_creator_set_email(LinphoneAccountCreator *obj, const char *email); void linphone_account_creator_set_suscribe(LinphoneAccountCreator *obj, int suscribre); const char * linphone_account_creator_get_username(LinphoneAccountCreator *obj); const char * linphone_account_creator_get_domain(LinphoneAccountCreator *obj); int linphone_account_creator_test_existence(LinphoneAccountCreator *obj); int linphone_account_creator_test_validation(LinphoneAccountCreator *obj); LinphoneProxyConfig * linphone_account_creator_validate(LinphoneAccountCreator *obj); void linphone_account_creator_destroy(LinphoneAccountCreator *obj); struct _LinphoneAuthInfo; /** * @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. * **/ typedef struct _LinphoneAuthInfo LinphoneAuthInfo; 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); void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username); void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid); 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); /* 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); struct _LinphoneChatRoom; /** * @addtogroup chatroom * @{ */ /** * A chat room message to old content to be sent. *
Can be created by linphone_chat_room_create_message(). */ typedef struct _LinphoneChatMessage LinphoneChatMessage; /** * A chat room is the place where text messages are exchanged. *
Can be created by linphone_core_create_chat_room(). */ typedef struct _LinphoneChatRoom LinphoneChatRoom; /** * Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org * @param lc #LinphoneCore object * @param to destination address for messages * @return #LinphoneChatRoom where messaging can take place. */ LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to); /** * Destructor * @param cr #LinphoneChatRoom object */ void linphone_chat_room_destroy(LinphoneChatRoom *cr); /** * create a message attached to a dedicated chat room; */ LinphoneChatMessage* linphone_chat_room_create_message(const LinphoneChatRoom *cr,const char* message); /** * get peer address \link linphone_core_create_chat_room() associated to \endlink this #LinphoneChatRoom * @param cr #LinphoneChatRoom object * @return #LinphoneAddress peer address */ const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr); /** * send a message to peer member of this chat room. * @param cr #LinphoneChatRoom object * @param msg message to be sent */ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); /** *LinphoneChatMessageState is used to notify if messages have been succesfully delivered or not. */ typedef enum _LinphoneChatMessageStates { LinphoneChatMessageStateIdle, /** Status on this subscription request is notified by \link linphone_friend_set_inc_subscribe_policy() changing policy \endlink for this friend * @param lc #LinphoneCore object * @param lf #LinphoneFriend corresponding to the subscriber * @param url of the subscriber * Callback prototype * */ typedef void (*NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url); /** 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 * @deprecated use #MessageReceived instead. * * @param lc #LinphoneCore object * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. * @param from #LinphoneAddress from * @param message incoming message * */ typedef void (*TextMessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); /** * Chat message callback prototype * * @param lc #LinphoneCore object * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. * @param LinphoneChatMessage incoming message * */ typedef void (*MessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); /** Callback prototype */ 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 for in progress transfers. The new_call_state is the state of the call resulting of the transfer, at the other party. */ typedef void (*LinphoneTransferStateChanged)(struct _LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state); /** Callback prototype for receiving quality statistics for calls*/ typedef void (*CallStatsUpdated)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); /** * This structure holds all callbacks that the application should implement. * None is mandatory. **/ typedef struct _LinphoneVTable{ LinphoneGlobalStateCb global_state_changed; /** A text message has been received */ MessageReceived message_received; /** a message is received, can be text or external body*/ DtmfReceived dtmf_received; /**< A dtmf has been received received */ ReferReceived refer_received; /**< An out of call refer was received */ CallEncryptionChangedCb call_encryption_changed; /**