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

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


The following commit(s) were added to refs/heads/4.0.x by this push:
     new 6690b77  [OPENMEETINGS-1142] secure mode and device list retrieval are 
removed
6690b77 is described below

commit 6690b776f9c6ad7545659a9b008e4ba67c9e62e1
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Thu Jul 19 21:54:25 2018 +0700

    [OPENMEETINGS-1142] secure mode and device list retrieval are removed
---
 openmeetings-flash/src/main/flex/main.mxml         |   6 --
 .../main/flex/org/apache/openmeetings/OmVideo.as   |  40 +++++---
 .../org/apache/openmeetings/web/common/main.js     |  28 ++++++
 .../org/apache/openmeetings/web/room/settings.js   | 109 ++++++++++++++-------
 .../java/org/apache/openmeetings/web/room/video.js |   2 +
 openmeetings-web/src/main/webapp/css/room.css      |   4 +
 6 files changed, 135 insertions(+), 54 deletions(-)

diff --git a/openmeetings-flash/src/main/flex/main.mxml 
b/openmeetings-flash/src/main/flex/main.mxml
index 53c6432..135161e 100644
--- a/openmeetings-flash/src/main/flex/main.mxml
+++ b/openmeetings-flash/src/main/flex/main.mxml
@@ -138,12 +138,6 @@
                        ExternalInterface.addCallback("vidResize", vidResize);
                        switch (params.mode) {
                                case 'settings': {
-                                       
ExternalInterface.addCallback("getDevices", function ():Object {
-                                               return {
-                                                       cams: Camera.names
-                                                       , mics: Microphone.names
-                                               };
-                                       });
                                        
ExternalInterface.addCallback("camChanged", function (val:int):void {
                                                selectedCam = val;
                                                camChanged(null);
diff --git 
a/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as 
b/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
index dd04138..52c02c0 100644
--- a/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
+++ b/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
@@ -57,6 +57,7 @@ public class OmVideo {
        private var volume:int = 50;
        private var lastVolume:int = 50;
        private var cursorCbk:Function = null;
+       private var vidRect:Object = {x: 0, y: 0, width: 0, height: 0};
 
        public function OmVideo(ui:UIComponent, params:Object, 
cursorCbk:Function = null) {
                this.ui = ui;
@@ -67,8 +68,10 @@ public class OmVideo {
        private function getVideo():Video {
                if (vid === null) {
                        vid = new Video();
-                       vid.width = width;
-                       vid.height = height;
+                       vid.width = vidRect.width || width;
+                       vid.height = vidRect.height || height;
+                       vid.x = vidRect.x || 0;
+                       vid.y = vidRect.y || 0;
                        ui.addChild(vid);
                }
                return vid;
@@ -78,33 +81,43 @@ public class OmVideo {
                return mic;
        }
 
-       public function resize(_width:int, _height:int):void {
-               debug("resize:: " + _width + "x" + _height);
-               this.width = ui.width = _width;
-               this.height = ui.height = _height;
+       private function setBg():void {
                var g:Graphics = ui.graphics;
                if (!!cam && !cam.muted) {
                        g.beginFill(0x000000, 1);
-                       g.drawRect(0, 0, _width, _height);
+                       g.drawRect(0, 0, this.width, this.height);
                        g.endFill();
                } else {
                        g.clear();
                }
        }
 
+       public function resize(_width:int, _height:int):void {
+               debug("resize:: " + _width + "x" + _height);
+               this.width = ui.width = _width;
+               this.height = ui.height = _height;
+               setBg();
+       }
+
        public function vidResize(_width:int, _height:int):void {
                debug("vidResize:: " + _width + "x" + _height);
-               vid.width = _width;
-               vid.height = _height;
+               vidRect.width = _width;
+               vidRect.height = _height;
                if (_width < this.width) {
-                       vid.x = (this.width - _width) / 2;
+                       vidRect.x = (this.width - _width) / 2;
                } else {
-                       vid.x = 0;
+                       vidRect.x = 0;
                }
                if (_height < this.height) {
-                       vid.y = (this.height - _height) / 2;
+                       vidRect.y = (this.height - _height) / 2;
                } else {
-                       vid.y = 0;
+                       vidRect.y = 0;
+               }
+               if (!!vid) {
+                       vid.width = vidRect.width;
+                       vid.height = vidRect.height;
+                       vid.x = vidRect.x;
+                       vid.y = vidRect.y;
                }
        }
 
@@ -235,6 +248,7 @@ public class OmVideo {
                        debug("::camera settings ", cam.keyFrameInterval, 
cam.width, cam.height, cam.fps);
                        videoStreamSettings.setMode(cam.width, cam.height, 
cam.fps);
                        ns.videoStreamSettings = videoStreamSettings;
+                       setBg();
                }
                ns.attachAudio(mic);
                _setVolume(volume);
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js
index 1745c0c..e910382 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/main.js
@@ -23,6 +23,7 @@ var Settings = (function() {
        };
 })();
 var OmUtil = (function() {
+       let options, errs;
        const self = {};
        function _confirmDlg(_id, okHandler) {
                const confirm = $('#' + _id);
@@ -49,13 +50,40 @@ var OmUtil = (function() {
        function _tmpl(tmplId, newId) {
                return $(tmplId).clone().attr('id', newId || '');
        }
+       function _error(msg) {
+               if (typeof(msg) === 'object') {
+                       msg = msg.name + ": " + msg.message;
+               }
+               if (!!errs && errs.length > 0) {
+                       errs.data("kendoNotification").show(msg, "error");
+               }
+               return console.error(msg);
+       }
+       function _debugEnabled() {
+               return !!options && !!options.debug;
+       }
+       function _info() {
+               if (_debugEnabled()) {
+                       console.info.apply(this, arguments);
+               }
+       }
+       function _log() {
+               if (_debugEnabled()) {
+                       console.log.apply(this, arguments);
+               }
+       }
 
        self.confirmDlg = _confirmDlg;
        self.tmpl = _tmpl;
+       self.debugEnabled = _debugEnabled;
+       self.enableDebug = function() { if (!!options) { options.debug = true; 
} };
        self.sendMessage = function(m) {
                const msg = JSON.stringify(m || {});
                Wicket.WebSocket.send(msg);
        };
+       self.error = _error;
+       self.info = _info;
+       self.log = _log;
        return self;
 })();
 Wicket.BrowserInfo.collectExtraInfo = function(info) {
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
index 621cb6c..4d39f05 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
@@ -18,6 +18,17 @@ var VideoSettings = (function() {
                        VideoManager.refresh(o.uid, s.video);
                }
        }
+       function _clear(_ms) {
+               const ms = _ms;
+               if (ms !== null && 'function' === typeof(ms.getAudioTracks)) {
+                       ms.getAudioTracks().forEach(function(track) {
+                               track.stop();
+                       });
+                       ms.getVideoTracks().forEach(function(track) {
+                               track.stop();
+                       });
+               }
+       }
        function _init(options) {
                o = JSON.parse(JSON.stringify(options));
                vs = $('#video-settings');
@@ -102,43 +113,71 @@ var VideoSettings = (function() {
        function _micActivity(level) {
                lm.progressbar('value', Math.max(0, level));
        }
-       function _initSwf() {
-               const obj = swf.getDevices();
-               cam.find('option[value!="-1"]').remove();
-               for (let i = 0; i < obj.cams.length; ++i) {
-                       const o = $('<option></option>').attr('value', 
i).text(obj.cams[i]);
-                       if (i === s.video.cam) {
-                               o.prop('selected', true);
-                       }
-                       cam.append(o);
+       function _initDevices() {
+               if (!navigator.mediaDevices || 
!navigator.mediaDevices.enumerateDevices) {
+                       OmUtil.error('enumerateDevices() not supported.');
+                       return;
                }
-               cam.prop('disabled', false).change(function() {
-                       _readValues();
-                       swf.camChanged(s.video.cam);
-               });
+               cam.find('option[value!="-1"]').remove();
                mic.find('option[value!="-1"]').remove();
-               for (let i = 0; i < obj.mics.length; ++i) {
-                       const o = $('<option></option>').attr('value', 
i).text(obj.mics[i]);
-                       if (i === s.video.mic) {
-                               o.prop('selected', true);
-                       }
-                       mic.append(o);
-               }
-               mic.prop('disabled', false).change(function() {
-                       _readValues();
-                       swf.micChanged(s.video.mic);
-               });
-               res.change(function() {
-                       _readValues();
-                       swf.resChanged(s.video.width, s.video.height);
-               });
-               res.find('option').each(function() {
-                       const o = $(this).data();
-                       if (o.width === s.video.width && o.height === 
s.video.height) {
-                               $(this).prop('selected', true);
-                               return false;
-                       }
-               });
+               navigator.mediaDevices.getUserMedia({video:true, audio:true})
+                       .then(function(stream) {
+                               const devices = 
navigator.mediaDevices.enumerateDevices()
+                                       .then(function(devices) {
+                                               return devices;
+                                       })
+                                       .catch(function(err) { throw err; });
+                               _clear(stream);
+                               return devices;
+                       })
+                       .then(function(devices) {
+                               let cCount = 0, mCount = 0;
+                               devices.forEach(function(device) {
+                                       if ('audioinput' === device.kind) {
+                                               const o = 
$('<option></option>').attr('value', mCount).text(device.label)
+                                                       .data('device-id', 
device.deviceId);
+                                               if (mCount === s.video.cam) {
+                                                       o.prop('selected', 
true);
+                                               }
+                                               mic.append(o);
+                                               mCount++;
+                                       } else if ('videoinput' === 
device.kind) {
+                                               const o = 
$('<option></option>').attr('value', cCount).text(device.label)
+                                                       .data('device-id', 
device.deviceId);
+                                               if (cCount === s.video.cam) {
+                                                       o.prop('selected', 
true);
+                                               }
+                                               cam.append(o);
+                                               cCount++;
+                                       }
+                               });
+                               cam.prop('disabled', 
false).off().change(function() {
+                                       _readValues();
+                                       swf.camChanged(s.video.cam);
+                               });
+                               mic.prop('disabled', 
false).off().change(function() {
+                                       _readValues();
+                                       swf.micChanged(s.video.mic);
+                               });
+                               res.off().change(function() {
+                                       _readValues();
+                                       swf.resChanged(s.video.width, 
s.video.height);
+                               });
+                               res.find('option').each(function() {
+                                       const o = $(this).data();
+                                       if (o.width === s.video.width && 
o.height === s.video.height) {
+                                               $(this).prop('selected', true);
+                                               return false;
+                                       }
+                               });
+                               _readValues();
+                       })
+                       .catch(function(err) {
+                               OmUtil.error(err);
+                       });
+       }
+       function _initSwf() {
+               _initDevices();
                _readValues();
                swf.init(s.video.cam, s.video.mic
                        , o.interview ? 320 : s.video.width, o.interview ? 260 
: s.video.height);
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video.js
index a359503..34fdcfe 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video.js
@@ -36,6 +36,7 @@ var Video = (function() {
        }
        function _swfLoaded() {
                if (Room.getOptions().interview) {
+                       v.parent().parent().removeClass('secure');
                        _resizePod();
                } else {
                        const h = _resizeDlg(size.width, size.height);
@@ -45,6 +46,7 @@ var Video = (function() {
        function _securityMode() {
                if (Room.getOptions().interview) {
                        _resizeDlgArea(Math.max(300, swf.attr('width')), 
Math.max(200, swf.attr('height')));
+                       v.parent().parent().addClass('secure');
                } else {
                        v.dialog('option', 'position', {my: 'center', at: 
'center', of: VideoUtil.container()});
                }
diff --git a/openmeetings-web/src/main/webapp/css/room.css 
b/openmeetings-web/src/main/webapp/css/room.css
index f61c6a0..cbca4bb 100644
--- a/openmeetings-web/src/main/webapp/css/room.css
+++ b/openmeetings-web/src/main/webapp/css/room.css
@@ -527,6 +527,10 @@
 .pod-area .pod-big.ui-hightlight {
        box-shadow: 3px 3px 4px blue;
 }
+.pod-area .pod.secure, .pod-area .pod.secure 
.ui-dialog.video.user-video.secure {
+       min-width: 300px;
+       min-height: 200px;
+}
 .width250 {
        min-width: 250px;
        max-width: 250px;

Reply via email to