Exemplo n.º 1
0
        /// <summary>
        /// 初始化AnyChat sdk
        /// 注册 callback
        /// </summary>
        public static void Init(IntPtr hWnd)
        {
            AnyChatCoreSDK.ActiveCallLog(true);
            ulong dwFuncMode = AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOPLAY
                               | AnyChatCoreSDK.BRAC_FUNC_CHKDEPENDMODULE
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_NET_SUPPORTUPNP
                               | AnyChatCoreSDK.BRAC_FUNC_FIREWALL_OPEN
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOVOLUME
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_CONFIG_LOCALINI;

            ///初始化
            ANYCHATAPI.AnyChatCoreSDK.InitSDK(hWnd, dwFuncMode);

            ///注册回调
            ///视频
            ANYCHATAPI.AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24,
                                                           video_Callback, hWnd.ToInt32());
            //声音
            ANYCHATAPI.AnyChatCoreSDK.SetAudioDataCallBack(audio_Callback, hWnd.ToInt32());
            //文字
            ANYCHATAPI.AnyChatCoreSDK.SetTextMessageCallBack(text_Callback, hWnd.ToInt32());
            //透明通道
            ANYCHATAPI.AnyChatCoreSDK.SetTransBufferCallBack(transBuff_Callback, hWnd.ToInt32());
            //p2p文件传输
            ANYCHATAPI.AnyChatCoreSDK.SetTransFileCallBack(transFile_callback, hWnd.ToInt32());
            ///与服务器端数据回调
            ANYCHATAPI.AnyChatCoreSDK.SetSDKFilterDataCallBack(filterData_callback, hWnd.ToInt32());
            ///提供服务器端验证
            AnyChatCoreSDK.SetServerAuthPass(new StringBuilder(""));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化AnyChat sdk
        /// 注册 callback
        /// </summary>
        public static bool Init(IntPtr hWnd)
        {
            bool isok = false;

            AnyChatCoreSDK.ActiveCallLog(true);
            ulong dwFuncMode = AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP//BRAC_FUNC_VIDEO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOPLAY
                               | AnyChatCoreSDK.BRAC_FUNC_CHKDEPENDMODULE
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_NET_SUPPORTUPNP
                               | AnyChatCoreSDK.BRAC_FUNC_FIREWALL_OPEN
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOVOLUME
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_CONFIG_LOCALINI;

            ///初始化
            if (AnyChatCoreSDK.InitSDK(hWnd, dwFuncMode) == 0)
            {
                isok = true;
            }

            int useHWCodec = 1;

            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_CORESDK_USEHWCODEC, ref useHWCodec, sizeof(int));

            ///注册回调
            ///视频
            AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, video_Callback, hWnd.ToInt32());
            ///视频扩展
            AnyChatCoreSDK.SetVideoDataExCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, videoEx_Callback, hWnd.ToInt32());
            //声音
            AnyChatCoreSDK.SetAudioDataCallBack(audio_Callback, hWnd.ToInt32());
            //声音扩展
            AnyChatCoreSDK.SetAudioDataExCallBack(audioEx_Callback, hWnd.ToInt32());
            //文字
            AnyChatCoreSDK.SetTextMessageCallBack(text_Callback, hWnd.ToInt32());
            //透明通道
            AnyChatCoreSDK.SetTransBufferCallBack(transBuff_Callback, hWnd.ToInt32());
            //p2p文件传输
            AnyChatCoreSDK.SetTransFileCallBack(transFile_callback, hWnd.ToInt32());
            ///与服务器端数据回调
            //AnyChatCoreSDK.SetSDKFilterDataCallBack(filterData_callback, hWnd.ToInt32());
            ///提供服务器端验证
            AnyChatCoreSDK.SetServerAuthPass("");
            //保存视频
            AnyChatCoreSDK.SetRecordCallBack(RecordCallBack_Callback, hWnd.ToInt32());
            //设置音量变化回调函数
            AnyChatCoreSDK.SetVolumeChangeCallBack(VolumeChange_callBack, hWnd.ToInt32());
            //设置视频呼叫事件回调函数
            AnyChatCoreSDK.SetVideoCallEventCallBack(VideoCallEvent_callBack, hWnd.ToInt32());

            //设置业务对象事件通知回调函数
            //AnyChatCoreSDK.BRAC_SetObjectEventNotifyCallBack(ObjectEvent_callBack, hWnd.ToInt32());
            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_OBJECTEVENT, Marshal.GetFunctionPointerForDelegate(ObjectEvent_callBack), hWnd);

            return(isok);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 应用设置
        /// </summary>
        private void ApplySetting()
        {
            int retCode   = 0;
            int streamIdx = Int32.Parse((comboBox_videoDeviceList.SelectedItem as ComboBoxItem).Value.ToString());
            //streamIdx = streamIdx + 1;

            //设置码率
            int videoBitrate = 0;

            videoBitrate = Int32.Parse((comboBox_VideoBitrate.SelectedItem as ComboBoxItem).Value.ToString());
            //retCode = AnyChatCoreSDK.SetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_BITRATECTRL, ref videoBitrate, sizeof(int));
            retCode = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_BITRATECTRL, ref videoBitrate, sizeof(int));


            //设置分辨率
            string videoResolution = string.Empty;

            videoResolution = (comboBox_VideoResolution.SelectedItem as ComboBoxItem).Value.ToString();
            string[] resolutionArray = videoResolution.Split('x');
            int      videoWidth      = Int32.Parse(resolutionArray[0]);
            int      videoHeigth     = Int32.Parse(resolutionArray[1]);

            //retCode = AnyChatCoreSDK.SetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_WIDTHCTRL, ref videoWidth, sizeof(int));
            retCode = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_WIDTHCTRL, ref videoWidth, sizeof(int));
            //retCode = AnyChatCoreSDK.SetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_HEIGHTCTRL, ref videoHeigth, sizeof(int));
            retCode = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_HEIGHTCTRL, ref videoHeigth, sizeof(int));

            //设置帧率
            int videoFPS = 0;

            videoFPS = Int32.Parse((comboBox_VideoFPS.SelectedItem as ComboBoxItem).Value.ToString());
            //retCode = AnyChatCoreSDK.SetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_FPSCTRL, ref videoFPS, sizeof(int));
            retCode = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_FPSCTRL, ref videoFPS, sizeof(int));


            //让视频设置参数生效
            int isApply = 1;

            //retCode = AnyChatCoreSDK.SetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_APPLYPARAM, ref isApply, sizeof(int));
            retCode = AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_APPLYPARAM, ref isApply, sizeof(int));

            //AnyChatCoreSDK.UserCameraControlEx(-1, false, streamIdx, 0, string.Empty);
            //Thread.Sleep(500);
            //Application.DoEvents();
            //AnyChatCoreSDK.UserCameraControlEx(-1, true, streamIdx, 0, string.Empty);
        }
