From bfde438c8fe475f55cdb67b08daaa5ec8b343004 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 24 May 2017 13:27:25 +0200 Subject: Update janus.nojquery.js. --- js/lib/janus.nojquery.js | 117 +++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 60 deletions(-) (limited to 'js') diff --git a/js/lib/janus.nojquery.js b/js/lib/janus.nojquery.js index 0dfce72..2343ac6 100644 --- a/js/lib/janus.nojquery.js +++ b/js/lib/janus.nojquery.js @@ -143,7 +143,10 @@ Janus.init = function(options) { } else { Janus.error("Error attaching stream to element"); } - } else { + } else if(adapter.browserDetails.browser === 'safari' || window.navigator.userAgent.match(/iPad/i) || window.navigator.userAgent.match(/iPhone/i)) { + element.src = URL.createObjectURL(stream); + } + else { element.srcObject = stream; } }; @@ -155,7 +158,10 @@ Janus.init = function(options) { } else if(typeof to.src !== 'undefined') { to.src = from.src; } - } else { + } else if(adapter.browserDetails.browser === 'safari' || window.navigator.userAgent.match(/iPad/i) || window.navigator.userAgent.match(/iPhone/i)) { + to.src = from.src; + } + else { to.srcObject = from.srcObject; } }; @@ -192,7 +198,11 @@ Janus.init = function(options) { return; } // Got payload - params.success(JSON.parse(XHR.responseText)); + try { + params.success(JSON.parse(XHR.responseText)); + } catch(e) { + params.error(XHR, XHR.status, 'Could not parse response, error: ' + e + ', text: ' + XHR.responseText); + } }; } try { @@ -204,7 +214,11 @@ Janus.init = function(options) { return; } // Got payload - params.success(JSON.parse(XHR.responseText)); + try { + params.success(JSON.parse(XHR.responseText)); + } catch(e) { + params.error(XHR, XHR.status, 'Could not parse response, error: ' + e + ', text: ' + XHR.responseText); + } } } catch(e) { // Something broke up @@ -225,44 +239,8 @@ Janus.init = function(options) { if(oldOBF && typeof oldOBF == "function") oldOBF(); } - function addJsList(srcArray) { - if (!srcArray || !Array.isArray(srcArray) || srcArray.length == 0) { - options.callback(); - } - var count = 0; - addJs(srcArray[count],next); - - function next() { - count++; - if (count 0)) { @@ -1354,11 +1346,11 @@ function Janus(gatewayCallbacks) { config.pc.addStream(stream); pluginHandle.onlocalstream(stream); } - config.pc.onaddstream = function(remoteStream) { + config.pc.ontrack = function(remoteStream) { Janus.log("Handling Remote Stream"); Janus.debug(remoteStream); config.remoteStream = remoteStream; - pluginHandle.onremotestream(remoteStream.stream); + pluginHandle.onremotestream(remoteStream.streams[0]); }; // Any data channel to create? if(isDataEnabled(media)) { @@ -1535,6 +1527,9 @@ function Janus(gatewayCallbacks) { } Janus.debug(videoSupport); } else if(media.video === 'screen' || media.video === 'window') { + if (!media.screenshareFrameRate) { + media.screenshareFrameRate = 3; + } // Not a webcam, but screen capture if(window.location.protocol !== 'https:') { // Screen sharing mandates HTTPS @@ -1574,7 +1569,8 @@ function Janus(gatewayCallbacks) { googLeakyBucket: true, maxWidth: window.screen.width, maxHeight: window.screen.height, - maxFrameRate: 3, + minFrameRate: media.screenshareFrameRate, + maxFrameRate: media.screenshareFrameRate, chromeMediaSource: 'screen' } }, @@ -1654,7 +1650,8 @@ function Janus(gatewayCallbacks) { chromeMediaSource: 'desktop', maxWidth: window.screen.width, maxHeight: window.screen.height, - maxFrameRate: 3 + minFrameRate: media.screenshareFrameRate, + maxFrameRate: media.screenshareFrameRate, }, optional: [ {googLeakyBucket: true}, @@ -2069,11 +2066,11 @@ function Janus(gatewayCallbacks) { } else if(config.pc.getStats && adapter.browserDetails.browser == "firefox") { // Do it the Firefox way if(config.remoteStream === null || config.remoteStream === undefined - || config.remoteStream.stream === null || config.remoteStream.stream === undefined) { + || config.remoteStream.streams[0] === null || config.remoteStream.streams[0] === undefined) { Janus.warn("Remote stream unavailable"); return "Remote stream unavailable"; } - var videoTracks = config.remoteStream.stream.getVideoTracks(); + var videoTracks = config.remoteStream.streams[0].getVideoTracks(); if(videoTracks === null || videoTracks === undefined || videoTracks.length < 1) { Janus.warn("No video track"); return "No video track"; -- cgit v1.2.3