]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweaks
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 5 Oct 2015 18:00:33 +0000 (13:00 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 6 Nov 2015 20:01:54 +0000 (14:01 -0600)
html5/verto/video_demo/index.html
html5/verto/video_demo/verto.js
src/mod/endpoints/mod_verto/mod_verto.c

index 6c42ff1ad5bda216ce022e8aa1f337bd9b6a289b..276b75b36beba2898d5f3c34621eba0e7bf930a4 100644 (file)
@@ -361,6 +361,7 @@ if ($('#devices').is(':visible')) {
 </script>
 <!--<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="speedbtn">Check Speed</button>
 <button data-inline="true"id="logoutbtn">Log Out</button>
 
 <div id="devices" style="border-style:outset;border-width:2px">
index 1c935dcb3ef6b13a68ddb45dd88521bc9d241a49..a0e2d6f6c86e48ae016982fd29ac48187e971309 100644 (file)
@@ -197,7 +197,46 @@ function check_vid() {
     return use_vid;
 }
 
-// Attach audio output device to video element using device/sink ID.                                                                                            
+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.                                                                                           
 function attachSinkId(element, sinkId) {
     if (typeof element.sinkId !== 'undefined') {
        element.setSinkId(sinkId)
@@ -559,54 +598,34 @@ var callbacks = {
        ringing = false;
 
         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);
-                   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>");
+           do_speed_test(function() {
+               
                online(true);
                goto_page("main");
+
                $("input[type='radio']").checkboxradio("refresh");
                $("input[type='checkbox']").checkboxradio("refresh");
-           });
-           
-           /*
-            verto.subscribe("presence", {
-                handler: function(v, e) {
-                    console.error("PRESENCE:", e);
-                }
-               });
-           */
 
-            if (!window.location.hash) {
-                goto_page("main");
-            }
 
-           if (autocall) {
-               autocall = false;
-               docall();
-           }
+               /*
+                 verto.subscribe("presence", {
+                  handler: function(v, e) {
+                  console.error("PRESENCE:", e);
+                  }
+                 });
+               */
+               
+               if (!window.location.hash) {
+                    goto_page("main");
+               }
+               
+               if (autocall) {
+                   autocall = false;
+                   docall();
+               }
+           });
+
         } else {
             goto_page("main");
             goto_dialog("login-error");
@@ -1512,6 +1531,13 @@ function init() {
        $("#errordisplay").html("");
     });
 
+    $("#speedbtn").click(function() {
+       do_speed_test(function() {
+           goto_page("main");
+       });
+       $("#errordisplay").html("");
+    });
+
     $("#loginbtn").click(function() {
         online(false);
         vertoHandle.loginData({
index 02f1f0ebb8e41ec0fd53e922477b3ce8782927bc..d159013ec6a024418325b278ed298ba7239bcd93 100644 (file)
@@ -1866,6 +1866,7 @@ static void client_run(jsock_t *jsock)
                                                        char *p = s+4;
                                                        int loops = 0;
                                                        int rem = 0;
+                                                       int dur = 0, j = 0;
 
                                                        if (!(size = atoi(p))) {
                                                                continue;
@@ -1884,21 +1885,29 @@ static void client_run(jsock_t *jsock)
 
                                                        switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000);
                                                        ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
-
                                                        loops = size / 1024;
                                                        rem = size % 1024;
                                                        switch_snprintf(repl, sizeof(repl), "#SPB ");
                                                        memset(repl+4, '.', 1024);
-                                                       a = switch_time_now();
-                                                       for (i = 0; i < loops; i++) {
-                                                               ws_write_frame(&jsock->ws, WSOC_TEXT, repl, 1024);
-                                                       }
-                                                       if (rem) {
-                                                               ws_write_frame(&jsock->ws, WSOC_TEXT, repl, rem);
+
+                                                       for (j = 0; j < 10 ; j++) {
+                                                               int ddur = 0;
+                                                               a = switch_time_now();
+                                                               for (i = 0; i < loops; i++) {
+                                                                       ws_write_frame(&jsock->ws, WSOC_TEXT, repl, 1024);
+                                                               }
+                                                               if (rem) {
+                                                                       ws_write_frame(&jsock->ws, WSOC_TEXT, repl, rem);
+                                                               }
+                                                               b = switch_time_now();
+                                                               ddur += ((b - a) / 1000);
+                                                               dur += ddur;
+
                                                        }
-                                                       b = switch_time_now();
 
-                                                       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));
                                                }
                                        }