react-native-webrtc 111.0.0 → 111.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.
@@ -2,8 +2,12 @@ name: Android CI
2
2
  on:
3
3
  push:
4
4
  branches: [ master ]
5
+ paths-ignore:
6
+ - '**.md'
5
7
  pull_request:
6
8
  branches: [ master ]
9
+ paths-ignore:
10
+ - '**.md'
7
11
 
8
12
  jobs:
9
13
  android-compile:
@@ -26,4 +30,4 @@ jobs:
26
30
 
27
31
  - name: Compile Android Example
28
32
  run: ./gradlew assembleDebug
29
- working-directory: ./examples/GumTestApp/android
33
+ working-directory: ./examples/GumTestApp/android
@@ -2,8 +2,12 @@ name: iOS CI
2
2
  on:
3
3
  push:
4
4
  branches: [ master ]
5
+ paths-ignore:
6
+ - '**.md'
5
7
  pull_request:
6
8
  branches: [ master ]
9
+ paths-ignore:
10
+ - '**.md'
7
11
 
8
12
  jobs:
9
13
  ios-compile:
package/ISSUE_TEMPLATE.md CHANGED
@@ -1,25 +1,40 @@
1
1
  <!--
2
- If you have a question then please ask it on our community Discourse: https://react-native-webrtc.discourse.group/
3
- otherwise if you wanted to report a bug then you are in the right place!
2
+ If you have any questions then please use our Community Discourse: https://react-native-webrtc.discourse.group/
3
+ Otherwise you are in the right place for reporting bugs.
4
4
 
5
5
  Please include as much information as possible and make the issue title as descriptive as you can.
6
- -->
7
-
8
- #### Expected Behavior
9
-
6
+ But most of all please take your time and explain to the best of your abilities.
10
7
 
8
+ Code samples can be very helpful but even more so if displayed correctly.
9
+ Here is an example of how you can use syntax highlighting.
11
10
 
12
- #### Observed Behavior
11
+ ```javascript
13
12
 
13
+ console.log( 'Hello World' );
14
14
 
15
+ ```
15
16
 
16
- #### Steps to reproduce the issue
17
+ More info can be found over here.
18
+ https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting
19
+ -->
17
20
 
21
+ #### Expected Behavior:
22
+ <!--
23
+ Explain what you expect to happen.
24
+ -->
18
25
 
26
+ #### Observed Behavior:
27
+ <!--
28
+ Explain what is actually happening.
29
+ -->
19
30
 
20
- #### Platform Information
31
+ #### Steps to reproduce the issue:
32
+ <!--
33
+ Explain how the issue can be reproduced.
34
+ If we manage to reproduce the issue then it is more likely to be addressed in an update.
35
+ -->
21
36
 
37
+ #### Platform Information
22
38
  * **React Native Version**:
23
- * **Plugin Version**:
24
- * **OS**: <!-- Android / iOS / macOS / Web / Expo -->
25
- * **OS Version**:
39
+ * **WebRTC Module Version**:
40
+ * **Platform OS + Version**: <!-- Android / iOS / macOS / Web / Expo -->
package/README.md CHANGED
@@ -10,27 +10,35 @@ A WebRTC module for React Native.
10
10
 
11
11
  ## Feature Overview
12
12
 
13
- | | Android | iOS | macOS | Windows* | Web* | Expo* |
13
+ | | Android | iOS | macOS* | Windows* | Web* | Expo* |
14
14
  | :-: | :-------: | :---: | :-----: | :--------: | :----: | :-----: |
15
- | Audio/Video | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | - | :heavy_check_mark: | :heavy_check_mark: |
16
- | Data Channels | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | - | :heavy_check_mark: | :heavy_check_mark: |
17
- | Screen Capture | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | - | :heavy_check_mark: | :heavy_check_mark: |
15
+ | Audio/Video | :heavy_check_mark: | :heavy_check_mark: | - | - | :heavy_check_mark: | :heavy_check_mark: |
16
+ | Data Channels | :heavy_check_mark: | :heavy_check_mark: | - | - | :heavy_check_mark: | :heavy_check_mark: |
17
+ | Screen Capture | :heavy_check_mark: | :heavy_check_mark: | - | - | :heavy_check_mark: | :heavy_check_mark: |
18
18
  | Plan B | - | - | - | - | - | - |
