react-native-webrtc 1.94.1 → 1.94.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/README.md CHANGED
@@ -7,7 +7,7 @@ A WebRTC module for React Native.
7
7
  - Support iOS / macOS / Android.
8
8
  - Support Video / Audio / Data Channels.
9
9
 
10
- **NOTE** for Expo users: this plugin doesn't work unless you eject.
10
+ > 🚨 Expo: This package is not available in the [Expo Go](https://expo.dev/client) app. Learn how you can use this package in [Custom Dev Clients](https://docs.expo.dev/development/getting-started/) via the out-of-tree [Expo Config Plugin](https://github.com/expo/config-plugins/tree/master/packages/react-native-webrtc).
11
11
 
12
12
  ## Community
13
13
 
@@ -15,7 +15,7 @@ Everyone is welcome to our [Discourse community](https://react-native-webrtc.dis
15
15
 
16
16
  ## WebRTC Revision
17
17
 
18
- * Currently used revision: [M94](https://github.com/jitsi/webrtc/commit/561d58b4136684f4247ed780ce090a871be7cf75)
18
+ * Currently used revision: [M94](https://github.com/jitsi/webrtc/releases/tag/v94.0.0)
19
19
  * Supported architectures
20
20
  * Android: armeabi-v7a, arm64-v8a, x86, x86_64
21
21
  * iOS: arm64, x86_64 (for bitcode support, run [this script](https://github.com/react-native-webrtc/react-native-webrtc/blob/master/tools/downloadBitcode.sh))
@@ -107,9 +107,11 @@ class GetUserMediaImpl {
107
107
 
108
108
  AudioSource audioSource = pcFactory.createAudioSource(peerConstraints);
109
109
  AudioTrack track = pcFactory.createAudioTrack(id, audioSource);
110
+
111
+ // surfaceTextureHelper is initialized for videoTrack only, so its null here.
110
112
  tracks.put(
111
113
  id,
112
- new TrackPrivate(track, audioSource, /* videoCapturer */ null));
114
+ new TrackPrivate(track, audioSource, /* videoCapturer */ null, /* surfaceTextureHelper */ null));
113
115
 
114
116
  return track;
115
117
  }
@@ -381,7 +383,7 @@ class GetUserMediaImpl {
381
383
  VideoTrack track = pcFactory.createVideoTrack(id, videoSource);
382
384
 
383
385
  track.setEnabled(true);
384
- tracks.put(id, new TrackPrivate(track, videoSource, videoCaptureController));
386
+ tracks.put(id, new TrackPrivate(track, videoSource, videoCaptureController, surfaceTextureHelper));
385
387
 
386
388
  videoCaptureController.startCapture();
387
389
 
@@ -405,6 +407,8 @@ class GetUserMediaImpl {
405
407
  * if {@link #track} is a {@link VideoTrack}.
406
408
  */
407
409
  public final AbstractVideoCaptureController videoCaptureController;
410
+
411
+ private final SurfaceTextureHelper surfaceTextureHelper;
408
412
 
409
413
  /**
410
414
  * Whether this object has been disposed or not.
@@ -424,10 +428,12 @@ class GetUserMediaImpl {
424
428
  public TrackPrivate(
425
429
  MediaStreamTrack track,
426
430
  MediaSource mediaSource,
427
- AbstractVideoCaptureController videoCaptureController) {
431
+ AbstractVideoCaptureController videoCaptureController,
432
+ SurfaceTextureHelper surfaceTextureHelper) {
428
433
  this.track = track;
429
434
  this.mediaSource = mediaSource;
430
435
  this.videoCaptureController = videoCaptureController;
436
+ this.surfaceTextureHelper = surfaceTextureHelper;
431
437
  this.disposed = false;
432
438
  }
433
439
 
@@ -438,6 +444,18 @@ class GetUserMediaImpl {
438
444
  videoCaptureController.dispose();
439
445
  }
440
446
  }
447
+
448
+ /*
449
+ * As per webrtc library documentation - The caller still has ownership of {@code
450
+ * surfaceTextureHelper} and is responsible for making sure surfaceTextureHelper.dispose() is
451
+ * called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new
452
+ * VideoCapturer once the previous VideoCapturer has been disposed. */
453
+
454
+ if(surfaceTextureHelper != null) {
455
+ surfaceTextureHelper.stopListening();
456
+ surfaceTextureHelper.dispose();
457
+ }
458
+
441
459
  mediaSource.dispose();
442
460
  track.dispose();
443
461
  disposed = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webrtc",
3
- "version": "1.94.1",
3
+ "version": "1.94.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
@@ -20,8 +20,7 @@
20
20
  "dependencies": {
21
21
  "base64-js": "1.5.1",
22
22
  "event-target-shim": "6.0.2",
23
- "tar": "6.1.11",
24
- "uuid": "3.4.0"
23
+ "tar": "6.1.11"
25
24
  },
26
25
  "peerDependencies": {
27
26
  "react-native": ">=0.60.0"
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { NativeModules } from 'react-native';
3
3
  import { defineCustomEventTarget } from 'event-target-shim';
4
- import uuid from 'uuid';
4
+ import { uniqueID } from './RTCUtil';
5
5
 
6
6
  import MediaStreamTrack from './MediaStreamTrack';
7
7
 
@@ -40,7 +40,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
40
40
  super();
41
41
 
42
42
  // Assigm a UUID to start with. It may get overridden for remote streams.
43
- this.id = uuid.v4();
43
+ this.id = uniqueID();
44
44
  // Local MediaStreams are created by WebRTCModule to have their id and
45
45
  // reactTag equal because WebRTCModule follows the respective standard's
46
46
  // recommendation for id generation i.e. uses UUID which is unique enough
package/src/RTCUtil.js CHANGED
@@ -112,6 +112,27 @@ function normalizeMediaConstraints(constraints, mediaType) {
112
112
  }
113
113
  }
114
114
 
115
+ /**
116
+ * Utility for creating short random strings from float point values.
117
+ * We take 4 characters from the end after converting to a string.
118
+ * Conversion to string gives us some letters as we don't want just numbers.
119
+ * Should be suitable to pass for enough randomness.
120
+ *
121
+ * @return {String} 4 random characters
122
+ */
123
+ function chr4() {
124
+ return Math.random().toString(16).slice(-4);
125
+ }
126
+
127
+ /**
128
+ * Put together a random string in UUIDv4 format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
129
+ *
130
+ * @return {String} uuidv4
131
+ */
132
+ export function uniqueID() {
133
+ return `${chr4()}${chr4()}-${chr4()}-${chr4()}-${chr4()}-${chr4()}${chr4()}${chr4()}`;
134
+ }
135
+
115
136
  /**
116
137
  * Utility for deep cloning an object. Object.assign() only does a shallow copy.
117
138
  *