AnyChat(全名叫Anychat SDK),也叫音視頻互動開發(fā)平臺;是一套跨平臺的即時通訊解決方案,基于先進的H.264視頻編碼標準、AAC音頻編碼標準與P2P技術(shù),整合了佰銳科技在音視頻編碼、多媒體通訊領(lǐng)域領(lǐng)先的開發(fā)技術(shù)和豐富的產(chǎn)品經(jīng)驗而設(shè)計的高質(zhì)量、寬適應(yīng)性、分布式、模塊化的網(wǎng)絡(luò)音視頻互動平臺。
可以進行雙人或多人的語音實時通話,支持Windows、Web、Android、iOS、Mac、Linux等跨平臺通信。
所提供的SDK支持C++、Delphi、Java、C#、VB、object-c等多種語音開發(fā)。
AnyChat包括音頻視頻錄制,拍照,服務(wù)器錄像,文字聊天,文件發(fā)送等多種功能。
界面如下

調(diào)用流程:
1.在所要監(jiān)聽的類中調(diào)用重載WndProc方法,實現(xiàn)windows消息的監(jiān)聽。
/// <summary>/// 重載/// </summary>/// <param name="m"></param>protected override void WndProc(ref Message m){if (m.Msg == AnyChatCoreSDK.WM_GV_CONNECT){//客戶端連接服務(wù)器,表示是否連接成功int succed = m.WParam.ToInt32();//連接服務(wù)器成功if (succed == 1){//登錄服務(wù)器(在WndProc中的獲取方法回調(diào)結(jié)果。參數(shù):AnyChatCoreSDK.WM_GV_LOGINSYSTEM)int ret = AnyChatCoreSDK.Login(PublicMembers.g_Name, "", 0);}else{PublicMembers.ShowRightTip("登錄失敗。錯誤代碼:" + succed, "");}}else if (m.Msg == AnyChatCoreSDK.WM_GV_LOGINSYSTEM){//客戶端登錄系統(tǒng),wParam(INT)表示自己的用戶ID號int userid = m.WParam.ToInt32();if (m.LParam.ToInt32() == 0){m_myUserID = userid;//進入房間(在WndProc中的獲取方法回調(diào)結(jié)果。參數(shù):AnyChatCoreSDK.WM_GV_ENTERROOM)int ret = AnyChatCoreSDK.EnterRoom(m_RoomID, "", 0);}else{MessageBox.Show("登錄服務(wù)器失敗,代碼出錯為:" + m.LParam.ToInt32(), "警告");}}else if (m.Msg == AnyChatCoreSDK.WM_GV_ENTERROOM){//客戶端進入房間if (m.LParam.ToInt32() == 0){//綁定本機視頻窗口 -1代表自己int ret = AnyChatCoreSDK.SetVideoPos(-1, picLocalVideo.Handle, 0, 0, picLocalVideo.Width, picLocalVideo.Height);//開啟本地視頻 -1代表自己ret = AnyChatCoreSDK.UserCameraControl(-1, true);//開啟本地聲音 -1代表自己ret = AnyChatCoreSDK.UserSpeakControl(-1, true);}else{MessageBox.Show("申請進入房間失敗,出錯代碼為:" + m.LParam.ToInt32(), "警告");}}else if (m.Msg == AnyChatCoreSDK.WM_GV_ONLINEUSER){//收到當前房間的在線用戶信息,進入房間后觸發(fā)一次int usrcnt = m.WParam.ToInt32();int cnt = 0;//在線用戶數(shù)量AnyChatCoreSDK.GetOnlineUser(null, ref cnt);//獲取在線用戶數(shù)量int[] userArr = new int[cnt];//在線用戶IDAnyChatCoreSDK.GetOnlineUser(userArr, ref cnt);//獲取在線用戶ID數(shù)組}else if (m.Msg == AnyChatCoreSDK.WM_GV_LINKCLOSE){//客戶端掉線處理}else if (m.Msg == AnyChatCoreSDK.WM_GV_USERATROOM){//用戶進入(離開)房間,wParam(INT)表示用戶ID號、//用戶IDint userID = m.WParam.ToInt32();//發(fā)生狀態(tài)int boEntered = m.LParam.ToInt32();if (boEntered == 1){//進入房間m_others.Add(userID);StartVideo(userID);}else{//退出房間m_others.Remove(userID);EndVideo(userID);}}base.WndProc(ref m);}2.初始化AnyChat的SDK
//設(shè)置回調(diào)函數(shù)SystemSetting.Text_OnReceive = new TextReceivedHandler(Received_CallBack);//文本回調(diào)涵數(shù)SystemSetting.TransBuffer_OnReceive = new TransBufferReceivedHandler(Received_TransBuffer);//透明通道傳輸回調(diào)SystemSetting.TransFile_OnReceive = new TransFileReceivedHandler(Received_TransFile);//文件傳輸回調(diào)SystemSetting.TransRecord_OnReceive = new TransRecordHandler(File_CallBack);//拍照錄像回調(diào)函數(shù)//初始化SystemSetting.Init(this.Handle);//設(shè)置內(nèi)核參數(shù) 設(shè)置保存路徑int ret = 0;ret = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_RECORD_TMPDIR, Application.StartupPath, Application.StartupPath.Length);ret = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_SNAPSHOT_TMPDIR, Application.StartupPath, Application.StartupPath.Length);
3.連接AnyChat服務(wù)器。使用AnyChat功能必須先連接并登錄AnyChat服務(wù)器。執(zhí)行連接操作后會觸發(fā)windows消息回調(diào) AnyChatCoreSDK.WM_GV_CONNECT
//登錄AnyChat (IP從配置文件中獲取)string IP = XmlHelper.GetXmlAttribute(PublicMembers.Config, "http://Configuration//IP", "value").Value;//連接服務(wù)器(在WndProc中的獲取方法回調(diào)結(jié)果。參數(shù):AnyChatCoreSDK.WM_GV_CONNECT)ret = AnyChatCoreSDK.Connect(IP, 8906);
4.登錄AnyChat服務(wù)器。執(zhí)行連接操作后會觸發(fā)windows消息回調(diào) AnyChatCoreSDK.WM_GV_LOGINSYSTEM
//登錄服務(wù)器(在WndProc中的獲取方法回調(diào)結(jié)果。參數(shù):AnyChatCoreSDK.WM_GV_LOGINSYSTEM)int ret = AnyChatCoreSDK.Login(PublicMembers.g_Name, "", 0);
5.服務(wù)器登錄成功后進入指定房間,只有在同一個房間內(nèi)的用戶才可以進行視頻音頻交互。
//進入房間(在WndProc中的獲取方法回調(diào)結(jié)果。參數(shù):AnyChatCoreSDK.WM_GV_ENTERROOM)int ret = AnyChatCoreSDK.EnterRoom(m_RoomID, "", 0);
6.打開,關(guān)閉音頻視頻
//綁定本機視頻窗口 -1代表自己,通過指定userId來綁定視頻窗口int ret = AnyChatCoreSDK.SetVideoPos(-1, picLocalVideo.Handle, 0, 0, picLocalVideo.Width, picLocalVideo.Height);//開啟本地視頻 -1代表自己ret = AnyChatCoreSDK.UserCameraControl(-1, true);//開啟本地聲音 -1代表自己ret = AnyChatCoreSDK.UserSpeakControl(-1, true);
7.發(fā)送文件,文字,錄制等操作
//發(fā)送文字int ret = AnyChatCoreSDK.SendTextMessage(-1, true, text, length);//發(fā)送文件 filepath:文件路徑int taskId = 0;int flag = AnyChatCoreSDK.TransFile(userId, filepath, 1, 0, 0, ref taskId);//開啟聲音int ret = AnyChatCoreSDK.UserSpeakControl(userId, true);//關(guān)閉聲音int ret = AnyChatCoreSDK.UserSpeakControl(userId, false);//開啟視頻int ret = AnyChatCoreSDK.UserCameraControl(userId, true);//關(guān)閉視頻int ret = AnyChatCoreSDK.UserCameraControl(userId, false);//開始錄像ulong flag = 0;//0為錄制視頻 1為錄制音頻int ret = AnyChatCoreSDK.StreamRecordCtrl(userId, true, flag, 0);//停止錄像ulong flag = 0;//0為錄制視頻 1為錄制音頻int ret = AnyChatCoreSDK.StreamRecordCtrl(userId, false, flag, 0);//拍照AnyChatCoreSDK.SnapShot(userId, 1, 1);
關(guān)于AnyChat的視頻會議程序?qū)嵗斀獾南嚓P(guān)內(nèi)容,先給大家介紹這么多,有問題歡迎各位大俠更貼留言,我會及時和大家聯(lián)系的,謝謝大家一直以來對武林網(wǎng)網(wǎng)站的支持。
新聞熱點
疑難解答
圖片精選