Пример #1
0
        private void Awake()
        {
            //make sure the wrapper was initialized
            TryStaticInitialize();
            if (sStaticInitSuccessful == false)
            {
                Debug.LogError("Initialization of the webrtc plugin failed. StaticInitSuccessful is false. ");
                mFactory = null;
                return;
            }

#if UNITY_WEBGL && !UNITY_EDITOR
            mFactory = new Byn.Media.Browser.BrowserCallFactory();
#else
            try
            {
                Byn.Media.Native.NativeWebRtcCallFactory factory = new Byn.Media.Native.NativeWebRtcCallFactory();
                mFactory = factory;
                if (Application.platform == RuntimePlatform.Android
                    //for testing only
                    //|| Application.platform == RuntimePlatform.OSXEditor
                    //|| Application.platform == RuntimePlatform.WindowsEditor
                    )
                {
                    mVideoFactory = new Native.UnityVideoCapturerFactory();
                    factory.AddVideoCapturerFactory(mVideoFactory);
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to create the call factory. This might be because a platform specific " +
                               " dll is missing or set to inactive in the unity editor.");
                Debug.LogException(e);
            }
#endif
        }
        private void Awake()
        {
            //make sure the wrapper was initialized
            TryStaticInitialize();
            if (sStaticInitSuccessful == false)
            {
                Debug.LogError("Initialization of the webrtc plugin failed. StaticInitSuccessful is false. ");
                mFactory = null;
                return;
            }


#if UNITY_WEBGL && !UNITY_EDITOR
            mFactory = new Byn.Media.Browser.BrowserCallFactory();
#else
            if (INTERNAL_VERBOSE_LOG)
            {
                Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogLevel(WebRtcCSharp.LoggingSeverity.LS_INFO);
                //this will route the log via SLog class to the Unity log. This can cause crashes
                //and doesn't work on all platforms
                //Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogToSLog(WebRtcCSharp.LoggingSeverity.LS_NONE);
            }
            else
            {
                Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogLevel(WebRtcCSharp.LoggingSeverity.LS_NONE);
            }
            try
            {
                Byn.Media.Native.NativeWebRtcCallFactory factory = new Byn.Media.Native.NativeWebRtcCallFactory();
                mFactory = factory;


                //old video input system relied on callbacks not supported in IL2CPP
                if (OBSOLETE_UNITY_CAMERA)
                {
#if ENABLE_IL2CPP
                    Debug.LogWarning("UnityVideoCapturerFactory isn't supported with IL2CPP");
#else
                    mVideoFactory = new Native.UnityVideoCapturerFactory();
                    factory.AddVideoCapturerFactory(mVideoFactory);
#endif
                }


#if UNITY_IOS
                //workaround for WebRTC / Unity audio bug on ios
                //WebRTC will deactivate the audio session once all calls ended
                //This will keep it active as Unity relies on this session as well
                WebRtcCSharp.IosHelper.InitAudioLayer();
#endif
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to create the call factory. This might be because a platform specific " +
                               " dll is missing or set to inactive in the unity editor.");
                Debug.LogException(e);
            }
#endif

            SetDefaultLogger(true, false);
        }