From 7b6eb1b82a917e58cd1edbc92901fc3c8620030d Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 19 May 2020 11:11:42 +0200 Subject: [PATCH 01/10] fix RTCPeerConnection.prototype.getStats.length to match features detection --- js/RTCPeerConnection.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/RTCPeerConnection.js b/js/RTCPeerConnection.js index 896307f4..929f6c44 100644 --- a/js/RTCPeerConnection.js +++ b/js/RTCPeerConnection.js @@ -552,13 +552,14 @@ RTCPeerConnection.prototype.createDTMFSender = function (track) { return new RTCDTMFSender(this, track); }; -RTCPeerConnection.prototype.getStats = function (selector) { +RTCPeerConnection.prototype.getStats = function () { // Detect callback usage to assist 5.0.1 to 5.0.2 migration // TODO remove on 6.0.0 Errors.detectDeprecatedCallbaksUsage('RTCPeerConnection.prototype.getStats', arguments); - var self = this; + var self = this, + selector = arguments[0]; if (selector && !(selector instanceof MediaStreamTrack)) { throw new Error('getStats() must be called with null or a valid MediaStreamTrack instance as argument'); From 012c714e46509b422dc135ac542dfb4a4253157f Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 19 May 2020 11:12:02 +0200 Subject: [PATCH 02/10] build dist/cordova-plugin-iosrtc.js --- dist/cordova-plugin-iosrtc.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/cordova-plugin-iosrtc.js b/dist/cordova-plugin-iosrtc.js index 0caa0beb..c799596a 100644 --- a/dist/cordova-plugin-iosrtc.js +++ b/dist/cordova-plugin-iosrtc.js @@ -2251,13 +2251,14 @@ RTCPeerConnection.prototype.createDTMFSender = function (track) { return new RTCDTMFSender(this, track); }; -RTCPeerConnection.prototype.getStats = function (selector) { +RTCPeerConnection.prototype.getStats = function () { // Detect callback usage to assist 5.0.1 to 5.0.2 migration // TODO remove on 6.0.0 Errors.detectDeprecatedCallbaksUsage('RTCPeerConnection.prototype.getStats', arguments); - var self = this; + var self = this, + selector = arguments[0]; if (selector && !(selector instanceof MediaStreamTrack)) { throw new Error('getStats() must be called with null or a valid MediaStreamTrack instance as argument'); From 163728ddea6a2c97e472f33f40ba762a14dbe7fc Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 19 May 2020 11:14:56 +0200 Subject: [PATCH 03/10] add restoreCallbacksSupport on RTCPeerConnection.prototype getStats --- js/iosrtc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/iosrtc.js b/js/iosrtc.js index 86891fa2..8deb1e3c 100644 --- a/js/iosrtc.js +++ b/js/iosrtc.js @@ -169,6 +169,7 @@ function restoreCallbacksSupport() { callbackifyPrototype(RTCPeerConnection.prototype, 'setRemoteDescription'); callbackifyPrototype(RTCPeerConnection.prototype, 'setLocalDescription'); callbackifyPrototype(RTCPeerConnection.prototype, 'addIceCandidate'); + callbackifyPrototype(RTCPeerConnection.prototype, 'getStats'); } function registerGlobals(doNotRestoreCallbacksSupport) { From f2ab55c7b82ad32b3d059c313bce1fb2467fa14d Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 19 May 2020 11:15:06 +0200 Subject: [PATCH 04/10] build dist/cordova-plugin-iosrtc.js --- dist/cordova-plugin-iosrtc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/cordova-plugin-iosrtc.js b/dist/cordova-plugin-iosrtc.js index c799596a..151838b7 100644 --- a/dist/cordova-plugin-iosrtc.js +++ b/dist/cordova-plugin-iosrtc.js @@ -3171,6 +3171,7 @@ function restoreCallbacksSupport() { callbackifyPrototype(RTCPeerConnection.prototype, 'setRemoteDescription'); callbackifyPrototype(RTCPeerConnection.prototype, 'setLocalDescription'); callbackifyPrototype(RTCPeerConnection.prototype, 'addIceCandidate'); + callbackifyPrototype(RTCPeerConnection.prototype, 'getStats'); } function registerGlobals(doNotRestoreCallbacksSupport) { From 0697a1e2d20d56868c4c576153461fc07c3ecb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harold=20Th=C3=A9tiot?= Date: Fri, 22 May 2020 22:52:01 +0200 Subject: [PATCH 05/10] Update RTCPeerConnection.js --- js/RTCPeerConnection.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/RTCPeerConnection.js b/js/RTCPeerConnection.js index 929f6c44..896307f4 100644 --- a/js/RTCPeerConnection.js +++ b/js/RTCPeerConnection.js @@ -552,14 +552,13 @@ RTCPeerConnection.prototype.createDTMFSender = function (track) { return new RTCDTMFSender(this, track); }; -RTCPeerConnection.prototype.getStats = function () { +RTCPeerConnection.prototype.getStats = function (selector) { // Detect callback usage to assist 5.0.1 to 5.0.2 migration // TODO remove on 6.0.0 Errors.detectDeprecatedCallbaksUsage('RTCPeerConnection.prototype.getStats', arguments); - var self = this, - selector = arguments[0]; + var self = this; if (selector && !(selector instanceof MediaStreamTrack)) { throw new Error('getStats() must be called with null or a valid MediaStreamTrack instance as argument'); From 50264b0ae42972c773ed1c4adfc8fe33b77c7f48 Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Fri, 22 May 2020 23:08:21 +0200 Subject: [PATCH 06/10] add arg on callbackifyMethod to return method.length > 0 on some features detection --- js/iosrtc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/iosrtc.js b/js/iosrtc.js index 8deb1e3c..4ba36125 100644 --- a/js/iosrtc.js +++ b/js/iosrtc.js @@ -122,7 +122,7 @@ function requestPermission(needMic, needCamera, callback) { } function callbackifyMethod(originalMethod) { - return function () { + return function (arg) { var success, failure, originalArgs = Array.prototype.slice.call(arguments); From 8dfa4549f621f2becf87a638514d185ebc5e8d07 Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Fri, 22 May 2020 23:09:33 +0200 Subject: [PATCH 07/10] add RTCStatsResponse.prototype.forEach to handle legacy firefox style usage of getStats --- js/RTCStatsResponse.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/RTCStatsResponse.js b/js/RTCStatsResponse.js index a8331282..72e84f8b 100644 --- a/js/RTCStatsResponse.js +++ b/js/RTCStatsResponse.js @@ -10,6 +10,10 @@ function RTCStatsResponse(data) { return data; }; + this.forEach = function (callback, thisArg) { + return data.forEach(callback, thisArg); + }; + this.namedItem = function () { return null; }; From d7970bafc4910c1cc11c2a794985fc5d1a3ccded Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Fri, 22 May 2020 23:10:32 +0200 Subject: [PATCH 08/10] update dist/cordova-plugin-iosrtc.js build --- dist/cordova-plugin-iosrtc.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/cordova-plugin-iosrtc.js b/dist/cordova-plugin-iosrtc.js index 151838b7..47420005 100644 --- a/dist/cordova-plugin-iosrtc.js +++ b/dist/cordova-plugin-iosrtc.js @@ -2251,14 +2251,13 @@ RTCPeerConnection.prototype.createDTMFSender = function (track) { return new RTCDTMFSender(this, track); }; -RTCPeerConnection.prototype.getStats = function () { +RTCPeerConnection.prototype.getStats = function (selector) { // Detect callback usage to assist 5.0.1 to 5.0.2 migration // TODO remove on 6.0.0 Errors.detectDeprecatedCallbaksUsage('RTCPeerConnection.prototype.getStats', arguments); - var self = this, - selector = arguments[0]; + var self = this; if (selector && !(selector instanceof MediaStreamTrack)) { throw new Error('getStats() must be called with null or a valid MediaStreamTrack instance as argument'); @@ -2486,6 +2485,10 @@ function RTCStatsResponse(data) { return data; }; + this.forEach = function (callback, thisArg) { + return data.forEach(callback, thisArg); + }; + this.namedItem = function () { return null; }; @@ -3124,7 +3127,7 @@ function requestPermission(needMic, needCamera, callback) { } function callbackifyMethod(originalMethod) { - return function () { + return function (arg) { var success, failure, originalArgs = Array.prototype.slice.call(arguments); From a76178a1a02036f7a15ad63e8695b0b06853d29c Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Sat, 23 May 2020 12:06:12 +0200 Subject: [PATCH 09/10] fix jshint --- js/iosrtc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/iosrtc.js b/js/iosrtc.js index 4ba36125..8763b001 100644 --- a/js/iosrtc.js +++ b/js/iosrtc.js @@ -122,7 +122,7 @@ function requestPermission(needMic, needCamera, callback) { } function callbackifyMethod(originalMethod) { - return function (arg) { + return function (arg) { // jshint ignore:line var success, failure, originalArgs = Array.prototype.slice.call(arguments); From df3105cae3de0488bc67c07e8d3e18ebd068f80d Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Sat, 23 May 2020 12:06:28 +0200 Subject: [PATCH 10/10] update dist/cordova-plugin-iosrtc.js build --- dist/cordova-plugin-iosrtc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/cordova-plugin-iosrtc.js b/dist/cordova-plugin-iosrtc.js index 47420005..959c64b5 100644 --- a/dist/cordova-plugin-iosrtc.js +++ b/dist/cordova-plugin-iosrtc.js @@ -3127,7 +3127,7 @@ function requestPermission(needMic, needCamera, callback) { } function callbackifyMethod(originalMethod) { - return function (arg) { + return function (arg) { // jshint ignore:line var success, failure, originalArgs = Array.prototype.slice.call(arguments);