]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7977 - [Verto Communicator] Fixing default resolution and cleaning code
authorStefan Yohansson <stefan@evolux.net.br>
Tue, 18 Aug 2015 18:28:32 +0000 (15:28 -0300)
committerroot <root@dev-vm1.evolux.net.br>
Wed, 19 Aug 2015 20:36:46 +0000 (17:36 -0300)
html5/verto/js/src/jquery.FSRTC.js
html5/verto/verto_communicator/js/app.js
html5/verto/verto_communicator/js/controllers.js
html5/verto/verto_communicator/js/directives.js
html5/verto/verto_communicator/js/storage-service.js
html5/verto/verto_communicator/js/verto-service.js

index d2b4bd40861624b9b7f96e0df934155a471e525c..07ccd0031652ba26d4f071d7bdcab4b4782df81a 100644 (file)
@@ -1040,7 +1040,11 @@ var iceTimer;
     var checkRes = function (cam, func) {
 
        if (resI >= resList.length) {
-           if (func) return func();
+            var res = {
+               'validRes': $.FSRTC.validRes,
+               'bestResSupported': $.FSRTC.bestResSupported()
+            };
+           if (func) return func(res);
            return;
        }
 
index 7dee7d1898e15a8f20449b559b7cd64cd1998022..f30cd2d4cee7baeae1aed1268eacaf6a7c0f8474 100644 (file)
@@ -20,17 +20,17 @@ var vertoApp = angular.module('vertoApp', [
 vertoApp.config(['$routeProvider',
   function($routeProvider) {
     $routeProvider.
-      when('/login', {
-        title: 'Login',
-        templateUrl: 'partials/login.html',
-        controller: 'LoginController'
-      }).
-      when('/dialpad', {
-        title: 'Dialpad',
-        templateUrl: 'partials/dialpad.html',
-        controller: 'DialPadController'
-      }).
-      when('/incall', {
+    when('/login', {
+      title: 'Login',
+      templateUrl: 'partials/login.html',
+      controller: 'LoginController'
+    }).
+    when('/dialpad', {
+      title: 'Dialpad',
+      templateUrl: 'partials/dialpad.html',
+      controller: 'DialPadController'
+    }).
+    when('/incall', {
         title: 'In a Call',
         templateUrl: 'partials/incall.html',
         controller: 'InCallController'
@@ -40,25 +40,26 @@ vertoApp.config(['$routeProvider',
         templateUrl: 'partials/contributors.html',
         controller: 'ContributorsController',
       }).*/
-      when('/browser-upgrade', {
-        title: '',
-        templateUrl: 'partials/browser_upgrade.html',
-        controller: 'BrowserUpgradeController'
-      }).
-      otherwise({
-        redirectTo: '/login'
-      });
-  }]);
+    when('/browser-upgrade', {
+      title: '',
+      templateUrl: 'partials/browser_upgrade.html',
+      controller: 'BrowserUpgradeController'
+    }).
+    otherwise({
+      redirectTo: '/login'
+    });
+  }
+]);
 
 vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt',
   function($rootScope, $location, toastr, prompt) {
-    $rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
+    $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
       $rootScope.title = current.$$route.title;
     });
 
     $rootScope.safeProtocol = false;
 
-    if(window.location.protocol == 'https:') {
+    if (window.location.protocol == 'https:') {
       $rootScope.safeProtocol = true;
     }
 
@@ -79,7 +80,7 @@ vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt',
         message: message,
         input: true,
         label: label
-      }).then(function (ret) {
+      }).then(function(ret) {
         if (angular.isFunction(callback)) {
           callback(ret);
         }
@@ -89,4 +90,5 @@ vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt',
 
     };
 
-}]);
+  }
+]);
index 7ba9a3fc20c3779f729ffa1013947eee21d01f87..4a09295e337b65f4a37ed0d4b563ad893b113682 100644 (file)
@@ -2,12 +2,14 @@
 
 /* Controllers */
 
