react-native-webrtc 124.0.4 → 124.0.6
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/.nvmrc +1 -0
- package/android/build.gradle +3 -2
- package/android/consumer-rules.pro +2 -0
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +30 -3
- package/android/src/main/java/com/oney/WebRTCModule/CameraCaptureController.java +180 -73
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +53 -24
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionNotification.java +11 -19
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +0 -2
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +4 -2
- package/android/src/main/java/com/oney/WebRTCModule/RTCVideoViewManager.java +25 -0
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +6 -4
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +20 -14
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +37 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +15 -9
- package/android/src/main/java/org/webrtc/Camera1Helper.java +0 -1
- package/android/src/main/java/org/webrtc/Camera2Helper.java +4 -3
- package/ios/RCTWebRTC/CaptureController.h +3 -0
- package/ios/RCTWebRTC/CaptureController.m +12 -0
- package/ios/RCTWebRTC/I420Converter.h +22 -0
- package/ios/RCTWebRTC/I420Converter.m +164 -0
- package/ios/RCTWebRTC/PIPController.h +24 -0
- package/ios/RCTWebRTC/PIPController.m +234 -0
- package/ios/RCTWebRTC/RTCVideoViewManager.h +23 -0
- package/ios/RCTWebRTC/RTCVideoViewManager.m +131 -28
- package/ios/RCTWebRTC/SampleBufferVideoCallView.h +12 -0
- package/ios/RCTWebRTC/SampleBufferVideoCallView.m +178 -0
- package/ios/RCTWebRTC/ScreenCaptureController.m +4 -0
- package/ios/RCTWebRTC/VideoCaptureController.h +3 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +95 -30
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +4 -8
- package/ios/RCTWebRTC/WebRTCModule+RTCAudioSession.m +20 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCDataChannel.m +31 -40
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +5 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +93 -28
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +26 -55
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +11 -28
- package/ios/RCTWebRTC/WebRTCModuleOptions.h +1 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.h +9 -0
- package/ios/RCTWebRTC/videoEffects/ProcessorProvider.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.h +13 -0
- package/ios/RCTWebRTC/videoEffects/VideoEffectProcessor.m +23 -0
- package/ios/RCTWebRTC/videoEffects/VideoFrameProcessor.h +8 -0
- package/ios/RCTWebRTC.xcodeproj/project.pbxproj +4 -0
- package/lib/commonjs/Constraints.js +2 -0
- package/lib/commonjs/Constraints.js.map +1 -0
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +31 -5
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/RTCAudioSession.js +33 -0
- package/lib/commonjs/RTCAudioSession.js.map +1 -0
- package/lib/commonjs/RTCPIPView.js +38 -0
- package/lib/commonjs/RTCPIPView.js.map +1 -0
- package/lib/commonjs/RTCPeerConnection.js +2 -4
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +2 -3
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Constraints.js +2 -0
- package/lib/module/Constraints.js.map +1 -0
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +32 -6
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/RTCAudioSession.js +26 -0
- package/lib/module/RTCAudioSession.js.map +1 -0
- package/lib/module/RTCPIPView.js +26 -0
- package/lib/module/RTCPIPView.js.map +1 -0
- package/lib/module/RTCPeerConnection.js +2 -4
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCUtil.js +2 -3
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/Constraints.d.ts +19 -0
- package/lib/typescript/MediaDevices.d.ts +2 -1
- package/lib/typescript/MediaStreamTrack.d.ts +27 -5
- package/lib/typescript/RTCAudioSession.d.ts +10 -0
- package/lib/typescript/RTCPIPView.d.ts +15 -0
- package/lib/typescript/RTCPeerConnection.d.ts +2 -1
- package/lib/typescript/RTCUtil.d.ts +7 -1
- package/lib/typescript/RTCView.d.ts +58 -1
- package/lib/typescript/getUserMedia.d.ts +4 -4
- package/lib/typescript/index.d.ts +5 -3
- package/package.json +2 -1
- package/src/.eslintrc.cjs +1 -1
- package/src/Constraints.ts +21 -0
- package/src/MediaDevices.ts +2 -2
- package/src/MediaStreamTrack.ts +47 -9
- package/src/RTCAudioSession.ts +25 -0
- package/src/RTCPIPView.tsx +47 -0
- package/src/RTCPeerConnection.ts +4 -5
- package/src/RTCUtil.ts +10 -3
- package/src/RTCView.ts +60 -2
- package/src/getUserMedia.ts +4 -3
- package/src/index.ts +12 -3
- package/tools/release.sh +1 -1
- package/tsconfig.json +3 -1
- package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/RCTWebRTC.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/tools/build-webrtc.py +0 -344
|
@@ -9,6 +9,7 @@ import RTCRtpSender from './RTCRtpSender';
|
|
|
9
9
|
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
10
10
|
import RTCSessionDescription, { RTCSessionDescriptionInit } from './RTCSessionDescription';
|
|
11
11
|
import RTCTrackEvent from './RTCTrackEvent';
|
|
12
|
+
import { RTCOfferOptions } from './RTCUtil';
|
|
12
13
|
declare type RTCSignalingState = 'stable' | 'have-local-offer' | 'have-remote-offer' | 'have-local-pranswer' | 'have-remote-pranswer' | 'closed';
|
|
13
14
|
declare type RTCIceGatheringState = 'new' | 'gathering' | 'complete';
|
|
14
15
|
declare type RTCPeerConnectionState = 'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed';
|
|
@@ -61,7 +62,7 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
61
62
|
_remoteStreams: Map<string, MediaStream>;
|
|
62
63
|
_pendingTrackEvents: any[];
|
|
63
64
|
constructor(configuration?: RTCConfiguration);
|
|
64
|
-
createOffer(options
|
|
65
|
+
createOffer(options?: RTCOfferOptions): Promise<any>;
|
|
65
66
|
createAnswer(): Promise<any>;
|
|
66
67
|
setConfiguration(configuration: any): void;
|
|
67
68
|
setLocalDescription(sessionDescription?: RTCSessionDescription | RTCSessionDescriptionInit): Promise<void>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export declare type RTCOfferOptions = {
|
|
2
|
+
iceRestart?: boolean;
|
|
3
|
+
offerToReceiveAudio?: boolean;
|
|
4
|
+
offerToReceiveVideo?: boolean;
|
|
5
|
+
voiceActivityDetection?: boolean;
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
8
|
* Put together a random string in UUIDv4 format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
|
3
9
|
*
|
|
@@ -24,7 +30,7 @@ export declare function isSdpTypeValid(type: string): boolean;
|
|
|
24
30
|
* @param options - user supplied options
|
|
25
31
|
* @return Normalized options
|
|
26
32
|
*/
|
|
27
|
-
export declare function normalizeOfferOptions(options?:
|
|
33
|
+
export declare function normalizeOfferOptions(options?: RTCOfferOptions): Record<string, string>;
|
|
28
34
|
/**
|
|
29
35
|
* Normalize the given constraints in something we can work with.
|
|
30
36
|
*/
|
|
@@ -5,7 +5,7 @@ import { ViewProps } from 'react-native';
|
|
|
5
5
|
*
|
|
6
6
|
* So we list them here for documentation purposes.
|
|
7
7
|
*/
|
|
8
|
-
interface RTCVideoViewProps extends ViewProps {
|
|
8
|
+
export interface RTCVideoViewProps extends ViewProps {
|
|
9
9
|
/**
|
|
10
10
|
* Indicates whether the video specified by {@link #streamURL} should be
|
|
11
11
|
* mirrored during rendering. Commonly, applications choose to mirror the
|
|
@@ -21,6 +21,8 @@ interface RTCVideoViewProps extends ViewProps {
|
|
|
21
21
|
* resembles the CSS style object-fit.
|
|
22
22
|
*
|
|
23
23
|
* objectFit: 'contain' | 'cover'
|
|
24
|
+
*
|
|
25
|
+
* Defaults to 'cover'.
|
|
24
26
|
*/
|
|
25
27
|
objectFit?: 'contain' | 'cover';
|
|
26
28
|
/**
|
|
@@ -55,6 +57,61 @@ interface RTCVideoViewProps extends ViewProps {
|
|
|
55
57
|
* zOrder: number
|
|
56
58
|
*/
|
|
57
59
|
zOrder?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Picture in picture options for this view. Disabled if not supplied.
|
|
62
|
+
*
|
|
63
|
+
* Note: this should only be generally only used with remote video tracks,
|
|
64
|
+
* as the local camera may stop while in the background.
|
|
65
|
+
*
|
|
66
|
+
* iOS only. Requires iOS 15.0 or above, and the PIP background mode capability.
|
|
67
|
+
*/
|
|
68
|
+
iosPIP?: RTCIOSPIPOptions;
|
|
69
|
+
/**
|
|
70
|
+
* Callback function that is called when the dimensions of the video change.
|
|
71
|
+
*
|
|
72
|
+
* @param {Object} event - The event object containing the new dimensions.
|
|
73
|
+
* @param {Object} event.nativeEvent - The native event data.
|
|
74
|
+
* @param {number} event.nativeEvent.width - The width of the video.
|
|
75
|
+
* @param {number} event.nativeEvent.height - The height of the video.
|
|
76
|
+
*/
|
|
77
|
+
onDimensionsChange?: (event: {
|
|
78
|
+
nativeEvent: {
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
};
|
|
82
|
+
}) => void;
|
|
83
|
+
}
|
|
84
|
+
export interface RTCIOSPIPOptions {
|
|
85
|
+
/**
|
|
86
|
+
* Whether PIP can be launched from this view.
|
|
87
|
+
*
|
|
88
|
+
* Defaults to true.
|
|
89
|
+
*/
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The preferred size of the PIP window.
|
|
93
|
+
*/
|
|
94
|
+
preferredSize?: {
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Indicates whether Picture in Picture starts automatically
|
|
100
|
+
* when the controller embeds its content inline and the app
|
|
101
|
+
* transitions to the background.
|
|
102
|
+
*
|
|
103
|
+
* Defaults to true.
|
|
104
|
+
*
|
|
105
|
+
* See: AVPictureInPictureController.canStartPictureInPictureAutomaticallyFromInline
|
|
106
|
+
*/
|
|
107
|
+
startAutomatically?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Indicates whether Picture in Picture should stop automatically
|
|
110
|
+
* when the app returns to the foreground.
|
|
111
|
+
*
|
|
112
|
+
* Defaults to true.
|
|
113
|
+
*/
|
|
114
|
+
stopAutomatically?: boolean;
|
|
58
115
|
}
|
|
59
116
|
declare const _default: import("react-native").HostComponent<RTCVideoViewProps>;
|
|
60
117
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { MediaTrackConstraints } from './Constraints';
|
|
1
2
|
import MediaStream from './MediaStream';
|
|
2
|
-
interface Constraints {
|
|
3
|
-
audio?: boolean |
|
|
4
|
-
video?: boolean |
|
|
3
|
+
export interface Constraints {
|
|
4
|
+
audio?: boolean | MediaTrackConstraints;
|
|
5
|
+
video?: boolean | MediaTrackConstraints;
|
|
5
6
|
}
|
|
6
7
|
export default function getUserMedia(constraints?: Constraints): Promise<MediaStream>;
|
|
7
|
-
export {};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import mediaDevices from './MediaDevices';
|
|
2
2
|
import MediaStream from './MediaStream';
|
|
3
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
3
|
+
import MediaStreamTrack, { type MediaTrackSettings } from './MediaStreamTrack';
|
|
4
4
|
import permissions from './Permissions';
|
|
5
|
+
import RTCAudioSession from './RTCAudioSession';
|
|
5
6
|
import RTCErrorEvent from './RTCErrorEvent';
|
|
6
7
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
8
|
+
import RTCPIPView, { startIOSPIP, stopIOSPIP } from './RTCPIPView';
|
|
7
9
|
import RTCPeerConnection from './RTCPeerConnection';
|
|
8
10
|
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
9
11
|
import RTCRtpSender from './RTCRtpSender';
|
|
10
12
|
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
11
13
|
import RTCSessionDescription from './RTCSessionDescription';
|
|
12
|
-
import RTCView from './RTCView';
|
|
14
|
+
import RTCView, { type RTCVideoViewProps, type RTCIOSPIPOptions } from './RTCView';
|
|
13
15
|
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
14
|
-
export { RTCIceCandidate, RTCPeerConnection, RTCSessionDescription, RTCView, ScreenCapturePickerView, RTCRtpTransceiver, RTCRtpReceiver, RTCRtpSender, RTCErrorEvent, MediaStream, MediaStreamTrack, mediaDevices, permissions, registerGlobals };
|
|
16
|
+
export { RTCIceCandidate, RTCPeerConnection, RTCSessionDescription, RTCView, RTCPIPView, ScreenCapturePickerView, RTCRtpTransceiver, RTCRtpReceiver, RTCRtpSender, RTCErrorEvent, RTCAudioSession, MediaStream, MediaStreamTrack, type MediaTrackSettings, type RTCVideoViewProps, type RTCIOSPIPOptions, mediaDevices, permissions, registerGlobals, startIOSPIP, stopIOSPIP, };
|
|
15
17
|
declare function registerGlobals(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webrtc",
|
|
3
|
-
"version": "124.0.
|
|
3
|
+
"version": "124.0.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"lint": "eslint --max-warnings 0 . && tsc --noEmit",
|
|
32
|
+
"lintfix": "eslint --max-warnings 0 --fix . && tsc --noEmit",
|
|
32
33
|
"prepare": "husky install && bob build",
|
|
33
34
|
"format": "tools/format.sh"
|
|
34
35
|
},
|
package/src/.eslintrc.cjs
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export type MediaTrackConstraints = {
|
|
3
|
+
width?: ConstrainNumber;
|
|
4
|
+
height?: ConstrainNumber;
|
|
5
|
+
frameRate?: ConstrainNumber;
|
|
6
|
+
facingMode?: ConstrainString;
|
|
7
|
+
deviceId?: ConstrainString;
|
|
8
|
+
groupId?: ConstrainString;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type ConstrainNumber = number | {
|
|
12
|
+
exact?: number,
|
|
13
|
+
ideal?: number,
|
|
14
|
+
max?: number,
|
|
15
|
+
min?: number,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ConstrainString = string | {
|
|
19
|
+
exact?: string,
|
|
20
|
+
ideal?: string,
|
|
21
|
+
}
|
package/src/MediaDevices.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EventTarget, Event, defineEventAttribute } from 'event-target-shim/inde
|
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import getDisplayMedia from './getDisplayMedia';
|
|
5
|
-
import getUserMedia from './getUserMedia';
|
|
5
|
+
import getUserMedia, { Constraints } from './getUserMedia';
|
|
6
6
|
|
|
7
7
|
const { WebRTCModule } = NativeModules;
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ class MediaDevices extends EventTarget<MediaDevicesEventMap> {
|
|
|
37
37
|
* @param {*} constraints
|
|
38
38
|
* @returns {Promise}
|
|
39
39
|
*/
|
|
40
|
-
getUserMedia(constraints) {
|
|
40
|
+
getUserMedia(constraints: Constraints) {
|
|
41
41
|
return getUserMedia(constraints);
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/MediaStreamTrack.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EventTarget, Event, defineEventAttribute } from 'event-target-shim/index';
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { MediaTrackConstraints } from './Constraints';
|
|
4
5
|
import { addListener, removeListener } from './EventEmitter';
|
|
5
6
|
import Logger from './Logger';
|
|
6
|
-
import { deepClone } from './RTCUtil';
|
|
7
|
+
import { deepClone, normalizeConstraints } from './RTCUtil';
|
|
7
8
|
|
|
8
9
|
const log = new Logger('pc');
|
|
9
10
|
const { WebRTCModule } = NativeModules;
|
|
@@ -22,6 +23,15 @@ export type MediaStreamTrackInfo = {
|
|
|
22
23
|
readyState: MediaStreamTrackState;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
export type MediaTrackSettings = {
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
frameRate?: number;
|
|
30
|
+
facingMode?: string;
|
|
31
|
+
deviceId?: string;
|
|
32
|
+
groupId?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
type MediaStreamTrackEventMap = {
|
|
26
36
|
ended: Event<'ended'>;
|
|
27
37
|
mute: Event<'mute'>;
|
|
@@ -29,9 +39,9 @@ type MediaStreamTrackEventMap = {
|
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventMap> {
|
|
32
|
-
_constraints:
|
|
42
|
+
_constraints: MediaTrackConstraints;
|
|
33
43
|
_enabled: boolean;
|
|
34
|
-
_settings:
|
|
44
|
+
_settings: MediaTrackSettings;
|
|
35
45
|
_muted: boolean;
|
|
36
46
|
_peerConnectionId: number;
|
|
37
47
|
_readyState: MediaStreamTrackState;
|
|
@@ -97,6 +107,8 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
|
|
|
97
107
|
*
|
|
98
108
|
* This is how the reference application (AppRTCMobile) implements camera
|
|
99
109
|
* switching.
|
|
110
|
+
*
|
|
111
|
+
* @deprecated Use applyConstraints instead.
|
|
100
112
|
*/
|
|
101
113
|
_switchCamera(): void {
|
|
102
114
|
if (this.remote) {
|
|
@@ -107,10 +119,15 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
|
|
|
107
119
|
throw new Error('Only implemented for video tracks');
|
|
108
120
|
}
|
|
109
121
|
|
|
110
|
-
|
|
122
|
+
const constraints = deepClone(this._settings);
|
|
123
|
+
|
|
124
|
+
delete constraints.deviceId;
|
|
125
|
+
constraints.facingMode = this._settings.facingMode === 'user' ? 'environment' : 'user';
|
|
126
|
+
|
|
127
|
+
this.applyConstraints(constraints);
|
|
111
128
|
}
|
|
112
129
|
|
|
113
|
-
|
|
130
|
+
_setVideoEffects(names: string[]) {
|
|
114
131
|
if (this.remote) {
|
|
115
132
|
throw new Error('Not implemented for remote tracks');
|
|
116
133
|
}
|
|
@@ -119,7 +136,11 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
|
|
|
119
136
|
throw new Error('Only implemented for video tracks');
|
|
120
137
|
}
|
|
121
138
|
|
|
122
|
-
WebRTCModule.
|
|
139
|
+
WebRTCModule.mediaStreamTrackSetVideoEffects(this.id, names);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_setVideoEffect(name: string) {
|
|
143
|
+
this._setVideoEffects([ name ]);
|
|
123
144
|
}
|
|
124
145
|
|
|
125
146
|
/**
|
|
@@ -150,8 +171,25 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
|
|
|
150
171
|
WebRTCModule.mediaStreamTrackSetVolume(this.remote ? this._peerConnectionId : -1, this.id, volume);
|
|
151
172
|
}
|
|
152
173
|
|
|
153
|
-
|
|
154
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Applies a new set of constraints to the track.
|
|
176
|
+
*
|
|
177
|
+
* @param constraints An object listing the constraints
|
|
178
|
+
* to apply to the track's constrainable properties; any existing
|
|
179
|
+
* constraints are replaced with the new values specified, and any
|
|
180
|
+
* constrainable properties not included are restored to their default
|
|
181
|
+
* constraints. If this parameter is omitted, all currently set custom
|
|
182
|
+
* constraints are cleared.
|
|
183
|
+
*/
|
|
184
|
+
async applyConstraints(constraints?: MediaTrackConstraints): Promise<void> {
|
|
185
|
+
if (this.kind !== 'video') {
|
|
186
|
+
throw new Error('Only implemented for video tracks');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const normalized = normalizeConstraints({ video: constraints ?? true });
|
|
190
|
+
|
|
191
|
+
this._settings = await WebRTCModule.mediaStreamTrackApplyConstraints(this.id, normalized.video);
|
|
192
|
+
this._constraints = constraints ?? {};
|
|
155
193
|
}
|
|
156
194
|
|
|
157
195
|
clone(): never {
|
|
@@ -166,7 +204,7 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
|
|
|
166
204
|
return deepClone(this._constraints);
|
|
167
205
|
}
|
|
168
206
|
|
|
169
|
-
getSettings() {
|
|
207
|
+
getSettings(): MediaTrackSettings {
|
|
170
208
|
return deepClone(this._settings);
|
|
171
209
|
}
|
|
172
210
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const { WebRTCModule } = NativeModules;
|
|
4
|
+
|
|
5
|
+
export default class RTCAudioSession {
|
|
6
|
+
/**
|
|
7
|
+
* To be called when CallKit activates the audio session.
|
|
8
|
+
*/
|
|
9
|
+
static audioSessionDidActivate() {
|
|
10
|
+
// Only valid for iOS
|
|
11
|
+
if (Platform.OS === 'ios') {
|
|
12
|
+
WebRTCModule.audioSessionDidActivate();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* To be called when CallKit deactivates the audio session.
|
|
18
|
+
*/
|
|
19
|
+
static audioSessionDidDeactivate() {
|
|
20
|
+
// Only valid for iOS
|
|
21
|
+
if (Platform.OS === 'ios') {
|
|
22
|
+
WebRTCModule.audioSessionDidDeactivate();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Component, forwardRef } from 'react';
|
|
2
|
+
import ReactNative, { UIManager } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import RTCView, { RTCIOSPIPOptions, RTCVideoViewProps } from './RTCView';
|
|
5
|
+
|
|
6
|
+
export interface RTCPIPViewProps extends RTCVideoViewProps {
|
|
7
|
+
iosPIP?: RTCIOSPIPOptions & {
|
|
8
|
+
fallbackView?: Component;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type RTCViewInstance = InstanceType<typeof RTCView>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A convenience wrapper around RTCView to handle the fallback view as a prop.
|
|
16
|
+
*/
|
|
17
|
+
const RTCPIPView = forwardRef<RTCViewInstance, RTCPIPViewProps>((props, ref) => {
|
|
18
|
+
const rtcViewProps = { ...props };
|
|
19
|
+
const fallbackView = rtcViewProps.iosPIP?.fallbackView;
|
|
20
|
+
|
|
21
|
+
delete rtcViewProps.iosPIP?.fallbackView;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<RTCView ref={ref}
|
|
25
|
+
{...rtcViewProps}>
|
|
26
|
+
{fallbackView}
|
|
27
|
+
</RTCView>
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export function startIOSPIP(ref) {
|
|
32
|
+
UIManager.dispatchViewManagerCommand(
|
|
33
|
+
ReactNative.findNodeHandle(ref.current),
|
|
34
|
+
UIManager.getViewManagerConfig('RTCVideoView').Commands.startIOSPIP,
|
|
35
|
+
[]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function stopIOSPIP(ref) {
|
|
40
|
+
UIManager.dispatchViewManagerCommand(
|
|
41
|
+
ReactNative.findNodeHandle(ref.current),
|
|
42
|
+
UIManager.getViewManagerConfig('RTCVideoView').Commands.stopIOSPIP,
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default RTCPIPView;
|
package/src/RTCPeerConnection.ts
CHANGED
|
@@ -18,6 +18,7 @@ import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
|
18
18
|
import RTCSessionDescription, { RTCSessionDescriptionInit } from './RTCSessionDescription';
|
|
19
19
|
import RTCTrackEvent from './RTCTrackEvent';
|
|
20
20
|
import * as RTCUtil from './RTCUtil';
|
|
21
|
+
import { RTCOfferOptions } from './RTCUtil';
|
|
21
22
|
|
|
22
23
|
const log = new Logger('pc');
|
|
23
24
|
const { WebRTCModule } = NativeModules;
|
|
@@ -132,7 +133,7 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
132
133
|
log.debug(`${this._pcId} ctor`);
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
async createOffer(options) {
|
|
136
|
+
async createOffer(options?:RTCOfferOptions) {
|
|
136
137
|
log.debug(`${this._pcId} createOffer`);
|
|
137
138
|
|
|
138
139
|
const {
|
|
@@ -535,13 +536,11 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
|
|
|
535
536
|
}
|
|
536
537
|
|
|
537
538
|
getSenders(): RTCRtpSender[] {
|
|
538
|
-
|
|
539
|
-
return this._transceivers.map(e => !e.transceiver.stopped && e.transceiver.sender).filter(Boolean);
|
|
539
|
+
return this._transceivers.filter(e => !e.transceiver.stopped).map(e => e.transceiver.sender);
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
getReceivers(): RTCRtpReceiver[] {
|
|
543
|
-
|
|
544
|
-
return this._transceivers.map(e => !e.transceiver.stopped && e.transceiver.receiver).filter(Boolean);
|
|
543
|
+
return this._transceivers.filter(e => !e.transceiver.stopped).map(e => e.transceiver.receiver);
|
|
545
544
|
}
|
|
546
545
|
|
|
547
546
|
close(): void {
|
package/src/RTCUtil.ts
CHANGED
|
@@ -12,6 +12,13 @@ const FACING_MODES = [ 'user', 'environment' ];
|
|
|
12
12
|
|
|
13
13
|
const ASPECT_RATIO = 16 / 9;
|
|
14
14
|
|
|
15
|
+
export type RTCOfferOptions = {
|
|
16
|
+
iceRestart?:boolean;
|
|
17
|
+
offerToReceiveAudio?: boolean;
|
|
18
|
+
offerToReceiveVideo?: boolean;
|
|
19
|
+
voiceActivityDetection?:boolean
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
const STANDARD_OFFER_OPTIONS = {
|
|
16
23
|
icerestart: 'IceRestart',
|
|
17
24
|
offertoreceiveaudio: 'OfferToReceiveAudio',
|
|
@@ -157,10 +164,10 @@ export function isSdpTypeValid(type: string): boolean {
|
|
|
157
164
|
* @param options - user supplied options
|
|
158
165
|
* @return Normalized options
|
|
159
166
|
*/
|
|
160
|
-
export function normalizeOfferOptions(options
|
|
161
|
-
const newOptions = {};
|
|
167
|
+
export function normalizeOfferOptions(options?: RTCOfferOptions) {
|
|
168
|
+
const newOptions: Record<string,string> = {};
|
|
162
169
|
|
|
163
|
-
if (
|
|
170
|
+
if (typeof options !== 'object') {
|
|
164
171
|
return newOptions;
|
|
165
172
|
}
|
|
166
173
|
|
package/src/RTCView.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { requireNativeComponent, ViewProps } from 'react-native';
|
|
|
6
6
|
*
|
|
7
7
|
* So we list them here for documentation purposes.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
interface RTCVideoViewProps extends ViewProps {
|
|
9
|
+
export interface RTCVideoViewProps extends ViewProps {
|
|
11
10
|
/**
|
|
12
11
|
* Indicates whether the video specified by {@link #streamURL} should be
|
|
13
12
|
* mirrored during rendering. Commonly, applications choose to mirror the
|
|
@@ -24,6 +23,8 @@ interface RTCVideoViewProps extends ViewProps {
|
|
|
24
23
|
* resembles the CSS style object-fit.
|
|
25
24
|
*
|
|
26
25
|
* objectFit: 'contain' | 'cover'
|
|
26
|
+
*
|
|
27
|
+
* Defaults to 'cover'.
|
|
27
28
|
*/
|
|
28
29
|
objectFit?: 'contain' | 'cover';
|
|
29
30
|
|
|
@@ -59,6 +60,63 @@ interface RTCVideoViewProps extends ViewProps {
|
|
|
59
60
|
* zOrder: number
|
|
60
61
|
*/
|
|
61
62
|
zOrder?: number;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Picture in picture options for this view. Disabled if not supplied.
|
|
67
|
+
*
|
|
68
|
+
* Note: this should only be generally only used with remote video tracks,
|
|
69
|
+
* as the local camera may stop while in the background.
|
|
70
|
+
*
|
|
71
|
+
* iOS only. Requires iOS 15.0 or above, and the PIP background mode capability.
|
|
72
|
+
*/
|
|
73
|
+
iosPIP?: RTCIOSPIPOptions;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Callback function that is called when the dimensions of the video change.
|
|
77
|
+
*
|
|
78
|
+
* @param {Object} event - The event object containing the new dimensions.
|
|
79
|
+
* @param {Object} event.nativeEvent - The native event data.
|
|
80
|
+
* @param {number} event.nativeEvent.width - The width of the video.
|
|
81
|
+
* @param {number} event.nativeEvent.height - The height of the video.
|
|
82
|
+
*/
|
|
83
|
+
onDimensionsChange?: (event: { nativeEvent: { width: number; height: number } }) => void;
|
|
62
84
|
}
|
|
63
85
|
|
|
86
|
+
export interface RTCIOSPIPOptions {
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Whether PIP can be launched from this view.
|
|
90
|
+
*
|
|
91
|
+
* Defaults to true.
|
|
92
|
+
*/
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The preferred size of the PIP window.
|
|
97
|
+
*/
|
|
98
|
+
preferredSize?: {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Indicates whether Picture in Picture starts automatically
|
|
105
|
+
* when the controller embeds its content inline and the app
|
|
106
|
+
* transitions to the background.
|
|
107
|
+
*
|
|
108
|
+
* Defaults to true.
|
|
109
|
+
*
|
|
110
|
+
* See: AVPictureInPictureController.canStartPictureInPictureAutomaticallyFromInline
|
|
111
|
+
*/
|
|
112
|
+
startAutomatically?: boolean;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Indicates whether Picture in Picture should stop automatically
|
|
116
|
+
* when the app returns to the foreground.
|
|
117
|
+
*
|
|
118
|
+
* Defaults to true.
|
|
119
|
+
*/
|
|
120
|
+
stopAutomatically?: boolean;
|
|
121
|
+
}
|
|
64
122
|
export default requireNativeComponent<RTCVideoViewProps>('RTCVideoView');
|
package/src/getUserMedia.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
import { MediaTrackConstraints } from './Constraints';
|
|
5
6
|
import MediaStream from './MediaStream';
|
|
6
7
|
import MediaStreamError from './MediaStreamError';
|
|
7
8
|
import permissions from './Permissions';
|
|
@@ -9,9 +10,9 @@ import * as RTCUtil from './RTCUtil';
|
|
|
9
10
|
|
|
10
11
|
const { WebRTCModule } = NativeModules;
|
|
11
12
|
|
|
12
|
-
interface Constraints {
|
|
13
|
-
audio?: boolean |
|
|
14
|
-
video?: boolean |
|
|
13
|
+
export interface Constraints {
|
|
14
|
+
audio?: boolean | MediaTrackConstraints;
|
|
15
|
+
video?: boolean | MediaTrackConstraints;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export default function getUserMedia(constraints: Constraints = {}): Promise<MediaStream> {
|
package/src/index.ts
CHANGED
|
@@ -12,17 +12,19 @@ import { setupNativeEvents } from './EventEmitter';
|
|
|
12
12
|
import Logger from './Logger';
|
|
13
13
|
import mediaDevices from './MediaDevices';
|
|
14
14
|
import MediaStream from './MediaStream';
|
|
15
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
15
|
+
import MediaStreamTrack, { type MediaTrackSettings } from './MediaStreamTrack';
|
|
16
16
|
import MediaStreamTrackEvent from './MediaStreamTrackEvent';
|
|
17
17
|
import permissions from './Permissions';
|
|
18
|
+
import RTCAudioSession from './RTCAudioSession';
|
|
18
19
|
import RTCErrorEvent from './RTCErrorEvent';
|
|
19
20
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
21
|
+
import RTCPIPView, { startIOSPIP, stopIOSPIP } from './RTCPIPView';
|
|
20
22
|
import RTCPeerConnection from './RTCPeerConnection';
|
|
21
23
|
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
22
24
|
import RTCRtpSender from './RTCRtpSender';
|
|
23
25
|
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
24
26
|
import RTCSessionDescription from './RTCSessionDescription';
|
|
25
|
-
import RTCView from './RTCView';
|
|
27
|
+
import RTCView, { type RTCVideoViewProps, type RTCIOSPIPOptions } from './RTCView';
|
|
26
28
|
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
27
29
|
|
|
28
30
|
Logger.enable(`${Logger.ROOT_PREFIX}:*`);
|
|
@@ -35,16 +37,23 @@ export {
|
|
|
35
37
|
RTCPeerConnection,
|
|
36
38
|
RTCSessionDescription,
|
|
37
39
|
RTCView,
|
|
40
|
+
RTCPIPView,
|
|
38
41
|
ScreenCapturePickerView,
|
|
39
42
|
RTCRtpTransceiver,
|
|
40
43
|
RTCRtpReceiver,
|
|
41
44
|
RTCRtpSender,
|
|
42
45
|
RTCErrorEvent,
|
|
46
|
+
RTCAudioSession,
|
|
43
47
|
MediaStream,
|
|
44
48
|
MediaStreamTrack,
|
|
49
|
+
type MediaTrackSettings,
|
|
50
|
+
type RTCVideoViewProps,
|
|
51
|
+
type RTCIOSPIPOptions,
|
|
45
52
|
mediaDevices,
|
|
46
53
|
permissions,
|
|
47
|
-
registerGlobals
|
|
54
|
+
registerGlobals,
|
|
55
|
+
startIOSPIP,
|
|
56
|
+
stopIOSPIP,
|
|
48
57
|
};
|
|
49
58
|
|
|
50
59
|
declare const global: any;
|
package/tools/release.sh
CHANGED
|
@@ -33,7 +33,7 @@ git_log_cmd='git log '$last_version'..HEAD --no-merges --pretty=format:%h%x20%s%
|
|
|
33
33
|
|
|
34
34
|
# --- commit with change logs
|
|
35
35
|
git add package.json package-lock.json
|
|
36
|
-
git commit -m "release ${version}" -m "$($git_log_cmd)"
|
|
36
|
+
git commit -m "release: ${version}" -m "$($git_log_cmd)"
|
|
37
37
|
git tag -a "$version" -m "$($git_log_cmd)"
|
|
38
38
|
|
|
39
39
|
# --- success messages
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": ["src/**/*.ts"],
|
|
2
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "es6",
|
|
5
5
|
"module": "commonjs",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"jsx": "react-native",
|
|
10
10
|
"resolveJsonModule": true,
|
|
11
11
|
"noImplicitAny": false,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
12
14
|
},
|
|
13
15
|
"exclude": ["node_modules"]
|
|
14
16
|
}
|
package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>RCTWebRTC.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|