From 828d6eaf0177caff9b60052be3c83b2008f85416 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 3 Oct 2015 02:36:28 -0500 Subject: [PATCH] first pass, add some funcs to conference and speed test features and fix bugs in ws.c for big payloads --- html5/verto/js/src/jquery.jsonrpcclient.js | 33 +++++ html5/verto/video_demo/index.html | 17 ++- html5/verto/video_demo/js/verto-min.js | 6 +- html5/verto/video_demo/verto.js | 27 +++- .../mod_conference/conference_video.c | 98 ++++++++++++-- .../mod_conference/mod_conference.c | 2 +- .../mod_conference/mod_conference.h | 4 + src/mod/endpoints/mod_verto/mod_verto.c | 39 +++++- src/mod/endpoints/mod_verto/ws.c | 125 +++++++++++++----- src/mod/endpoints/mod_verto/ws.h | 7 +- 10 files changed, 297 insertions(+), 61 deletions(-) diff --git a/html5/verto/js/src/jquery.jsonrpcclient.js b/html5/verto/js/src/jquery.jsonrpcclient.js index a02885e802..58d9986aec 100644 --- a/html5/verto/js/src/jquery.jsonrpcclient.js +++ b/html5/verto/js/src/jquery.jsonrpcclient.js @@ -91,6 +91,19 @@ /// The next JSON-RPC request id. $.JsonRpcClient.prototype._current_id = 1; + + $.JsonRpcClient.prototype.speedTest = function (bytes, cb) { + var socket = this.options.getSocket(this.wsOnMessage); + if (socket !== null) { + this.speedCB = cb; + this.speedBytes = bytes; + socket.send("#SPU"); + socket.send("#SPB\n" + new Array(bytes).join(".")); + } + }; + + + /** * @fn call * @memberof $.JsonRpcClient @@ -382,6 +395,26 @@ $.JsonRpcClient.prototype._wsOnMessage = function(event) { // Check if this could be a JSON RPC message. var response; + + // Special sub proto + if (event.data[0] == "#" && event.data[1] == "S" && event.data[2] == "P") { + if (event.data[3] == "U") { + this.up_dur = parseInt(event.data.substring(4)); + } else if (this.speedCB && event.data[3] == "D") { + this.down_dur = parseInt(event.data.substring(4)); + + var up_kps = (((this.speedBytes * 8) / (this.up_dur / 1000)) / 1024).toFixed(0); + var down_kps = (((this.speedBytes * 8) / (this.down_dur / 1000)) / 1024).toFixed(0); + + console.info("Speed Test: Up: " + up_kps + " Down: " + down_kps); + this.speedCB(event, { upDur: this.up_dur, downDur: this.down_dur, upKPS: up_kps, downKPS: down_kps }); + this.speedCB = null; + } + + return; + } + + try { response = $.parseJSON(event.data); diff --git a/html5/verto/video_demo/index.html b/html5/verto/video_demo/index.html index bd3d98fe4a..6c42ff1ad5 100644 --- a/html5/verto/video_demo/index.html +++ b/html5/verto/video_demo/index.html @@ -91,7 +91,7 @@ div#preload { display: none; }
@@ -108,6 +108,18 @@ div#preload { display: none; } +
+ + +

Testing Network Connection

+ + + +
+ +