Linphone 集成配置

一、準備工作

1.1 添加依賴庫

libz.tbd

libiconv.tbd

libsqlite3.tbd

libc++.tbd

libstdc++.6.tbd

libresolv.tbd

AudioToolbox.framework

UIKit.framework

QuartzCore.framework

OpenGLES.framework

MessageUI.framework

MediaPlayer.framework

CoreGraphics.framework

MobileCoreServices.framework

AddressBookUI.framework

AddressBook.framework

SystemConfiguration.framework

CFNetwork.framework

AssetsLibrary.framework

AVFoundation.framework

CoreAudio.framework

CoreMedia.framework

CoreTelephony.framework

CoreVideo.framework

Foundation.framework

CoreLocation.framework

新增:VideoToolBox.framework

新增: libxml2.2.tbd

1.2、Other Linker Flags 中增加 -ObjC

Other Linker Flags 中增加 -lxml2

1.2、將Framework Search Paths 設置為? /usr/lib/libxml2.tbd

1.2、GTMBase64.m設置為arc環(huán)境:? -fro-objc-arc

1.2、Header Search Paths設置

$(SDKROOT)/usr/include/libxml2

$(SRCROOT)/liblinphone-sdk/apple-darwin/include

1.2、Library Search Paths設置

$(inherited)

$(PROJECT_DIR)/liblinphone-sdk/apple-darwin/lib

$(PROJECT_DIR)/liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins

1.2、User Header Search Paths設置

$(SDKROOT)/usr/include/libxml2

1.2、Enable Bitcode 設置 NO

1.3、新建PrefixHeader.pch文件,加入#import

->Prefix Header設置為 LinphoneDemo/PrefixHeader.pch

#ifdef __OBJC__#import

#import "LinphoneManager.h"

//#import "XMPPStream+Secure.h"

#import "Utils.h"

#endif

1.4、權限設置

NSAppleMusicUsageDescriptionApp 需要您的同意,才能訪問媒體資料庫

NSBluetoothPeripheralUsageDescriptionApp 需要您的同意,才能訪問藍牙

NSCalendarsUsageDescriptionApp 需要您的同意,才能訪問日歷

NSCameraUsageDescriptionApp 需要您的同意,才能訪問相機

NSContactsUsageDescriptionApp 需要您的同意,才能讀取通訊錄

NSHealthShareUsageDescriptionApp 需要您的同意,才能訪問健康分享

NSHealthUpdateUsageDescriptionApp 需要您的同意,才能訪問健康更新

NSLocationAlwaysUsageDescriptionApp 需要您的同意,才能始終訪問位置

NSLocationUsageDescriptionApp 需要您的同意,才能訪問位置

NSLocationWhenInUseUsageDescriptionApp 需要您的同意,才能在使用期間訪問位置

NSMicrophoneUsageDescriptionApp 需要您的同意,才能訪問麥克風

NSMotionUsageDescriptionApp 需要您的同意,才能訪問運動與健身

NSPhotoLibraryUsageDescriptionApp 需要您的同意,才能訪問相冊

NSRemindersUsageDescriptionApp 需要您的同意,才能訪問提醒事項

1.5、http請求設置NSAppTransportSecurityNSAllowsArbitraryLoads

1.6、后臺運行? /*? 打電話? 下載網(wǎng)絡數(shù)據(jù)? 遠程通知? 接電話? */

一般的iOS程序進入后臺后會被系統(tǒng)掛起,就會停止執(zhí)行,不能執(zhí)行任何操作。

?從iOS4開始,蘋果增加了特性,很好的支持了語音通話功能:

?蘋果支持應用可以在后臺播放和錄制聲音;

?蘋果支持網(wǎng)絡托管,保證應用在后臺時,還能保持網(wǎng)絡連接,能接收到來電;

?應用可以設置一個超時處理,程序在后臺運行時,周期性地喚醒應用,保證客戶端和服務器有長連接,使網(wǎng)絡不斷開

?SDK封裝了這些特性,保證了在iOS平臺上,有很好的語音通話體驗。開發(fā)者需要修改配置文件,這樣iOS工程才能支持這些特性UIBackgroundModesaudiofetchremote-notificationvoip

二、導入Linphone SDK

2.1? 將下面兩個文件中的.a文件全部在Linked Frameworks and Libraries 中添加進去/Users/Admin/Desktop/GitLab/WiseUC/liblinphone-sdk/apple-darwin/lib/Users/Admin/Desktop/GitLab/WiseUC/liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins

2.2查看項目是否有如下配置,有即正確,沒有則自己添加上Header Search Patchs

$(SRCROOT)/liblinphone-sdk/apple-darwin/includeLibrary

Search Patchs$(inherited)$(PROJECT_DIR)/liblinphone-sdk/apple-darwin/lib$(PROJECT_DIR)/liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins

