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

View File

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