Esempio n. 1
0
        public BrowserMediaNetwork(NetworkConfig lNetConfig)
        {
            if (lNetConfig.AllowRenegotiation)
            {
                SLog.LW("NetworkConfig.AllowRenegotiation is set to true. This is not supported in the browser version yet! Flag ignored.", this.GetType().Name);
            }
            string signalingUrl = lNetConfig.SignalingUrl;

            IceServer[] iceServers = null;
            if (lNetConfig.IceServers != null)
            {
                iceServers = lNetConfig.IceServers.ToArray();
            }


            //TODO: change this to avoid the use of json

            StringBuilder iceServersJson = new StringBuilder();

            BrowserWebRtcNetwork.IceServersToJson(iceServers, iceServersJson);

            /*
             * Example:
             * {"{IceServers":[{"urls":["turn:because-why-not.com:12779"],"username":"******","credential":"testpassword"},{"urls":["stun:stun.l.google.com:19302"],"username":"","credential":""}], "SignalingUrl":"ws://because-why-not.com:12776/callapp", "IsConference":"False"}
             */

            string conf = "{\"IceServers\":" + iceServersJson.ToString() + ", \"SignalingUrl\":\"" + signalingUrl + "\", \"IsConference\":\"" + false + "\"}";

            SLog.L("Creating BrowserMediaNetwork config: " + conf, this.GetType().Name);
            mReference = UnityMediaNetwork_Create(conf);
        }
        /// <summary>
        /// Creates a new network by using a JSON configuration string. This is used to configure the server connection for the signaling channel
        /// and to define webrtc specific configurations such as stun server used to connect through firewalls.
        ///
        ///
        /// </summary>
        /// <param name="config"></param>
        public BrowserWebRtcNetwork(string websocketUrl, IceServer[] lIceServers)
        {
            string conf = ConstructorParamToJson(websocketUrl, lIceServers);

            SLog.L("Creating BrowserWebRtcNetwork config: " + conf, this.GetType().Name);
            mReference = UnityWebRtcNetworkCreate(conf);
        }
Esempio n. 3
0
 public override void Dispose()
 {
     SLog.L("UnityVideoCapturerer disposing", UnityVideoCapturerFactory.LOGTAG);
     if (mTexture != null)
     {
         mTexture.Stop();
     }
     base.Dispose();
     SLog.L("UnityVideoCapturerer disposed", UnityVideoCapturerFactory.LOGTAG);
 }
Esempio n. 4
0
        //called by webrtc
        public override bool Start(VideoFormat capture_format)
        {
            UpdateBufferSize(capture_format.width, capture_format.height);
            UpdateFrame(VideoType.kARGB, mImageBuffer, (uint)mImageBuffer.Length, mRequestedWidth, mRequestedHeight, 0, false);
            mRequestedFps = capture_format.framerate();

            if (mRequestedFps < 1 || mRequestedFps > 60)
            {
                mRequestedFps = 30;
            }

            mRunning = true;
            SLog.L("UnityVideoCapturerer " + mName + " started", UnityVideoCapturerFactory.LOGTAG);
            return(true);
        }
Esempio n. 5
0
    protected virtual void Init()
    {
        if (uDebugConsole)
        {
            DebugHelper.ActivateConsole();
        }
        if (uLog)
        {
            if (sLogSet == false)
            {
                SLog.SetLogger(OnLog);
                sLogSet = true;
                SLog.L("Log active");
            }
        }

        //This can be used to get the native webrtc log but causes a huge slowdown
        //only use if not webgl
        bool nativeWebrtcLog = true;

        if (nativeWebrtcLog)
        {
#if UNITY_ANDROID
            //uncomment for debug log via log cat
            //Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogLevel(WebRtcCSharp.LoggingSeverity.LS_INFO);
#elif UNITY_IOS
            //uncomment for log output via xcode
            //Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogLevel(WebRtcCSharp.LoggingSeverity.LS_INFO);
#elif (!UNITY_WEBGL || UNITY_EDITOR)
            Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogLevel(WebRtcCSharp.LoggingSeverity.LS_INFO);
            //Byn.Net.Native.NativeWebRtcNetworkFactory.SetNativeLogToSLog(WebRtcCSharp.LoggingSeverity.LS_INFO);
#else
            //webgl. logging isn't supported here and has to be done via the browser.
            Debug.LogWarning("Platform doesn't support native webrtc logging.");
#endif
        }

        if (UnityCallFactory.Instance == null)
        {
            Debug.LogError("UnityCallFactory failed to initialize");
        }

        //not yet implemented
        //CustomUnityVideo.Instance.Register();
    }
Esempio n. 6
0
 //
 private void SetupUnityCamera()
 {
     SLog.L("UnityVideoCapturerer " + mName + " unity setup " + mRequestedWidth + "x" + mRequestedHeight + " FPS: " + mRequestedFps, UnityVideoCapturerFactory.LOGTAG);
     mTexture = new WebCamTexture(mName, mRequestedWidth, mRequestedHeight, mRequestedFps);
     mTexture.Play();
 }
Esempio n. 7
0
 //called by webrtc
 public override void Stop()
 {
     mRunning = false;
     SLog.L("UnityVideoCapturerer " + mName + " stopped", UnityVideoCapturerFactory.LOGTAG);
 }
Esempio n. 8
0
 public UnityVideoCapturer(string name = null)
 {
     mName = name;
     SLog.L("UnityVideoCapturerer " + name + " created", UnityVideoCapturerFactory.LOGTAG);
 }