/* 通知 */

NSString *const kLinphoneCoreUpdate? ? ? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneCoreUpdate";

//顯示狀態(tài)

NSString *const kLinphoneDisplayStatusUpdate? ? ? ? ? ? ? ? ? = @"LinphoneDisplayStatusUpdate";

//接收到信息

NSString *const kLinphoneMessageReceived? ? ? ? ? ? ? ? ? ? ? = @"LinphoneMessageReceived";

//開始編輯文字

NSString *const kLinphoneTextComposeEvent? ? ? ? ? ? ? ? ? ? = @"LinphoneTextComposeStarted";

//通話更新

NSString *const kLinphoneCallUpdate? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneCallUpdate";

//注冊更新

NSString *const kLinphoneRegistrationUpdate? ? ? ? ? ? ? ? ? ? ? = @"LinphoneRegistrationUpdate";

//通訊錄更新

NSString *const kLinphoneAddressBookUpdate? ? ? ? ? ? ? ? ? ? = @"LinphoneAddressBookUpdate";

//主視圖更新

NSString *const kLinphoneMainViewChange? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneMainViewChange";

//日志更新

NSString *const kLinphoneLogsUpdate? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneLogsUpdate";

//設置更新

NSString *const kLinphoneSettingsUpdate? ? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneSettingsUpdate";

//藍牙可用性更新

NSString *const kLinphoneBluetoothAvailabilityUpdate? ? ? ? ? ? = @"LinphoneBluetoothAvailabilityUpdate";

//配置狀態(tài)更新

NSString *const kLinphoneConfiguringStateUpdate? ? ? ? ? ? ? ? = @"LinphoneConfiguringStateUpdate";

//全局狀態(tài)更新

NSString *const kLinphoneGlobalStateUpdate? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneGlobalStateUpdate";

//接收到通知

NSString *const kLinphoneNotifyReceived? ? ? ? ? ? ? ? ? ? ? ? ? ? ? = @"LinphoneNotifyReceived";

NSString *const kLinphoneNotifyPresenceReceivedForUriOrTel = @"LinphoneNotifyPresenceReceivedForUriOrTel";

//通話加密狀態(tài)改變

NSString *const kLinphoneCallEncryptionChanged? ? ? ? ? ? ? ? ? = @"LinphoneCallEncryptionChanged";

//文件傳輸發(fā)送更新

NSString *const kLinphoneFileTransferSendUpdate? ? ? ? ? ? ? ? = @"LinphoneFileTransferSendUpdate";

//文件傳輸接受更新

NSString *const kLinphoneFileTransferRecvUpdate? ? ? ? ? ? ? ? = @"LinphoneFileTransferRecvUpdate";

/* 通話狀態(tài)Enum*/

typedef enum _LinphoneCallState

