Пример #1
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);
        }
Пример #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));

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