/* 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 #ifndef LINPHONE_PUBLIC #define LINPHONE_PUBLIC MS2_PUBLIC #endif #ifdef __cplusplus extern "C" { #endif struct _LinphoneCore; /** * Linphone core main object created by function linphone_core_new() . * @ingroup initializing */ typedef struct _LinphoneCore LinphoneCore; struct _LpConfig; typedef struct _LCSipTransports{ int udp_port; int tcp_port; int dtls_port; int tls_port; } 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 LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *uri); LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri); const char *linphone_address_get_scheme(const LinphoneAddress *u); LINPHONE_PUBLIC const char *linphone_address_get_display_name(const LinphoneAddress* u); LINPHONE_PUBLIC const char *linphone_address_get_username(const LinphoneAddress *u); LINPHONE_PUBLIC 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); LINPHONE_PUBLIC void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name); LINPHONE_PUBLIC void linphone_address_set_username(LinphoneAddress *uri, const char *username); LINPHONE_PUBLIC 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*/ LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri); LINPHONE_PUBLIC char *linphone_address_as_string(const LinphoneAddress *u); LINPHONE_PUBLIC char *linphone_address_as_string_uri_only(const LinphoneAddress *u); LINPHONE_PUBLIC bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2); LINPHONE_PUBLIC 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 LinphoneCallLog; /** * Enum describing type of media encryption types. **/ enum LinphoneMediaEncryption { LinphoneMediaEncryptionNone, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionZRTP }; /** * Enum describing type of media encryption types. **/ typedef enum LinphoneMediaEncryption LinphoneMediaEncryption; /*public: */ LINPHONE_PUBLIC LinphoneAddress *linphone_call_log_get_from(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneAddress *linphone_call_log_get_to(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneAddress *linphone_call_log_get_remote_address(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneCallDir linphone_call_log_get_dir(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneCallStatus linphone_call_log_get_status(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneCallStatus linphone_call_log_video_enabled(LinphoneCallLog *cl); LINPHONE_PUBLIC time_t linphone_call_log_get_start_date(LinphoneCallLog *cl); LINPHONE_PUBLIC int linphone_call_log_get_duration(LinphoneCallLog *cl); LINPHONE_PUBLIC float linphone_call_log_get_quality(LinphoneCallLog *cl); LINPHONE_PUBLIC void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up); LINPHONE_PUBLIC void *linphone_call_log_get_user_pointer(const LinphoneCallLog *cl); void linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey); const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl); 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); LINPHONE_PUBLIC const char *linphone_call_log_get_call_id(const LinphoneCallLog *cl); LINPHONE_PUBLIC char * linphone_call_log_to_str(LinphoneCallLog *cl); struct _LinphoneCallParams; /** * The LinphoneCallParams is an object containing various call related parameters. * It can be used to retrieve parameters from a currently running call or modify the call's characteristics * dynamically. **/ typedef struct _LinphoneCallParams LinphoneCallParams; const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp); LINPHONE_PUBLIC LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); LINPHONE_PUBLIC void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); LINPHONE_PUBLIC bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); LinphoneMediaEncryption linphone_call_params_get_media_encryption(const LinphoneCallParams *cp); void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, LinphoneMediaEncryption e); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp); bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp); void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw); void linphone_call_params_destroy(LinphoneCallParams *cp); bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *cp); void linphone_call_params_enable_low_bandwidth(LinphoneCallParams *cp, bool_t enabled); void linphone_call_params_set_record_file(LinphoneCallParams *cp, const char *path); const char *linphone_call_params_get_record_file(const LinphoneCallParams *cp); void linphone_call_params_add_custom_header(LinphoneCallParams *params, const char *header_name, const char *header_value); const char *linphone_call_params_get_custom_header(const LinphoneCallParams *params, const char *header_name); /** * Enum describing failure reasons. * @ingroup initializing **/ enum _LinphoneReason{ LinphoneReasonNone, LinphoneReasonNoResponse, /** 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 */ LINPHONE_PUBLIC void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val); #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register LINPHONE_PUBLIC void linphone_proxy_config_edit(LinphoneProxyConfig *obj); LINPHONE_PUBLIC 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 * */ LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); LINPHONE_PUBLIC void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val); LINPHONE_PUBLIC void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix); LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj); LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); LINPHONE_PUBLIC const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg); LINPHONE_PUBLIC const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj); LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj); LINPHONE_PUBLIC const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj); int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj); LINPHONE_PUBLIC 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); LINPHONE_PUBLIC 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); /* * return the transport from either : service route, route, or addr * @returns cfg object * @return transport as string (I.E udp, tcp, tls, dtls)*/ LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(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 */ LINPHONE_PUBLIC 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 */ LINPHONE_PUBLIC void linphone_proxy_config_set_user_data(LinphoneProxyConfig *cr, void * ud); /* * get user data to a proxy config. return null if any */ LINPHONE_PUBLIC 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; LINPHONE_PUBLIC 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); void linphone_auth_info_set_realm(LinphoneAuthInfo *info, const char *realm); void linphone_auth_info_set_ha1(LinphoneAuthInfo *info, const char *ha1); 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); const char *linphone_auth_info_get_realm(const LinphoneAuthInfo *i); const char *linphone_auth_info_get_ha1(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; /** *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; /**