Exemplo n.º 4
0
 //退出释放资源
 public static void Release(int myroomID)
 {
     AnyChatCoreSDK.LeaveRoom(myroomID);
     AnyChatCoreSDK.Logout();
     AnyChatCoreSDK.Release();
 }
Exemplo n.º 5
0
 /// <summary>
 /// ��Ƶ�ص�
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="buf"></param>
 /// <param name="len"></param>
 /// <param name="bitMap"></param>
 /// <param name="userValue"></param>
 private static void VideoData_CallBack(int userId, IntPtr buf, int len, AnyChatCoreSDK.BITMAPINFOHEADER bitMap, int userValue)
 {
     if (Video_OnCallBack != null)
         Video_OnCallBack(userId, buf, len, bitMap, userValue);
 }
Exemplo n.º 6
0
 /// <summary>
 /// ���������仯�ص���������
 /// </summary>
 /// <param name="device">��Ƶ�豸</param>
 /// <param name="currentVolume">��ǰ����</param>
 /// <param name="userValue">������Ϣ</param>
 private static void SetVolumeChange_CallBack(AnyChatCoreSDK.AudioDevice device, int currentVolume, int userValue)
 {
     if (SetVolumeChange_OnReceive != null)
         SetVolumeChange_OnReceive(device, currentVolume, userValue);
 }
Exemplo n.º 7
0
 /// <summary>
 /// ��Ƶ�ص�
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="buf"></param>
 /// <param name="len"></param>
 /// <param name="format"></param>
 /// <param name="userValue"></param>
 private static void AudioData_CallBack(int userId, IntPtr buf, int len, AnyChatCoreSDK.WaveFormat format, int userValue)
 {
     if (Audio_OnCallBack != null)
         Audio_OnCallBack(userId, buf, len, format, userValue);
 }
Exemplo n.º 8
0
 // AnyChat内核回调
 public static void VideoData_CallBack(int userId, IntPtr buf, int len, AnyChatCoreSDK.BITMAPINFOHEADER bitMap, int userValue)
 {
     if (VideoDataHandler != null)
         VideoDataHandler(userId, buf, len, bitMap, userValue);
 }