-var vertoControllers = angular.module('vertoControllers', ['ui.bootstrap', 'vertoService', 'storageService']);
+var vertoControllers = angular.module('vertoControllers', ['ui.bootstrap',
+  'vertoService', 'storageService'
+]);
 
 
 vertoControllers.filter('gravatar',
   function() {
-    return function (email, size) {
+    return function(email, size) {
       if (angular.isUndefined(size)) {
         size = 40;
       }
@@ -17,8 +19,11 @@ vertoControllers.filter('gravatar',
   });
 
 
-vertoControllers.controller('MainController', ['$scope', '$rootScope', '$location', '$modal', '$timeout', 'verto', 'storage', 'toastr', 'Fullscreen', 'prompt',
-  function($scope, $rootScope, $location, $modal, $timeout, verto, storage, toastr, Fullscreen, prompt) {
+vertoControllers.controller('MainController', ['$scope', '$rootScope',
+  '$location', '$modal', '$timeout', 'verto', 'storage', 'toastr',
+  'Fullscreen', 'prompt',
+  function($scope, $rootScope, $location, $modal,
+    $timeout, verto, storage, toastr, Fullscreen, prompt) {
     console.debug('Executing MainController.');
 
     var myVideo = document.getElementById("webcam");
@@ -42,7 +47,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     /**
      * if user data saved, use stored data for logon
      */
-    if(storage.data.ui_connected && storage.data.ws_connected) {
+    if (storage.data.ui_connected && storage.data.ws_connected) {
       $scope.verto.data.name = storage.data.name;
       $scope.verto.data.email = storage.data.email;
       $scope.verto.data.login = storage.data.login;
@@ -50,7 +55,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
 
       verto.connect(function(v, connected) {
         $scope.$apply(function() {
-          if(connected) {
+          if (connected) {
             toastr.success('Nice to see you again.', 'Welcome back');
             $location.path('/dialpad');
           }
@@ -84,7 +89,8 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
             toastr.success('Login successful.', 'Welcome');
             $location.path('/dialpad');
           } else {
-            toastr.error('There was an error while trying to login. Please try again.', 'Error');
+            toastr.error('There was an error while trying to login. \
+            Please try again.', 'Error');
           }
         });
       };
@@ -114,7 +120,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
         verto.hangup();
       }
 
-      if(verto.data.call) {
+      if (verto.data.call) {
         prompt({
           title: 'Oops, Active Call in Course.',
           message: 'It seems that you are in a call. Do you want to hang up?'
@@ -130,7 +136,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     /**
      * Shows a modal with the settings.
      */
-    $scope.openModalSettings = function () {
+    $scope.openModalSettings = function() {
       var modalInstance = $modal.open({
         animation: $scope.animationsEnabled,
         templateUrl: 'partials/modal_settings.html',
@@ -138,18 +144,18 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
       });
 
       modalInstance.result.then(
-        function (result) {
+        function(result) {
           console.log(result);
         },
-        function () {
+        function() {
           console.info('Modal dismissed at: ' + new Date());
         }
       );
 
       modalInstance.rendered.then(
-       function() {
-         jQuery.material.init();
-       }
+        function() {
+          jQuery.material.init();
+        }
       );
     };
 
@@ -161,18 +167,18 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
       });
 
       modalInstance.result.then(
-        function (result) {
+        function(result) {
           console.log(result);
         },
-        function () {
+        function() {
           console.info('Modal dismissed at: ' + new Date());
         }
       );
 
       modalInstance.rendered.then(
-       function() {
-         jQuery.material.init();
-       }
+        function() {
+          jQuery.material.init();
+        }
       );
 
     };
@@ -180,8 +186,8 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     $scope.showContributors = function() {
       $scope.openModal('partials/contributors.html', 'ContributorsController');
     };
-     
-     /**
+
+    /**
      * Updates the display adding the new number touched.
      *
      * @param {String} number - New touched number.
@@ -203,8 +209,8 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     };
 
 
-    $scope.toggleCallHistory = function () {
-      if(!$scope.call_history) {
+    $scope.toggleCallHistory = function() {
+      if (!$scope.call_history) {
         angular.element("#call_history").addClass('active');
         angular.element("#call-history-wrapper").addClass('active');
       } else {
@@ -218,33 +224,33 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
       storage.data.call_history = [];
     }
 
-    $scope.toggleChat = function () {
-      if($scope.chatStatus && $rootScope.activePane == 'chat') {
+    $scope.toggleChat = function() {
+      if ($scope.chatStatus && $rootScope.activePane == 'chat') {
         $rootScope.chat_counter = 0;
       }
       angular.element('#wrapper').toggleClass('toggled');
       $scope.chatStatus = angular.element('#wrapper').hasClass('toggled');
     };
 
-    $scope.openChat = function () {
+    $scope.openChat = function() {
       $scope.chatStatus = false;
       angular.element('#wrapper').removeClass('toggled');
     };
 
-    $scope.closeChat = function () {
+    $scope.closeChat = function() {
       $scope.chatStatus = true;
       angular.element('#wrapper').addClass('toggled');
     };
 
     $scope.goFullscreen = function() {
-      if(storage.data.userStatus != 'connected') {
+      if (storage.data.userStatus != 'connected') {
         return;
       }
       $rootScope.fullscreenEnabled = !Fullscreen.isEnabled();
-      if(Fullscreen.isEnabled()) {
+      if (Fullscreen.isEnabled()) {
         Fullscreen.cancel();
       } else {
-        Fullscreen.enable( document.getElementsByTagName('body')[0] );
+        Fullscreen.enable(document.getElementsByTagName('body')[0]);
       }
     }
 
@@ -253,34 +259,34 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     });
 
     $rootScope.$on('call.hangup', function(event, data) {
-      if(Fullscreen.isEnabled()) {
+      if (Fullscreen.isEnabled()) {
         Fullscreen.cancel();
       }
 
 
       console.log($scope.chatStatus);
-      if(!$scope.chatStatus) {
+      if (!$scope.chatStatus) {
         angular.element('#wrapper').toggleClass('toggled');
         $scope.chatStatus = angular.element('#wrapper').hasClass('toggled');
       }
-      
+
       $rootScope.dialpadNumber = '';
       console.debug('Redirecting to dialpad page.');
       $location.path('/dialpad');
 
       try {
         $rootScope.$digest();
-      } catch(e) {
+      } catch (e) {
         console.log('not digest');
       }
     });
 
-    $rootScope.$on('page.incall', function (event, data) {
+    $rootScope.$on('page.incall', function(event, data) {
       prompt({
         title: 'Oops, Active Call in Course.',
         message: 'It seems you were in a call before leaving the last time. Wanna go back to that?'
       }).then(function() {
-        verto.changeData(storage.data.verto);
+        verto.changeData(angular.fromJson(storage.data.verto));
         console.log('redirect to incall page');
         $location.path('/incall');
       }, function() {
@@ -292,8 +298,8 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     $rootScope.callActive = function(data) {
       verto.data.mutedMic = storage.data.mutedMic;
       verto.data.mutedVideo = storage.data.mutedVideo;
-      
-      if(!storage.data.cur_call) {
+
+      if (!storage.data.cur_call) {
         storage.data.call_start = new Date();
       }
       storage.data.userStatus = 'connected';
@@ -312,7 +318,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     $rootScope.$on('call.active', function(event, data) {
       $rootScope.callActive(data);
     });
-    
+
     $rootScope.$on('call.calling', function(event, data) {
       storage.data.calling = true;
     });
@@ -336,12 +342,22 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
 
         $scope.answerCall();
         storage.data.called_number = data;
-        
-        storage.data.call_history.unshift({'number': data, 'direction': 'inbound', 'status': true, 'call_start': Date()});
+
+        storage.data.call_history.unshift({
+          'number': data,
+          'direction': 'inbound',
+          'status': true,
+          'call_start': Date()
+        });
         $location.path('/incall');
       }, function() {
         $scope.declineCall();
-        storage.data.call_history.unshift({'number': data, 'direction': 'inbound', 'status': false, 'call_start': Date()});
+        storage.data.call_history.unshift({
+          'number': data,
+          'direction': 'inbound',
+          'status': false,
+          'call_start': Date()
+        });
       });
     });
 
@@ -374,7 +390,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
 
     $scope.answerCall = function() {
       storage.data.onHold = false;
-      
+
       verto.data.call.answer({
         useStereo: verto.data.useStereo,
         useCamera: verto.data.useCamera,
@@ -383,7 +399,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
         callee_id_number: verto.data.login
       });
 
-      
+
       $location.path('/incall');
     };
 
@@ -393,7 +409,7 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     };
 
     $scope.screenshare = function() {
-      if(verto.data.shareCall) {
+      if (verto.data.shareCall) {
         verto.screenshareHangup();
         return false;
       }
@@ -401,10 +417,11 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     };
 
     $scope.play = function() {
-      var file = $scope.promptInput('Please, enter filename', '', 'File', function(file) {
-        verto.data.conf.play(file);
-        console.log('play file :', file);
-      });
+      var file = $scope.promptInput('Please, enter filename', '', 'File',
+        function(file) {
+          verto.data.conf.play(file);
+          console.log('play file :', file);
+        });
 
     };
 
@@ -413,10 +430,11 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     };
 
     $scope.record = function() {
-      var file = $scope.promptInput('Please, enter filename', '', 'File', function(file) {
-         verto.data.conf.record(file);
-        console.log('recording file :', file);
-      });
+      var file = $scope.promptInput('Please, enter filename', '', 'File',
+        function(file) {
+          verto.data.conf.record(file);
+          console.log('recording file :', file);
+        });
     };
 
     $scope.stopRecord = function() {
@@ -424,18 +442,22 @@ vertoControllers.controller('MainController', ['$scope', '$rootScope', '$locatio
     };
 
     $scope.snapshot = function() {
-      var file = $scope.promptInput('Please, enter filename', '', 'File', function(file) {
-        verto.data.conf.snapshot(file);
-        console.log('snapshot file :', file);
-      });
+      var file = $scope.promptInput('Please, enter filename', '', 'File',
+        function(file) {
+          verto.data.conf.snapshot(file);
+          console.log('snapshot file :', file);
+        });
     };
 
 
-  }]);
+  }
+]);
 
 
-vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http', '$location', '$anchorScroll', '$timeout', 'verto',
-  function($scope, $rootScope, $http, $location, $anchorScroll, $timeout, verto) {
+vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http',
+  '$location', '$anchorScroll', '$timeout', 'verto',
+  function($scope, $rootScope, $http, $location, $anchorScroll, $timeout,
+    verto) {
     console.debug('Executing ChatController.');
 
     function scrollToChatBottom() {
@@ -457,7 +479,7 @@ vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http',
     clearConferenceChat();
 
     $scope.$watch('activePane', function() {
-      if($scope.activePane == 'chat') {
+      if ($scope.activePane == 'chat') {
         $rootScope.chat_counter = 0;
       }
       $rootScope.activePane = $scope.activePane;
@@ -468,11 +490,12 @@ vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http',
       console.log('chat.newMessage', data);
       $scope.$apply(function() {
         $scope.messages.push(data);
-        if(data.from != verto.data.name && (!$scope.chatStatus || $scope.activePane != 'chat')) {
+        if (data.from != verto.data.name && (!$scope.chatStatus ||
+            $scope.activePane != 'chat')) {
           ++$rootScope.chat_counter;
         }
         $timeout(function() {
-            scrollToChatBottom();
+          scrollToChatBottom();
         }, 300);
       });
     });
@@ -542,8 +565,9 @@ vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http',
       if (memberIdx < 0) {
         console.log('Didn\'t find the member uuid ' + member.uuid);
       } else {
-        $scope.$apply(function () {
-          console.log('Updating', memberIdx, ' <', $scope.members[memberIdx], '> with <', member, '>');
+        $scope.$apply(function() {
+          console.log('Updating', memberIdx, ' <', $scope.members[memberIdx],
+            '> with <', member, '>');
           angular.extend($scope.members[memberIdx], member);
         });
       }
@@ -612,24 +636,32 @@ vertoControllers.controller('ChatController', ['$scope', '$rootScope', '$http',
       var exten = '1800';
       verto.data.conf.transfer(memberID, exten);
     };
-  }]);
+  }
+]);
 
 
-vertoControllers.controller('MenuController', ['$scope', '$http', '$location', 'verto', 'storage',
+vertoControllers.controller('MenuController', ['$scope', '$http', '$location',
+  'verto', 'storage',
   function($scope, $http, $location, verto, storage) {
     console.debug('Executing MenuController.');
-  }]);
+  }
+]);
 
 
-vertoControllers.controller('ModalSettingsController', ['$scope', '$http', '$location', '$modalInstance', 'verto', 'storage',
+vertoControllers.controller('ModalSettingsController', ['$scope', '$http',
+  '$location', '$modalInstance', 'verto', 'storage',
   function($scope, $http, $location, $modalInstance, verto, storage) {
     console.debug('Executing ModalSettingsController.');
-    $scope.verto = storage.data.verto;
+
+
+    $scope.verto = verto;
+    $scope.verto = angular.fromJson(storage.data.verto);
     $scope.storage = storage;
 
     $scope.ok = function() {
       $modalInstance.close('Ok.');
-      verto.changeData(storage.data.verto);
+      storage.data.verto = angular.toJson($scope.verto);
+      verto.changeData($scope.verto);
     };
 
     $scope.cancel = function() {
@@ -639,9 +671,11 @@ vertoControllers.controller('ModalSettingsController', ['$scope', '$http', '$loc
     $scope.refreshDeviceList = function() {
       verto.refreshDevices();
     }
-  }]);
+  }
+]);
 
-vertoControllers.controller('ModalLoginInformationController', ['$scope', '$http', '$location', '$modalInstance', 'verto', 'storage',
+vertoControllers.controller('ModalLoginInformationController', ['$scope',
+  '$http', '$location', '$modalInstance', 'verto', 'storage',
   function($scope, $http, $location, $modalInstance, verto, storage) {
     console.debug('Executing ModalLoginInformationController.');
 
@@ -656,9 +690,11 @@ vertoControllers.controller('ModalLoginInformationController', ['$scope', '$http
       $modalInstance.dismiss('cancel');
     };
 
-  }]);
+  }
+]);
 
-vertoControllers.controller('LoginController', ['$scope', '$http', '$location', 'verto',
+vertoControllers.controller('LoginController', ['$scope', '$http', '$location',
+  'verto',
   function($scope, $http, $location, verto) {
     $scope.checkBrowser();
 
@@ -667,16 +703,18 @@ vertoControllers.controller('LoginController', ['$scope', '$http', '$location',
      */
     verto.data.name = $scope.storage.data.name;
     verto.data.email = $scope.storage.data.email;
-    if($scope.storage.data.login != '' && $scope.storage.data.password != '') {
+    if ($scope.storage.data.login != '' && $scope.storage.data.password != '') {
       verto.data.login = $scope.storage.data.login;
       verto.data.password = $scope.storage.data.password;
     }
 
     console.debug('Executing LoginController.');
-  }]);
+  }
+]);
 
 
-vertoControllers.controller('DialPadController', ['$rootScope', '$scope', '$http', '$location', 'toastr', 'verto', 'storage',
+vertoControllers.controller('DialPadController', ['$rootScope', '$scope',
+  '$http', '$location', 'toastr', 'verto', 'storage',
   function($rootScope, $scope, $http, $location, toastr, verto, storage) {
     console.debug('Executing DialPadController.');
 
@@ -684,11 +722,11 @@ vertoControllers.controller('DialPadController', ['$rootScope', '$scope', '$http
     storage.data.videoCall = false;
     storage.data.userStatus = 'connecting';
     storage.data.calling = false;
-    
+
     /**
      * fill dialpad via querystring [?autocall=\d+]
      */
-    if($location.search().autocall) {
+    if ($location.search().autocall) {
       $rootScope.dialpadNumber = $location.search().autocall;
     }
 
@@ -701,12 +739,12 @@ vertoControllers.controller('DialPadController', ['$rootScope', '$scope', '$http
     };
 
     $rootScope.transfer = function() {
-      if(!$rootScope.dialpadNumber) {
+      if (!$rootScope.dialpadNumber) {
         return false;
       }
       verto.data.call.transfer($rootScope.dialpadNumber);
     };
+
     /**
      * Call to the number in the $rootScope.dialpadNumber.
      */
@@ -714,7 +752,7 @@ vertoControllers.controller('DialPadController', ['$rootScope', '$scope', '$http
       storage.data.onHold = false;
       storage.data.cur_call = 0;
       $rootScope.dialpadNumber = extension;
-      if(!$rootScope.dialpadNumber && storage.data.called_number) {
+      if (!$rootScope.dialpadNumber && storage.data.called_number) {
         $rootScope.dialpadNumber = storage.data.called_number;
         return false;
       } else if (!$rootScope.dialpadNumber && !storage.data.called_number) {
@@ -726,22 +764,30 @@ vertoControllers.controller('DialPadController', ['$rootScope', '$scope', '$http
         console.debug('A call is already in progress.');
         return false;
       }
-      
+
       storage.data.mutedVideo = false;
       storage.data.mutedMic = false;
 
       storage.data.videoCall = false;
       verto.call($rootScope.dialpadNumber);
-      
+
       storage.data.called_number = $rootScope.dialpadNumber;
-      storage.data.call_history.unshift({'number': $rootScope.dialpadNumber, 'direction': 'outbound', 'call_start': Date()});
+      storage.data.call_history.unshift({
+        'number': $rootScope.dialpadNumber,
+        'direction': 'outbound',
+        'call_start': Date()
+      });
       $location.path('/incall');
     }
-  }]);
+  }
+]);
+
 
+vertoControllers.controller('InCallController', ['$rootScope', '$scope',
+  '$http', '$location', '$modal', '$timeout', 'toastr', 'verto', 'storage', 'prompt', 'Fullscreen',
+  function($rootScope, $scope, $http, $location, $modal, $timeout, toatr,
+    verto, storage, prompt, Fullscreen) {
 
-vertoControllers.controller('InCallController', ['$rootScope', '$scope', '$http', '$location', '$modal', '$timeout', 'toastr', 'verto', 'storage', 'prompt', 'Fullscreen',
-  function($rootScope, $scope, $http, $location, $modal, $timeout, toatr, verto, storage, prompt, Fullscreen) {
     console.debug('Executing InCallController.');
     $scope.layout = null;
     $scope.checkBrowser();
@@ -749,25 +795,26 @@ vertoControllers.controller('InCallController', ['$rootScope', '$scope', '$http'
     $scope.callTemplate = 'partials/phone_call.html';
     $scope.dialpadTemplate = '';
     $scope.incall = true;
-    
 
-    if(storage.data.videoCall) {
+
+    if (storage.data.videoCall) {
       $scope.callTemplate = 'partials/video_call.html';
     }
-    
+
     $rootScope.$on('call.video', function(event, data) {
       $timeout(function() {
         $scope.callTemplate = 'partials/video_call.html';
       });
     });
-   
+
     /**
      * toggle dialpad in incall page
      */
     $scope.toggleDialpad = function() {
-      $scope.openModal('partials/dialpad_widget.html', 'ModalDialpadController');
-      
-      /* 
+      $scope.openModal('partials/dialpad_widget.html',
+        'ModalDialpadController');
+
+      /*
       if(!$scope.dialpadTemplate) {
         $scope.dialpadTemplate = 'partials/dialpad_widget.html';
       } else {
@@ -775,7 +822,7 @@ vertoControllers.controller('InCallController', ['$rootScope', '$scope', '$http'
       }
       */
     }
-    
+
     /**
      * TODO: useless?
      */
@@ -803,52 +850,61 @@ vertoControllers.controller('InCallController', ['$rootScope', '$scope', '$http'
 
     $scope.muteMic = verto.muteMic;
     $scope.muteVideo = verto.muteVideo;
-    
-     $timeout(function() {
-       console.log('broadcast time-start incall');
-       $scope.$broadcast('timer-start');
-     }, 1000);
 
-  }]);
+    $timeout(function() {
+      console.log('broadcast time-start incall');
+      $scope.$broadcast('timer-start');
+    }, 1000);
+
+  }
+]);
 
-vertoControllers.controller('ModalDialpadController', ['$scope', '$modalInstance', function($scope, $modalInstance) {
-  
-  $scope.ok = function() {
-    $modalInstance.close('Ok.');
-  };
+vertoControllers.controller('ModalDialpadController', ['$scope',
+  '$modalInstance',
+  function($scope, $modalInstance) {
 
-  $scope.cancel = function() {
-    $modalInstance.dismiss('cancel');
-  };
+    $scope.ok = function() {
+      $modalInstance.close('Ok.');
+    };
+
+    $scope.cancel = function() {
+      $modalInstance.dismiss('cancel');
+    };
 
-}]);
+  }
+]);
 
-vertoControllers.controller('BrowserUpgradeController', ['$scope', '$http', '$location', 'verto', 'storage', 'Fullscreen',
+vertoControllers.controller('BrowserUpgradeController', ['$scope', '$http',
+  '$location', 'verto', 'storage', 'Fullscreen',
   function($scope, $http, $location, verto, storage, Fullscreen) {
     console.debug('Executing BrowserUpgradeController.');
 
-}]);
+  }
+]);
 
-vertoControllers.controller('ContributorsController', ['$scope', '$http', 'toastr', function($scope, $http, toastr) {
-  $http.get(window.location.pathname+'/contributors.txt')
-    .success(function(data) {
+vertoControllers.controller('ContributorsController', ['$scope', '$http',
+  'toastr',
+  function($scope, $http, toastr) {
+    $http.get(window.location.pathname + '/contributors.txt')
+      .success(function(data) {
 
-      var contributors = [];
+        var contributors = [];
 
-      angular.forEach(data, function(value, key) {
-        var re = /(.*) <(.*)>/;
-        var name = value.replace(re, "$1");
-        var email = value.replace(re, "$2");
+        angular.forEach(data, function(value, key) {
+          var re = /(.*) <(.*)>/;
+          var name = value.replace(re, "$1");
+          var email = value.replace(re, "$2");
 
-        this.push({
-          'name': name,
-          'email': email
-        });
-      }, contributors);
-        
-      $scope.contributors = contributors;
-    })
-    .error(function() {
-      toastr.error('contributors not found.');
-    });
-}]);
+          this.push({
+            'name': name,
+            'email': email
+          });
+        }, contributors);
+
+        $scope.contributors = contributors;
+      })
+      .error(function() {
+        toastr.error('contributors not found.');
+      });
+  }
+]);
index ac79c9b862afbbe6696727b1af6c86db1d8ff121..5b809f6ea6d6aec74a60fffb90c1baa6afb768cc 100644 (file)
@@ -18,7 +18,7 @@ vertoDirectives.directive('videoTag',
       // Moving the video tag to the new place inside the incall page.
       console.log('Moving the video to element.');
       jQuery('video').removeClass('hide').appendTo(element);
-      jQuery('video').css('display','block');
+      jQuery('video').css('display', 'block');
       scope.callActive();
 
       element.on('$destroy', function() {
@@ -62,19 +62,19 @@ vertoDirectives.directive('showControls',
       jQuery('.video-footer').fadeIn('slow');
       jQuery('.video-hover-buttons').fadeIn('slow');
       element.parent().bind('mousemove', function() {
-        if(Fullscreen.isEnabled()) {
+        if (Fullscreen.isEnabled()) {
           clearTimeout(i);
           jQuery('.video-footer').fadeIn('slow');
           jQuery('.video-hover-buttons').fadeIn(500);
-          i = setTimeout(function () {
-            if(Fullscreen.isEnabled()) {
+          i = setTimeout(function() {
+            if (Fullscreen.isEnabled()) {
               jQuery('.video-footer').fadeOut('slow');
               jQuery('.video-hover-buttons').fadeOut(500);
             }
           }, 3000);
         }
       });
-      element.parent().bind('mouseleave', function () {
+      element.parent().bind('mouseleave', function() {
         jQuery('.video-footer').fadeIn();
         jQuery('.video-hover-buttons').fadeIn();
       });
@@ -84,4 +84,4 @@ vertoDirectives.directive('showControls',
     return {
       link: link
     };
-});
+  });
index 8b153fcc45b9ee3dac737785becd1cd0f518e540..46cc760bd44767ad9432d8922d9c3610159cbb3a 100644 (file)
@@ -2,34 +2,36 @@
 
 var storageService = angular.module('storageService', ['ngStorage']);
 
-storageService.service('storage', ['$rootScope', '$localStorage', 'verto', function($rootScope, $localStorage, verto) {
-  var data = $localStorage;
+storageService.service('storage', ['$rootScope', '$localStorage', 'verto',
+  function($rootScope, $localStorage, verto) {
+    var data = $localStorage;
 
-  data.$default({
-    ui_connected: false,
-    ws_connected: false,
-    cur_call: 0,
-    called_number: '',
-    useVideo: true,
-    call_history: [],
-    call_start: false,
-    name: '',
-    email: '',
-    login: '',
-    password: '',
-    userStatus: 'disconnected',
-    mutedVideo: false,
-    mutedMic: false,
-    verto: verto
-  });
+    data.$default({
+      ui_connected: false,
+      ws_connected: false,
+      cur_call: 0,
+      called_number: '',
+      useVideo: true,
+      call_history: [],
+      call_start: false,
+      name: '',
+      email: '',
+      login: '',
+      password: '',
+      userStatus: 'disconnected',
+      mutedVideo: false,
+      mutedMic: false,
+      verto: angular.toJson(verto)
+    });
 
-  return {
-    data: data,
-    reset: function() {
-      data.ui_connected = false;
-      data.ws_connected = false;
-      data.cur_call = 0;
-      data.userStatus = 'disconnected';
-    },
-  };
-}]);
+    return {
+      data: data,
+      reset: function() {
+        data.ui_connected = false;
+        data.ws_connected = false;
+        data.cur_call = 0;
+        data.userStatus = 'disconnected';
+      },
+    };
+  }
+]);
index 16194c18649c9b8733b11a63640f5400a67c4f6a..8d16e718dbce135ba00e1cf0d966d6a81b6b70c6 100644 (file)
@@ -2,38 +2,95 @@
 
 /* Controllers */
 
-var videoQuality = [
-  {id: 'qvga', label: 'QVGA 320x240'},
-  {id: 'vga', label: 'VGA 640x480'},
-  {id: 'qvga_wide', label: 'QVGA WIDE 320x180'},
-  {id: 'vga_wide', label: 'VGA WIDE 640x360'},
-  {id: 'hd', label: 'HD 1280x720'},
-  {id: 'hhd', label: 'HHD 1920x1080'},
-];
+var videoQuality = [{
+  id: 'qvga',
+  label: 'QVGA 320x240',
+  width: 320,
+  height: 240
+}, {
+  id: 'vga',
+  label: 'VGA 640x480',
+  width: 640,
+  height: 480
+}, {
+  id: 'qvga_wide',
+  label: 'QVGA WIDE 320x180',
+  width: 320,
+  height: 180
+}, {
+  id: 'vga_wide',
+  label: 'VGA WIDE 640x360',
+  width: 640,
+  height: 360
+}, {
+  id: 'hd',
+  label: 'HD 1280x720',
+  width: 1280,
+  height: 720
+}, {
+  id: 'hhd',
+  label: 'HHD 1920x1080',
+  width: 1920,
+  height: 1080
+}, ];
 
 var videoResolution = {
-  qvga: {width: 320, height: 240},
-  vga: {width: 640, height: 480},
-  qvga_wide: {width: 320, height: 180},
-  vga_wide: {width: 640, height: 360},
-  hd: {width: 1280, height: 720},
-  hhd: {width: 1920, height: 1080},
+  qvga: {
+    width: 320,
+    height: 240
+  },
+  vga: {
+    width: 640,
+    height: 480
+  },
+  qvga_wide: {
+    width: 320,
+    height: 180
+  },
+  vga_wide: {
+    width: 640,
+    height: 360
+  },
+  hd: {
+    width: 1280,
+    height: 720
+  },
+  hhd: {
+    width: 1920,
+    height: 1080
+  },
 };
 
-var bandwidth = [
-  {id: '250', label: '250kb'},
-  {id: '500', label: '500kb'},
-  {id: '1024', label: '1mb'},
-  {id: '1536', label: '1.5mb'},
-  {id: '2048', label: '2mb'},
-  {id: '5120', label: '5mb'},
-  {id: '0', label: 'No Limit'},
-  {id: 'default', label: 'Server Default'},
-];
+var bandwidth = [{
+  id: '250',
+  label: '250kb'
+}, {
+  id: '500',
+  label: '500kb'
+}, {
+  id: '1024',
+  label: '1mb'
+}, {
+  id: '1536',
+  label: '1.5mb'
+}, {
+  id: '2048',
+  label: '2mb'
+}, {
+  id: '5120',
+  label: '5mb'
+}, {
+  id: '0',
+  label: 'No Limit'
+}, {
+  id: 'default',
+  label: 'Server Default'
+}, ];
 
 var vertoService = angular.module('vertoService', ['ngCookies']);
 
-vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', function($rootScope, $cookieStore, $location) {
+vertoService.service('verto', ['$rootScope', '$cookieStore', '$location',
+  function($rootScope, $cookieStore, $location) {
     var data = {
       // Connection data.
       instance: null,
@@ -72,6 +129,8 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
       incomingBandwidth: $cookieStore.get('verto_demo_incomingBandwidth') || 'default',
       vidQual: $cookieStore.get('verto_demo_vqual') || 'qvga',
       localVideo: $cookieStore.get('verto_demo_local_video_checked') || false,
+      bestWidth: '',
+      bestHeight: '',
       selectedVideo: null,
       selectedAudio: null,
       selectedShare: null
@@ -112,11 +171,24 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
     }
 
     function getVideoParams() {
+      var maxWidth, maxHeight;
+
+      maxWidth = data.bestWidth;
+      maxHeight = data.bestHeight;
+
+      if(!data.bestWidth) {
+        maxWidth = videoResolution[data.vidQual].width;
+      }
+
+      if(!data.bestHeight) {
+        maxHeight = videoResolution[data.vidQual].height;
+      }
+
       return {
         minWidth: videoResolution[data.vidQual].width,
         minHeight: videoResolution[data.vidQual].height,
-        maxWidth: videoResolution[data.vidQual].width,
-        maxHeight: videoResolution[data.vidQual].height
+        maxWidth: maxWidth,
+        maxHeight: maxHeight
       };
     }
 
@@ -161,8 +233,14 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
         console.debug('Attempting to refresh the devices.');
 
 
-        data.videoDevices = [{id: 'none', label: 'No camera'}];
-        data.shareDevices = [{id: 'screen', label: 'Screen'}];
+        data.videoDevices = [{
+          id: 'none',
+          label: 'No camera'
+        }];
+        data.shareDevices = [{
+          id: 'screen',
+          label: 'Screen'
+        }];
         data.audioDevices = [];
 
         data.selectedVideo = 'none';
@@ -171,10 +249,16 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
 
         for (var i in jQuery.verto.videoDevices) {
           var device = jQuery.verto.videoDevices[i];
-          if(!device.label) {
-            data.videoDevices.push({id: 'Camera ' + i, label: 'Camera ' + i});
+          if (!device.label) {
+            data.videoDevices.push({
+              id: 'Camera ' + i,
+              label: 'Camera ' + i
+            });
           } else {
-            data.videoDevices.push({id: device.id, label: device.label || device.id});
+            data.videoDevices.push({
+              id: device.id,
+              label: device.label || device.id
+            });
           }
 
           // Selecting the first source.
@@ -182,12 +266,18 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
             data.selectedVideo = device.id;
           }
 
-          if(!device.label) {
-            data.shareDevices.push({id: 'Share Device ' + i, label: 'Share Device ' + i});
+          if (!device.label) {
+            data.shareDevices.push({
+              id: 'Share Device ' + i,
+              label: 'Share Device ' + i
+            });
             continue;
           }
 
-          data.shareDevices.push({id: device.id, label: device.label || device.id});
+          data.shareDevices.push({
+            id: device.id,
+            label: device.label || device.id
+          });
         }
 
         data.audioDevices = [];
@@ -198,11 +288,17 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
             data.selectedAudio = device.id;
           }
 
-          if(!device.label) {
-            data.audioDevices.push({id: 'Microphone ' + i, label: 'Microphone ' + i});
+          if (!device.label) {
+            data.audioDevices.push({
+              id: 'Microphone ' + i,
+              label: 'Microphone ' + i
+            });
             continue;
           }
-          data.audioDevices.push({id: device.id, label: device.label || device.id});
+          data.audioDevices.push({
+            id: device.id,
+            label: device.label || device.id
+          });
         }
 
         console.debug('Devices were refreshed.');
@@ -230,6 +326,35 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
         }
       },
 
+      updateResolutions: function(supportedResolutions) {
+        console.debug('Attempting to sync supported and available resolutions');
+
+        var removed = 0;
+
+        angular.forEach(videoQuality, function(resolution, id) {
+          var supported = false;
+          angular.forEach(supportedResolutions, function(res) {
+            var width = res[0];
+            var height = res[1];
+
+            if(resolution.width == width && resolution.height == height) {
+              supported = true;
+            }
+          });
+
+          if(!supported) {
+            delete videoQuality[id];
+            ++removed;
+          }
+        });
+
+        videoQuality.length = videoQuality.length - removed;
+        this.videoQuality = videoQuality;
+        this.data.vidQual = videoQuality[videoQuality.length - 1].id;
+
+        return videoQuality;
+      },
+
       /**
        * Connects to the verto server. Automatically calls `onWSLogin`
        * callback set in the verto object.
@@ -268,8 +393,11 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
 
           data.liveArray = new $.verto.liveArray(
             data.instance, pvtData.laChannel,
-            pvtData.laName,
-            {subParams: {callID: dialog ? dialog.callID : null}});
+            pvtData.laName, {
+              subParams: {
+                callID: dialog ? dialog.callID : null
+              }
+            });
 
           data.liveArray.onErr = function(obj, args) {
             console.log('liveArray.onErr', obj, args);
@@ -278,7 +406,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
           data.liveArray.onChange = function(obj, args) {
             console.log('liveArray.onChange', obj, args);
 
-            switch(args.action) {
+            switch (args.action) {
               case 'bootObj':
                 $rootScope.$emit('members.boot', args.data);
                 break;
@@ -346,7 +474,10 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
               case $.verto.enum.message.info:
                 var body = params.body;
                 var from = params.from_msg_name || params.from;
-                $rootScope.$emit('chat.newMessage', {from: from, body: body});
+                $rootScope.$emit('chat.newMessage', {
+                  from: from,
+                  body: body
+                });
                 break;
               default:
                 break;
@@ -354,9 +485,9 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
           },
 
           onDialogState: function(d) {
-            if(!data.call) {
+            if (!data.call) {
               data.call = d;
-              if(d.state.name !== 'ringing') {
+              if (d.state.name !== 'ringing') {
                 inCall();
               }
             }
@@ -386,7 +517,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
                 break;
               case "destroy":
                 console.debug('Destroying: ' + d.cause);
-                if(d.params.screenShare) {
+                if (d.params.screenShare) {
                   cleanShareCall(that);
                 } else {
                   cleanCall();
@@ -404,7 +535,11 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
           }
         };
 
-        var init = function() {
+        var init = function(resolutions) {
+          data.bestWidth = resolutions['bestResSupported'][0];
+          data.bestHeight = resolutions['bestResSupported'][1];
+
+          that.updateResolutions(resolutions['validRes']);
 
           that.refreshVideoResolution();
 
@@ -479,7 +614,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
           caller_id_name: data.name,
           caller_id_number: data.login,
           outgoingBandwidth: data.outgoingBandwidth,
-             incomingBandwidth: data.incomingBandwidth,
+          incomingBandwidth: data.incomingBandwidth,
           useVideo: data.useVideo,
           useStereo: data.useStereo,
           useCamera: data.selectedVideo,
@@ -535,15 +670,15 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
       },
 
       screenshareHangup: function() {
-          if(!data.shareCall) {
-            console.debug('There is no call to hangup.');
-            return false;
-          }
+        if (!data.shareCall) {
+          console.debug('There is no call to hangup.');
+          return false;
+        }
 
-          console.log('shareCall End', data.shareCall);
-          data.shareCall.hangup();
+        console.log('shareCall End', data.shareCall);
+        data.shareCall.hangup();
 
-          console.debug('The screencall was hangup.');
+        console.debug('The screencall was hangup.');
 
       },
 
@@ -648,4 +783,5 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', functi
         }
       }
     };
-  }]);
+  }
+]);