发布时间:2017-1-23 22:54:26 编辑 分享查询网我要评论
本篇文章主要介绍了"linphone3.4.0代码分析 ",主要涉及到linphone3.4.0代码分析 方面的内容,对于linphone3.4.0代码分析 感兴趣的同学可以参考一下。



/** * This structure holds all callbacks that the application should implement. *  None is mandatory.**/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*/    NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/    NewSubscribtionRequestCb new_subscription_request; /**< Notify about pending subscription request */    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 */    ReferReceived refer_received; /**< An out of call refer was received */    BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/    NotifyReceivedCb notify_recv; /**< Other notifications*/    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*/} LinphoneCoreVTable;


    linphonec_vtable.notify_presence_recv = linphonec_notify_presence_received;
    linphonec_vtable.new_subscription_request = linphonec_new_unknown_subscriber;
    linphonec_vtable.auth_info_requested = linphonec_prompt_for_auth;
    linphonec_vtable.display_status = linphonec_display_status;

2、Sal(Signaling Abstraction Layer)

 This header files defines the Signaling Abstraction Layer.
 The purpose of this layer is too allow experiment different call signaling
 protocols and implementations under linphone, for example SIP, JINGLE...

struct Sal{ SalCallbacks callbacks; MSList
*calls; /*MSList of SalOp */ MSList *registers;/*MSList of SalOp */ MSList *out_subscribes;/*MSList of SalOp */ MSList *in_subscribes;/*MSList of SalOp */ MSList *pending_auths;/*MSList of SalOp */ MSList *other_transactions; /*MSList of SalOp */ int running; int session_expires; int keepalive_period; void *up; bool_t one_matching_codec; bool_t double_reg;};


typedef void (*SalOnCallReceived)(SalOp *op);typedef void (*SalOnCallRinging)(SalOp *op);typedef void (*SalOnCallAccepted)(SalOp *op);typedef void (*SalOnCallAck)(SalOp *op);typedef void (*SalOnCallUpdating)(SalOp *op);/*< Called when a reINVITE is received*/typedef void (*SalOnCallTerminated)(SalOp *op, const char *from);typedef void (*SalOnCallFailure)(SalOp *op, SalError error, SalReason reason, const char *details, int code);typedef void (*SalOnCallReleased)(SalOp *salop);typedef void (*SalOnAuthRequested)(SalOp *op, const char *realm, const char *username);typedef void (*SalOnAuthSuccess)(SalOp *op, const char *realm, const char *username);typedef void (*SalOnRegisterSuccess)(SalOp *op, bool_t registered);typedef void (*SalOnRegisterFailure)(SalOp *op, SalError error, SalReason reason, const char *details);typedef void (*SalOnVfuRequest)(SalOp *op);typedef void (*SalOnDtmfReceived)(SalOp *op, char dtmf);typedef void (*SalOnRefer)(Sal *sal, SalOp *op, const char *referto);typedef void (*SalOnTextReceived)(Sal *sal, const char *from, const char *msg);typedef void (*SalOnNotify)(SalOp *op, const char *from, const char *value);typedef void (*SalOnNotifyPresence)(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg);typedef void (*SalOnSubscribeReceived)(SalOp *salop, const char *from);typedef void (*SalOnSubscribeClosed)(SalOp *salop, const char *from);typedef void (*SalOnInternalMsg)(Sal *sal, const char *msg);typedef void (*SalOnPingReply)(SalOp *salop);typedef struct SalCallbacks{    SalOnCallReceived call_received;    SalOnCallRinging call_ringing;    SalOnCallAccepted call_accepted;    SalOnCallAck call_ack;    SalOnCallUpdating call_updating;    SalOnCallTerminated call_terminated;    SalOnCallFailure call_failure;    SalOnCallReleased call_released;    SalOnAuthRequested auth_requested;    SalOnAuthSuccess auth_success;    SalOnRegisterSuccess register_success;    SalOnRegisterFailure register_failure;    SalOnVfuRequest vfu_request;    SalOnDtmfReceived dtmf_received;    SalOnRefer refer_received;    SalOnTextReceived text_received;    SalOnNotify notify;    SalOnNotifyPresence notify_presence;    SalOnSubscribeReceived subscribe_received;    SalOnSubscribeClosed subscribe_closed;    SalOnInternalMsg internal_message;    SalOnPingReply ping_reply;}SalCallbacks;

SalCallbacks linphone_sal_callbacks={


/** * LinphoneCallState enum represents the different state a call can reach into. * The application is notified of state changes through the LinphoneCoreVTable::call_state_changed callback. * @ingroup call_control**/typedef enum _LinphoneCallState{    LinphoneCallIdle,                    /**<Initial call state */    LinphoneCallIncomingReceived, /**<This is a new incoming call */    LinphoneCallOutgoingInit, /**<An outgoing call is started */    LinphoneCallOutgoingProgress, /**<An outgoing call is in progress */    LinphoneCallOutgoingRinging, /**<An outgoing call is ringing at remote end */    LinphoneCallOutgoingEarlyMedia, /**<An outgoing call is proposed early media */    LinphoneCallConnected, /**<Connected, the call is answered */    LinphoneCallStreamsRunning, /**<The media streams are established and running*/    LinphoneCallPausing, /**<The call is pausing at the initiative of local end */    LinphoneCallPaused, /**< The call is paused, remote end has accepted the pause */    LinphoneCallResuming, /**<The call is being resumed by local end*/    LinphoneCallRefered, /**<The call is being transfered to another party, resulting in a new outgoing call to follow immediately*/    LinphoneCallError, /**<The call encountered an error*/    LinphoneCallEnd, /**<The call ended normally*/    LinphoneCallPausedByRemote, /**<The call is paused by remote end*/    LinphoneCallUpdatedByRemote, /**<The call's parameters are updated, used for example when video is asked by remote */    LinphoneCallIncomingEarlyMedia, /**<We are proposing early media to an incoming call */    LinphoneCallUpdated, /**<The remote accepted the call update initiated by us */    LinphoneCallReleased /**< The call object is no more retained by the core */} LinphoneCallState;



/** * Instanciates a LinphoneCore object. * @ingroup initializing *  * The LinphoneCore object is the primary handle for doing all phone actions. * It should be unique within your application. * @param vtable a LinphoneCoreVTable structure holding your application callbacks * @param 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. * @param 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. * @param userdata an opaque user pointer that can be retrieved at any time (for example in *        callbacks) using linphone_core_get_user_data(). * **/LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,                        const char *config_path, const char *factory_config_path, void * userdata)


上一篇:代码的坏味道(14)——重复代码(Duplicate Code)