react-native-webrtc 1.92.2 → 1.94.0
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/.prettierignore +9 -0
- package/.prettierrc.json +10 -0
- package/android/libs/.placeholder +0 -0
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +199 -255
- package/apple/.placeholder +0 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +5 -3
- package/metro.config.js +3 -4
- package/metro.config.macos.js +7 -8
- package/package.json +20 -12
- package/react-native.config.js +5 -6
- package/src/EventEmitter.js +1 -1
- package/src/MediaDevices.js +6 -12
- package/src/MediaStream.js +120 -131
- package/src/MediaStreamError.js +8 -10
- package/src/MediaStreamErrorEvent.js +6 -7
- package/src/MediaStreamEvent.js +6 -7
- package/src/MediaStreamTrack.js +89 -103
- package/src/MediaStreamTrackEvent.js +6 -7
- package/src/MessageEvent.js +7 -8
- package/src/Permissions.js +26 -23
- package/src/RTCDataChannel.js +127 -145
- package/src/RTCDataChannelEvent.js +6 -7
- package/src/RTCEvent.js +5 -6
- package/src/RTCIceCandidate.js +15 -16
- package/src/RTCIceCandidateEvent.js +8 -9
- package/src/RTCPeerConnection.js +295 -325
- package/src/RTCSessionDescription.js +15 -16
- package/src/RTCUtil.js +56 -57
- package/src/RTCView.js +59 -69
- package/src/ScreenCapturePickerView.js +2 -5
- package/src/getDisplayMedia.js +7 -6
- package/src/getUserMedia.js +85 -85
- package/src/index.js +28 -34
- package/tools/build-webrtc.py +61 -49
- package/tools/downloadBitcode.sh +4 -16
- package/tools/downloadWebRTC.js +100 -0
- package/android/libs/libjingle_peerconnection.so.jar +0 -0
- package/android/libs/libwebrtc.jar +0 -0
- package/apple/WebRTC.xcframework.tgz +0 -0
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
|
File without changes
|
|
@@ -180,11 +180,6 @@ class GetUserMediaImpl {
|
|
|
180
180
|
final ReadableMap constraints,
|
|
181
181
|
final Callback successCallback,
|
|
182
182
|
final Callback errorCallback) {
|
|
183
|
-
// TODO: change getUserMedia constraints format to support new syntax
|
|
184
|
-
// constraint format seems changed, and there is no mandatory any more.
|
|
185
|
-
// and has a new syntax/attrs to specify resolution
|
|
186
|
-
// should change `parseConstraints()` according
|
|
187
|
-
// see: https://www.w3.org/TR/mediacapture-streams/#idl-def-MediaTrackConstraints
|
|
188
183
|
|
|
189
184
|
AudioTrack audioTrack = null;
|
|
190
185
|
VideoTrack videoTrack = null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.oney.WebRTCModule;
|
|
2
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
3
4
|
import androidx.annotation.Nullable;
|
|
4
5
|
|
|
5
6
|
import android.util.Log;
|
|
@@ -39,7 +40,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
39
40
|
private final SparseArray<PeerConnectionObserver> mPeerConnectionObservers;
|
|
40
41
|
final Map<String, MediaStream> localStreams;
|
|
41
42
|
|
|
42
|
-
private GetUserMediaImpl getUserMediaImpl;
|
|
43
|
+
private final GetUserMediaImpl getUserMediaImpl;
|
|
43
44
|
|
|
44
45
|
public static class Options {
|
|
45
46
|
private VideoEncoderFactory videoEncoderFactory = null;
|
|
@@ -132,6 +133,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
132
133
|
getUserMediaImpl = new GetUserMediaImpl(this, reactContext);
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
@NonNull
|
|
135
137
|
@Override
|
|
136
138
|
public String getName() {
|
|
137
139
|
return "WebRTCModule";
|
|
@@ -457,22 +459,6 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
457
459
|
return getUserMediaImpl.getTrack(trackId);
|
|
458
460
|
}
|
|
459
461
|
|
|
460
|
-
private static MediaStreamTrack getLocalTrack(
|
|
461
|
-
MediaStream localStream,
|
|
462
|
-
String trackId) {
|
|
463
|
-
for (AudioTrack track : localStream.audioTracks) {
|
|
464
|
-
if (track.id().equals(trackId)) {
|
|
465
|
-
return track;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
for (VideoTrack track : localStream.videoTracks) {
|
|
469
|
-
if (track.id().equals(trackId)) {
|
|
470
|
-
return track;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return null;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
462
|
/**
|
|
477
463
|
* Turns an "options" <tt>ReadableMap</tt> into a <tt>MediaConstraints</tt> object.
|
|
478
464
|
*
|
|
@@ -517,192 +503,167 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
517
503
|
|
|
518
504
|
@ReactMethod
|
|
519
505
|
public void mediaStreamCreate(String id) {
|
|
520
|
-
ThreadUtils.runOnExecutor(() ->
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
MediaStream mediaStream = mFactory.createLocalMediaStream(id);
|
|
525
|
-
localStreams.put(id, mediaStream);
|
|
506
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
507
|
+
MediaStream mediaStream = mFactory.createLocalMediaStream(id);
|
|
508
|
+
localStreams.put(id, mediaStream);
|
|
509
|
+
});
|
|
526
510
|
}
|
|
527
511
|
|
|
528
512
|
@ReactMethod
|
|
529
513
|
public void mediaStreamAddTrack(String streamId, String trackId) {
|
|
530
|
-
ThreadUtils.runOnExecutor(() ->
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
private void mediaStreamAddTrackAsync(String streamId, String trackId) {
|
|
535
|
-
MediaStream stream = localStreams.get(streamId);
|
|
536
|
-
MediaStreamTrack track = getTrack(trackId);
|
|
514
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
515
|
+
MediaStream stream = localStreams.get(streamId);
|
|
516
|
+
MediaStreamTrack track = getTrack(trackId);
|
|
537
517
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
518
|
+
if (stream == null || track == null) {
|
|
519
|
+
Log.d(TAG, "mediaStreamAddTrack() stream || track is null");
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
542
522
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
523
|
+
String kind = track.kind();
|
|
524
|
+
if ("audio".equals(kind)) {
|
|
525
|
+
stream.addTrack((AudioTrack)track);
|
|
526
|
+
} else if ("video".equals(kind)) {
|
|
527
|
+
stream.addTrack((VideoTrack)track);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
549
530
|
}
|
|
550
531
|
|
|
551
532
|
@ReactMethod
|
|
552
533
|
public void mediaStreamRemoveTrack(String streamId, String trackId) {
|
|
553
|
-
ThreadUtils.runOnExecutor(() ->
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
private void mediaStreamRemoveTrackAsync(String streamId, String trackId) {
|
|
558
|
-
MediaStream stream = localStreams.get(streamId);
|
|
559
|
-
MediaStreamTrack track = getTrack(trackId);
|
|
534
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
535
|
+
MediaStream stream = localStreams.get(streamId);
|
|
536
|
+
MediaStreamTrack track = getTrack(trackId);
|
|
560
537
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
538
|
+
if (stream == null || track == null) {
|
|
539
|
+
Log.d(TAG, "mediaStreamRemoveTrack() stream || track is null");
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
565
542
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
543
|
+
String kind = track.kind();
|
|
544
|
+
if ("audio".equals(kind)) {
|
|
545
|
+
stream.removeTrack((AudioTrack)track);
|
|
546
|
+
} else if ("video".equals(kind)) {
|
|
547
|
+
stream.removeTrack((VideoTrack)track);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
572
550
|
}
|
|
573
551
|
|
|
574
552
|
@ReactMethod
|
|
575
553
|
public void mediaStreamRelease(String id) {
|
|
576
|
-
ThreadUtils.runOnExecutor(() ->
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
Log.d(TAG, "mediaStreamRelease() stream is null");
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
554
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
555
|
+
MediaStream stream = localStreams.get(id);
|
|
556
|
+
if (stream == null) {
|
|
557
|
+
Log.d(TAG, "mediaStreamRelease() stream is null");
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
585
560
|
|
|
586
|
-
|
|
561
|
+
localStreams.remove(id);
|
|
587
562
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
563
|
+
// MediaStream.dispose() may be called without an exception only if
|
|
564
|
+
// it's no longer added to any PeerConnection.
|
|
565
|
+
for (int i = 0, size = mPeerConnectionObservers.size(); i < size; i++) {
|
|
566
|
+
mPeerConnectionObservers.valueAt(i).removeStream(stream);
|
|
567
|
+
}
|
|
593
568
|
|
|
594
|
-
|
|
569
|
+
stream.dispose();
|
|
570
|
+
});
|
|
595
571
|
}
|
|
596
572
|
|
|
597
573
|
@ReactMethod
|
|
598
574
|
public void mediaStreamTrackRelease(String id) {
|
|
599
|
-
ThreadUtils.runOnExecutor(() ->
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
track.setEnabled(false);
|
|
610
|
-
getUserMediaImpl.disposeTrack(id);
|
|
575
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
576
|
+
MediaStreamTrack track = getLocalTrack(id);
|
|
577
|
+
if (track == null) {
|
|
578
|
+
Log.d(TAG, "mediaStreamTrackRelease() track is null");
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
track.setEnabled(false);
|
|
582
|
+
getUserMediaImpl.disposeTrack(id);
|
|
583
|
+
});
|
|
611
584
|
}
|
|
612
585
|
|
|
613
586
|
@ReactMethod
|
|
614
587
|
public void mediaStreamTrackSetEnabled(String id, boolean enabled) {
|
|
615
|
-
ThreadUtils.runOnExecutor(() ->
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
track.setEnabled(enabled);
|
|
628
|
-
getUserMediaImpl.mediaStreamTrackSetEnabled(id, enabled);
|
|
588
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
589
|
+
MediaStreamTrack track = getTrack(id);
|
|
590
|
+
if (track == null) {
|
|
591
|
+
Log.d(TAG, "mediaStreamTrackSetEnabled() track is null");
|
|
592
|
+
return;
|
|
593
|
+
} else if (track.enabled() == enabled) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
track.setEnabled(enabled);
|
|
597
|
+
getUserMediaImpl.mediaStreamTrackSetEnabled(id, enabled);
|
|
598
|
+
});
|
|
629
599
|
}
|
|
630
600
|
|
|
631
601
|
@ReactMethod
|
|
632
602
|
public void mediaStreamTrackSwitchCamera(String id) {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
603
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
604
|
+
MediaStreamTrack track = getLocalTrack(id);
|
|
605
|
+
if (track != null) {
|
|
606
|
+
getUserMediaImpl.switchCamera(id);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
637
609
|
}
|
|
638
610
|
|
|
639
611
|
@ReactMethod
|
|
640
612
|
public void peerConnectionSetConfiguration(ReadableMap configuration,
|
|
641
613
|
int id) {
|
|
642
|
-
ThreadUtils.runOnExecutor(() ->
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
Log.d(TAG, "peerConnectionSetConfiguration() peerConnection is null");
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
peerConnection.setConfiguration(parseRTCConfiguration(configuration));
|
|
614
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
615
|
+
PeerConnection peerConnection = getPeerConnection(id);
|
|
616
|
+
if (peerConnection == null) {
|
|
617
|
+
Log.d(TAG, "peerConnectionSetConfiguration() peerConnection is null");
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
peerConnection.setConfiguration(parseRTCConfiguration(configuration));
|
|
621
|
+
});
|
|
654
622
|
}
|
|
655
623
|
|
|
656
624
|
@ReactMethod
|
|
657
625
|
public void peerConnectionAddStream(String streamId, int id) {
|
|
658
|
-
ThreadUtils.runOnExecutor(() ->
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if (pco == null || !pco.addStream(mediaStream)) {
|
|
670
|
-
Log.e(TAG, "peerConnectionAddStream() failed");
|
|
671
|
-
}
|
|
626
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
627
|
+
MediaStream mediaStream = localStreams.get(streamId);
|
|
628
|
+
if (mediaStream == null) {
|
|
629
|
+
Log.d(TAG, "peerConnectionAddStream() mediaStream is null");
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
|
|
633
|
+
if (pco == null || !pco.addStream(mediaStream)) {
|
|
634
|
+
Log.e(TAG, "peerConnectionAddStream() failed");
|
|
635
|
+
}
|
|
636
|
+
});
|
|
672
637
|
}
|
|
673
638
|
|
|
674
639
|
@ReactMethod
|
|
675
640
|
public void peerConnectionRemoveStream(String streamId, int id) {
|
|
676
|
-
ThreadUtils.runOnExecutor(() ->
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (pco == null || !pco.removeStream(mediaStream)) {
|
|
688
|
-
Log.e(TAG, "peerConnectionRemoveStream() failed");
|
|
689
|
-
}
|
|
641
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
642
|
+
MediaStream mediaStream = localStreams.get(streamId);
|
|
643
|
+
if (mediaStream == null) {
|
|
644
|
+
Log.d(TAG, "peerConnectionRemoveStream() mediaStream is null");
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
|
|
648
|
+
if (pco == null || !pco.removeStream(mediaStream)) {
|
|
649
|
+
Log.e(TAG, "peerConnectionRemoveStream() failed");
|
|
650
|
+
}
|
|
651
|
+
});
|
|
690
652
|
}
|
|
691
653
|
|
|
692
654
|
@ReactMethod
|
|
693
655
|
public void peerConnectionCreateOffer(int id,
|
|
694
656
|
ReadableMap options,
|
|
695
657
|
Callback callback) {
|
|
696
|
-
ThreadUtils.runOnExecutor(() ->
|
|
697
|
-
|
|
698
|
-
}
|
|
658
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
659
|
+
PeerConnection peerConnection = getPeerConnection(id);
|
|
699
660
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
661
|
+
if (peerConnection == null) {
|
|
662
|
+
Log.d(TAG, "peerConnectionCreateOffer() peerConnection is null");
|
|
663
|
+
callback.invoke(false, "peerConnection is null");
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
704
666
|
|
|
705
|
-
if (peerConnection != null) {
|
|
706
667
|
peerConnection.createOffer(new SdpObserver() {
|
|
707
668
|
@Override
|
|
708
669
|
public void onCreateFailure(String s) {
|
|
@@ -723,26 +684,22 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
723
684
|
@Override
|
|
724
685
|
public void onSetSuccess() {}
|
|
725
686
|
}, constraintsForOptions(options));
|
|
726
|
-
}
|
|
727
|
-
Log.d(TAG, "peerConnectionCreateOffer() peerConnection is null");
|
|
728
|
-
callback.invoke(false, "peerConnection is null");
|
|
729
|
-
}
|
|
687
|
+
});
|
|
730
688
|
}
|
|
731
689
|
|
|
732
690
|
@ReactMethod
|
|
733
691
|
public void peerConnectionCreateAnswer(int id,
|
|
734
692
|
ReadableMap options,
|
|
735
693
|
Callback callback) {
|
|
736
|
-
ThreadUtils.runOnExecutor(() ->
|
|
737
|
-
|
|
738
|
-
}
|
|
694
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
695
|
+
PeerConnection peerConnection = getPeerConnection(id);
|
|
739
696
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
697
|
+
if (peerConnection == null) {
|
|
698
|
+
Log.d(TAG, "peerConnectionCreateAnswer() peerConnection is null");
|
|
699
|
+
callback.invoke(false, "peerConnection is null");
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
744
702
|
|
|
745
|
-
if (peerConnection != null) {
|
|
746
703
|
peerConnection.createAnswer(new SdpObserver() {
|
|
747
704
|
@Override
|
|
748
705
|
public void onCreateFailure(String s) {
|
|
@@ -763,10 +720,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
763
720
|
@Override
|
|
764
721
|
public void onSetSuccess() {}
|
|
765
722
|
}, constraintsForOptions(options));
|
|
766
|
-
}
|
|
767
|
-
Log.d(TAG, "peerConnectionCreateAnswer() peerConnection is null");
|
|
768
|
-
callback.invoke(false, "peerConnection is null");
|
|
769
|
-
}
|
|
723
|
+
});
|
|
770
724
|
}
|
|
771
725
|
|
|
772
726
|
@ReactMethod
|
|
@@ -822,48 +776,43 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
822
776
|
public void peerConnectionSetRemoteDescription(ReadableMap sdpMap,
|
|
823
777
|
int id,
|
|
824
778
|
Callback callback) {
|
|
825
|
-
ThreadUtils.runOnExecutor(() ->
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
PeerConnection peerConnection = getPeerConnection(id);
|
|
833
|
-
if (peerConnection == null) {
|
|
834
|
-
Log.d(TAG, "peerConnectionSetRemoteDescription() peerConnection is null");
|
|
835
|
-
callback.invoke(false, "peerConnection is null");
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
779
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
780
|
+
PeerConnection peerConnection = getPeerConnection(id);
|
|
781
|
+
if (peerConnection == null) {
|
|
782
|
+
Log.d(TAG, "peerConnectionSetRemoteDescription() peerConnection is null");
|
|
783
|
+
callback.invoke(false, "peerConnection is null");
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
838
786
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
787
|
+
SessionDescription sdp = new SessionDescription(
|
|
788
|
+
SessionDescription.Type.fromCanonicalForm(sdpMap.getString("type")),
|
|
789
|
+
sdpMap.getString("sdp")
|
|
790
|
+
);
|
|
843
791
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
792
|
+
peerConnection.setRemoteDescription(new SdpObserver() {
|
|
793
|
+
@Override
|
|
794
|
+
public void onCreateSuccess(final SessionDescription sdp) {
|
|
795
|
+
}
|
|
848
796
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
797
|
+
@Override
|
|
798
|
+
public void onSetSuccess() {
|
|
799
|
+
SessionDescription newSdp = peerConnection.getRemoteDescription();
|
|
800
|
+
WritableMap newSdpMap = Arguments.createMap();
|
|
801
|
+
newSdpMap.putString("type", newSdp.type.canonicalForm());
|
|
802
|
+
newSdpMap.putString("sdp", newSdp.description);
|
|
803
|
+
callback.invoke(true, newSdpMap);
|
|
804
|
+
}
|
|
857
805
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
806
|
+
@Override
|
|
807
|
+
public void onCreateFailure(String s) {
|
|
808
|
+
}
|
|
861
809
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
810
|
+
@Override
|
|
811
|
+
public void onSetFailure(String s) {
|
|
812
|
+
callback.invoke(false, s);
|
|
813
|
+
}
|
|
814
|
+
}, sdp);
|
|
815
|
+
});
|
|
867
816
|
}
|
|
868
817
|
|
|
869
818
|
@ReactMethod
|
|
@@ -909,34 +858,28 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
909
858
|
|
|
910
859
|
@ReactMethod
|
|
911
860
|
public void peerConnectionGetStats(int peerConnectionId, Promise promise) {
|
|
912
|
-
ThreadUtils.runOnExecutor(() ->
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
promise.reject(new Exception("PeerConnection ID not found"));
|
|
922
|
-
} else {
|
|
923
|
-
pco.getStats(promise);
|
|
924
|
-
}
|
|
861
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
862
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(peerConnectionId);
|
|
863
|
+
if (pco == null || pco.getPeerConnection() == null) {
|
|
864
|
+
Log.d(TAG, "peerConnectionGetStats() peerConnection is null");
|
|
865
|
+
promise.reject(new Exception("PeerConnection ID not found"));
|
|
866
|
+
} else {
|
|
867
|
+
pco.getStats(promise);
|
|
868
|
+
}
|
|
869
|
+
});
|
|
925
870
|
}
|
|
926
871
|
|
|
927
872
|
@ReactMethod
|
|
928
873
|
public void peerConnectionClose(int id) {
|
|
929
|
-
ThreadUtils.runOnExecutor(() ->
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
mPeerConnectionObservers.remove(id);
|
|
939
|
-
}
|
|
874
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
875
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
|
|
876
|
+
if (pco == null || pco.getPeerConnection() == null) {
|
|
877
|
+
Log.d(TAG, "peerConnectionClose() peerConnection is null");
|
|
878
|
+
} else {
|
|
879
|
+
pco.close();
|
|
880
|
+
mPeerConnectionObservers.remove(id);
|
|
881
|
+
}
|
|
882
|
+
});
|
|
940
883
|
}
|
|
941
884
|
|
|
942
885
|
@ReactMethod
|
|
@@ -971,20 +914,17 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
971
914
|
|
|
972
915
|
@ReactMethod
|
|
973
916
|
public void dataChannelClose(int peerConnectionId, String reactTag) {
|
|
974
|
-
ThreadUtils.runOnExecutor(() ->
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
if (pco == null || pco.getPeerConnection() == null) {
|
|
983
|
-
Log.d(TAG, "dataChannelClose() peerConnection is null");
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
917
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
918
|
+
// Forward to PeerConnectionObserver which deals with DataChannels
|
|
919
|
+
// because DataChannel is owned by PeerConnection.
|
|
920
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(peerConnectionId);
|
|
921
|
+
if (pco == null || pco.getPeerConnection() == null) {
|
|
922
|
+
Log.d(TAG, "dataChannelClose() peerConnection is null");
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
986
925
|
|
|
987
|
-
|
|
926
|
+
pco.dataChannelClose(reactTag);
|
|
927
|
+
});
|
|
988
928
|
}
|
|
989
929
|
|
|
990
930
|
@ReactMethod
|
|
@@ -1005,22 +945,26 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
1005
945
|
String reactTag,
|
|
1006
946
|
String data,
|
|
1007
947
|
String type) {
|
|
1008
|
-
ThreadUtils.runOnExecutor(() ->
|
|
1009
|
-
|
|
948
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
949
|
+
// Forward to PeerConnectionObserver which deals with DataChannels
|
|
950
|
+
// because DataChannel is owned by PeerConnection.
|
|
951
|
+
PeerConnectionObserver pco = mPeerConnectionObservers.get(peerConnectionId);
|
|
952
|
+
if (pco == null || pco.getPeerConnection() == null) {
|
|
953
|
+
Log.d(TAG, "dataChannelSend() peerConnection is null");
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
pco.dataChannelSend(reactTag, data, type);
|
|
958
|
+
});
|
|
1010
959
|
}
|
|
1011
960
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
// Forward to PeerConnectionObserver which deals with DataChannels
|
|
1017
|
-
// because DataChannel is owned by PeerConnection.
|
|
1018
|
-
PeerConnectionObserver pco = mPeerConnectionObservers.get(peerConnectionId);
|
|
1019
|
-
if (pco == null || pco.getPeerConnection() == null) {
|
|
1020
|
-
Log.d(TAG, "dataChannelSend() peerConnection is null");
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
961
|
+
@ReactMethod
|
|
962
|
+
public void addListener(String eventName) {
|
|
963
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
964
|
+
}
|
|
1023
965
|
|
|
1024
|
-
|
|
966
|
+
@ReactMethod
|
|
967
|
+
public void removeListeners(Integer count) {
|
|
968
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
1025
969
|
}
|
|
1026
970
|
}
|
|
File without changes
|
|
@@ -56,6 +56,10 @@
|
|
|
56
56
|
return self;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
- (void)dealloc {
|
|
60
|
+
self.device = NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
- (void)startCapture {
|
|
60
64
|
if (self.deviceId) {
|
|
61
65
|
self.device = [AVCaptureDevice deviceWithUniqueID:self.deviceId];
|
|
@@ -73,9 +77,7 @@
|
|
|
73
77
|
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
76
|
-
|
|
77
|
-
[self registerSystemPressureStateObserverForDevice:self.device];
|
|
78
|
-
|
|
80
|
+
|
|
79
81
|
AVCaptureDeviceFormat *format
|
|
80
82
|
= [self selectFormatForDevice:self.device
|
|
81
83
|
withTargetWidth:self.width
|