react-native-webrtc 106.0.0-beta.6 → 106.0.0-beta.7

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.
Files changed (35) hide show
  1. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +1 -1
  2. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +20 -6
  3. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +10 -0
  4. package/ios/RCTWebRTC/SerializeUtils.m +4 -2
  5. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +19 -12
  6. package/lib/commonjs/MediaStreamTrack.js +8 -7
  7. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  8. package/lib/commonjs/RTCIceCandidate.js +14 -4
  9. package/lib/commonjs/RTCIceCandidate.js.map +1 -1
  10. package/lib/commonjs/RTCPeerConnection.js +40 -26
  11. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  12. package/lib/commonjs/RTCRtpTransceiver.js +2 -9
  13. package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
  14. package/lib/commonjs/RTCView.js +0 -55
  15. package/lib/commonjs/RTCView.js.map +1 -1
  16. package/lib/module/MediaStreamTrack.js +8 -7
  17. package/lib/module/MediaStreamTrack.js.map +1 -1
  18. package/lib/module/RTCIceCandidate.js +14 -4
  19. package/lib/module/RTCIceCandidate.js.map +1 -1
  20. package/lib/module/RTCPeerConnection.js +40 -26
  21. package/lib/module/RTCPeerConnection.js.map +1 -1
  22. package/lib/module/RTCRtpTransceiver.js +2 -9
  23. package/lib/module/RTCRtpTransceiver.js.map +1 -1
  24. package/lib/module/RTCView.js +0 -49
  25. package/lib/module/RTCView.js.map +1 -1
  26. package/lib/typescript/MediaStreamTrack.d.ts +2 -1
  27. package/lib/typescript/RTCIceCandidate.d.ts +5 -1
  28. package/lib/typescript/RTCRtpTransceiver.d.ts +0 -3
  29. package/lib/typescript/RTCView.d.ts +53 -46
  30. package/package.json +1 -1
  31. package/src/MediaStreamTrack.ts +7 -6
  32. package/src/RTCIceCandidate.ts +8 -5
  33. package/src/RTCPeerConnection.ts +41 -14
  34. package/src/RTCRtpTransceiver.ts +2 -9
  35. package/src/RTCView.ts +53 -49
@@ -156,7 +156,12 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
156
156
  transceiversInfo
157
157
  } = await WebRTCModule.peerConnectionSetLocalDescription(this._pcId, desc);
158
158
 
159
- this.localDescription = new RTCSessionDescription(sdpInfo);
159
+ if (sdpInfo.type && sdpInfo.sdp) {
160
+ this.localDescription = new RTCSessionDescription(sdpInfo);
161
+ } else {
162
+ this.localDescription = null;
163
+ }
164
+
160
165
  this._updateTransceivers(transceiversInfo);
161
166
 
162
167
  log.debug(`${this._pcId} setLocalDescription OK`);