19
- | Unified Plan* | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | - | :heavy_check_mark: | :heavy_check_mark: |
19
+ | Unified Plan* | :heavy_check_mark: | :heavy_check_mark: | - | - | :heavy_check_mark: | :heavy_check_mark: |
20
+ | Simulcast* | :heavy_check_mark: | :heavy_check_mark: | - | - | :heavy_check_mark: | :heavy_check_mark: |
21
+
22
+ > **macOS** - We don't currently actively support macOS at this time.
23
+ Support might return in the future.
20
24
 
21
25
  > **Windows** - We don't currently support the [react-native-windows](https://github.com/microsoft/react-native-windows) platform at this time.
22
26
  Anyone interested in getting the ball rolling? We're open to contributions.
23
27
 
24
- > **Web** - The [react-native-webrtc-web-shim](https://github.com/react-native-webrtc/react-native-webrtc-web-shim) project provides a shim for [react-native-web](https://github.com/necolas/react-native-web) support.
25
- Which will allow you to use [(almost)](https://github.com/react-native-webrtc/react-native-webrtc-web-shim/tree/main#setup) the exact same code in your [react-native-web](https://github.com/necolas/react-native-web) project as you would with [react-native](https://reactnative.dev/) directly.
28
+ > **Web** - The [react-native-webrtc-web-shim](https://github.com/react-native-webrtc/react-native-webrtc-web-shim) project provides a shim for [react-native-web](https://github.com/necolas/react-native-web) support. Which will allow you to use [(almost)](https://github.com/react-native-webrtc/react-native-webrtc-web-shim/tree/main#setup) the exact same code in your [react-native-web](https://github.com/necolas/react-native-web) project as you would with [react-native](https://reactnative.dev/) directly.
29
+
30
+ > **Expo** - As this module includes native code it is not available in the [Expo Go](https://expo.dev/client) app by default.
31
+ However you can get things working via the [expo-dev-client](https://docs.expo.dev/development/getting-started/) library and out-of-tree [config-plugins/react-native-webrtc](https://github.com/expo/config-plugins/tree/master/packages/react-native-webrtc) package.
26
32
 
27
- > **Expo** - Sadly this module is not available in the [Expo Go](https://expo.dev/client) app by default due to including much needed native code. However you can get things working via the [expo-dev-client](https://docs.expo.dev/development/getting-started/) library and out-of-tree [config-plugins/react-native-webrtc](https://github.com/expo/config-plugins/tree/master/packages/react-native-webrtc) package.
33
+ > **Unified Plan** - As of version 106.0.0 Unified Plan is the only supported mode.
34
+ Those still in need of Plan B will need to use an older release.
28
35
 
29
- > **Unified Plan** - As of version 106.0.0 Unified Plan is the only supported mode. Those still in need of Plan B can use and old release.
36
+ > **Simulcast** - As of version 111.0.0 Simulcast is now possible with ease.
37
+ Software encode/decode factories have been enabled by default.
30
38
 
31
39
  ## WebRTC Revision
32
40
 
33
- * Currently used revision: [M106](https://github.com/jitsi/webrtc/tree/M106)
41
+ * Currently used revision: [M111](https://github.com/jitsi/webrtc/tree/M111)
34
42
  * Supported architectures
35
43
  * Android: armeabi-v7a, arm64-v8a, x86, x86_64
36
44
  * iOS: arm64, x86_64
@@ -43,6 +51,7 @@ Don't forget to follow platform guides below to cover any extra required steps.
43
51
 
44
52
  **npm:** `npm install react-native-webrtc --save`
45
53
  **yarn:** `yarn add react-native-webrtc`
54
+ **pnpm:** `pnpm install react-native-webrtc`
46
55
 
47
56
  ## Guides
48
57
 
@@ -5,12 +5,12 @@ def safeExtGet(prop, fallback) {
5
5
  }
6
6
 
7
7
  android {
8
- compileSdkVersion safeExtGet('compileSdkVersion', 23)
8
+ compileSdkVersion safeExtGet('compileSdkVersion', 24)
9
9
  buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")
10
10
 
11
11
  defaultConfig {
12
- minSdkVersion safeExtGet('minSdkVersion', 19)
13
- targetSdkVersion safeExtGet('targetSdkVersion', 23)
12
+ minSdkVersion safeExtGet('minSdkVersion', 24)
13
+ targetSdkVersion safeExtGet('targetSdkVersion', 24)
14
14
  versionCode 1
15
15
  versionName "1.0"
16
16
  }
@@ -321,7 +321,6 @@ class GetUserMediaImpl {
321
321
  trackInfo.putBoolean("enabled", track.enabled());
322
322
  trackInfo.putString("id", trackId);
323
323
  trackInfo.putString("kind", track.kind());
324
- trackInfo.putString("label", trackId);
325
324
  trackInfo.putString("readyState", track.state().toString().toLowerCase());
326
325
  trackInfo.putBoolean("remote", false);
327
326
 
@@ -21,30 +21,35 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
21
21
 
22
22
  private final Intent mediaProjectionPermissionResultData;
23
23
 
24
- private final OrientationEventListener orientatationListener;
24
+ private final OrientationEventListener orientationListener;
25
25
 
26
26
  public ScreenCaptureController(Context context, int width, int height, Intent mediaProjectionPermissionResultData) {
27
27
  super(width, height, DEFAULT_FPS);
28
28
 
29
29
  this.mediaProjectionPermissionResultData = mediaProjectionPermissionResultData;
30
30
 
31
- this.orientatationListener = new OrientationEventListener(context) {
31
+ this.orientationListener = new OrientationEventListener(context) {
32
32
  @Override
33
33
  public void onOrientationChanged(int orientation) {
34
- try {
35
- DisplayMetrics displayMetrics = DisplayUtils.getDisplayMetrics((Activity) context);
36
- int width = displayMetrics.widthPixels;
37
- int height = displayMetrics.heightPixels;
38
- videoCapturer.changeCaptureFormat(width, height, DEFAULT_FPS);
39
- } catch (Exception ex) {
40
- // We ignore exceptions here. The video capturer runs on its own
41
- // thread and we cannot synchronize with it.
42
- }
34
+ DisplayMetrics displayMetrics = DisplayUtils.getDisplayMetrics((Activity) context);
35
+ final int width = displayMetrics.widthPixels;
36
+ final int height = displayMetrics.heightPixels;
37
+
38
+ // Pivot to the executor thread because videoCapturer.changeCaptureFormat runs in the main
39
+ // thread and may deadlock.
40
+ ThreadUtils.runOnExecutor(() -> {
41
+ try {
42
+ videoCapturer.changeCaptureFormat(width, height, DEFAULT_FPS);
43
+ } catch (Exception ex) {
44
+ // We ignore exceptions here. The video capturer runs on its own
45
+ // thread and we cannot synchronize with it.
46
+ }
47
+ });
43
48
  }
44
49
  };
45
50
 
46
- if (this.orientatationListener.canDetectOrientation()) {
47
- this.orientatationListener.enable();
51
+ if (this.orientationListener.canDetectOrientation()) {
52
+ this.orientationListener.enable();
48
53
  }
49
54
  }
50
55
 
@@ -55,7 +60,7 @@ public class ScreenCaptureController extends AbstractVideoCaptureController {
55
60
  @Override
56
61
  public void onStop() {
57
62
  Log.w(TAG, "Media projection stopped.");
58
- orientatationListener.disable();
63
+ orientationListener.disable();
59
64
  stopCapture();
60
65
 
61
66
  if (capturerEventsListener != null) {
@@ -173,12 +173,21 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
173
173
  iceServersArray = map.getArray("iceServers");
174
174
  }
175
175
  List<PeerConnection.IceServer> iceServers = createIceServers(iceServersArray);
176
+
176
177
  PeerConnection.RTCConfiguration conf = new PeerConnection.RTCConfiguration(iceServers);
178
+ conf.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
177
179
 
178
180
  // Required for perfect negotiation.
179
181
  conf.enableImplicitRollback = true;
180
182
 
181
- conf.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
183
+ // Enable GCM ciphers.
184
+ CryptoOptions cryptoOptions = CryptoOptions.builder()
185
+ .setEnableGcmCryptoSuites(true)
186
+ .setEnableAes128Sha1_32CryptoCipher(false)
187
+ .setEnableEncryptedRtpHeaderExtensions(false)
188
+ .setRequireFrameEncryption(false)
189
+ .createCryptoOptions();
190
+ conf.cryptoOptions = cryptoOptions;
182
191
 
183
192
  if (map == null) {
184
193
  return conf;
@@ -873,7 +882,8 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
873
882
  @ReactMethod
874
883
  public void peerConnectionCreateOffer(int id, ReadableMap options, Promise promise) {
875
884
  ThreadUtils.runOnExecutor(() -> {
876
- PeerConnection peerConnection = getPeerConnection(id);
885
+ PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
886
+ PeerConnection peerConnection = pco.getPeerConnection();
877
887
 
878
888
  if (peerConnection == null) {
879
889
  Log.d(TAG, "peerConnectionCreateOffer() peerConnection is null");
@@ -881,6 +891,11 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
881
891
  return;
882
892
  }
883
893
 
894
+ List<String> receiversIds = new ArrayList<>();
895
+ for (RtpTransceiver transceiver : peerConnection.getTransceivers()) {
896
+ receiversIds.add(transceiver.getReceiver().id());
897
+ }
898
+
884
899
  final SdpObserver observer = new SdpObserver() {
885
900
  @Override
886
901
  public void onCreateFailure(String s) {
@@ -899,6 +914,19 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
899
914
  params.putArray("transceiversInfo", getTransceiversInfo(peerConnection));
900
915
  params.putMap("sdpInfo", sdpInfo);
901
916
 
917
+ WritableArray newTransceivers = Arguments.createArray();
918
+ for (RtpTransceiver transceiver : peerConnection.getTransceivers()) {
919
+ if (!receiversIds.contains(transceiver.getReceiver().id())) {
920
+ WritableMap newTransceiver = Arguments.createMap();
921
+ newTransceiver.putInt("transceiverOrder", pco.getNextTransceiverId());
922
+ newTransceiver.putMap(
923
+ "transceiver", SerializeUtils.serializeTransceiver(id, transceiver));
924
+ newTransceivers.pushMap(newTransceiver);
925
+ }
926
+ }
927
+
928
+ params.putArray("newTransceivers", newTransceivers);
929
+
902
930
  promise.resolve(params);
903
931
  });
904
932
  }
@@ -323,13 +323,15 @@ public class WebRTCView extends ViewGroup {
323
323
  private void removeRendererFromVideoTrack() {
324
324
  if (rendererAttached) {
325
325
  if (videoTrack != null) {
326
- try {
327
- ThreadUtils.submitToExecutor(() -> { videoTrack.removeSink(surfaceViewRenderer); }).get();
328
- } catch (Throwable tr) {
329
- // XXX If WebRTCModule#mediaStreamTrackRelease has already been
330
- // invoked on videoTrack, then it is no longer safe to call removeSink
331
- // on the instance, it will throw IllegalStateException.
332
- }
326
+ ThreadUtils.runOnExecutor(() -> {
327
+ try {
328
+ videoTrack.removeSink(surfaceViewRenderer);
329
+ } catch (Throwable tr) {
330
+ // XXX If WebRTCModule#mediaStreamTrackRelease has already been
331
+ // invoked on videoTrack, then it is no longer safe to call removeSink
332
+ // on the instance, it will throw IllegalStateException.
333
+ }
334
+ });
333
335
  }
334
336
 
335
337
  surfaceViewRenderer.release();
@@ -518,27 +520,25 @@ public class WebRTCView extends ViewGroup {
518
520
  }
519
521
 
520
522
  try {
521
- surfaceViewRendererInstances++;
522
523
  surfaceViewRenderer.init(sharedContext, rendererEvents);
524
+ surfaceViewRendererInstances++;
523
525
  } catch (Exception e) {
524
526
  Logging.e(
525
527
  TAG, "Failed to initialize surfaceViewRenderer on instance " + surfaceViewRendererInstances, e);
526
- surfaceViewRendererInstances--;
528
+ return;
527
529
  }
528
530
 
529
- try {
530
- ThreadUtils.submitToExecutor(() -> { videoTrack.addSink(surfaceViewRenderer); }).get();
531
- } catch (Throwable tr) {
532
- // XXX If WebRTCModule#mediaStreamTrackRelease has already been
533
- // invoked on videoTrack, then it is no longer safe to call addSink
534
- // on the instance, it will throw IllegalStateException.
535
-
536
- Log.e(TAG, "Failed to add renderer", tr);
531
+ ThreadUtils.runOnExecutor(() -> {
532
+ try {
533
+ videoTrack.addSink(surfaceViewRenderer);
534
+ } catch (Throwable tr) {
535
+ // XXX If WebRTCModule#mediaStreamTrackRelease has already been
536
+ // invoked on videoTrack, then it is no longer safe to call addSink
537
+ // on the instance, it will throw IllegalStateException.
537
538
 
538
- surfaceViewRenderer.release();
539
- surfaceViewRendererInstances--;
540
- return;
541
- }
539
+ Log.e(TAG, "Failed to add renderer", tr);
540
+ }
541
+ });
542
542
 
543
543
  rendererAttached = true;
544
544
  }
@@ -88,11 +88,17 @@
88
88
 
89
89
  + (nonnull RTCConfiguration *)RTCConfiguration:(id)json {
90
90
  RTCConfiguration *config = [[RTCConfiguration alloc] init];
91
+ config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
91
92
 
92
93
  // Required for perfect negotiation.
93
94
  config.enableImplicitRollback = YES;
94
95
 
95
- config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
96
+ // Enable GCM ciphers.
97
+ RTCCryptoOptions *cryptoOptions = [[RTCCryptoOptions alloc] initWithSrtpEnableGcmCryptoSuites:YES
98
+ srtpEnableAes128Sha1_32CryptoCipher:NO
99
+ srtpEnableEncryptedRtpHeaderExtensions:NO
100
+ sframeRequireFrameEncryption:NO];
101
+ config.cryptoOptions = cryptoOptions;
96
102
 
97
103
  if (!json) {
98
104
  return config;
@@ -75,7 +75,7 @@
75
75
  VideoCaptureController *vcc = (VideoCaptureController *)videoTrack.captureController;
76
76
  AVCaptureDeviceFormat *format = vcc.selectedFormat;
77
77
  CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
78
- settings = @{@"height" : @(dimensions.height), @"width" : @(dimensions.width), @"frameRate" : @(3)};
78
+ settings = @{@"height" : @(dimensions.height), @"width" : @(dimensions.width), @"frameRate" : @(30)};
79
79
  }
80
80
  }
81
81
 
@@ -83,7 +83,6 @@
83
83
  @"enabled" : @(track.isEnabled),
84
84
  @"id" : trackId,
85
85
  @"kind" : track.kind,
86
- @"label" : trackId,
87
86
  @"readyState" : @"live",
88
87
  @"remote" : @(NO),
89
88
  @"settings" : settings
@@ -155,7 +154,6 @@ RCT_EXPORT_METHOD(getDisplayMedia : (RCTPromiseResolveBlock)resolve rejecter : (
155
154
  @"enabled" : @(videoTrack.isEnabled),
156
155
  @"id" : videoTrack.trackId,
157
156
  @"kind" : videoTrack.kind,
158
- @"label" : videoTrack.trackId,
159
157
  @"readyState" : @"live",
160
158
  @"remote" : @(NO)
161
159
  };
@@ -218,14 +216,13 @@ RCT_EXPORT_METHOD(getUserMedia
218
216
  VideoCaptureController *vcc = (VideoCaptureController *)videoTrack.captureController;
219
217
  AVCaptureDeviceFormat *format = vcc.selectedFormat;
220
218
  CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
221
- settings = @{@"height" : @(dimensions.height), @"width" : @(dimensions.width), @"frameRate" : @(3)};
219
+ settings = @{@"height" : @(dimensions.height), @"width" : @(dimensions.width), @"frameRate" : @(30)};
222
220
  }
223
221
 
224
222
  [tracks addObject:@{
225
223
  @"enabled" : @(track.isEnabled),
226
224
  @"id" : trackId,
227
225
  @"kind" : track.kind,
228
- @"label" : trackId,
229
226
  @"readyState" : @"live",
230
227
  @"remote" : @(NO),
231
228
  @"settings" : settings
@@ -120,18 +120,31 @@ RCT_EXPORT_METHOD(peerConnectionCreateOffer
120
120
  RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:options
121
121
  optionalConstraints:nil];
122
122
 
123
+ NSMutableArray *receiversIds = [NSMutableArray new];
124
+ for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
125
+ [receiversIds addObject:transceiver.receiver.receiverId];
126
+ }
127
+
123
128
  RTCCreateSessionDescriptionCompletionHandler handler = ^(RTCSessionDescription *desc, NSError *error) {
124
129
  dispatch_async(self.workerQueue, ^{
125
130
  if (error) {
126
131
  reject(@"E_OPERATION_ERROR", error.localizedDescription, nil);
127
132
  } else {
128
- NSMutableDictionary *sdpInfo = [NSMutableDictionary new];
129
- sdpInfo[@"type"] = [RTCSessionDescription stringForType:desc.type];
130
- sdpInfo[@"sdp"] = desc.sdp;
133
+ NSMutableArray *newTransceivers = [NSMutableArray new];
134
+ for (RTCRtpTransceiver *transceiver in peerConnection.transceivers) {
135
+ if (![receiversIds containsObject:transceiver.receiver.receiverId]) {
136
+ NSMutableDictionary *newTransceiver = [NSMutableDictionary new];
137
+ newTransceiver[@"transceiverOrder"] = [NSNumber numberWithInt:_transceiverNextId++];
138
+ newTransceiver[@"transceiver"] =
139
+ [SerializeUtils transceiverToJSONWithPeerConnectionId:objectID transceiver:transceiver];
140
+ [newTransceivers addObject:newTransceiver];
141
+ }
142
+ }
131
143
  id data = @{
132
- @"sdpInfo" : sdpInfo,
144
+ @"sdpInfo" : @{@"type" : [RTCSessionDescription stringForType:desc.type], @"sdp" : desc.sdp},
133
145
  @"transceiversInfo" :
134
- [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
146
+ [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection],
147
+ @"newTransceivers" : newTransceivers
135
148
  };
136
149
  resolve(data);
137
150
  }
@@ -160,11 +173,8 @@ RCT_EXPORT_METHOD(peerConnectionCreateAnswer
160
173
  if (error) {
161
174
  reject(@"E_OPERATION_ERROR", error.localizedDescription, nil);
162
175
  } else {
163
- NSMutableDictionary *sdpInfo = [NSMutableDictionary new];
164
- sdpInfo[@"type"] = [RTCSessionDescription stringForType:desc.type];
165
- sdpInfo[@"sdp"] = desc.sdp;
166
176
  id data = @{
167
- @"sdpInfo" : sdpInfo,
177
+ @"sdpInfo" : @{@"type" : [RTCSessionDescription stringForType:desc.type], @"sdp" : desc.sdp},
168
178
  @"transceiversInfo" :
169
179
  [SerializeUtils constructTransceiversInfoArrayWithPeerConnection:peerConnection]
170
180
  };
@@ -44,22 +44,20 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
44
44
  * built afterwards.
45
45
  */
46
46
  constructor(arg) {
47
- super(); // Assigm a UUID to start with. It may get overridden for remote streams.
48
-
49
- _defineProperty(this, "id", void 0);
50
-
51
- _defineProperty(this, "active", true);
47
+ super(); // Assign a UUID to start with. It will get overridden for remote streams.
52
48
 
53
49
  _defineProperty(this, "_tracks", []);
54
50
 
51
+ _defineProperty(this, "_id", void 0);
52
+
55
53
  _defineProperty(this, "_reactTag", void 0);
56
54
 
57
- this.id = (0, _RTCUtil.uniqueID)(); // Local MediaStreams are created by WebRTCModule to have their id and
55
+ this._id = (0, _RTCUtil.uniqueID)(); // Local MediaStreams are created by WebRTCModule to have their id and
58
56
  // reactTag equal because WebRTCModule follows the respective standard's
59
57
  // recommendation for id generation i.e. uses UUID which is unique enough
60
58
  // for the purposes of reactTag.
61
59
 
62
- this._reactTag = this.id;
60
+ this._reactTag = this._id;
63
61
 
64
62
  if (typeof arg === 'undefined') {
65
63
  WebRTCModule.mediaStreamCreate(this.id);
@@ -76,7 +74,7 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
76
74
  this.addTrack(track);
77
75
  }
78
76
  } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
79
- this.id = arg.streamId;
77
+ this._id = arg.streamId;
80
78
  this._reactTag = arg.streamReactTag;
81
79
 
82
80
  for (const trackInfo of arg.tracks) {
@@ -89,6 +87,15 @@ class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA
89
87
  }
90
88
  }
91
89
 
90
+ get id() {
91
+ return this._id;
92
+ }
93
+
94
+ get active() {
95
+ // TODO: can we reliably report this value?
96
+ return true;
97
+ }
98
+
92
99
  addTrack(track) {
93
100
  const index = this._tracks.indexOf(track);
94
101
 
@@ -1 +1 @@
1
- {"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","id","_reactTag","mediaStreamCreate","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","index","indexOf","mediaStreamAddTrack","remote","_peerConnectionId","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,mBAAmB,GAAG,CAAE,QAAF,EAAY,UAAZ,EAAwB,UAAxB,EAAoC,aAApC,CAA5B;;AAEe,MAAMC,WAAN,SAA0B,8CAAwB,GAAGD,mBAA3B,CAA1B,CAA0E;AAMrF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAGI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIE,EAAAA,WAAW,CAACC,GAAD,EAAM;AACb,YADa,CAGb;;AAHa;;AAAA,oCAzBR,IAyBQ;;AAAA,qCAvBa,EAuBb;;AAAA;;AAIb,SAAKC,EAAL,GAAU,wBAAV,CAJa,CAKb;AACA;AACA;AACA;;AACA,SAAKC,SAAL,GAAiB,KAAKD,EAAtB;;AAEA,QAAI,OAAOD,GAAP,KAAe,WAAnB,EAAgC;AAC5BL,MAAAA,YAAY,CAACQ,iBAAb,CAA+B,KAAKF,EAApC;AACH,KAFD,MAEO,IAAID,GAAG,YAAYF,WAAnB,EAAgC;AACnCH,MAAAA,YAAY,CAACQ,iBAAb,CAA+B,KAAKF,EAApC;;AAEA,WAAK,MAAMG,KAAX,IAAoBJ,GAAG,CAACK,SAAJ,EAApB,EAAqC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2C,kBAAb,CAAgC,KAAKpC,SAArC;AACH;;AA5HoF","sourcesContent":["\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport MediaStreamTrack from './MediaStreamTrack';\nimport { uniqueID } from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = [ 'active', 'inactive', 'addtrack', 'removetrack' ];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n id: string;\n active = true;\n\n _tracks: MediaStreamTrack[] = [];\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the parameters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assigm a UUID to start with. It may get overridden for remote streams.\n this.id = uniqueID();\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this.id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this.id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n addTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index !== -1) {\n return;\n }\n\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n removeTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index === -1) {\n return;\n }\n\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n getTracks(): MediaStreamTrack[] {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n toURL(): string {\n return this._reactTag;\n }\n\n release(releaseTracks = true): void {\n const tracks = [ ...this._tracks ];\n\n for (const track of tracks) {\n this.removeTrack(track);\n\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}
1
+ {"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","_id","_reactTag","mediaStreamCreate","id","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","active","index","indexOf","mediaStreamAddTrack","remote","_peerConnectionId","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,mBAAmB,GAAG,CAAE,QAAF,EAAY,UAAZ,EAAwB,UAAxB,EAAoC,aAApC,CAA5B;;AAEe,MAAMC,WAAN,SAA0B,8CAAwB,GAAGD,mBAA3B,CAA1B,CAA0E;AAKrF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAGI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIE,EAAAA,WAAW,CAACC,GAAD,EAAM;AACb,YADa,CAGb;;AAHa,qCAzBa,EAyBb;;AAAA;;AAAA;;AAIb,SAAKC,GAAL,GAAW,wBAAX,CAJa,CAMb;AACA;AACA;AACA;;AACA,SAAKC,SAAL,GAAiB,KAAKD,GAAtB;;AAEA,QAAI,OAAOD,GAAP,KAAe,WAAnB,EAAgC;AAC5BL,MAAAA,YAAY,CAACQ,iBAAb,CAA+B,KAAKC,EAApC;AACH,KAFD,MAEO,IAAIJ,GAAG,YAAYF,WAAnB,EAAgC;AACnCH,MAAAA,YAAY,CAACQ,iBAAb,CAA+B,KAAKC,EAApC;;AAEA,WAAK,MAAMC,KAAX,IAAoBL,GAAG,CAACM,SAAJ,EAApB,EAAqC;AACjC,aAAKC,QAAL,CAAcF,KAAd;AACH;AACJ,KANM,MAMA,IAAIG,KAAK,CAACC,OAAN,CAAcT,GAAd,CAAJ,EAAwB;AAC3BL,MAAAA,YAAY,CAACQ,iBAAb,CAA+B,KAAKC,EAApC;;AAEA,WAAK,MAAMC,KAAX,IAAoBL,GAApB,EAAyB;AACrB,aAAKO,QAAL,CAAcF,KAAd;AACH;AACJ,KANM,MAMA,IAAI,OAAOL,GAAP,KAAe,QAAf,IAA2BA,GAAG,CAACU,QAA/B,IAA2CV,GAA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C,CAAC,CAA9F,EAAiGlB,KAAK,CAACD,EAAvG;AACH;;AAEDE,EAAAA,SAAS,GAAuB;AAC5B,WAAO,KAAKQ,OAAL,CAAaa,KAAb,EAAP;AACH;;AAEDC,EAAAA,YAAY,CAACC,OAAD,EAAwC;AAChD,WAAO,KAAKf,OAAL,CAAagB,IAAb,CAAkBzB,KAAK,IAAIA,KAAK,CAACD,EAAN,KAAayB,OAAxC,CAAP;AACH;;AAEDE,EAAAA,cAAc,GAAuB;AACjC,WAAO,KAAKjB,OAAL,CAAakB,MAAb,CAAoB3B,KAAK,IAAIA,KAAK,CAAC4B,IAAN,KAAe,OAA5C,CAAP;AACH;;AAEDC,EAAAA,cAAc,GAAuB;AACjC,WAAO,KAAKpB,OAAL,CAAakB,MAAb,CAAoB3B,KAAK,IAAIA,KAAK,CAAC4B,IAAN,KAAe,OAA5C,CAAP;AACH;;AAEDE,EAAAA,KAAK,GAAU;AACX,UAAM,IAAIC,KAAJ,CAAU,kBAAV,CAAN;AACH;;AAEDC,EAAAA,KAAK,GAAW;AACZ,WAAO,KAAKnC,SAAZ;AACH;;AAEDoC,EAAAA,OAAO,GAA6B;AAAA,QAA5BC,aAA4B,uEAAZ,IAAY;AAChC,UAAM3B,MAAM,GAAG,CAAE,GAAG,KAAKE,OAAV,CAAf;;AAEA,SAAK,MAAMT,KAAX,IAAoBO,MAApB,EAA4B;AACxB,WAAKY,WAAL,CAAiBnB,KAAjB;;AAEA,UAAIkC,aAAJ,EAAmB;AACflC,QAAAA,KAAK,CAACiC,OAAN;AACH;AACJ;;AAED3C,IAAAA,YAAY,CAAC6C,kBAAb,CAAgC,KAAKtC,SAArC;AACH;;AAtIoF","sourcesContent":["\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport MediaStreamTrack from './MediaStreamTrack';\nimport { uniqueID } from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = [ 'active', 'inactive', 'addtrack', 'removetrack' ];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n _tracks: MediaStreamTrack[] = [];\n\n _id: string;\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the parameters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assign a UUID to start with. It will get overridden for remote streams.\n this._id = uniqueID();\n\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this._id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this._id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n get id(): string {\n return this._id;\n }\n\n get active(): boolean {\n // TODO: can we reliably report this value?\n\n return true;\n }\n\n addTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index !== -1) {\n return;\n }\n\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n removeTrack(track: MediaStreamTrack): void {\n const index = this._tracks.indexOf(track);\n\n if (index === -1) {\n return;\n }\n\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.remote ? track._peerConnectionId : -1, track.id);\n }\n\n getTracks(): MediaStreamTrack[] {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): MediaStreamTrack[] {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n toURL(): string {\n return this._reactTag;\n }\n\n release(releaseTracks = true): void {\n const tracks = [ ...this._tracks ];\n\n for (const track of tracks) {\n this.removeTrack(track);\n\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}
@@ -99,9 +99,29 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
99
99
  log.debug(`${this._pcId} createOffer`);
100
100
  const {
101
101
  sdpInfo,
102
+ newTransceivers,
102
103
  transceiversInfo
103
104
  } = await WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options));
104
105
  log.debug(`${this._pcId} createOffer OK`);
106
+ newTransceivers === null || newTransceivers === void 0 ? void 0 : newTransceivers.forEach(t => {
107
+ const {
108
+ transceiverOrder,
109
+ transceiver
110
+ } = t;
111
+ const newSender = new _RTCRtpSender.default({ ...transceiver.sender,
112
+ track: null
113
+ });
114
+ const remoteTrack = transceiver.receiver.track ? new _MediaStreamTrack.default(transceiver.receiver.track) : null;
115
+ const newReceiver = new _RTCRtpReceiver.default({ ...transceiver.receiver,
116
+ track: remoteTrack
117
+ });
118
+ const newTransceiver = new _RTCRtpTransceiver.default({ ...transceiver,
119
+ sender: newSender,
120
+ receiver: newReceiver
121
+ });
122
+
123
+ this._insertTransceiverSorted(transceiverOrder, newTransceiver);
124
+ });
105
125
 
106
126
  this._updateTransceivers(transceiversInfo);
107
127