FS-11960: [js] replaces all deprecated js methods for FF warnings
This commit is contained in:
parent
1c80a83d57
commit
d5a065243f
|
@ -57,7 +57,7 @@
|
||||||
var result = sdpLine.match(pattern);
|
var result = sdpLine.match(pattern);
|
||||||
return (result && result.length == 2) ? result[1] : null;
|
return (result && result.length == 2) ? result[1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a new m= line with the specified codec as the first one.
|
// Returns a new m= line with the specified codec as the first one.
|
||||||
function setDefaultCodec(mLine, payload) {
|
function setDefaultCodec(mLine, payload) {
|
||||||
var elements = mLine.split(' ');
|
var elements = mLine.split(' ');
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
console.error('Error attaching stream to element.');
|
console.error('Error attaching stream to element.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoteStream(self, stream) {
|
function onRemoteStream(self, stream) {
|
||||||
if (self.options.useVideo) {
|
if (self.options.useVideo) {
|
||||||
self.options.useVideo.style.display = 'block';
|
self.options.useVideo.style.display = 'block';
|
||||||
|
@ -259,9 +259,9 @@
|
||||||
console.log("REMOTE STREAM", stream, element);
|
console.log("REMOTE STREAM", stream, element);
|
||||||
|
|
||||||
FSRTCattachMediaStream(element, stream);
|
FSRTCattachMediaStream(element, stream);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//self.options.useAudio.play();
|
//self.options.useAudio.play();
|
||||||
self.remoteStream = stream;
|
self.remoteStream = stream;
|
||||||
onRemoteStreamSuccess(self, stream);
|
onRemoteStreamSuccess(self, stream);
|
||||||
|
@ -297,38 +297,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.localStream && !self.options.useStream) {
|
if (self.localStream && !self.options.useStream) {
|
||||||
if(typeof self.localStream.stop == 'function') {
|
var tracks = self.localStream.getTracks();
|
||||||
self.localStream.stop();
|
console.log("Stopping localStream tracks:", tracks);
|
||||||
} else {
|
tracks.forEach(function(track){ track.stop() })
|
||||||
if (self.localStream.active){
|
|
||||||
var tracks = self.localStream.getTracks();
|
|
||||||
console.log(tracks);
|
|
||||||
tracks.forEach(function(track, index){
|
|
||||||
console.log(track);
|
|
||||||
track.stop();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.localStream = null;
|
self.localStream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.options.localVideo) {
|
if (self.options.localVideo) {
|
||||||
deactivateLocalVideo(self.options.localVideo);
|
deactivateLocalVideo(self.options.localVideo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.options.localVideoStream && !self.options.useStream) {
|
if (self.options.localVideoStream && !self.options.useStream) {
|
||||||
if(typeof self.options.localVideoStream.stop == 'function') {
|
var tracks = self.options.localVideoStream.getTracks();
|
||||||
self.options.localVideoStream.stop();
|
console.log("Stopping localVideoStream tracks:", tracks);
|
||||||
} else {
|
tracks.forEach(function(track){ track.stop() })
|
||||||
if (self.options.localVideoStream.active){
|
|
||||||
var tracks = self.options.localVideoStream.getTracks();
|
|
||||||
console.log(tracks);
|
|
||||||
tracks.forEach(function(track, index){
|
|
||||||
console.log(track);
|
|
||||||
track.stop();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.peer) {
|
if (self.peer) {
|
||||||
|
@ -347,7 +329,7 @@
|
||||||
if (!self.localStream) {
|
if (!self.localStream) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var audioTracks = self.localStream.getAudioTracks();
|
var audioTracks = self.localStream.getAudioTracks();
|
||||||
|
|
||||||
for (var i = 0, len = audioTracks.length; i < len; i++ ) {
|
for (var i = 0, len = audioTracks.length; i < len; i++ ) {
|
||||||
switch(what) {
|
switch(what) {
|
||||||
|
@ -379,7 +361,7 @@
|
||||||
if (!self.localStream) {
|
if (!self.localStream) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var videoTracks = self.localStream.getVideoTracks();
|
var videoTracks = self.localStream.getVideoTracks();
|
||||||
|
|
||||||
for (var i = 0, len = videoTracks.length; i < len; i++ ) {
|
for (var i = 0, len = videoTracks.length; i < len; i++ ) {
|
||||||
switch(what) {
|
switch(what) {
|
||||||
|
@ -546,15 +528,15 @@
|
||||||
if (obj.options.useCamera) {
|
if (obj.options.useCamera) {
|
||||||
opt.push({sourceId: obj.options.useCamera});
|
opt.push({sourceId: obj.options.useCamera});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestFrameRate) {
|
if (bestFrameRate) {
|
||||||
opt.push({minFrameRate: bestFrameRate});
|
opt.push({minFrameRate: bestFrameRate});
|
||||||
opt.push({maxFrameRate: bestFrameRate});
|
opt.push({maxFrameRate: bestFrameRate});
|
||||||
}
|
}
|
||||||
|
|
||||||
video = {
|
video = {
|
||||||
mandatory: obj.options.videoParams,
|
mandatory: obj.options.videoParams,
|
||||||
optional: opt
|
optional: opt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -564,9 +546,9 @@
|
||||||
width: {min: obj.options.videoParams.minWidth, max: obj.options.videoParams.maxWidth},
|
width: {min: obj.options.videoParams.minWidth, max: obj.options.videoParams.maxWidth},
|
||||||
height: {min: obj.options.videoParams.minHeight, max: obj.options.videoParams.maxHeight}
|
height: {min: obj.options.videoParams.minHeight, max: obj.options.videoParams.maxHeight}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var useVideo = obj.options.useVideo;
|
var useVideo = obj.options.useVideo;
|
||||||
|
|
||||||
if (useVideo && obj.options.useCamera && obj.options.useCamera !== "none") {
|
if (useVideo && obj.options.useCamera && obj.options.useCamera !== "none") {
|
||||||
|
@ -574,7 +556,7 @@
|
||||||
//video.optional = [];
|
//video.optional = [];
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
if (obj.options.useCamera !== "any") {
|
if (obj.options.useCamera !== "any") {
|
||||||
//video.optional.push({sourceId: obj.options.useCamera});
|
//video.optional.push({sourceId: obj.options.useCamera});
|
||||||
video = assignMediaIdToConstraint(obj.options.useCamera, video);
|
video = assignMediaIdToConstraint(obj.options.useCamera, video);
|
||||||
|
@ -595,10 +577,10 @@
|
||||||
|
|
||||||
return {audio: audio, video: video, useVideo: useVideo};
|
return {audio: audio, video: video, useVideo: useVideo};
|
||||||
}
|
}
|
||||||
|
|
||||||
$.FSRTC.prototype.call = function(profile) {
|
$.FSRTC.prototype.call = function(profile) {
|
||||||
checkCompat();
|
checkCompat();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var screen = false;
|
var screen = false;
|
||||||
|
|
||||||
|
@ -610,13 +592,13 @@
|
||||||
|
|
||||||
function onSuccess(stream) {
|
function onSuccess(stream) {
|
||||||
self.localStream = stream;
|
self.localStream = stream;
|
||||||
|
|
||||||
if (screen) {
|
if (screen) {
|
||||||
self.constraints.offerToReceiveVideo = false;
|
self.constraints.offerToReceiveVideo = false;
|
||||||
self.constraints.offerToReceiveAudio = false;
|
self.constraints.offerToReceiveAudio = false;
|
||||||
self.constraints.offerToSendAudio = false;
|
self.constraints.offerToSendAudio = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.peer = FSRTCPeerConnection({
|
self.peer = FSRTCPeerConnection({
|
||||||
type: self.type,
|
type: self.type,
|
||||||
attachStream: self.localStream,
|
attachStream: self.localStream,
|
||||||
|
@ -696,7 +678,7 @@
|
||||||
// 2013, @muazkh - github.com/muaz-khan
|
// 2013, @muazkh - github.com/muaz-khan
|
||||||
// MIT License - https://www.webrtc-experiment.com/licence/
|
// MIT License - https://www.webrtc-experiment.com/licence/
|
||||||
// Documentation - https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCPeerConnection
|
// Documentation - https://github.com/muaz-khan/WebRTC-Experiment/tree/master/RTCPeerConnection
|
||||||
|
|
||||||
function FSRTCPeerConnection(options) {
|
function FSRTCPeerConnection(options) {
|
||||||
var gathering = false, done = false;
|
var gathering = false, done = false;
|
||||||
var config = {};
|
var config = {};
|
||||||
|
@ -730,7 +712,7 @@
|
||||||
if (options.onICEComplete) {
|
if (options.onICEComplete) {
|
||||||
options.onICEComplete();
|
options.onICEComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.type == "offer") {
|
if (options.type == "offer") {
|
||||||
options.onICESDP(peer.localDescription);
|
options.onICESDP(peer.localDescription);
|
||||||
} else {
|
} else {
|
||||||
|
@ -749,7 +731,7 @@
|
||||||
if (!gathering) {
|
if (!gathering) {
|
||||||
gathering = setTimeout(ice_handler, 1000);
|
gathering = setTimeout(ice_handler, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
if (event.candidate) {
|
if (event.candidate) {
|
||||||
options.onICE(event.candidate);
|
options.onICE(event.candidate);
|
||||||
|
@ -785,23 +767,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
peer.onaddstream = function(event) {
|
// peer.onaddstream = function(event) { // OLD API
|
||||||
var remoteMediaStream = event.stream;
|
peer.ontrack = function(event) {
|
||||||
|
console.log('Peer Track', event)
|
||||||
|
// var remoteMediaStream = event.stream;
|
||||||
|
var remoteMediaStream = event.streams[0];
|
||||||
|
|
||||||
// onRemoteStreamEnded(MediaStream)
|
|
||||||
remoteMediaStream.oninactive = function () {
|
remoteMediaStream.oninactive = function () {
|
||||||
if (options.onRemoteStreamEnded) options.onRemoteStreamEnded(remoteMediaStream);
|
if (options.onRemoteStreamEnded) options.onRemoteStreamEnded(remoteMediaStream);
|
||||||
};
|
};
|
||||||
|
|
||||||
// onRemoteStream(MediaStream)
|
|
||||||
if (options.onRemoteStream) options.onRemoteStream(remoteMediaStream);
|
if (options.onRemoteStream) options.onRemoteStream(remoteMediaStream);
|
||||||
|
|
||||||
//console.debug('on:add:stream', remoteMediaStream);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//var constraints = options.constraints || {
|
//var constraints = options.constraints || {
|
||||||
// offerToReceiveAudio: true,
|
// offerToReceiveAudio: true,
|
||||||
//offerToReceiveVideo: true
|
//offerToReceiveVideo: true
|
||||||
//};
|
//};
|
||||||
|
|
||||||
// onOfferSDP(RTCSessionDescription)
|
// onOfferSDP(RTCSessionDescription)
|
||||||
|
@ -959,16 +940,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
stop: function() {
|
stop: function() {
|
||||||
peer.close();
|
if (options.attachStream instanceof MediaStream) {
|
||||||
if (options.attachStream) {
|
var tracks = options.attachStream.getTracks();
|
||||||
if(typeof options.attachStream.stop == 'function') {
|
tracks.forEach(function(track){ track.stop() })
|
||||||
options.attachStream.stop();
|
options.attachStream = null
|
||||||
} else {
|
|
||||||
options.attachStream.active = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
peer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +1038,6 @@
|
||||||
console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options);
|
console.error('Unexpected error on media id assurance attempts:', error, 'Options:', options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.FSRTC.resSupported = function(w, h) {
|
$.FSRTC.resSupported = function(w, h) {
|
||||||
for (var i in $.FSRTC.validRes) {
|
for (var i in $.FSRTC.validRes) {
|
||||||
if ($.FSRTC.validRes[i][0] == w && $.FSRTC.validRes[i][1] == h) {
|
if ($.FSRTC.validRes[i][0] == w && $.FSRTC.validRes[i][1] == h) {
|
||||||
|
@ -1095,9 +1072,9 @@
|
||||||
'validRes': $.FSRTC.validRes,
|
'validRes': $.FSRTC.validRes,
|
||||||
'bestResSupported': $.FSRTC.bestResSupported()
|
'bestResSupported': $.FSRTC.bestResSupported()
|
||||||
};
|
};
|
||||||
|
|
||||||
localStorage.setItem("res_" + cam, $.toJSON(res));
|
localStorage.setItem("res_" + cam, $.toJSON(res));
|
||||||
|
|
||||||
if (func) return func(res);
|
if (func) return func(res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1115,23 +1092,21 @@
|
||||||
video = assignMediaIdToConstraint(cam, video);
|
video = assignMediaIdToConstraint(cam, video);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserMedia({
|
getUserMedia({
|
||||||
constraints: {
|
constraints: { audio: ttl++ == 0, video: video },
|
||||||
audio: ttl++ == 0,
|
|
||||||
video: video
|
|
||||||
},
|
|
||||||
onsuccess: function(e) {
|
onsuccess: function(e) {
|
||||||
e.getTracks().forEach(function(track) {track.stop();});
|
e.getTracks().forEach(function(track) { track.stop() });
|
||||||
console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);},
|
console.info(w + "x" + h + " supported."); $.FSRTC.validRes.push([w, h]); checkRes(cam, func);
|
||||||
|
},
|
||||||
onerror: function(e) {console.warn( w + "x" + h + " not supported."); checkRes(cam, func);}
|
onerror: function(e) {console.warn( w + "x" + h + " not supported."); checkRes(cam, func);}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$.FSRTC.getValidRes = function (cam, func) {
|
$.FSRTC.getValidRes = function (cam, func) {
|
||||||
var used = [];
|
var used = [];
|
||||||
var cached = localStorage.getItem("res_" + cam);
|
var cached = localStorage.getItem("res_" + cam);
|
||||||
|
|
||||||
if (cached) {
|
if (cached) {
|
||||||
var cache = $.parseJSON(cached);
|
var cache = $.parseJSON(cached);
|
||||||
|
|
||||||
|
@ -1152,33 +1127,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
|
$.FSRTC.checkPerms = function (runtime, check_audio, check_video) {
|
||||||
getUserMedia({
|
getUserMedia({
|
||||||
constraints: {
|
constraints: { audio: check_audio, video: check_video },
|
||||||
audio: check_audio,
|
onsuccess: function(e) {
|
||||||
video: check_video,
|
e.getTracks().forEach(function(track) { track.stop() });
|
||||||
},
|
console.info("media perm init complete");
|
||||||
onsuccess: function(e) {
|
if (runtime) {
|
||||||
|
|
||||||
e.getTracks().forEach(function(track) {track.stop();});
|
|
||||||
|
|
||||||
console.info("media perm init complete");
|
|
||||||
if (runtime) {
|
|
||||||
setTimeout(runtime, 100, true);
|
setTimeout(runtime, 100, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onerror: function(e) {
|
onerror: function(e) {
|
||||||
if (check_video && check_audio) {
|
if (check_video && check_audio) {
|
||||||
console.error("error, retesting with audio params only");
|
console.error("error, retesting with audio params only");
|
||||||
return $.FSRTC.checkPerms(runtime, check_audio, false);
|
return $.FSRTC.checkPerms(runtime, check_audio, false);
|
||||||
}
|
}
|
||||||
|
console.error("media perm init error");
|
||||||
console.error("media perm init error");
|
if (runtime) {
|
||||||
|
runtime(false)
|
||||||
if (runtime) {
|
}
|
||||||
runtime(false)
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
|
@ -2837,16 +2837,15 @@
|
||||||
has_video++;
|
has_video++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
navigator.mediaDevices.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)})
|
||||||
|
.then(function(stream) {
|
||||||
|
Xstream = stream;
|
||||||
|
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log("The following error occurred: " + err.name);
|
||||||
|
});
|
||||||
|
|
||||||
navigator.getUserMedia({ audio: (has_audio > 0 ? true : false), video: (has_video > 0 ? true : false)},
|
|
||||||
function(stream) {
|
|
||||||
Xstream = stream;
|
|
||||||
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);
|
|
||||||
},
|
|
||||||
function(err) {
|
|
||||||
console.log("The following error occurred: " + err.name);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.mediaDevices.enumerateDevices().then(checkTypes).catch(handleError);
|
navigator.mediaDevices.enumerateDevices().then(checkTypes).catch(handleError);
|
||||||
|
|
Loading…
Reference in New Issue