@@ -186,12 +191,24 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
186
191
  if (successful) {
187
192
  log.debug(`${this._pcId} setRemoteDescription OK`);
188
193
 
189
- this.remoteDescription = new RTCSessionDescription(data.sdpInfo);
194
+ const {
195
+ sdpInfo,
196
+ newTransceivers,
197
+ transceiversInfo
198
+ } = data;
199
+
200
+ if (sdpInfo.type && sdpInfo.sdp) {
201
+ this.remoteDescription = new RTCSessionDescription(sdpInfo);
202
+ } else {
203
+ this.remoteDescription = null;
204
+ }
190
205
 
191
- data.newTransceivers?.forEach( t => {
206
+ newTransceivers?.forEach( t => {
192
207
  const { transceiverOrder, transceiver } = t;
193
- const newSender = new RTCRtpSender(transceiver.sender);
194
- const newReceiver = new RTCRtpReceiver(transceiver.receiver);
208
+ const newSender = new RTCRtpSender({ ...transceiver.sender, track: null });
209
+ const remoteTrack
210
+ = transceiver.receiver.track ? new MediaStreamTrack(transceiver.receiver.track) : null;
211
+ const newReceiver = new RTCRtpReceiver({ ...transceiver.receiver, track: remoteTrack });
195
212
  const newTransceiver = new RTCRtpTransceiver({
196
213
  ...transceiver,
197
214
  sender: newSender,
@@ -201,7 +218,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
201
218
  this._insertTransceiverSorted(transceiverOrder, newTransceiver);
202
219
  });
203
220
 
204
- this._updateTransceivers(data.transceiversInfo);
221
+ this._updateTransceivers(transceiversInfo);
205
222
 
206
223
  resolve();
207
224
  } else {
@@ -216,10 +233,19 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
216
233
  log.debug(`${this._pcId} addIceCandidate`);
217
234
 
218
235
  if (!candidate || !candidate.candidate) {
219
- // XXX end-of cantidates is not implemented: https://bugs.chromium.org/p/webrtc/issues/detail?id=9218
236
+ // XXX end-of candidates is not implemented: https://bugs.chromium.org/p/webrtc/issues/detail?id=9218
220
237
  return;
221
238
  }
222
239
 
240
+ if (
241
+ candidate.sdpMLineIndex === null ||
242
+ candidate.sdpMLineIndex === undefined ||
243
+ candidate.sdpMid === null ||
244
+ candidate.sdpMid === undefined
245
+ ) {
246
+ throw new TypeError('`sdpMLineIndex` and `sdpMid` must not null or undefined');
247
+ }
248
+
223
249
  const newSdp = await WebRTCModule.peerConnectionAddICECandidate(
224
250
  this._pcId,
225
251
  candidate.toJSON ? candidate.toJSON() : candidate
@@ -486,10 +512,9 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
486
512
  let track;
487
513
  let transceiver;
488
514
 
489
- // Make sure transceivers are stored in timestamp order. Also, we have to make
490
- // sure we do not add a transceiver if it exists.
491
- const [ { transceiver: oldTransceiver } = { transceiver: null } ]
492
- = this._transceivers.filter(({ transceiver }) => transceiver.id === ev.transceiver.id);
515
+ const [ oldTransceiver ] = this
516
+ .getTransceivers()
517
+ .filter(t => t.receiver.id === ev.receiver.id);
493
518
 
494
519
  // We need to fire this event for an existing track sometimes, like
495
520
  // when the transceiver direction (on the sending side) switches from
@@ -497,13 +522,15 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
497
522
 
498
523
  if (oldTransceiver) {
499
524
  transceiver = oldTransceiver;
500
- track = transceiver._receiver._track;
525
+ track = transceiver.receiver.track;
501
526
  transceiver._mid = ev.transceiver.mid;
502
527
  transceiver._currentDirection = ev.transceiver.currentDirection;
503
528
  transceiver._direction = ev.transceiver.direction;
504
529
  } else {
530
+ // TODO: re-evaluate if we need this branch at all. Since we now add new transceivers
531
+ // in sRD, we should always find them when this handler runs.
505
532
  track = new MediaStreamTrack(ev.receiver.track);
506
- const sender = new RTCRtpSender({ ...ev.transceiver.sender });
533
+ const sender = new RTCRtpSender({ ...ev.transceiver, track: null });
507
534
  const receiver = new RTCRtpReceiver({ ...ev.receiver, track });
508
535
 
509
536
  transceiver = new RTCRtpTransceiver({ ...ev.transceiver, receiver, sender });
@@ -678,7 +705,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
678
705
  for (const update of transceiverUpdates) {
679
706
  const [ transceiver ] = this
680
707
  .getTransceivers()
681
- .filter(t => t.id === update.transceiverId);
708
+ .filter(t => t.sender.id === update.transceiverId);
682
709
 
683
710
  if (!transceiver) {
684
711
  continue;
@@ -11,7 +11,6 @@ export default class RTCRtpTransceiver {
11
11
  _sender: RTCRtpSender;
12
12
  _receiver: RTCRtpReceiver;
13
13
 
14
- _id: string;
15
14
  _mid: string | null = null;
16
15
  _direction: string;
17
16
  _currentDirection: string;
@@ -19,7 +18,6 @@ export default class RTCRtpTransceiver {
19
18
 
20
19
  constructor(args: {
21
20
  peerConnectionId: number,
22
- id: string,
23
21
  isStopped: boolean,
24
22
  direction: string,
25
23
  currentDirection: string,
@@ -28,7 +26,6 @@ export default class RTCRtpTransceiver {
28
26
  receiver: RTCRtpReceiver,
29
27
  }) {
30
28
  this._peerConnectionId = args.peerConnectionId;
31
- this._id = args.id;
32
29
  this._mid = args.mid ? args.mid : null;
33
30
  this._direction = args.direction;
34
31
  this._currentDirection = args.currentDirection;
@@ -37,10 +34,6 @@ export default class RTCRtpTransceiver {
37
34
  this._receiver = args.receiver;
38
35
  }
39
36
 
40
- get id() {
41
- return this._id;
42
- }
43
-
44
37
  get mid() {
45
38
  return this._mid;
46
39
  }
@@ -68,7 +61,7 @@ export default class RTCRtpTransceiver {
68
61
 
69
62
  const oldDirection = this._direction;
70
63
 
71
- WebRTCModule.transceiverSetDirection(this._peerConnectionId, this.id, val)
64
+ WebRTCModule.transceiverSetDirection(this._peerConnectionId, this.sender.id, val)
72
65
  .catch(() => {
73
66
  this._direction = oldDirection;
74
67
  });
@@ -93,7 +86,7 @@ export default class RTCRtpTransceiver {
93
86
  return;
94
87
  }
95
88
 
96
- WebRTCModule.transceiverStop(this._peerConnectionId, this.id)
89
+ WebRTCModule.transceiverStop(this._peerConnectionId, this.sender.id)
97
90
  .then(() => this._setStopped());
98
91
  }
99
92
 
package/src/RTCView.ts CHANGED
@@ -1,5 +1,4 @@
1
-
2
- import { requireNativeComponent } from 'react-native';
1
+ import { requireNativeComponent, ViewProps } from 'react-native';
3
2
 
4
3
  /**
5
4
  * Native prop validation was removed from RN in:
@@ -8,53 +7,58 @@ import { requireNativeComponent } from 'react-native';
8
7
  * So we list them here for documentation purposes.
9
8
  */
10
9
 
11
- /**
12
- * Indicates whether the video specified by {@link #streamURL} should be
13
- * mirrored during rendering. Commonly, applications choose to mirror the
14
- * user-facing camera.
15
- *
16
- * mirror: boolean
17
- */
18
-
19
- /**
20
- * In the fashion of
21
- * https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth
22
- * and https://www.w3.org/TR/html5/rendering.html#video-object-fit,
23
- * resembles the CSS style object-fit.
24
- *
25
- * objectFit: 'contain' | 'cover'
26
- */
10
+ interface RTCVideoViewProps extends ViewProps {
11
+ /**
12
+ * Indicates whether the video specified by {@link #streamURL} should be
13
+ * mirrored during rendering. Commonly, applications choose to mirror the
14
+ * user-facing camera.
15
+ *
16
+ * mirror: boolean
17
+ */
18
+ mirror?: boolean;
27
19
 
28
- /**
29
- * URL / id of the stream that should be rendered.
30
- *
31
- * streamURL: string
32
- */
20
+ /**
21
+ * In the fashion of
22
+ * https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth
23
+ * and https://www.w3.org/TR/html5/rendering.html#video-object-fit,
24
+ * resembles the CSS style object-fit.
25
+ *
26
+ * objectFit: 'contain' | 'cover'
27
+ */
28
+ objectFit?: 'contain' | 'cover';
33
29
 
34
- /**
35
- * Similarly to the CSS property z-index, specifies the z-order of this
36
- * RTCView in the stacking space of all RTCViews. When RTCViews overlap,
37
- * zOrder determines which one covers the other. An RTCView with a larger
38
- * zOrder generally covers an RTCView with a lower one.
39
- *
40
- * Non-overlapping RTCViews may safely share a z-order (because one does not
41
- * have to cover the other).
42
- *
43
- * The support for zOrder is platform-dependent and/or
44
- * implementation-specific. Thus, specifying a value for zOrder is to be
45
- * thought of as giving a hint rather than as imposing a requirement. For
46
- * example, video renderers such as RTCView are commonly implemented using
47
- * OpenGL and OpenGL views may have different numbers of layers in their
48
- * stacking space. Android has three: a layer bellow the window (aka
49
- * default), a layer bellow the window again but above the previous layer
50
- * (aka media overlay), and above the window. Consequently, it is advisable
51
- * to limit the number of utilized layers in the stacking space to the
52
- * minimum sufficient for the desired display. For example, a video call
53
- * application usually needs a maximum of two zOrder values: 0 for the
54
- * remote video(s) which appear in the background, and 1 for the local
55
- * video(s) which appear above the remote video(s).
56
- *
57
- * zOrder: number
58
- */
30
+ /**
31
+ * URL / id of the stream that should be rendered.
32
+ *
33
+ * streamURL: string
34
+ */
35
+ streamURL: string;
36
+ /**
37
+ * Similarly to the CSS property z-index, specifies the z-order of this
38
+ * RTCView in the stacking space of all RTCViews. When RTCViews overlap,
39
+ * zOrder determines which one covers the other. An RTCView with a larger
40
+ * zOrder generally covers an RTCView with a lower one.
41
+ *
42
+ * Non-overlapping RTCViews may safely share a z-order (because one does not
43
+ * have to cover the other).
44
+ *
45
+ * The support for zOrder is platform-dependent and/or
46
+ * implementation-specific. Thus, specifying a value for zOrder is to be
47
+ * thought of as giving a hint rather than as imposing a requirement. For
48
+ * example, video renderers such as RTCView are commonly implemented using
49
+ * OpenGL and OpenGL views may have different numbers of layers in their
50
+ * stacking space. Android has three: a layer bellow the window (aka
51
+ * default), a layer bellow the window again but above the previous layer
52
+ * (aka media overlay), and above the window. Consequently, it is advisable
53
+ * to limit the number of utilized layers in the stacking space to the
54
+ * minimum sufficient for the desired display. For example, a video call
55
+ * application usually needs a maximum of two zOrder values: 0 for the
56
+ * remote video(s) which appear in the background, and 1 for the local
57
+ * video(s) which appear above the remote video(s).
58
+ *
59
+ * zOrder: number
60
+ */
61
+ zOrder?: number;
62
+ }
59
63
 
60
- export default requireNativeComponent('RTCVideoView');
64
+ export default requireNativeComponent<RTCVideoViewProps>('RTCVideoView');