From 5d854862baa349818875b029a356be5a73688583 Mon Sep 17 00:00:00 2001 From: davidliu Date: Thu, 11 Apr 2024 00:58:52 +0900 Subject: [PATCH 1/6] android,ios: don't reject promise for getStats (#1541) --- .../oney/WebRTCModule/PeerConnectionObserver.java | 6 +++--- .../java/com/oney/WebRTCModule/WebRTCModule.java | 6 +++--- ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m | 15 ++++++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java index 9ad3768fe..aa15b40f2 100644 --- a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +++ b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java @@ -255,9 +255,9 @@ public void receiverGetStats(String receiverId, Promise promise) { public void senderGetStats(String senderId, Promise promise) { RtpSender targetSender = null; - for (RtpSender r : peerConnection.getSenders()) { - if (r.id().equals(senderId)) { - targetSender = r; + for (RtpSender s : peerConnection.getSenders()) { + if (s.id().equals(senderId)) { + targetSender = s; break; } } diff --git a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java index c545a15b6..4c392115b 100644 --- a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +++ b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java @@ -1245,7 +1245,7 @@ public void receiverGetStats(int pcId, String receiverId, Promise promise) { PeerConnectionObserver pco = mPeerConnectionObservers.get(pcId); if (pco == null || pco.getPeerConnection() == null) { Log.d(TAG, "receiverGetStats() peerConnection is null"); - promise.reject(new Exception("PeerConnection ID not found")); + promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>()))); } else { pco.receiverGetStats(receiverId, promise); } @@ -1258,7 +1258,7 @@ public void senderGetStats(int pcId, String senderId, Promise promise) { PeerConnectionObserver pco = mPeerConnectionObservers.get(pcId); if (pco == null || pco.getPeerConnection() == null) { Log.d(TAG, "senderGetStats() peerConnection is null"); - promise.reject(new Exception("PeerConnection ID not found")); + promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>()))); } else { pco.senderGetStats(senderId, promise); } @@ -1311,7 +1311,7 @@ public void peerConnectionGetStats(int peerConnectionId, Promise promise) { PeerConnectionObserver pco = mPeerConnectionObservers.get(peerConnectionId); if (pco == null || pco.getPeerConnection() == null) { Log.d(TAG, "peerConnectionGetStats() peerConnection is null"); - promise.reject(new Exception("PeerConnection ID not found")); + promise.resolve(StringUtils.statsToJSON(new RTCStatsReport(0, new HashMap<>()))); } else { pco.getStats(promise); } diff --git a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m index 5d968d83b..8d5344fba 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m @@ -354,7 +354,8 @@ @implementation WebRTCModule (RTCPeerConnection) : (RCTPromiseRejectBlock)reject) { RTCPeerConnection *peerConnection = self.peerConnections[objectID]; if (!peerConnection) { - reject(@"invalid_id", @"PeerConnection ID not found", nil); + RCTLogWarn(@"PeerConnection %@ not found in peerConnectionGetStats()", objectID); + resolve(@"[]"); return; } @@ -370,7 +371,8 @@ @implementation WebRTCModule (RTCPeerConnection) : (RCTPromiseRejectBlock)reject) { RTCPeerConnection *peerConnection = self.peerConnections[pcId]; if (!peerConnection) { - reject(@"invalid_id", @"PeerConnection ID not found", nil); + RCTLogWarn(@"PeerConnection %@ not found in receiverGetStats()", pcId); + resolve(@"[]"); return; } @@ -383,7 +385,8 @@ @implementation WebRTCModule (RTCPeerConnection) } if (!receiver) { - reject(@"invalid_id", @"Receiver ID not found", nil); + RCTLogWarn(@"RTCRtpReceiver %@ not found in receiverGetStats()", receiverId); + resolve(@"[]"); return; } @@ -400,7 +403,8 @@ @implementation WebRTCModule (RTCPeerConnection) : (RCTPromiseRejectBlock)reject) { RTCPeerConnection *peerConnection = self.peerConnections[pcId]; if (!peerConnection) { - reject(@"invalid_id", @"PeerConnection ID not found", nil); + RCTLogWarn(@"PeerConnection %@ not found in senderGetStats()", pcId); + resolve(@"[]"); return; } @@ -413,7 +417,8 @@ @implementation WebRTCModule (RTCPeerConnection) } if (!sender) { - reject(@"invalid_id", @"Sender ID not found", nil); + RCTLogWarn(@"RTCRtpSender %@ not found in senderGetStats()", senderId); + resolve(@"[]"); return; } From c0c446ad856b4ccb1ce358bc17b3480de98338d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 11 Apr 2024 22:31:38 +0200 Subject: [PATCH 2/6] ios: fix not being able to deactivate encodings This must have been one of the nastiest bugs to catch. The JS layer passes the encoding parameters as JSON, which includes the "active" element set to the boolean value `true`. RN converts that to an NSDictionary, but since NSDictionary doesn't support booleans (BOOL is a C type, not an Obj-C type) the boolean values get converted to NSNumber. Assigning any NSNumber to a BOOL will always result in a true value, because it's actually an object! In order to get the actual boolean value one has to use `boolValue`: `[theNumber boolValue]`, which returns BOOL. So yeah, if your simulcast layer suspension code is mysteriously not working on iOS... this is why :-P --- ios/RCTWebRTC/WebRTCModule+Transceivers.m | 2 +- src/RTCRtpEncodingParameters.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RCTWebRTC/WebRTCModule+Transceivers.m b/ios/RCTWebRTC/WebRTCModule+Transceivers.m index 7b9ae2bd1..bc5ed14a6 100644 --- a/ios/RCTWebRTC/WebRTCModule+Transceivers.m +++ b/ios/RCTWebRTC/WebRTCModule+Transceivers.m @@ -269,7 +269,7 @@ - (RTCRtpParameters *)updateParametersWithOptions:(NSDictionary *)options params NSDictionary *encodingUpdate = encodingsArray[i]; RTCRtpEncodingParameters *encoding = encodings[i]; - encoding.isActive = encodingUpdate[@"active"]; + encoding.isActive = [encodingUpdate[@"active"] boolValue]; encoding.rid = encodingUpdate[@"rid"]; encoding.maxBitrateBps = encodingUpdate[@"maxBitrate"]; encoding.maxFramerate = encodingUpdate[@"maxFramerate"]; diff --git a/src/RTCRtpEncodingParameters.ts b/src/RTCRtpEncodingParameters.ts index f53f11060..320b6b1b5 100644 --- a/src/RTCRtpEncodingParameters.ts +++ b/src/RTCRtpEncodingParameters.ts @@ -66,7 +66,7 @@ export default class RTCRtpEncodingParameters { toJSON(): RTCRtpEncodingParametersInit { const obj = { - active: this.active, + active: Boolean(this.active), }; if (this._rid !== null) { From 8dfc9c394b4bf627c0214255466ebd3b160ca563 Mon Sep 17 00:00:00 2001 From: Johnathon Weaver Date: Wed, 17 Apr 2024 14:38:36 +0800 Subject: [PATCH 3/6] Revert "android, ios: remove track when removed from peerconnection (#1525)" (#1550) This reverts commit e4c648ec316e304de9846745ad92e4af1f9ed2b5. --- .../main/java/com/oney/WebRTCModule/PeerConnectionObserver.java | 2 -- ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m | 2 -- 2 files changed, 4 deletions(-) diff --git a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java index aa15b40f2..dfc2901a8 100644 --- a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +++ b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java @@ -483,8 +483,6 @@ public void onRemoveTrack(RtpReceiver receiver) { params.putInt("pcId", this.id); params.putString("receiverId", receiver.id()); - remoteTracks.remove(receiver.id()); - webRTCModule.sendEvent("peerConnectionOnRemoveTrack", params); }); }; diff --git a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m index 8d5344fba..20db4a56e 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m @@ -927,8 +927,6 @@ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection params[@"pcId"] = peerConnection.reactTag; params[@"receiverId"] = rtpReceiver.receiverId; - [peerConnection.remoteTracks removeObjectForKey:rtpReceiver.receiverId]; - [self sendEventWithName:kEventPeerConnectionOnRemoveTrack body:params]; }); } From 882f8b1224222487d648b2261095122313dab6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 11 Apr 2024 23:03:33 +0200 Subject: [PATCH 4/6] release 118.0.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c0c446a ios: fix not being able to deactivate encodings ( Saúl Ibarra Corretgé 2024-04-11 22:31:38 +0200) 5d85486 android,ios: don't reject promise for getStats (#1541) ( davidliu 2024-04-11 00:58:52 +0900) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c76e836f..c8426dc67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-webrtc", - "version": "118.0.5", + "version": "118.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-native-webrtc", - "version": "118.0.5", + "version": "118.0.6", "license": "MIT", "dependencies": { "base64-js": "1.5.1", diff --git a/package.json b/package.json index 903c83f5c..42004cd92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-webrtc", - "version": "118.0.5", + "version": "118.0.6", "repository": { "type": "git", "url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git" From 822cac737379e546a7bc0642f4dbf0dc8772caf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 18 Apr 2024 13:32:21 +0200 Subject: [PATCH 5/6] release 118.0.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 882f8b1 release 118.0.6 ( Saúl Ibarra Corretgé 2024-04-11 23:03:33 +0200) 8dfc9c3 Revert "android, ios: remove track when removed from peerconnection (#1525)" (#1550) ( Johnathon Weaver 2024-04-17 14:38:36 +0800) c0c446a ios: fix not being able to deactivate encodings ( Saúl Ibarra Corretgé 2024-04-11 22:31:38 +0200) 5d85486 android,ios: don't reject promise for getStats (#1541) ( davidliu 2024-04-11 00:58:52 +0900) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8426dc67..941cfa1e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-webrtc", - "version": "118.0.6", + "version": "118.0.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-native-webrtc", - "version": "118.0.6", + "version": "118.0.7", "license": "MIT", "dependencies": { "base64-js": "1.5.1", diff --git a/package.json b/package.json index 42004cd92..f58c5b3e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-webrtc", - "version": "118.0.6", + "version": "118.0.7", "repository": { "type": "git", "url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git" From 495658da24ffab6680b9e99276325901b33489ac Mon Sep 17 00:00:00 2001 From: davidliu Date: Fri, 3 May 2024 17:18:31 +0900 Subject: [PATCH 6/6] ci: fix build (#1562) * ci: fix build * Update Podfile ios version * Update Podfile --- examples/GumTestApp/ios/Podfile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/GumTestApp/ios/Podfile b/examples/GumTestApp/ios/Podfile index 8dccad756..8be5f3b28 100644 --- a/examples/GumTestApp/ios/Podfile +++ b/examples/GumTestApp/ios/Podfile @@ -56,5 +56,25 @@ target 'GumTestApp' do :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) + + # NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4. + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4' + end + end + + installer.pods_project.build_configurations.each do |config| + installer.pods_project.targets.each do |target| + if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" + config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' + end + end + + # Set the preprocessing macro for the whole Pods project + existing_flags = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)'] + existing_flags << '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = existing_flags + end end -end \ No newline at end of file +end