Пример #1
0
        static MFWCore()
        {
            StartEventMonitor();
            mediaStatistics.CollectionChanged += (sender, args) =>
            {
                mediaStatisticsCallBack?.Invoke(mediaStatistics);
            };
            var errno = ErrorNumber.OK;

            //注册回调函数
            errno = WrapperProxy.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 = WrapperProxy.PreInitialize();
            if (ErrorNumber.OK != errno)
            {
                var msg = "Pre-initialization failed. Error number = " + errno.ToString();
                log.Error(msg);
                throw new Exception(msg);
            }
            //参数设定 KVList
            #region Default Properties
            var defaultProperties = new Dictionary <PropertyKey, string>()
            {
                { PropertyKey.PLCM_MFW_KVLIST_KEY_MINSYS, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_ProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Transport, "TCP" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_ServerType, "standard" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Register_Expires_Interval, "300" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_UserName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Domain, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_AuthorizationName, "soaktestuser" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Password, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_CookieHead, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Base_Cred, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_AnonymousToken_Cred, "YWxpY2U6c2FtZXRpbWU=" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_Anonymous_Cred, "anonymous" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_MaxCallNum, "6" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_NetworkCallRate, "384" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_AesEcription, "off" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_DefaultAudioStartPort, "3230" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_DefaultAudioEndPort, "3550" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_DefaultVideoStartPort, "3230" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_DefaultVideoEndPort, "3550" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_SIPClientListeningPort, "5060" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_CallSettings_SIPClientListeningTLSPort, "5061" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_EnableSVC, "true" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_LogLevel, "DEBUG" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_User_Agent, "MFW_SDK" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_UserName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_Password, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_TCPServer, "0.0.0.0:3478" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_UDPServer, "0.0.0.0:3478" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_TLSServer, "0.0.0.0:3478" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_AUTHTOKEN_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_INIT_AUTHTOKEN, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_RTO, "100" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_RC, "7" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_RM, "16" },
                { PropertyKey.PLCM_MFW_KVLIST_QOS_ServiceType, "" },
                { PropertyKey.PLCM_MFW_KVLIST_QOS_Audio, "" },
                { PropertyKey.PLCM_MFW_KVLIST_QOS_Video, "" },
                { PropertyKey.PLCM_MFW_KVLIST_QOS_Fecc, "" },
                { PropertyKey.PLCM_MFW_KVLIST_QOS_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_DBM_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_REG_ID, "" },
                { PropertyKey.PLCM_MFW_KVLIST_LPR_Enable, "true" },
                { PropertyKey.PLCM_MFW_KVLIST_CERT_PATH, "./TLS Certificate/instance0/" },
                { PropertyKey.PLCM_MFW_KVLIST_CERT_CHECKFQDN, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_HttpConnect_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpProxyPort, "" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpProxyUserName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpPassword, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_HttpProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_HttpProxyPort, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_HttpProxyUserName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_ICE_HttpPassword, "" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpProxyPort, "80" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpProxyUserName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpPassword, "" },
                { PropertyKey.PLCM_MFW_KVLIST_PRODUCT, "PLCM_MFW_IBM" },
                { PropertyKey.PLCM_MFW_KVLIST_AutoZoom_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_TLSOffLoad_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_TLSOffLoad_Host, "" },
                { PropertyKey.PLCM_MFW_KVLIST_TLSOffLoad_Port, "0" },
                { PropertyKey.PLCM_MFW_KVLIST_HttpTunnel_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpTunnelProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_HttpTunnelProxyPort, "443" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpTunnelProxyServer, "" },
                { PropertyKey.PLCM_MFW_KVLIST_MEDIA_HttpTunnelProxyPort, "443" },
                { PropertyKey.PLCM_MFW_KVLIST_RTPMode, "RTP/AVP" },
                { PropertyKey.PLCM_MFW_KVLIST_TCPBFCPForced, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_G729B_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_SAML_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_iLBCFrame, "30" },
                { PropertyKey.PLCM_MFW_KVLIST_BFCP_CONTENT_Enable, "true" },
                { PropertyKey.PLCM_MFW_KVLIST_SUPPORT_PORTRAIT_MODE, "" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_DisplayName, "" },
                { PropertyKey.PLCM_MFW_KVLIST_FECC_Enable, "true" },
                { PropertyKey.PLCM_MFW_KVLIST_Comfortable_Noise_Enable, "true" },
                { PropertyKey.PLCM_MFW_KVLIST_SIP_Header_Compact_Enable, "false" },
                { PropertyKey.PLCM_MFW_KVLIST_KEY_MAXSYS, "" },
                { PropertyKey.LocalAddr, "" },
                { PropertyKey.CalleeAddr, "" },
                { PropertyKey.AUDIO_INPUT_DEVICE, "" },
                { PropertyKey.AUDIO_OUTPUT_DEVICE, "" },
                { PropertyKey.AUDIO_OUTPUT_DEVICE_FOR_RINGTONE, "" },
                { PropertyKey.VIDEO_INPUT_DEVICE, "" },
                { PropertyKey.MONITOR_DEVICE, "" },
                { PropertyKey.SOUND_INCOMING, "incoming.wav" },
                { PropertyKey.SOUND_CLOSED, "closed.wav" },
                { PropertyKey.SOUND_RINGING, "ringing.wav" },
                { PropertyKey.SOUND_HOLD, "hold.wav" },
                { PropertyKey.ICE_AUTH_TOKEN, "" },
                { PropertyKey.LayoutType, "Presentation" }
            };
            #endregion

            propertyManager.SetProperties(defaultProperties);
            //初始化
            errno = WrapperProxy.Initialize();
            if (ErrorNumber.OK != errno)
            {
                var errMsg = "Initialize failed. Error number = " + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            var version = WrapperProxy.GetVersion();
            log.Info("**********************************************************************");
            log.Info("        PLCM MFW  App Initialized Successful ( version: " + version + " )");
            log.Info("**********************************************************************");

            //Get Devices
            var errNo = WrapperProxy.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 = WrapperProxy.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 = WrapperProxy.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 = WrapperProxy.GetDevice(DeviceType.MONITOR);
            if (ErrorNumber.OK != errNo)
            {
                var errMsg = "Get monitor device failed. Error number = " + errNo;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
        }