From aa5738eb702f3d53e5079ca84e84dd055cc375f1 Mon Sep 17 00:00:00 2001 From: davidliu Date: Thu, 28 Mar 2024 22:28:31 +0900 Subject: [PATCH] android, ios: remove track from remoteTracks in onRemoveTrack --- .../main/java/com/oney/WebRTCModule/PeerConnectionObserver.java | 2 ++ ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m | 2 ++ 2 files changed, 4 insertions(+) diff --git a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java index 1b759f69c..03ae9b0e1 100644 --- a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +++ b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java @@ -591,6 +591,8 @@ 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 fb9beeb1f..5d968d83b 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m @@ -922,6 +922,8 @@ - (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]; }); }