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 = CAPI.Unity_MediaNetwork_Create(conf); }
//Checks if the network and media component are available public static bool IsAvailable() { #if UNITY_WEBGL try { //js side will check if all needed functions are available and if the browser is supported return(BrowserWebRtcNetwork.IsAvailable() && CAPI.Unity_MediaNetwork_IsAvailable()); } catch (EntryPointNotFoundException) { //method is missing entirely } #endif return(false); }