码迷,mamicode.com
首页 > 其他好文 > 详细

linphone3.4.0代码分析

时间:2016-12-19 21:41:19      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:recv   tor   run   oba   call   codec   factor   creat   接口   

主要类型定义:

1、LinphoneCoreVTable

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


app(GTK)中相对应的实现接口函数:
    vtable.call_state_changed=linphone_gtk_call_state_changed;
    vtable.registration_state_changed=linphone_gtk_registration_state_changed;
    vtable.show=linphone_gtk_show;
    vtable.notify_presence_recv=linphone_gtk_notify_recv;
    vtable.new_subscription_request=linphone_gtk_new_unknown_subscriber;
    vtable.auth_info_requested=linphone_gtk_auth_info_requested;
    vtable.display_status=linphone_gtk_display_status;
    vtable.display_message=linphone_gtk_display_message;
    vtable.display_warning=linphone_gtk_display_warning;
    vtable.display_url=linphone_gtk_display_url;
    vtable.call_log_updated=linphone_gtk_call_log_updated;
    vtable.text_received=linphone_gtk_text_received;
    vtable.refer_received=linphone_gtk_refer_received;
    vtable.buddy_info_updated=linphone_gtk_buddy_info_updated;


app(linphonec)中相对应的实现接口函数:
    linphonec_vtable.call_state_changed=linphonec_call_state_changed;
    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;
    linphonec_vtable.display_message=linphonec_display_something;
    linphonec_vtable.display_warning=linphonec_display_warning;
    linphonec_vtable.display_url=linphonec_display_url;
    linphonec_vtable.text_received=linphonec_text_received;
    linphonec_vtable.dtmf_received=linphonec_dtmf_received;
    linphonec_vtable.refer_received=linphonec_display_refer;
    linphonec_vtable.notify_recv=linphonec_notify_received;

 

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

 

3、SalCallbacks

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;

linphone中的sal层默认实现:
SalCallbacks linphone_sal_callbacks={
    call_received,
    call_ringing,
    call_accepted,
    call_ack,
    call_updating,
    call_terminated,
    call_failure,
    call_released,
    auth_requested,
    auth_success,
    register_success,
    register_failure,
    vfu_request,
    dtmf_received,
    refer_received,
    text_received,
    notify,
    notify_presence,
    subscribe_received,
    subscribe_closed,
    internal_message,
    ping_reply
};

4、LinphoneCallState

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

 

 

 

主要函数:

1、linphone_core_new

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

 

 

 

 

 

 

 

 

aa

linphone3.4.0代码分析

标签:recv   tor   run   oba   call   codec   factor   creat   接口   

原文地址:http://www.cnblogs.com/jingzhishen/p/6198881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!