AnyChat的視頻會議法式實例詳解。本站提示廣大學習愛好者:(AnyChat的視頻會議法式實例詳解)文章只能為提供參考,不一定能成為您想要的結果。以下是AnyChat的視頻會議法式實例詳解正文
AnyChat(全名叫Anychat SDK),也叫音視頻互動開辟平台;是一套跨平台的即時通信處理計劃,基於先輩的H.264視頻編碼尺度、AAC音頻編碼尺度與P2P技巧,整合了佰銳科技在音視頻編碼、多媒體通信范疇搶先的開辟技巧和豐碩的產物經歷而設計的高質量、寬順應性、散布式、模塊化的收集音視頻互動平台。
可以停止雙人或多人的語音及時通話,支撐Windows、Web、Android、iOS、Mac、Linux等跨平台通訊。
所供給的SDK支撐C++、Delphi、Java、C#、VB、object-c等多種語音開辟。
AnyChat包含音頻視頻錄制,攝影,辦事器錄相,文字聊天,文件發送等多種功效。
界面以下
挪用流程:
1.在所要監聽的類中挪用重載WndProc辦法,完成windows新聞的監聽。
/// <summary> /// 重載 /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { if (m.Msg == AnyChatCoreSDK.WM_GV_CONNECT) { //客戶端銜接辦事器,表現能否銜接勝利 int succed = m.WParam.ToInt32(); //銜接辦事器勝利 if (succed == 1) { //登錄辦事器(在WndProc中的獲得辦法回調成果。參數:AnyChatCoreSDK.WM_GV_LOGINSYSTEM) int ret = AnyChatCoreSDK.Login(PublicMembers.g_Name, "", 0); } else { PublicMembers.ShowRightTip("登錄掉敗。毛病代碼:" + succed, ""); } } else if (m.Msg == AnyChatCoreSDK.WM_GV_LOGINSYSTEM) { //客戶端登錄體系,wParam(INT)表現本身的用戶ID號 int userid = m.WParam.ToInt32(); if (m.LParam.ToInt32() == 0) { m_myUserID = userid; //進入房間(在WndProc中的獲得辦法回調成果。參數:AnyChatCoreSDK.WM_GV_ENTERROOM) int ret = AnyChatCoreSDK.EnterRoom(m_RoomID, "", 0); } else { MessageBox.Show("登錄辦事器掉敗,代碼失足為:" + 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) { //收到以後房間的在線用戶信息,進入房間後觸發一次 int usrcnt = m.WParam.ToInt32(); int cnt = 0;//在線用戶數目 AnyChatCoreSDK.GetOnlineUser(null, ref cnt);//獲得在線用戶數目 int[] userArr = new int[cnt];//在線用戶ID AnyChatCoreSDK.GetOnlineUser(userArr, ref cnt);//獲得在線用戶ID數組 } else if (m.Msg == AnyChatCoreSDK.WM_GV_LINKCLOSE) { //客戶端失落線處置 } else if (m.Msg == AnyChatCoreSDK.WM_GV_USERATROOM) { //用戶進入(分開)房間,wParam(INT)表現用戶ID號、 //用戶ID int userID = m.WParam.ToInt32(); //產生狀況 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
//設置回調函數 SystemSetting.Text_OnReceive = new TextReceivedHandler(Received_CallBack);//文本回調涵數 SystemSetting.TransBuffer_OnReceive = new TransBufferReceivedHandler(Received_TransBuffer);//通明通道傳輸回調 SystemSetting.TransFile_OnReceive = new TransFileReceivedHandler(Received_TransFile);//文件傳輸回調 SystemSetting.TransRecord_OnReceive = new TransRecordHandler(File_CallBack);//攝影錄相回調函數 //初始化 SystemSetting.Init(this.Handle); //設置內核參數 設置保留途徑 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辦事器。應用AnyChat功效必需先銜接並登錄AnyChat辦事器。履行銜接操作後會觸發windows新聞回調 AnyChatCoreSDK.WM_GV_CONNECT
//登錄AnyChat (IP從設置裝備擺設文件中獲得) string IP = XmlHelper.GetXmlAttribute(PublicMembers.Config, "//Configuration//IP", "value").Value; //銜接辦事器(在WndProc中的獲得辦法回調成果。參數:AnyChatCoreSDK.WM_GV_CONNECT) ret = AnyChatCoreSDK.Connect(IP, 8906);
4.登錄AnyChat辦事器。履行銜接操作後會觸發windows新聞回調 AnyChatCoreSDK.WM_GV_LOGINSYSTEM
//登錄辦事器(在WndProc中的獲得辦法回調成果。參數:AnyChatCoreSDK.WM_GV_LOGINSYSTEM) int ret = AnyChatCoreSDK.Login(PublicMembers.g_Name, "", 0);
5.辦事器登錄勝利落後入指定房間,只要在統一個房間內的用戶才可以停止視頻音頻交互。
//進入房間(在WndProc中的獲得辦法回調成果。參數:AnyChatCoreSDK.WM_GV_ENTERROOM) int ret = AnyChatCoreSDK.EnterRoom(m_RoomID, "", 0);
6.翻開,封閉音頻視頻
//綁定本機視頻窗口 -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.發送文件,文字,錄制等操作
//發送文字 int ret = AnyChatCoreSDK.SendTextMessage(-1, true, text, length); //發送文件 filepath:文件途徑 int taskId = 0; int flag = AnyChatCoreSDK.TransFile(userId, filepath, 1, 0, 0, ref taskId); //開啟聲響 int ret = AnyChatCoreSDK.UserSpeakControl(userId, true); //封閉聲響 int ret = AnyChatCoreSDK.UserSpeakControl(userId, false); //開啟視頻 int ret = AnyChatCoreSDK.UserCameraControl(userId, true); //封閉視頻 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);
關於AnyChat的視頻會議法式實例詳解的相干內容,先給年夜家引見這麼多,有成績迎接列位年夜俠更貼留言,我會實時和年夜家接洽的,感謝年夜家一向以來對網站的支撐。