From 2209f089b39c43c06d027b7bfa8ad9b51396c378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kilian=20K=C3=B6ppchen?= Date: Sat, 28 Mar 2015 15:07:21 +0100 Subject: [PATCH] Add code to test sent and received FPS --- Uebertragung/WebApp/js/helper.js | 1 - Uebertragung/WebApp/network-facade.js | 12 +++++- Uebertragung/WebApp/video.html | 9 ++++- .../ApplicationServer/WebSocketServer.cpp | 12 +++++- .../ApplicationServer/WebSocketServer.h | 37 +++++++++++++++++-- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/Uebertragung/WebApp/js/helper.js b/Uebertragung/WebApp/js/helper.js index 389c15d..503ccb0 100644 --- a/Uebertragung/WebApp/js/helper.js +++ b/Uebertragung/WebApp/js/helper.js @@ -42,7 +42,6 @@ var calcOptimalSize = function(width, height, maxWidth, upscale=false) { new_height = (height * ratio); } } - console.log("optimal size: " + new_width + " x " + new_height); return [new_width, new_height]; }; diff --git a/Uebertragung/WebApp/network-facade.js b/Uebertragung/WebApp/network-facade.js index 470e38d..1ede4f7 100644 --- a/Uebertragung/WebApp/network-facade.js +++ b/Uebertragung/WebApp/network-facade.js @@ -23,6 +23,9 @@ var NetworkFacade = function (protocol) { console.log('NetworkFacade does not support protocol type ' + this.protocol); } this.streamingVideo = null; + this.counter = 0; + this.start = null; + this.stop = null; }; NetworkFacade.prototype.init = function(server, localName) { @@ -77,12 +80,17 @@ NetworkFacade.prototype.startStreamVideo = function(video_source, width) { var canvas = document.createElement("canvas"); canvas.setAttribute("type", "hidden"); var nwf = this; + this.start = performance.now(); this.streamingVideo = setInterval(function(){ + var start = performance.now(); drawPictureToCanvas(video_source, video_source.videoWidth, video_source.videoHeight, canvas, width); _image_data = canvas.toDataURL("image/jpeg"); _image_data = _image_data.replace(/^data:image\/jpeg;base64,/ig, ""); nwf.sendData(getXMLforPicture(canvas.width, canvas.height, _image_data)); - }, 50); + var stop = performance.now(); + console.log(stop - start); + nwf.counter += 1; + }, 0); return true; } else { @@ -97,7 +105,9 @@ NetworkFacade.prototype.stopStreamVideo = function(e) { hangUpFromHere(); } else if(this.protocol == "WebSocket") { + this.stop = performance.now(); clearInterval(this.streamingVideo); + console.log(this.stop - this.start + "ms" + " counter: " + this.counter); } else { // do nothing diff --git a/Uebertragung/WebApp/video.html b/Uebertragung/WebApp/video.html index a3dd94e..4e4b07a 100644 --- a/Uebertragung/WebApp/video.html +++ b/Uebertragung/WebApp/video.html @@ -22,7 +22,12 @@ navigator.getUserMedia ( // constraints { - video: true, + video: { + mandatory: { + maxWidth: 1280, + maxHeight: 720, + } + }, audio: false }, @@ -68,7 +73,7 @@ }
-