Exemplo n.º 9
0
        // 静态委托
        public void VideoDataCallbackDelegate(int userId, IntPtr buf, int len, AnyChatCoreSDK.BITMAPINFOHEADER bitMap, int userValue)
        {
            // 由于采用自动显示(在AnyChatCoreSDK.InitSDK时设置了AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP),所以屏蔽通过回调的方式显示视频,效率更高
            // 如果希望对视频进行处理,则可以设置AnyChatCoreSDK.BRAC_FUNC_VIDEO_CBDATA,去掉AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP,然后开放下面的代码即可
            // 有关AnyChat自动显示和回调显示的区别可参考:http://www.anychat.cn/faq/index.php?action=artikel&cat=2&id=196&artlang=zh
            /*
            int stride = bitMap.biWidth * 3;
            BitmapSource bs = BitmapSource.Create(bitMap.biWidth, bitMap.biHeight, 96, 96, PixelFormats.Bgr24, null, buf, len, stride);
            // 将图像进行翻转
            TransformedBitmap RotateBitmap = new TransformedBitmap();
            RotateBitmap.BeginInit();
            RotateBitmap.Source = bs;
            ScaleTransform scaleTransform = new ScaleTransform();
            scaleTransform.ScaleY = -1;
            RotateBitmap.Transform = scaleTransform;
            RotateBitmap.EndInit();
            RotateBitmap.Freeze();

            //// 异步操作
            Action action = new Action(delegate()
            {
               Dispatcher.BeginInvoke(new Action(delegate()
               {
                   if (userId == g_selfUserId)
                       localVideoImage.Source = RotateBitmap;
                   else if (userId == g_otherUserId)
                       remoteVideoImage.Source = RotateBitmap;
               }), null);
            });
            action.BeginInvoke(null, null);
            */
        }
Exemplo n.º 10
0
        /// <summary>
        /// 初始化AnyChat sdk
        /// 注册 callback
        /// </summary>
        public static bool Init(IntPtr hWnd)
        {
            bool isok = false;

            AnyChatCoreSDK.ActiveCallLog(true);
            ulong dwFuncMode = AnyChatCoreSDK.BRAC_FUNC_VIDEO_AUTODISP//BRAC_FUNC_VIDEO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOPLAY
                               | AnyChatCoreSDK.BRAC_FUNC_CHKDEPENDMODULE
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_NET_SUPPORTUPNP
                               | AnyChatCoreSDK.BRAC_FUNC_FIREWALL_OPEN
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_AUTOVOLUME
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_VOLUMECALC
                               | AnyChatCoreSDK.BRAC_FUNC_AUDIO_CBDATA
                               | AnyChatCoreSDK.BRAC_FUNC_CONFIG_LOCALINI;

            ///初始化
            if (AnyChatCoreSDK.InitSDK(hWnd, dwFuncMode) == 0)
            {
                isok = true;
            }

            int useHWCodec = 1;

            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_CORESDK_USEHWCODEC, ref useHWCodec, sizeof(int));

            int overLayTimeStamp = 1;

            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_LOCALVIDEO_OVERLAYTIMESTAMP, ref overLayTimeStamp, sizeof(int));

            string recordDir = "D:\\KingDom\\VideoCapture\\Bin";

            AnyChatCoreSDK.SetSDKOption(AnyChatCoreSDK.BRAC_SO_RECORD_TMPDIR, recordDir, recordDir.ToCharArray().Length);

            ///注册回调
            ///视频
            AnyChatCoreSDK.SetVideoDataCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, video_Callback, hWnd.ToInt32());
            ///视频扩展
            AnyChatCoreSDK.SetVideoDataExCallBack(AnyChatCoreSDK.PixelFormat.BRAC_PIX_FMT_RGB24, videoEx_Callback, hWnd.ToInt32());
            //声音
            AnyChatCoreSDK.SetAudioDataCallBack(audio_Callback, hWnd.ToInt32());
            //声音扩展
            AnyChatCoreSDK.SetAudioDataExCallBack(audioEx_Callback, hWnd.ToInt32());
            //文字
            AnyChatCoreSDK.SetTextMessageCallBack(text_Callback, hWnd.ToInt32());
            //透明通道
            AnyChatCoreSDK.SetTransBufferCallBack(transBuff_Callback, hWnd.ToInt32());
            //p2p文件传输
            AnyChatCoreSDK.SetTransFileCallBack(transFile_callback, hWnd.ToInt32());
            ///与服务器端数据回调
            //AnyChatCoreSDK.SetSDKFilterDataCallBack(filterData_callback, hWnd.ToInt32());
            ///提供服务器端验证
            AnyChatCoreSDK.SetServerAuthPass("");
            //保存视频
            //AnyChatCoreSDK.SetRecordCallBack(RecordCallBack_Callback, hWnd.ToInt32());
            //设置音量变化回调函数
            AnyChatCoreSDK.SetVolumeChangeCallBack(VolumeChange_callBack, hWnd.ToInt32());
            //设置视频呼叫事件回调函数
            AnyChatCoreSDK.SetVideoCallEventCallBack(VideoCallEvent_callBack, hWnd.ToInt32());

            //设置业务对象事件通知回调函数
            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_OBJECTEVENT, Marshal.GetFunctionPointerForDelegate(ObjectEvent_callBack), hWnd);

            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_STREAMRECORD, Marshal.GetFunctionPointerForDelegate(RecordSnapShot_callBack), hWnd);

            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_STREAMRECORDEX, Marshal.GetFunctionPointerForDelegate(RecordSnapShotEx_callBack), hWnd);

            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_SCREENEVENT, Marshal.GetFunctionPointerForDelegate(VideoScreenEvent_callBack), hWnd);

            //Core SDK事件回调(Json格式)
            AnyChatCoreSDK.SetCallBack(AnyChatCoreSDK.BRAC_CBTYPE_CORESDKEVENT, Marshal.GetFunctionPointerForDelegate(CoreSDKEvent_callBack), hWnd);

            return(isok);
        }
