From 1c27c66cb345536574348aa7a1102cbc0859243d Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 1 Jan 2018 22:11:45 -0500 Subject: [PATCH 1/5] GUACAMOLE-237: Move to new getUserMedia method. --- guacamole-common-js/src/main/webapp/modules/AudioRecorder.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js index 954b79f5c..f925716ca 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js @@ -183,11 +183,12 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { /** * A function which directly invokes the browser's implementation of - * navigator.getUserMedia() with all provided parameters. + * navigator.mediaDevices.getUserMedia() with all provided parameters. * * @type Function */ - var getUserMedia = (navigator.getUserMedia + var getUserMedia = (navigator.mediaDevices.getUserMedia + || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia).bind(navigator); From f6291c034cd3e8d672ee98afef1d7c86bba555cd Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 2 Jan 2018 11:43:24 -0500 Subject: [PATCH 2/5] GUACAMOLE-237: Define navigator.mediaDevices and getUserMedia when undefined. --- .../src/main/webapp/modules/AudioRecorder.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js index f925716ca..3a73d1dac 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js @@ -187,11 +187,15 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { * * @type Function */ - var getUserMedia = (navigator.mediaDevices.getUserMedia - || navigator.getUserMedia - || navigator.webkitGetUserMedia - || navigator.mozGetUserMedia - || navigator.msGetUserMedia).bind(navigator); + + if (navigator.mediaDevices === undefined) + navigator.mediaDevices = {}; + + if (navigator.mediaDevices.getUserMedia === undefined) + navigator.mediaDevices.getUserMedia = (navigator.getUserMedia + || navigator.webkitGetUserMedia + || navigator.mozGetUserMedia + || navigator.msGetUserMedia).bind(navigator); /** * Guacamole.ArrayBufferWriter wrapped around the audio output stream @@ -420,7 +424,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { var beginAudioCapture = function beginAudioCapture() { // Attempt to retrieve an audio input stream from the browser - getUserMedia({ 'audio' : true }, function streamReceived(stream) { + navigator.mediaDevices.getUserMedia({ 'audio' : true }, function streamReceived(stream) { // Create processing node which receives appropriately-sized audio buffers processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels); From 4c53f28aa235a1f9a883df3b9a101ae34821423d Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 2 Jan 2018 12:26:22 -0500 Subject: [PATCH 3/5] GUACAMOLE-237: Simplify checks for mediaDevices and getUserMedia. --- guacamole-common-js/src/main/webapp/modules/AudioRecorder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js index 3a73d1dac..454f3f625 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js @@ -188,10 +188,10 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { * @type Function */ - if (navigator.mediaDevices === undefined) + if (!navigator.mediaDevices) navigator.mediaDevices = {}; - if (navigator.mediaDevices.getUserMedia === undefined) + if (!navigator.mediaDevices.getUserMedia) navigator.mediaDevices.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia From f0a658bb975ea0f0abc6bbcc692212bf08434606 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 3 Jan 2018 12:19:48 -0500 Subject: [PATCH 4/5] GUACAMOLE-237: Update JSDoc comments for new code. --- .../src/main/webapp/modules/AudioRecorder.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js index 454f3f625..c1bb4ebff 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js @@ -182,15 +182,18 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { var context = Guacamole.AudioContextFactory.getAudioContext(); /** - * A function which directly invokes the browser's implementation of - * navigator.mediaDevices.getUserMedia() with all provided parameters. - * - * @type Function + * Some browsers do not implement navigator.mediaDevices - this + * shims in this functionality to ensure code compatibility. */ - if (!navigator.mediaDevices) navigator.mediaDevices = {}; + /** + * Browsers that either do not implement navigator.mediaDevices + * at all or do not implement it completely need the getUserMedia + * method defined. This shims in this function by detecting + * one of the supported legacy methods. + */ if (!navigator.mediaDevices.getUserMedia) navigator.mediaDevices.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia From e1443d87b9955927394aa73323b4fe039ebf46f2 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Wed, 3 Jan 2018 13:07:24 -0500 Subject: [PATCH 5/5] GUACAMOLE-237: Make standard comments instead of JSDoc comments. --- .../src/main/webapp/modules/AudioRecorder.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js index c1bb4ebff..d91bf50e5 100644 --- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js +++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js @@ -181,19 +181,15 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) { */ var context = Guacamole.AudioContextFactory.getAudioContext(); - /** - * Some browsers do not implement navigator.mediaDevices - this - * shims in this functionality to ensure code compatibility. - */ + // Some browsers do not implement navigator.mediaDevices - this + // shims in this functionality to ensure code compatibility. if (!navigator.mediaDevices) navigator.mediaDevices = {}; - /** - * Browsers that either do not implement navigator.mediaDevices - * at all or do not implement it completely need the getUserMedia - * method defined. This shims in this function by detecting - * one of the supported legacy methods. - */ + // Browsers that either do not implement navigator.mediaDevices + // at all or do not implement it completely need the getUserMedia + // method defined. This shims in this function by detecting + // one of the supported legacy methods. if (!navigator.mediaDevices.getUserMedia) navigator.mediaDevices.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia