From 0573fb38ba76fbb4eab0095f83ee646b53a8c49d Mon Sep 17 00:00:00 2001 From: Steve Seguin Date: Sun, 25 Sep 2022 21:09:30 -0400 Subject: [PATCH] v22.4 beta --- check.html | 77 ++- filters/anon.js | 24 +- filters/dog.js | 25 +- filters/sample.js | 26 +- index.html | 32 +- lib.js | 1477 +++++++++++++++++++++++++++++++++------------ main.css | 85 ++- main.js | 201 ++++-- regions.html | 94 +++ results.html | 65 +- speedtest.css | 1 + webrtc.js | 2 +- 12 files changed, 1571 insertions(+), 538 deletions(-) create mode 100644 regions.html diff --git a/check.html b/check.html index 253d934..2865e34 100644 --- a/check.html +++ b/check.html @@ -169,13 +169,13 @@ function next2(){ document.getElementById("page2").classList.add("hidden"); document.getElementById("page3").classList.remove("hidden"); - loadIframe(); + loadIframe(region); } function next3(){ document.getElementById("page3").classList.add("hidden"); document.getElementById("mainapp").classList.remove("hidden"); - loadIframe(); + loadIframe(region); } (function (w) { @@ -414,7 +414,33 @@ if (urlParams.has("sid")) { streamID = urlParams.get("sid"); + } else if (urlParams.has("push")) { + streamID = urlParams.get("push"); } + + var region = ""; + if (urlParams.has("location")) { + region = urlParams.get("location"); + } else if (urlParams.has("region")) { + region = urlParams.get("region"); + } + + + + + + + + + + + + + + + + + var iframe1 = document.createElement("iframe"); @@ -496,6 +522,8 @@ if (urlParams.has("id")) { recordResults = urlParams.get("id") || false; + } else if (urlParams.has("session")) { + recordResults = urlParams.get("session") || false; } iframe.src = srcString; @@ -566,6 +594,16 @@ clearInterval(interval); return; } + if (timer == 30){ + iframe.contentWindow.postMessage({ bitrate: 4000 }, "*"); + bitrate.target = 4000; + updateData("target", bitrate.target); + } + if (timer == 60){ + iframe.contentWindow.postMessage({ bitrate: 6000 }, "*"); + bitrate.target = 6000; + updateData("target", bitrate.target); + } if (timer!==null){ timer+=1 @@ -591,8 +629,8 @@ var bitrate = { element: "bitrate-graph", data: 0, - max: 6000, - target: 3000, + max: 6500, + target: 2500, }; var frames; var buffer = { @@ -654,13 +692,28 @@ var offset = borderWidth * 2; // Create gradient + var grd = context.createLinearGradient(0, 0, 0, height); - + if (type == "bitrate") { - // Higher values are green - grd.addColorStop(0, "#33C433"); - grd.addColorStop(0.7, "#F3F304"); - grd.addColorStop(0.9, "#F30404"); + + if (stat.target == 2500){ + grd.addColorStop(0, "#33C433"); + grd.addColorStop(0.7, "#33C433"); + grd.addColorStop(0.8, "#F3F304"); + grd.addColorStop(0.92, "#F30404"); + } else if (stat.target == 4000){ + grd.addColorStop(0, "#33C433"); + grd.addColorStop(0.5, "#33C433"); + grd.addColorStop(0.8, "#F3F304"); + grd.addColorStop(0.92, "#F30404"); + } else if (stat.target == 6000){ + grd.addColorStop(0, "#33C433"); + grd.addColorStop(0.3, "#33C433"); + grd.addColorStop(0.8, "#F3F304"); + grd.addColorStop(0.92, "#F30404"); + } + } else { // Higher values are red grd.addColorStop(0, "#F30404"); @@ -673,10 +726,10 @@ //context.fillStyle = "#009933"; //context.imageSmoothingEnabled = true; - yScale = height / stat.target; + yScale = height / stat.max; - if (stat.data > stat.target) { - stat.data = stat.target; + if (stat.data > stat.max) { + stat.data = stat.max; } if (type == "packetloss" && stat.data == 0.0) { diff --git a/filters/anon.js b/filters/anon.js index f01cb06..df599ca 100644 --- a/filters/anon.js +++ b/filters/anon.js @@ -1,16 +1,5 @@ -function effectsEngine(effectName){ - function loadScript(url){ - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = url; - script.onload = function(){ - this.remove(); - if (loadList.length){ - loadScript(loadList.pop()); - } - } - document.head.appendChild(script); - } +async function effectsEngine(effectName){ + var loadList = []; if (typeof JEELIZFACEFILTER == 'undefined' || JEELIZFACEFILTER==null){ loadList.push("./thirdparty/jeeliz/jeelizFaceFilter.js"); @@ -29,9 +18,13 @@ function effectsEngine(effectName){ if (loadList.length){ loadList.reverse(); - loadScript(loadList.pop()); + while (loadList.length){ + await loadScript(loadList.pop()); + } } + log("finished loading anon effect"); + // some globals: let THREECAMERA = null; // should be prop of window let ANONYMOUSMESH = null; @@ -63,6 +56,7 @@ function effectsEngine(effectName){ isTransformed = false; init_faceFilter("effectsCanvasTarget", session.canvasSource); } catch(e){ + errorlog(e); } } else { setTimeout(function(){main();},500); @@ -117,7 +111,7 @@ function effectsEngine(effectName){ threeStuffs.scene.add(dirLight); }, callbackTrack: function (detectState) { - if (effectName !== session.effects){ + if (effectName !== session.effect){ try{ JEELIZFACEFILTER.toggle_pause(true,false); // unload the filter when no longer active. Leaving the track active is required, else it breaks the app } catch(e){errorlog(e);} diff --git a/filters/dog.js b/filters/dog.js index 6fc0a1a..364d9c7 100644 --- a/filters/dog.js +++ b/filters/dog.js @@ -1,16 +1,5 @@ -function effectsEngine(effectName){ - function loadScript(url){ - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = url; - script.onload = function(){ - this.remove(); - if (loadList.length){ - loadScript(loadList.pop()); - } - } - document.head.appendChild(script); - } +async function effectsEngine(effectName){ + var loadList = []; if (typeof JEELIZFACEFILTER == 'undefined' || JEELIZFACEFILTER==null){ loadList.push("./thirdparty/jeeliz/jeelizFaceFilter.js"); @@ -32,10 +21,13 @@ function effectsEngine(effectName){ if (loadList.length){ loadList.reverse(); - loadScript(loadList.pop()); + while (loadList.length){ + await loadScript(loadList.pop()); + } } + var pathname = window.location.pathname.split("/"); pathname.pop(); pathname = window.location.protocol + "//" + window.location.host + pathname.join("/"); @@ -267,9 +259,9 @@ function effectsEngine(effectName){ isTransformed = false; DOGOBJ3D = new THREE.Object3D(); FRAMEOBJ3D = new THREE.Object3D(); - init_faceFilter("effectsCanvasTarget", session.canvasSource); } catch(e){ + errorlog(e); } } else { setTimeout(function(){main();},500); @@ -301,7 +293,7 @@ function effectsEngine(effectName){ init_threeScene(spec); }, callbackTrack: function (detectState) { - if (effectName !== session.effects){ + if (effectName !== session.effect){ try{ JEELIZFACEFILTER.toggle_pause(true,false); // unload the filter when no longer active. Leaving the track active is required, else it breaks the app } catch(e){errorlog(e);} @@ -353,5 +345,6 @@ function effectsEngine(effectName){ } }); } + log("returning main"); return main; } diff --git a/filters/sample.js b/filters/sample.js index 85c8bd7..1e19ebd 100644 --- a/filters/sample.js +++ b/filters/sample.js @@ -1,22 +1,18 @@ -function effectsEngine(){ +async function effectsEngine(){ console.log('LOADED SAMPLE'); - function loadScript(url, callback=false){ - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = url; - script.onload = function(){this.remove();if(callback){callback();}} - document.head.appendChild(script); - + var loadList = []; + loadList.push("./thirdparty/jeeliz/jeelizFaceFilter.js"); + loadList.push("./thirdparty/jeeliz/helpers/JeelizCanvas2DHelper.js"); + + if (loadList.length){ + loadList.reverse(); + while (loadList.length){ + await loadScript(loadList.pop()); + } } - loadScript("./thirdparty/jeeliz/jeelizFaceFilter.js", - function(){ - loadScript("./thirdparty/jeeliz/helpers/JeelizCanvas2DHelper.js"); - } - ); - function main(){ // entry point - console.log("."); + console.log("LOADED MAIN OF SAMPLE"); if (session.canvasSource && session.canvasSource.videoWidth && session.canvasSource.videoHeight && session.canvasWebGL){ if (session.canvasWebGL && !(document.getElementById("effectsCanvasTarget"))){ session.canvasWebGL.id = "effectsCanvasTarget"; diff --git a/index.html b/index.html index c7f43ae..e05dfb6 100644 --- a/index.html +++ b/index.html @@ -57,7 +57,7 @@ - + @@ -82,7 +82,7 @@ - +