This commit is contained in:
Anthony Minessale 2015-10-05 13:00:33 -05:00
parent aa0b28e235
commit 1c8088a4a0
3 changed files with 88 additions and 52 deletions

View File

@ -361,6 +361,7 @@ if ($('#devices').is(':visible')) {
</script> </script>
<!--<button data-inline="true" id="showdemo" onclick="toggle_demo();">View Demo Extensions</button>--> <!--<button data-inline="true" id="showdemo" onclick="toggle_demo();">View Demo Extensions</button>-->
<button data-inline="true" id="showdevices" onclick="toggle_device();">View Device Settings</button> <button data-inline="true" id="showdevices" onclick="toggle_device();">View Device Settings</button>
<button data-inline="true"id="speedbtn">Check Speed</button>
<button data-inline="true"id="logoutbtn">Log Out</button> <button data-inline="true"id="logoutbtn">Log Out</button>
<div id="devices" style="border-style:outset;border-width:2px"> <div id="devices" style="border-style:outset;border-width:2px">

View File

@ -197,7 +197,46 @@ function check_vid() {
return use_vid; return use_vid;
} }
function do_speed_test(fn)
{
goto_page("bwtest");
vertoHandle.rpcClient.speedTest(1024 * 256, function(e, obj) {
//console.error("Up: " + obj.upKPS, "Down: ", obj.downKPS);
var vid = "default";
if (outgoingBandwidth === "default") {
outgoingBandwidth = Math.ceil(obj.upKPS * .75).toString();
$("#vqual_hd").prop("checked", true);
vid = "1280x720";
if (outgoingBandwidth < 1024) {
$("#vqual_vga").prop("checked", true);
vid = "640x480";
}
if (outgoingBandwidth < 512) {
$("#vqual_qvga").prop("checked", true);
vid = "320x240";
}
}
if (incomingBandwidth === "default") {
incomingBandwidth = Math.ceil(obj.downKPS * .75).toString();
}
console.info(outgoingBandwidth, incomingBandwidth);
$("#bwinfo").html("<b>Bandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + " Vid: " + vid + "</b>");
if (fn) {
fn();
}
});
}
// Attach audio output device to video element using device/sink ID. // Attach audio output device to video element using device/sink ID.
function attachSinkId(element, sinkId) { function attachSinkId(element, sinkId) {
if (typeof element.sinkId !== 'undefined') { if (typeof element.sinkId !== 'undefined') {
element.setSinkId(sinkId) element.setSinkId(sinkId)
@ -559,37 +598,15 @@ var callbacks = {
ringing = false; ringing = false;
if (success) { if (success) {
vertoHandle.rpcClient.speedTest(1024 * 256, function(e, obj) {
//console.error("Up: " + obj.upKPS, "Down: ", obj.downKPS);
var vid = "default";
if (outgoingBandwidth === "default") {
outgoingBandwidth = Math.ceil(obj.upKPS * .75).toString();
$("#vqual_hd").prop("checked", true); do_speed_test(function() {
vid = "1280x720";
if (outgoingBandwidth < 1024) {
$("#vqual_vga").prop("checked", true);
vid = "640x480";
}
if (outgoingBandwidth < 512) {
$("#vqual_qvga").prop("checked", true);
vid = "320x240";
}
}
if (incomingBandwidth === "default") {
incomingBandwidth = Math.ceil(obj.downKPS * .75).toString();
}
console.info(outgoingBandwidth, incomingBandwidth);
$("#bwinfo").html("<b>Bandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + " Vid: " + vid + "</b>");
online(true); online(true);
goto_page("main"); goto_page("main");
$("input[type='radio']").checkboxradio("refresh"); $("input[type='radio']").checkboxradio("refresh");
$("input[type='checkbox']").checkboxradio("refresh"); $("input[type='checkbox']").checkboxradio("refresh");
});
/* /*
verto.subscribe("presence", { verto.subscribe("presence", {
@ -607,6 +624,8 @@ var callbacks = {
autocall = false; autocall = false;
docall(); docall();
} }
});
} else { } else {
goto_page("main"); goto_page("main");
goto_dialog("login-error"); goto_dialog("login-error");
@ -1512,6 +1531,13 @@ function init() {
$("#errordisplay").html(""); $("#errordisplay").html("");
}); });
$("#speedbtn").click(function() {
do_speed_test(function() {
goto_page("main");
});
$("#errordisplay").html("");
});
$("#loginbtn").click(function() { $("#loginbtn").click(function() {
online(false); online(false);
vertoHandle.loginData({ vertoHandle.loginData({

View File

@ -1866,6 +1866,7 @@ static void client_run(jsock_t *jsock)
char *p = s+4; char *p = s+4;
int loops = 0; int loops = 0;
int rem = 0; int rem = 0;
int dur = 0, j = 0;
if (!(size = atoi(p))) { if (!(size = atoi(p))) {
continue; continue;
@ -1884,11 +1885,13 @@ static void client_run(jsock_t *jsock)
switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000); switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000);
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl)); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
loops = size / 1024; loops = size / 1024;
rem = size % 1024; rem = size % 1024;
switch_snprintf(repl, sizeof(repl), "#SPB "); switch_snprintf(repl, sizeof(repl), "#SPB ");
memset(repl+4, '.', 1024); memset(repl+4, '.', 1024);
for (j = 0; j < 10 ; j++) {
int ddur = 0;
a = switch_time_now(); a = switch_time_now();
for (i = 0; i < loops; i++) { for (i = 0; i < loops; i++) {
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, 1024); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, 1024);
@ -1897,8 +1900,14 @@ static void client_run(jsock_t *jsock)
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, rem); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, rem);
} }
b = switch_time_now(); b = switch_time_now();
ddur += ((b - a) / 1000);
dur += ddur;
switch_snprintf(repl, sizeof(repl), "#SPD %ld", ((b - a) / 1000) - 200); }
dur /= j+1;
switch_snprintf(repl, sizeof(repl), "#SPD %d", dur);
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl)); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
} }
} }