Exemplo n.º 11
0
        private void GetSetting()
        {
            int retCode   = 0;
            int streamIdx = Int32.Parse((comboBox_videoDeviceList.SelectedItem as ComboBoxItem).Value.ToString());

            //streamIdx = streamIdx + 1;

            AnyChatCoreSDK.SelectVideoCapture((comboBox_videoDeviceList.SelectedItem as ComboBoxItem).Text);

            int videoBitrate = 0;

            if (streamIdx == 100)
            {
                retCode = AnyChatCoreSDK.QueryUserState(-1, AnyChatCoreSDK.BRAC_USERSTATE_VIDEOBITRATE, ref videoBitrate, sizeof(int));
            }
            else
            {
                retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOBITRATE, ref videoBitrate, sizeof(int));
            }
            for (int idx = 0; idx < comboBox_VideoBitrate.Items.Count; idx++)
            {
                if ((videoBitrate >= Int32.Parse((comboBox_VideoBitrate.Items[idx] as ComboBoxItem).Value.ToString())) &&
                    (videoBitrate <= Int32.Parse((comboBox_VideoBitrate.Items[idx + 1] as ComboBoxItem).Value.ToString())))
                {
                    comboBox_VideoBitrate.SelectedIndex = idx;
                    break;
                }
            }

            //分辨率
            int videoWidth  = 0;
            int videoHeigth = 0;

            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOWIDTH, ref videoWidth, sizeof(int));
            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOHEIGHT, ref videoHeigth, sizeof(int));
            string resolution = videoWidth.ToString() + "x" + videoHeigth;

            lblVideoResolution.Text = "(当前分辨率:	"+ resolution + ")";
            for (int idx = 0; idx < comboBox_VideoResolution.Items.Count; idx++)
            {
                if (resolution == (comboBox_VideoResolution.Items[idx] as ComboBoxItem).Text.ToString())
                {
                    comboBox_VideoResolution.SelectedIndex = idx;
                    break;
                }
            }


            //帧率
            int videoFPS = 0;

            //videoFPS = Int32.Parse((comboBox_VideoFPS.SelectedItem as ComboBoxItem).Value.ToString());
            retCode = AnyChatCoreSDK.GetUserStreamInfo(-1, streamIdx, AnyChatCoreSDK.BRAC_STREAMINFO_VIDEOFPS, ref videoFPS, sizeof(int));
            for (int idx = 0; idx < comboBox_VideoFPS.Items.Count; idx++)
            {
                if (videoFPS.ToString() == (comboBox_VideoFPS.Items[idx] as ComboBoxItem).Value.ToString())
                {
                    comboBox_VideoFPS.SelectedIndex = idx;
                    break;
                }
            }
        }