This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 6931d84  [OPENMEETINGS-1854] mic-level is improved, errors displaying 
is added
6931d84 is described below

commit 6931d84921fc38a27466bd47c7efa22b2b0e9104
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Wed Mar 21 12:57:04 2018 +0700

    [OPENMEETINGS-1854] mic-level is improved, errors displaying is added
---
 .../src/site/xdoc/BuildInstructions.xml            |  2 +-
 .../openmeetings/util/OpenmeetingsVariables.java   |  2 +-
 .../openmeetings/web/room/VideoSettings.html       |  1 +
 .../apache/openmeetings/web/room/settings-base.js  | 34 +++++++++-------------
 4 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/openmeetings-server/src/site/xdoc/BuildInstructions.xml 
b/openmeetings-server/src/site/xdoc/BuildInstructions.xml
index 1dabb92..672c5fe 100644
--- a/openmeetings-server/src/site/xdoc/BuildInstructions.xml
+++ b/openmeetings-server/src/site/xdoc/BuildInstructions.xml
@@ -60,7 +60,7 @@
                <section name="Tips and Gotchas">
                        <p>Eclipse ANSI colors plugin for colors in console</p>
                        <source><![CDATA[
-MAVEN_OPTS='-Xdebug 
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n' mvn clean -P 
allModules,quick,mysql,jetty jetty:run-exploded
+MAVEN_OPTS='-Xdebug 
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n' mvn clean -P 
allModules,quick,mysql jetty:run-exploded
 
 cd ..; mvn clean install -pl openmeetings-util -P allModules,quick; cd 
openmeetings-web;
 
diff --git 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index fb59d97..4a19aa4 100644
--- 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++ 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -97,7 +97,7 @@ public class OpenmeetingsVariables {
        public static final String CONFIG_REST_ALLOW_ORIGIN = 
"rest.allow.origin";
 
        public static final String HEADER_XFRAME_SAMEORIGIN = "SAMEORIGIN";
-       public static final String HEADER_CSP_SELF = "default-src 'self'; 
style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 
'unsafe-eval'; img-src 'self' data:;";
+       public static final String HEADER_CSP_SELF = "default-src 'self'; 
style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 
'unsafe-eval'; img-src 'self' data:; media-src 'self' blob:;";
        public static final int RECENT_ROOMS_COUNT = 5;
        public static final int USER_LOGIN_MINIMUM_LENGTH = 4;
        public static final int USER_PASSWORD_MINIMUM_LENGTH = 8;
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.html
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.html
index ef379d5..e2f1892 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.html
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.html
@@ -88,5 +88,6 @@
                        <wicket:message key="765"/>
                </div>
        </div>
+       <span id="jsNotifications"></span>
 </wicket:panel>
 </html>
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
index 687c597..eef5ea1 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
@@ -1,8 +1,8 @@
 /* Licensed under the Apache License, Version 2.0 (the "License") 
http://www.apache.org/licenses/LICENSE-2.0 */
 var MicLevel = (function() {
-       let ctx, analyser, mic, script;
+       let ctx, mic, script, vol = .0;
 
-       function _meter(cnts, rtcPeer, _micActivity, _error) {
+       function _meter(rtcPeer, _micActivity, _error) {
                if (!rtcPeer || 'function' !== typeof(rtcPeer.getLocalStream)) {
                        return;
                }
@@ -12,31 +12,26 @@ var MicLevel = (function() {
                }
                try {
                        ctx = new AudioContext();
-                       analyser = new AnalyserNode(ctx, {
-                               fftSize: 512
-                               , smoothingTimeConstant: 0.5,
-                       });
-                       script = ctx.createScriptProcessor(2048, 1, 1);
+                       script = ctx.createScriptProcessor(512);
                        mic = ctx.createMediaStreamSource(stream);
                        mic.connect(script);
                        script.connect(ctx.destination);
-                       mic.connect(analyser);
-                       analyser.connect(script);
-                       const arr =  new Uint8Array(analyser.frequencyBinCount);
                        let t = Date.now();
                        script.onaudioprocess = function(event) {
+                               const arr = event.inputBuffer.getChannelData()
+                                       , al = arr.length;
+                               let avg = 0.0;
+                               for (let i = 0; i < al; ++i) {
+                                       avg += arr[i] * arr[i];
+                               }
+                               avg = Math.sqrt(avg / al);
+                               vol = Math.max(avg, vol * .95);
+                               //we will continuously get volume but do not 
perform re-draw too often
                                if (Date.now() - t < 200) {
                                        return;
                                }
                                t = Date.now();
-                               analyser.getByteFrequencyData(arr);
-                               let avg = 0.0;
-                               for (let i = 0; i < arr.length; ++i) {
-                                       avg += arr[i];
-                               }
-                               avg /= arr.length;
-                               _micActivity(100 * avg / 255);
-                               console.log("avg = " + avg);
+                               _micActivity(140 * vol); // magic number
                        };
                } catch (err) {
                        _error(err);
@@ -46,8 +41,7 @@ var MicLevel = (function() {
                if (!!ctx) {
                        mic.disconnect(script);
                        script.disconnect(ctx.destination);
-                       mic.disconnect(analyser);
-                       analyser.disconnect(script);
+                       script.onaudioprocess = null;
                        ctx = null;
                }
        }

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to