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.
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +20 -6
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +10 -0
- package/ios/RCTWebRTC/SerializeUtils.m +4 -2
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +19 -12
- package/lib/commonjs/MediaStreamTrack.js +8 -7
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js +14 -4
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +40 -26
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +2 -9
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCView.js +0 -55
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +8 -7
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/RTCIceCandidate.js +14 -4
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +40 -26
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +2 -9
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCView.js +0 -49
- package/lib/module/RTCView.js.map +1 -1
- package/lib/typescript/MediaStreamTrack.d.ts +2 -1
- package/lib/typescript/RTCIceCandidate.d.ts +5 -1
- package/lib/typescript/RTCRtpTransceiver.d.ts +0 -3
- package/lib/typescript/RTCView.d.ts +53 -46
- package/package.json +1 -1
- package/src/MediaStreamTrack.ts +7 -6
- package/src/RTCIceCandidate.ts +8 -5
- package/src/RTCPeerConnection.ts +41 -14
- package/src/RTCRtpTransceiver.ts +2 -9
- package/src/RTCView.ts +53 -49
package/src/RTCPeerConnection.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
+
newTransceivers?.forEach( t => {
|
|
192
207
|
const { transceiverOrder, transceiver } = t;
|
|
193
|
-
const newSender = new RTCRtpSender(transceiver.sender);
|
|
194
|
-
const
|
|
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(
|
|
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
|
|
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
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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.
|
|
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
|
|
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;
|
package/src/RTCRtpTransceiver.ts
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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');
|