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); }
static public new void InjectJsCode() { //use sInjectionTried to block multiple calls. if (Application.platform == RuntimePlatform.WebGLPlayer && sInjectionTried == false) { sInjectionTried = true; Debug.Log("injecting webrtcvideochatplugin"); TextAsset txt = Resources.Load <TextAsset>("webrtcvideochatplugin"); if (txt == null) { Debug.LogError("Failed to find webrtcvideochatplugin.txt in Resource folder. Can't inject the JS plugin!"); return; } StringBuilder jsCode = new StringBuilder(); jsCode.Append("console.log('Start eval webrtcnetworkplugin!');"); jsCode.Append(txt.text); jsCode.Append("console.log('completed eval webrtcnetworkplugin!');"); BrowserWebRtcNetwork.ExternalEval(jsCode.ToString()); } }