react-native-webrtc 106.0.0 → 106.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +20 -16
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +11 -6
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +7 -12
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +14 -13
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +0 -1
- package/ios/RCTWebRTC/RTCVideoViewManager.m +34 -0
- package/ios/RCTWebRTC/SerializeUtils.h +1 -2
- package/ios/RCTWebRTC/SerializeUtils.m +1 -3
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +21 -15
- package/lib/commonjs/RTCPeerConnection.js +39 -18
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +1 -1
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +39 -18
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCUtil.js +1 -1
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +1 -1
- package/package.json +1 -1
- package/src/RTCPeerConnection.ts +45 -19
- package/src/RTCRtpEncodingParameters.ts +1 -1
- package/src/RTCUtil.ts +1 -1
|
@@ -128,23 +128,27 @@ public class CameraCaptureController extends AbstractVideoCaptureController {
|
|
|
128
128
|
String[] deviceNames = cameraEnumerator.getDeviceNames();
|
|
129
129
|
List<String> failedDevices = new ArrayList<>();
|
|
130
130
|
|
|
131
|
+
String name;
|
|
132
|
+
try {
|
|
133
|
+
int index = Integer.parseInt(deviceId);
|
|
134
|
+
name = deviceNames[index];
|
|
135
|
+
} catch (Exception e) {
|
|
136
|
+
Log.d(TAG, "failed to find device with id: " + deviceId);
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
// If deviceId is specified, then it takes precedence over facingMode.
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
failedDevices.add(name);
|
|
145
|
-
break; // fallback to facingMode
|
|
146
|
-
}
|
|
147
|
-
}
|
|
140
|
+
if (name != null) {
|
|
141
|
+
VideoCapturer videoCapturer
|
|
142
|
+
= cameraEnumerator.createCapturer(name, cameraEventsHandler);
|
|
143
|
+
String message = "Create user-specified camera " + name;
|
|
144
|
+
if (videoCapturer != null) {
|
|
145
|
+
Log.d(TAG, message + " succeeded");
|
|
146
|
+
this.isFrontFacing = cameraEnumerator.isFrontFacing(name);
|
|
147
|
+
return videoCapturer;
|
|
148
|
+
} else {
|
|
149
|
+
Log.d(TAG, message + " failed");
|
|
150
|
+
failedDevices.add(name);
|
|
151
|
+
break; // fallback to facingMode
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
|
|
@@ -396,8 +396,11 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
396
396
|
params.putMap("candidate", candidateParams);
|
|
397
397
|
SessionDescription newSdp = peerConnection.getLocalDescription();
|
|
398
398
|
WritableMap newSdpMap = Arguments.createMap();
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
// Can happen when doing a rollback.
|
|
400
|
+
if (newSdp != null) {
|
|
401
|
+
newSdpMap.putString("type", newSdp.type.canonicalForm());
|
|
402
|
+
newSdpMap.putString("sdp", newSdp.description);
|
|
403
|
+
}
|
|
401
404
|
params.putMap("sdp", newSdpMap);
|
|
402
405
|
|
|
403
406
|
webRTCModule.sendEvent("peerConnectionGotICECandidate", params);
|
|
@@ -438,8 +441,11 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
438
441
|
if (iceGatheringState == PeerConnection.IceGatheringState.COMPLETE) {
|
|
439
442
|
SessionDescription newSdp = peerConnection.getLocalDescription();
|
|
440
443
|
WritableMap newSdpMap = Arguments.createMap();
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
// Can happen when doing a rollback.
|
|
445
|
+
if (newSdp != null) {
|
|
446
|
+
newSdpMap.putString("type", newSdp.type.canonicalForm());
|
|
447
|
+
newSdpMap.putString("sdp", newSdp.description);
|
|
448
|
+
}
|
|
443
449
|
params.putMap("sdp", newSdpMap);
|
|
444
450
|
}
|
|
445
451
|
webRTCModule.sendEvent("peerConnectionIceGatheringChanged", params);
|
|
@@ -569,10 +575,9 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
569
575
|
@Override
|
|
570
576
|
public void onRemoveTrack(RtpReceiver receiver){
|
|
571
577
|
ThreadUtils.runOnExecutor(() -> {
|
|
572
|
-
MediaStreamTrack track = receiver.track();
|
|
573
578
|
WritableMap params = Arguments.createMap();
|
|
574
579
|
params.putInt("pcId", this.id);
|
|
575
|
-
params.putString("
|
|
580
|
+
params.putString("receiverId", receiver.id());
|
|
576
581
|
|
|
577
582
|
webRTCModule.sendEvent("peerConnectionOnRemoveTrack", params);
|
|
578
583
|
});
|
|
@@ -851,20 +851,15 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
851
851
|
* This serializes the transceivers current direction and mid and returns them
|
|
852
852
|
* for update when an sdp negotiation/renegotiation happens
|
|
853
853
|
*/
|
|
854
|
-
private ReadableArray getTransceiversInfo(
|
|
855
|
-
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
|
|
856
|
-
if (pco == null) {
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
PeerConnection peerConnection = pco.getPeerConnection();
|
|
854
|
+
private ReadableArray getTransceiversInfo(PeerConnection peerConnection) {
|
|
860
855
|
WritableArray transceiverUpdates = Arguments.createArray();
|
|
861
|
-
|
|
856
|
+
|
|
857
|
+
for (RtpTransceiver transceiver: peerConnection.getTransceivers()) {
|
|
862
858
|
RtpTransceiver.RtpTransceiverDirection direction = transceiver.getCurrentDirection();
|
|
863
859
|
if (direction == null) continue;
|
|
864
860
|
String directionSerialized = SerializeUtils.serializeDirection(direction);
|
|
865
861
|
WritableMap transceiverUpdate = Arguments.createMap();
|
|
866
862
|
transceiverUpdate.putString("transceiverId", transceiver.getSender().id());
|
|
867
|
-
transceiverUpdate.putInt("peerConnectionId", id);
|
|
868
863
|
transceiverUpdate.putString("mid", transceiver.getMid());
|
|
869
864
|
transceiverUpdate.putString("currentDirection", directionSerialized);
|
|
870
865
|
transceiverUpdate.putMap("senderRtpParameters",
|
|
@@ -923,7 +918,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
923
918
|
WritableMap sdpInfo = Arguments.createMap();
|
|
924
919
|
sdpInfo.putString("sdp", sdp.description);
|
|
925
920
|
sdpInfo.putString("type", sdp.type.canonicalForm());
|
|
926
|
-
params.putArray("transceiversInfo", getTransceiversInfo(
|
|
921
|
+
params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
|
|
927
922
|
params.putMap("sdpInfo", sdpInfo);
|
|
928
923
|
callback.invoke(true, params);
|
|
929
924
|
}
|
|
@@ -962,7 +957,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
962
957
|
WritableMap sdpInfo = Arguments.createMap();
|
|
963
958
|
sdpInfo.putString("sdp", sdp.description);
|
|
964
959
|
sdpInfo.putString("type", sdp.type.canonicalForm());
|
|
965
|
-
params.putArray("transceiversInfo", getTransceiversInfo(
|
|
960
|
+
params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
|
|
966
961
|
params.putMap("sdpInfo", sdpInfo);
|
|
967
962
|
callback.invoke(true, params);
|
|
968
963
|
}
|
|
@@ -1006,7 +1001,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
1006
1001
|
}
|
|
1007
1002
|
|
|
1008
1003
|
params.putMap("sdpInfo", newSdpMap);
|
|
1009
|
-
params.putArray("transceiversInfo", getTransceiversInfo(
|
|
1004
|
+
params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
|
|
1010
1005
|
promise.resolve(params);
|
|
1011
1006
|
}
|
|
1012
1007
|
|
|
@@ -1073,7 +1068,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
1073
1068
|
newSdpMap.putString("sdp", newSdp.description);
|
|
1074
1069
|
}
|
|
1075
1070
|
|
|
1076
|
-
params.putArray("transceiversInfo", getTransceiversInfo(
|
|
1071
|
+
params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
|
|
1077
1072
|
params.putMap("sdpInfo", newSdpMap);
|
|
1078
1073
|
|
|
1079
1074
|
WritableArray newTransceivers = Arguments.createArray();
|
|
@@ -192,7 +192,7 @@ public class WebRTCView extends ViewGroup {
|
|
|
192
192
|
Log.w(TAG, "No video stream for react tag: " + streamURL);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
return videoTrack;
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -339,14 +339,14 @@ public class WebRTCView extends ViewGroup {
|
|
|
339
339
|
private void removeRendererFromVideoTrack() {
|
|
340
340
|
if (rendererAttached) {
|
|
341
341
|
if (videoTrack != null) {
|
|
342
|
-
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
343
|
-
// invoked on videoTrack, then it is no longer safe to call removeSink
|
|
344
|
-
// on the instance, it will throw IllegalStateException.
|
|
345
342
|
try {
|
|
346
|
-
|
|
343
|
+
ThreadUtils.submitToExecutor(() -> {
|
|
344
|
+
videoTrack.removeSink(surfaceViewRenderer);
|
|
345
|
+
}).get();
|
|
347
346
|
} catch (Throwable tr) {
|
|
348
|
-
//
|
|
349
|
-
//
|
|
347
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
348
|
+
// invoked on videoTrack, then it is no longer safe to call removeSink
|
|
349
|
+
// on the instance, it will throw IllegalStateException.
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
@@ -548,14 +548,15 @@ public class WebRTCView extends ViewGroup {
|
|
|
548
548
|
surfaceViewRendererInstances--;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
552
|
-
// invoked on videoTrack, then it is no longer safe to call addSink
|
|
553
|
-
// on the instance, it will throw IllegalStateException.
|
|
554
551
|
try {
|
|
555
|
-
|
|
552
|
+
ThreadUtils.submitToExecutor(() -> {
|
|
553
|
+
videoTrack.addSink(surfaceViewRenderer);
|
|
554
|
+
}).get();
|
|
556
555
|
} catch (Throwable tr) {
|
|
557
|
-
//
|
|
558
|
-
//
|
|
556
|
+
// XXX If WebRTCModule#mediaStreamTrackRelease has already been
|
|
557
|
+
// invoked on videoTrack, then it is no longer safe to call addSink
|
|
558
|
+
// on the instance, it will throw IllegalStateException.
|
|
559
|
+
|
|
559
560
|
Log.e(TAG, "Failed to add renderer", tr);
|
|
560
561
|
|
|
561
562
|
surfaceViewRenderer.release();
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
#import <WebRTC/RTCMTLNSVideoView.h>
|
|
20
20
|
#endif
|
|
21
21
|
#import <WebRTC/RTCVideoTrack.h>
|
|
22
|
+
#import <WebRTC/RTCCVPixelBuffer.h>
|
|
23
|
+
#import <WebRTC/RTCVideoFrame.h>
|
|
22
24
|
|
|
23
25
|
#import "RTCVideoViewManager.h"
|
|
24
26
|
#import "WebRTCModule.h"
|
|
@@ -314,6 +316,38 @@ typedef NS_ENUM(NSInteger, RTCVideoViewObjectFit) {
|
|
|
314
316
|
|
|
315
317
|
_videoTrack = videoTrack;
|
|
316
318
|
|
|
319
|
+
// Clear the videoView by rendering a 1x1 blank frame.
|
|
320
|
+
CVPixelBufferRef pixelBuffer;
|
|
321
|
+
CVReturn err = CVPixelBufferCreate(NULL, 1, 1, kCVPixelFormatType_32BGRA, NULL, &pixelBuffer);
|
|
322
|
+
if (err == kCVReturnSuccess) {
|
|
323
|
+
const int kBytesPerPixel = 4;
|
|
324
|
+
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
|
325
|
+
int bufferWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
|
|
326
|
+
int bufferHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
|
|
327
|
+
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);
|
|
328
|
+
uint8_t *baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer);
|
|
329
|
+
|
|
330
|
+
for (int row = 0; row < bufferHeight; row++) {
|
|
331
|
+
uint8_t *pixel = baseAddress + row * bytesPerRow;
|
|
332
|
+
for (int column = 0; column < bufferWidth; column++) {
|
|
333
|
+
pixel[0] = 0; // BGRA, Blue value
|
|
334
|
+
pixel[1] = 0; // Green value
|
|
335
|
+
pixel[2] = 0; // Red value
|
|
336
|
+
pixel[3] = 0; // Alpha value
|
|
337
|
+
pixel += kBytesPerPixel;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
|
|
342
|
+
int64_t time = (int64_t)(CFAbsoluteTimeGetCurrent() * 1000000000);
|
|
343
|
+
RTCCVPixelBuffer *buffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
|
|
344
|
+
RTCVideoFrame *frame = [[[RTCVideoFrame alloc] initWithBuffer:buffer rotation:RTCVideoRotation_0 timeStampNs:time] newI420VideoFrame];
|
|
345
|
+
|
|
346
|
+
[self.videoView renderFrame: frame];
|
|
347
|
+
|
|
348
|
+
CVPixelBufferRelease(pixelBuffer);
|
|
349
|
+
}
|
|
350
|
+
|
|
317
351
|
// XXX This RTCVideoView strongly retains its videoTrack. The latter
|
|
318
352
|
// strongly retains the former as well though because RTCVideoTrack strongly
|
|
319
353
|
// retains the RTCVideoRenderers added to it. In other words, there is a
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
+ (RTCRtpTransceiverDirection)parseDirection: (NSString *_Nonnull) direction;
|
|
19
19
|
+ (RTCRtpTransceiverInit *_Nonnull)parseTransceiverOptions: (NSDictionary *_Nonnull) parameters;
|
|
20
20
|
+ (NSDictionary *_Nonnull)parametersToJSON: (RTCRtpParameters *_Nonnull) parameters;
|
|
21
|
-
+ (NSMutableArray *_Nonnull)constructTransceiversInfoArrayWithPeerConnection: (RTCPeerConnection *_Nonnull) peerConnection
|
|
22
|
-
peerConnectionId: (NSNumber *_Nonnull) peerConnectionId;
|
|
21
|
+
+ (NSMutableArray *_Nonnull)constructTransceiversInfoArrayWithPeerConnection: (RTCPeerConnection *_Nonnull) peerConnection;
|
|
23
22
|
+ (NSDictionary *_Nonnull)streamToJSONWithPeerConnectionId: (NSNumber *_Nonnull) id
|
|
24
23
|
stream: (RTCMediaStream *_Nonnull) stream
|
|
25
24
|
streamReactTag: (NSString *_Nonnull) streamReactTag;
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
+ (NSMutableArray *) constructTransceiversInfoArrayWithPeerConnection: (RTCPeerConnection *) peerConnection
|
|
26
|
-
peerConnectionId: (NSNumber *) peerConnectionId {
|
|
25
|
+
+ (NSMutableArray *) constructTransceiversInfoArrayWithPeerConnection: (RTCPeerConnection *) peerConnection {
|
|
27
26
|
NSMutableArray *transceiverUpdates = [NSMutableArray new];
|
|
28
27
|
|
|
29
28
|
for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
|
|
@@ -31,7 +30,6 @@
|
|
|
31
30
|
if ([transceiver currentDirection: ¤tDirection]) {
|
|
32
31
|
NSMutableDictionary *transceiverUpdate= [NSMutableDictionary new];
|
|
33
32
|
transceiverUpdate[@"transceiverId"] = transceiver.sender.senderId;
|
|
34
|
-
transceiverUpdate[@"peerConnectionId"] = peerConnectionId;
|
|
35
33
|
transceiverUpdate[@"mid"] = transceiver.mid;
|
|
36
34
|
NSString *currentDirectionSerialized = [SerializeUtils serializeDirection: currentDirection];
|
|
37
35
|
transceiverUpdate[@"currentDirection"] = currentDirectionSerialized;
|
|
@@ -156,7 +156,7 @@ RCT_EXPORT_METHOD(peerConnectionCreateOffer:(nonnull NSNumber *)objectID
|
|
|
156
156
|
@"sdp": sdp.sdp,
|
|
157
157
|
@"type": type
|
|
158
158
|
},
|
|
159
|
-
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection
|
|
159
|
+
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
|
|
160
160
|
}]);
|
|
161
161
|
}
|
|
162
162
|
}];
|
|
@@ -191,7 +191,7 @@ RCT_EXPORT_METHOD(peerConnectionCreateAnswer:(nonnull NSNumber *)objectID
|
|
|
191
191
|
callback(@[@(YES), @{
|
|
192
192
|
@"sdpInfo": @{@"sdp": sdp.sdp,
|
|
193
193
|
@"type": type},
|
|
194
|
-
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection
|
|
194
|
+
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
|
|
195
195
|
}]);
|
|
196
196
|
}
|
|
197
197
|
}];
|
|
@@ -223,7 +223,7 @@ RCT_EXPORT_METHOD(peerConnectionSetLocalDescription:(nonnull NSNumber *)objectID
|
|
|
223
223
|
}
|
|
224
224
|
id data = @{
|
|
225
225
|
@"sdpInfo": sdpInfo,
|
|
226
|
-
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection
|
|
226
|
+
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
|
|
227
227
|
};
|
|
228
228
|
resolve(data);
|
|
229
229
|
}
|
|
@@ -274,7 +274,7 @@ RCT_EXPORT_METHOD(peerConnectionSetRemoteDescription:(RTCSessionDescription *)sd
|
|
|
274
274
|
}
|
|
275
275
|
id data = @{
|
|
276
276
|
@"sdpInfo": sdpInfo,
|
|
277
|
-
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection
|
|
277
|
+
@"transceiversInfo": [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection],
|
|
278
278
|
@"newTransceivers": newTransceivers
|
|
279
279
|
};
|
|
280
280
|
callback(@[@(YES), data]);
|
|
@@ -738,10 +738,13 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack:(nonnull NSNumb
|
|
|
738
738
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection didChangeIceGatheringState:(RTCIceGatheringState)newState {
|
|
739
739
|
id newSdp = @{};
|
|
740
740
|
if (newState == RTCIceGatheringStateComplete) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
@
|
|
744
|
-
|
|
741
|
+
// Can happen when doing a rollback.
|
|
742
|
+
if (peerConnection.localDescription) {
|
|
743
|
+
newSdp = @{
|
|
744
|
+
@"type": [RTCSessionDescription stringForType:peerConnection.localDescription.type],
|
|
745
|
+
@"sdp": peerConnection.localDescription.sdp
|
|
746
|
+
};
|
|
747
|
+
}
|
|
745
748
|
}
|
|
746
749
|
[self sendEventWithName:kEventPeerConnectionIceGatheringChanged
|
|
747
750
|
body:@{
|
|
@@ -752,6 +755,14 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack:(nonnull NSNumb
|
|
|
752
755
|
}
|
|
753
756
|
|
|
754
757
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection didGenerateIceCandidate:(RTCIceCandidate *)candidate {
|
|
758
|
+
id newSdp = @{};
|
|
759
|
+
// Can happen when doing a rollback.
|
|
760
|
+
if (peerConnection.localDescription) {
|
|
761
|
+
newSdp = @{
|
|
762
|
+
@"type": [RTCSessionDescription stringForType:peerConnection.localDescription.type],
|
|
763
|
+
@"sdp": peerConnection.localDescription.sdp
|
|
764
|
+
};
|
|
765
|
+
}
|
|
755
766
|
[self sendEventWithName:kEventPeerConnectionGotICECandidate
|
|
756
767
|
body:@{
|
|
757
768
|
@"pcId": peerConnection.reactTag,
|
|
@@ -760,10 +771,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack:(nonnull NSNumb
|
|
|
760
771
|
@"sdpMLineIndex": @(candidate.sdpMLineIndex),
|
|
761
772
|
@"sdpMid": candidate.sdpMid
|
|
762
773
|
},
|
|
763
|
-
@"sdp":
|
|
764
|
-
@"type": [RTCSessionDescription stringForType:peerConnection.localDescription.type],
|
|
765
|
-
@"sdp": peerConnection.localDescription.sdp
|
|
766
|
-
}
|
|
774
|
+
@"sdp": newSdp
|
|
767
775
|
}];
|
|
768
776
|
}
|
|
769
777
|
|
|
@@ -864,12 +872,10 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(peerConnectionRemoveTrack:(nonnull NSNumb
|
|
|
864
872
|
- (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection
|
|
865
873
|
didRemoveReceiver:(RTC_OBJC_TYPE(RTCRtpReceiver) *)rtpReceiver {
|
|
866
874
|
dispatch_async(self.workerQueue, ^{
|
|
867
|
-
RTCMediaStreamTrack *track = rtpReceiver.track;
|
|
868
|
-
|
|
869
875
|
NSMutableDictionary *params = [NSMutableDictionary new];
|
|
870
876
|
|
|
871
877
|
params[@"pcId"] = peerConnection.reactTag;
|
|
872
|
-
params[@"
|
|
878
|
+
params[@"receiverId"] = rtpReceiver.receiverId;
|
|
873
879
|
|
|
874
880
|
[self sendEventWithName: kEventPeerConnectionOnRemoveTrack body: params];
|
|
875
881
|
});
|
|
@@ -78,12 +78,14 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
78
78
|
|
|
79
79
|
_defineProperty(this, "_pcId", void 0);
|
|
80
80
|
|
|
81
|
-
_defineProperty(this, "_transceivers",
|
|
81
|
+
_defineProperty(this, "_transceivers", void 0);
|
|
82
82
|
|
|
83
|
-
_defineProperty(this, "_remoteStreams",
|
|
83
|
+
_defineProperty(this, "_remoteStreams", void 0);
|
|
84
84
|
|
|
85
85
|
this._pcId = nextPeerConnectionId++;
|
|
86
86
|
WebRTCModule.peerConnectionInit(configuration, this._pcId);
|
|
87
|
+
this._transceivers = [];
|
|
88
|
+
this._remoteStreams = new Map();
|
|
87
89
|
|
|
88
90
|
this._registerEvents();
|
|
89
91
|
|
|
@@ -578,26 +580,31 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
578
580
|
return;
|
|
579
581
|
}
|
|
580
582
|
|
|
581
|
-
log.debug(`${this._pcId} onremovetrack`);
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
// - Mark the track as muted:
|
|
585
|
-
// https://w3c.github.io/webrtc-pc/#process-remote-track-removal
|
|
583
|
+
log.debug(`${this._pcId} onremovetrack ${ev.receiverId}`);
|
|
584
|
+
const receiver = this.getReceivers().find(r => r.id === ev.receiverId);
|
|
585
|
+
const track = receiver === null || receiver === void 0 ? void 0 : receiver.track;
|
|
586
586
|
|
|
587
|
-
|
|
588
|
-
|
|
587
|
+
if (receiver && track) {
|
|
588
|
+
// As per the spec:
|
|
589
|
+
// - Remove the track from any media streams that were previously passed to the `track` event.
|
|
590
|
+
// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack,
|
|
591
|
+
// - Mark the track as muted:
|
|
592
|
+
// https://w3c.github.io/webrtc-pc/#process-remote-track-removal
|
|
593
|
+
for (const stream of this._remoteStreams.values()) {
|
|
594
|
+
if (stream._tracks.includes(track)) {
|
|
595
|
+
const trackIdx = stream._tracks.indexOf(track);
|
|
589
596
|
|
|
590
|
-
|
|
591
|
-
const trackIdx = stream._tracks.indexOf(track);
|
|
597
|
+
log.debug(`${this._pcId} removetrack ${track.id}`);
|
|
592
598
|
|
|
593
|
-
|
|
599
|
+
stream._tracks.splice(trackIdx, 1); // @ts-ignore
|
|
594
600
|
|
|
595
601
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
602
|
+
stream.dispatchEvent(new _MediaStreamTrackEvent.default('removetrack', {
|
|
603
|
+
track
|
|
604
|
+
})); // Dispatch a mute event for the track.
|
|
599
605
|
|
|
600
|
-
|
|
606
|
+
track._setMutedInternal(true);
|
|
607
|
+
}
|
|
601
608
|
}
|
|
602
609
|
}
|
|
603
610
|
});
|
|
@@ -606,7 +613,14 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
606
613
|
return;
|
|
607
614
|
}
|
|
608
615
|
|
|
609
|
-
|
|
616
|
+
const sdpInfo = ev.sdp; // Can happen when doing a rollback.
|
|
617
|
+
|
|
618
|
+
if (sdpInfo.type && sdpInfo.sdp) {
|
|
619
|
+
this.localDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
620
|
+
} else {
|
|
621
|
+
this.localDescription = null;
|
|
622
|
+
}
|
|
623
|
+
|
|
610
624
|
const candidate = new _RTCIceCandidate.default(ev.candidate); // @ts-ignore
|
|
611
625
|
|
|
612
626
|
this.dispatchEvent(new _RTCIceCandidateEvent.default('icecandidate', {
|
|
@@ -621,7 +635,14 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
621
635
|
this.iceGatheringState = ev.iceGatheringState;
|
|
622
636
|
|
|
623
637
|
if (this.iceGatheringState === 'complete') {
|
|
624
|
-
|
|
638
|
+
const sdpInfo = ev.sdp; // Can happen when doing a rollback.
|
|
639
|
+
|
|
640
|
+
if (sdpInfo.type && sdpInfo.sdp) {
|
|
641
|
+
this.localDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
642
|
+
} else {
|
|
643
|
+
this.localDescription = null;
|
|
644
|
+
} // @ts-ignore
|
|
645
|
+
|
|
625
646
|
|
|
626
647
|
this.dispatchEvent(new _RTCIceCandidateEvent.default('icecandidate', {
|
|
627
648
|
candidate: null
|