Beispiel #1
0
        /// <summary>
        /// SDK初始化
        /// </summary>
        /// <param name="config">配置信息</param>
        private void SDKInit(IDictionary <PropertyKey, string> config)
        {
            var errno = ErrorNumber.OK;

            //注册回调函数
            errno = PlcmProxy.InstallCallback(addEventCallback, dispatchEventsCallback, addLogCallback, addDeviceCallback,
                                              displayMediaStatisticsCallback, displayCallStatisticsCallback, displayCodecCapabilities, addAppCallback);
            if (ErrorNumber.OK != errno)
            {
                var errMsg = "Register callback functions failed. Error number = " + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            //预初始化
            errno = PlcmProxy.PreInitialize();
            if (ErrorNumber.OK != errno)
            {
                var msg = "Pre-initialization failed. Error number = " + errno.ToString();
                log.Error(msg);
                throw new Exception(msg);
            }
            var dispName = config[PropertyKey.PLCM_MFW_KVLIST_KEY_DisplayName];

            if (!string.IsNullOrWhiteSpace(dispName))
            {
                config[PropertyKey.PLCM_MFW_KVLIST_KEY_DisplayName] = string.Empty;
            }
            qlConfig.SetProperties(config, false);
            //初始化
            errno = PlcmProxy.Initialize();
            if (ErrorNumber.OK != errno)
            {
                var errMsg = "Initialize failed. Error number = " + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            var version = PlcmProxy.GetVersion();

            log.Info("**********************************************************************");
            log.Info("        PLCM QLSDK  App Initialized Successful ( version: " + version + " )");
            log.Info("**********************************************************************");

            errno = PlcmProxy.UpdateConfig();
            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("配置失败, Errno={0}", errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            errno = PlcmProxy.RegisterClient();
            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("Register failed, Errno={0}", errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            if (!string.IsNullOrWhiteSpace(dispName))
            {
                qlConfig.SetProperty(PropertyKey.PLCM_MFW_KVLIST_KEY_DisplayName, dispName, true);
            }
            //获取音频输入设备信息
            var errNo = PlcmProxy.GetDevice(DeviceType.AUDIOINPUT);

            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "Get audio input device failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            //获取视频输入设备信息
            errNo = PlcmProxy.GetDevice(DeviceType.VIDEOINPUT);
            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "Get video input device failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            //获取音频输出设备信息
            errNo = PlcmProxy.GetDevice(DeviceType.AUDIOOUTPUT);
            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "Get audio output device failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            //获取显示器信息
            errNo = PlcmProxy.GetDevice(DeviceType.MONITOR);
            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "Get monitor device failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            //设置呼叫数自动
            errNo = PlcmProxy.SetRemoteVideoStreamNumber(-1, 0, 0);
            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "SetRemoteVideoStreamNumber failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
        }