提交 1cf4981a authored 作者: Christopher Rienzo's avatar Christopher Rienzo

Merge pull request #1553 in FS/freeswitch from…

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

* commit '96af587b':
  FS-11287: Provide option for user managed streams in Verto
...@@ -88,6 +88,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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,17 +461,26 @@ ...@@ -461,17 +461,26 @@
}); });
} }
getUserMedia({ if (self.options.useStream) {
constraints: { if (self.options.useVideo) {
audio: mediaParams.audio, self.options.localVideoStream = self.options.useStream;
video: mediaParams.video if (self.options.localVideo) {
}, activateLocalVideo(self.options.localVideo, self.options.useStream);
video: mediaParams.useVideo, }
onsuccess: onSuccess, }
onerror: onError onSuccess(self.options.useStream);
}); }
else {
getUserMedia({
constraints: {
audio: mediaParams.audio,
video: mediaParams.video
},
video: mediaParams.useVideo,
onsuccess: onSuccess,
onerror: onError
});
}
}; };
...@@ -499,7 +508,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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) {
......
...@@ -80,7 +80,8 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论