{

LinphoneCallIdle,? ? ? ? ? ? ? ? ? /**<通話初始化 */

LinphoneCallIncomingReceived,? ? ? /**<收到來電 */

LinphoneCallOutgoingInit,? ? ? ? ? /**<呼出電話初始化 */

LinphoneCallOutgoingProgress,? ? ? /**<呼出電話撥號中 */

LinphoneCallOutgoingRinging,? ? ? ? /**<呼出電話正在響鈴 */

LinphoneCallOutgoingEarlyMedia,? ? /**<早期媒體提出呼叫*/

LinphoneCallConnected,? ? ? ? ? ? ? /**<通話連接成功*/

LinphoneCallStreamsRunning,? ? ? ? /**媒體流已建立*/

LinphoneCallPausing,? ? ? ? ? ? ? ? /**<通話暫停中 */

LinphoneCallPaused,? ? ? ? ? ? ? ? /**< 通話暫停成功*/

LinphoneCallResuming,? ? ? ? ? ? ? /**<通話被恢復*/

LinphoneCallRefered,? ? ? ? ? ? ? ? /**通話轉移*/

LinphoneCallError,? ? ? ? ? ? ? ? ? /**<通話錯誤*/

LinphoneCallEnd,? ? ? ? ? ? ? ? ? ? /**<通話正常結束*/

LinphoneCallPausedByRemote,? ? ? ? /**<通話被對方暫停*/

LinphoneCallUpdatedByRemote,? ? ? ? /**<對方請求更新通話參數(shù) */

LinphoneCallIncomingEarlyMedia,

@required

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(PKPushType)type;更新證書

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type;收到推送來電

@optional

- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type;推送證書無效

(LinphoneCall)

/*******************************************************************************

*call通話相關方法

******************************************************************************/

linphone_call_state_to_string(LinphoneCallState cs);? ? ? ? ? ? 通話狀態(tài)-》string

linphone_call_get_user_data(const LinphoneCall *call);? ? ? ? ? 獲取,檢索與呼叫關聯(lián)的用戶指針。

linphone_call_set_user_data(LinphoneCall *call, void *ud);? ? ? 設置用戶數(shù)據(jù),將一個用戶指針分配給該呼叫。

linphone_call_get_core(const LinphoneCall *call);

linphone_call_get_state(const LinphoneCall *call);? ? ? ? ? ? ? 獲取通話狀態(tài)

linphone_core_get_current_call_remote_address(LinphoneCore *lc); 獲取當前調(diào)用的遠程地址,如果沒有當前調(diào)用,則為NULL。

(LinphoneCallLog)

/*******************************************************************************

*通話記錄相關方法(在這個里邊可以獲取到電話的相關信息)

******************************************************************************/

linphone_call_log_get_call_id(const LinphoneCallLog *cl);? ? ? ? 呼叫ID

linphone_call_log_get_dir(LinphoneCallLog *cl);

linphone_call_log_get_duration(LinphoneCallLog *cl);? ? ? ? ? ? ? 呼叫持續(xù)時間在幾秒鐘內(nèi)

linphone_call_log_get_from_address(LinphoneCallLog *cl);? ? ? ? ? 來電地址(即來自)呼叫。

linphone_call_log_get_local_stats(const LinphoneCallLog *cl);? ? 本地為本次計算的RTP統(tǒng)計信息。

linphone_call_log_get_quality(LinphoneCallLog *cl);? ? ? ? ? ? ? 呼叫的整體質(zhì)量指示。

linphone_call_log_get_ref_key(const LinphoneCallLog *cl);? ? ? ? 與呼叫記錄相關聯(lián)的引用鍵字符串,如果沒有關聯(lián),則返回NULL。

linphone_call_log_get_remote_address(LinphoneCallLog *cl);? ? ? ? 呼叫的遠程地址。

linphone_call_log_get_remote_stats(const LinphoneCallLog *cl);? ? 由遠程端計算的RTP統(tǒng)計信息

linphone_call_log_get_start_date(LinphoneCallLog *cl);? ? ? ? ? ? 通話開始的日期

linphone_call_log_get_status(LinphoneCallLog *cl);? ? ? ? ? ? ? ? 通話狀態(tài)

linphone_call_log_get_to_address(LinphoneCallLog *cl);? ? ? ? ? ? 呼叫的目的地址(即到)。

linphone_call_log_set_ref_key(LinphoneCallLog *cl, const char *refkey);? ? ? ? PARAM:refkey與呼叫記錄關聯(lián)的參考鍵字符串。

linphone_call_log_video_enabled(LinphoneCallLog *cl);? ? ? ? ? ? 表示視頻是否在通話結束時啟用。

linphone_call_log_to_str(LinphoneCallLog *cl);? ? ? ? ? ? ? ? ? ? 獲取描述呼叫的可讀字符串。

linphone_call_log_was_conference(LinphoneCallLog *cl);? ? ? ? ? ? 獲取呼叫類型,如果是會議的呼叫,則為TRUE

/*******************************************************************************

* 參考和用戶數(shù)據(jù)處理功能

******************************************************************************/

linphone_call_log_get_user_data(const LinphoneCallLog *cl);? ? ? 與通話記錄相關聯(lián)的用戶數(shù)據(jù)。

linphone_call_log_set_user_data(LinphoneCallLog *cl, void *ud);? 將用戶數(shù)據(jù)分配給通話記錄。

linphone_call_log_ref(LinphoneCallLog *cl);? ? ? ? ? ? ? ? ? ? ? 相同的LinphoneCallLog對象

linphone_call_log_unref(LinphoneCallLog *cl);? ? ? ? ? ? ? ? ? ? 釋放對通話記錄的引用。

(LinphoneAddress)

/*******************************************************************************

* 地址相關方法,在打電話時會用到這個。

******************************************************************************/

LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *addr);

LINPHONE_PUBLIC LinphoneAddress * linphone_address_clone(const LinphoneAddress *addr);

LINPHONE_PUBLIC LinphoneAddress * linphone_address_ref(LinphoneAddress *addr);

LINPHONE_PUBLIC void linphone_address_unref(LinphoneAddress *addr);

LINPHONE_PUBLIC 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);

LINPHONE_PUBLIC int linphone_address_get_port(const LinphoneAddress *u);

LINPHONE_PUBLIC int linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);

LINPHONE_PUBLIC int linphone_address_set_username(LinphoneAddress *uri, const char *username);

LINPHONE_PUBLIC int linphone_address_set_domain(LinphoneAddress *uri, const char *host);

LINPHONE_PUBLIC int linphone_address_set_port(LinphoneAddress *uri, int port);

LINPHONE_PUBLIC int linphone_address_set_transport(LinphoneAddress *uri,LinphoneTransportType type);

LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri);

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容