mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +00:00
FS-9242 convert to adapter.js
This commit is contained in:
@@ -108,6 +108,7 @@
|
||||
<script type="text/javascript" src="../js/src/jquery.jsonrpcclient.js"></script>
|
||||
<script type="text/javascript" src="../js/src/jquery.FSRTC.js"></script>
|
||||
<script type="text/javascript" src="../js/src/jquery.verto.js"></script>
|
||||
<script type="text/javascript" src="../js/src/vendor/adapter-latest.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/3rd-party/getScreenId.js"></script>
|
||||
<script type="text/javascript" src="js/3rd-party/md5.min.js"></script>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<div class="panel-body">
|
||||
<div class="preview-wrapper">
|
||||
<video id="videopreview" muted autoplay style="width: 100%;"></video>
|
||||
<div id="mic-meter">
|
||||
<div id="mic-meter" ng-if="audioContext">
|
||||
<div class="volumes">
|
||||
<div class="volume-segment"></div>
|
||||
<div class="volume-segment"></div>
|
||||
|
@@ -14,11 +14,7 @@
|
||||
'status': 'success',
|
||||
'message': $translate.instant('BROWSER_COMPATIBILITY')
|
||||
};
|
||||
navigator.getUserMedia = navigator.getUserMedia ||
|
||||
navigator.webkitGetUserMedia ||
|
||||
navigator.mozGetUserMedia;
|
||||
|
||||
if (!navigator.getUserMedia) {
|
||||
if (!navigator.mediaDevices.getUserMedia) {
|
||||
result['status'] = 'error';
|
||||
result['message'] = $translate.instant('BROWSER_WITHOUT_WEBRTC');
|
||||
reject(result);
|
||||
|
@@ -23,6 +23,7 @@
|
||||
mutedMic: false,
|
||||
preview: true,
|
||||
selectedVideo: null,
|
||||
selectedVideoName: null,
|
||||
selectedAudio: null,
|
||||
selectedShare: null,
|
||||
selectedSpeaker: null,
|
||||
|
@@ -4,8 +4,8 @@
|
||||
angular
|
||||
.module('vertoControllers')
|
||||
.controller('DialPadController', ['$rootScope', '$scope',
|
||||
'$http', '$location', 'toastr', 'verto', 'storage', 'CallHistory', 'eventQueue',
|
||||
function($rootScope, $scope, $http, $location, toastr, verto, storage, CallHistory, eventQueue) {
|
||||
'$http', '$location', 'toastr', 'verto', 'storage', 'CallHistory', 'eventQueue', '$timeout',
|
||||
function($rootScope, $scope, $http, $location, toastr, verto, storage, CallHistory, eventQueue, $timeout) {
|
||||
console.debug('Executing DialPadController.');
|
||||
|
||||
eventQueue.process();
|
||||
|
@@ -11,7 +11,10 @@
|
||||
$scope.storage = storage;
|
||||
console.debug('Executing PreviewController.');
|
||||
var localVideo = document.getElementById('videopreview');
|
||||
var volumes = document.querySelector('#mic-meter .volumes').children;
|
||||
var volumes = document.querySelector('#mic-meter .volumes');
|
||||
if (volumes) {
|
||||
volumes = volumes.children;
|
||||
}
|
||||
|
||||
$scope.localVideo = function() {
|
||||
var constraints = {
|
||||
@@ -31,10 +34,13 @@
|
||||
|
||||
});
|
||||
};
|
||||
var audioContext = null;
|
||||
if (typeof AudioContext !== "undefined") {
|
||||
audioContext = new AudioContext();
|
||||
}
|
||||
|
||||
var audioContext = new AudioContext();
|
||||
var mediaStreamSource = null;
|
||||
var meter;
|
||||
var meter = null;
|
||||
var streamObj = {};
|
||||
|
||||
function stopMedia(stream) {
|
||||
@@ -55,13 +61,12 @@
|
||||
}
|
||||
|
||||
streamObj = stream;
|
||||
localVideo.src = window.URL.createObjectURL(stream);
|
||||
|
||||
mediaStreamSource = audioContext.createMediaStreamSource(stream);
|
||||
meter = createAudioMeter(audioContext);
|
||||
mediaStreamSource.connect(meter);
|
||||
|
||||
renderMic();
|
||||
FSRTCattachMediaStream(localVideo, stream);
|
||||
if (audioContext) {
|
||||
mediaStreamSource = audioContext.createMediaStreamSource(stream);
|
||||
meter = createAudioMeter(audioContext);
|
||||
mediaStreamSource.connect(meter);
|
||||
};
|
||||
}
|
||||
|
||||
function renderMic() {
|
||||
@@ -109,8 +114,10 @@
|
||||
|
||||
$scope.endPreview = function() {
|
||||
localVideo.src = null;
|
||||
meter.shutdown();
|
||||
meter.onaudioprocess = null;
|
||||
if (audioContext) {
|
||||
meter.shutdown();
|
||||
meter.onaudioprocess = null;
|
||||
};
|
||||
stopMedia(streamObj);
|
||||
$location.path('/dialpad');
|
||||
storage.data.preview = false;
|
||||
|
@@ -33,6 +33,15 @@
|
||||
});
|
||||
|
||||
$scope.ok = function() {
|
||||
console.log('Camera Selected is', $scope.mydata.selectedVideo, $scope.verto.data.videoDevices);
|
||||
|
||||
angular.forEach(verto.data.videoDevices, function(video) {
|
||||
console.log('checking video ', video);
|
||||
if (video.id == $scope.mydata.selectedVideo) {
|
||||
$scope.mydata.selectedVideoName = video.label;
|
||||
console.log('Setting selectedVideoName to ', video.label);
|
||||
}
|
||||
})
|
||||
if ($scope.mydata.selectedSpeaker != storage.data.selectedSpeaker) {
|
||||
$rootScope.$emit('changedSpeaker', $scope.mydata.selectedSpeaker);
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@
|
||||
$rootScope.$on('progress.complete', function(ev, current_progress) {
|
||||
$scope.message = 'Complete';
|
||||
if(verto.data.connected) {
|
||||
if (storage.data.preview) {
|
||||
if (0 && storage.data.preview) {
|
||||
$location.path('/preview');
|
||||
}
|
||||
else {
|
||||
|
@@ -13,17 +13,35 @@
|
||||
.module('vertoDirectives')
|
||||
.directive('videoTag',
|
||||
function() {
|
||||
|
||||
function link(scope, element, attrs) {
|
||||
// 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');
|
||||
var videoElem = jQuery('#webcam');
|
||||
|
||||
var newParent = document.getElementsByClassName('video-tag-wrapper');
|
||||
newParent[0].appendChild(document.getElementById('webcam'));
|
||||
|
||||
$("#webcam").resize(function() {
|
||||
updateVideoSize();
|
||||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
updateVideoSize();
|
||||
});
|
||||
|
||||
updateVideoSize();
|
||||
|
||||
videoElem.removeClass('hide');
|
||||
videoElem.css('display', 'block');
|
||||
|
||||
scope.callActive("", {useVideo: true});
|
||||
|
||||
element.on('$destroy', function() {
|
||||
// Move the video back to the body.
|
||||
console.log('Moving the video back to body.');
|
||||
jQuery('video').addClass('hide').appendTo(jQuery('body'));
|
||||
videoElem.addClass('hide').appendTo(jQuery('body'));
|
||||
$(window).unbind('resize');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -113,6 +113,35 @@ var framerate = [{
|
||||
label: '30 FPS'
|
||||
}, ];
|
||||
|
||||
var updateReq;
|
||||
|
||||
var updateVideoSize = function(ms) {
|
||||
if (!ms) ms = 500;
|
||||
|
||||
clearTimeout(updateReq);
|
||||
updateReq = setTimeout(function () {
|
||||
var videoElem = jQuery('#webcam');
|
||||
videoElem.width("");
|
||||
videoElem.height("");
|
||||
|
||||
var w = videoElem.width();
|
||||
var h = videoElem.height();
|
||||
var new_w, new_h;
|
||||
var aspect = 1920 / 1080;
|
||||
var videoContainer = jQuery('div.video-wrapper');
|
||||
if (w > h) {
|
||||
new_w = videoContainer.width();
|
||||
new_h = Math.round(videoContainer.width() / aspect);
|
||||
} else {
|
||||
new_h = videoContainer.height();
|
||||
new_w = Math.round(videoContainer.height() / aspect);
|
||||
}
|
||||
videoElem.width(new_w);
|
||||
videoElem.height(new_h);
|
||||
console.log('Setting video size to ' + new_w + '/' + new_h);
|
||||
}, ms);
|
||||
}
|
||||
|
||||
var vertoService = angular.module('vertoService', ['ngCookies']);
|
||||
|
||||
vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'storage',
|
||||
@@ -317,7 +346,13 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||
|
||||
// Verify if selected devices are valid
|
||||
var videoFlag = data.videoDevices.some(function(device) {
|
||||
return device.id == storage.data.selectedVideo;
|
||||
console.log('Evaluating device ', device);
|
||||
if (device.label == storage.data.selectedVideoName) {
|
||||
console.log('Matched video selection by name: ', device.label);
|
||||
storage.data.selectedVideo = device.id;
|
||||
return true;
|
||||
}
|
||||
return device.id == storage.data.selectedVideo && storage.data.selectedVideo !== "none";
|
||||
});
|
||||
|
||||
var shareFlag = data.shareDevices.some(function(device) {
|
||||
@@ -332,7 +367,10 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||
return device.id == storage.data.selectedSpeaker;
|
||||
});
|
||||
|
||||
if (!videoFlag) storage.data.selectedVideo = data.videoDevices[0].id;
|
||||
console.log('Storage Video: ', storage.data.selectedVideo);
|
||||
console.log('Video Flag: ', videoFlag)
|
||||
|
||||
if (!videoFlag) storage.data.selectedVideo = data.videoDevices[data.videoDevices.length - 1].id;
|
||||
if (!shareFlag) storage.data.selectedShare = data.shareDevices[0].id;
|
||||
if (!audioFlag) storage.data.selectedAudio = data.audioDevices[0].id;
|
||||
if (!speakerFlag && data.speakerDevices.length > 0) storage.data.selectedSpeaker = data.speakerDevices[0].id;
|
||||
@@ -484,7 +522,6 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||
|
||||
data.liveArray.onChange = function(obj, args) {
|
||||
// console.log('liveArray.onChange', obj, args);
|
||||
|
||||
switch (args.action) {
|
||||
case 'bootObj':
|
||||
$rootScope.$emit('members.boot', args.data);
|
||||
@@ -560,6 +597,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||
console.log("conference-liveArray-join");
|
||||
stopConference();
|
||||
startConference(v, dialog, params.pvtData);
|
||||
updateVideoSize();
|
||||
}
|
||||
break;
|
||||
case "conference-liveArray-part":
|
||||
@@ -616,6 +654,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
|
||||
console.debug('Talking to:', d.cidString());
|
||||
data.callState = 'active';
|
||||
callActive(d.lastState.name, d.params);
|
||||
updateVideoSize();
|
||||
break;
|
||||
case "hangup":
|
||||
console.debug('Call ended with cause: ' + d.cause);
|
||||
|
Reference in New Issue
Block a user