Merge pull request #1553 in FS/freeswitch from ~THEHUNMONKGROUP/freeswitch:feature/FS-11287-provide-option-for-user-managed to master

* commit '96af587bf325ce35459cbd82e2e79bda0133a810':
  FS-11287: Provide option for user managed streams in Verto
This commit is contained in:
Christopher Rienzo 2018-08-28 14:16:50 +00:00
commit 1cf4981a82
2 changed files with 53 additions and 23 deletions

View File

@ -88,6 +88,7 @@
onICE: function() {}, onICE: function() {},
onOfferSDP: function() {} onOfferSDP: function() {}
}, },
useStream: null,
}, options); }, options);
this.audioEnabled = true; this.audioEnabled = true;
@ -295,7 +296,7 @@
self.options.useVideo['src'] = ''; self.options.useVideo['src'] = '';
} }
if (self.localStream) { if (self.localStream && !self.options.useStream) {
if(typeof self.localStream.stop == 'function') { if(typeof self.localStream.stop == 'function') {
self.localStream.stop(); self.localStream.stop();
} else { } else {
@ -312,11 +313,10 @@
} }
if (self.options.localVideo) { if (self.options.localVideo) {
self.options.localVideo.style.display = 'none'; deactivateLocalVideo(self.options.localVideo);
self.options.localVideo['src'] = '';
} }
if (self.options.localVideoStream) { if (self.options.localVideoStream && !self.options.useStream) {
if(typeof self.options.localVideoStream.stop == 'function') { if(typeof self.options.localVideoStream.stop == 'function') {
self.options.localVideoStream.stop(); self.options.localVideoStream.stop();
} else { } else {
@ -449,7 +449,7 @@
console.log("Audio constraints", mediaParams.audio); console.log("Audio constraints", mediaParams.audio);
console.log("Video constraints", mediaParams.video); console.log("Video constraints", mediaParams.video);
if (self.options.useVideo && self.options.localVideo) { if (self.options.useVideo && self.options.localVideo && !self.options.useStream) {
getUserMedia({ getUserMedia({
constraints: { constraints: {
audio: false, audio: false,
@ -461,6 +461,16 @@
}); });
} }
if (self.options.useStream) {
if (self.options.useVideo) {
self.options.localVideoStream = self.options.useStream;
if (self.options.localVideo) {
activateLocalVideo(self.options.localVideo, self.options.useStream);
}
}
onSuccess(self.options.useStream);
}
else {
getUserMedia({ getUserMedia({
constraints: { constraints: {
audio: mediaParams.audio, audio: mediaParams.audio,
@ -470,8 +480,7 @@
onsuccess: onSuccess, onsuccess: onSuccess,
onerror: onError onerror: onError
}); });
}
}; };
@ -499,7 +508,7 @@
} }
} }
if (obj.options.useVideo && obj.options.localVideo) { if (obj.options.useVideo && obj.options.localVideo && !obj.options.useStream) {
getUserMedia({ getUserMedia({
constraints: { constraints: {
audio: false, audio: false,
@ -647,7 +656,16 @@
console.log("Audio constraints", mediaParams.audio); console.log("Audio constraints", mediaParams.audio);
console.log("Video constraints", mediaParams.video); console.log("Video constraints", mediaParams.video);
if (mediaParams.audio || mediaParams.video) { if (self.options.useStream) {
if (self.options.useVideo) {
self.options.localVideoStream = self.options.useStream;
if (self.options.localVideo) {
activateLocalVideo(self.options.localVideo, self.options.useStream);
}
}
onSuccess(self.options.useStream);
}
else if (mediaParams.audio || mediaParams.video) {
getUserMedia({ getUserMedia({
constraints: { constraints: {
@ -953,6 +971,16 @@
//optional: [] //optional: []
}; };
function activateLocalVideo(el, stream) {
el.srcObject = stream;
el.style.display = 'block';
}
function deactivateLocalVideo(el) {
el.srcObject = null;
el.style.display = 'none';
}
function getUserMedia(options) { function getUserMedia(options) {
var n = navigator, var n = navigator,
media; media;
@ -968,8 +996,7 @@
function streaming(stream) { function streaming(stream) {
if (options.localVideo) { if (options.localVideo) {
options.localVideo['srcObject'] = stream; activateLocalVideo(options.localVideo, stream);
options.localVideo.style.display = 'block';
} }
if (options.onsuccess) { if (options.onsuccess) {

View File

@ -80,7 +80,8 @@
userVariables: {}, userVariables: {},
iceServers: false, iceServers: false,
ringSleep: 6000, ringSleep: 6000,
sessid: null sessid: null,
useStream: null
}, options); }, options);
if (verto.options.deviceParams.useCamera) { if (verto.options.deviceParams.useCamera) {
@ -1941,7 +1942,8 @@
tag: verto.options.tag, tag: verto.options.tag,
localTag: verto.options.localTag, localTag: verto.options.localTag,
login: verto.options.login, login: verto.options.login,
videoParams: verto.options.videoParams videoParams: verto.options.videoParams,
useStream: verto.options.useStream,
}, params); }, params);
@ -2099,7 +2101,8 @@
useCamera: dialog.useCamera, useCamera: dialog.useCamera,
useMic: dialog.useMic, useMic: dialog.useMic,
useSpeak: dialog.useSpeak, useSpeak: dialog.useSpeak,
turnServer: verto.options.turnServer turnServer: verto.options.turnServer,
useStream: dialog.params.useStream
}); });
dialog.rtc.verto = dialog.verto; dialog.rtc.verto = dialog.verto;