react-native-webrtc 106.0.0-beta.2 → 106.0.0-beta.4
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/.eslintignore +6 -0
- package/.github/stale.yml +15 -0
- package/.github/workflows/ci.yml +17 -0
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +36 -0
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +65 -26
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +30 -1
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/ProcessorProvider.java +37 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +57 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessor.java +19 -0
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoFrameProcessorFactoryInterface.java +13 -0
- package/ios/RCTWebRTC/SerializeUtils.m +18 -5
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +53 -5
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +5 -4
- package/ios/RCTWebRTC.xcodeproj/project.pbxproj +46 -9
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/RCTWebRTC.xcworkspace/contents.xcworkspacedata +10 -0
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +2 -2
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +3 -3
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +15 -3
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/Permissions.js +3 -3
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCDataChannel.js +6 -5
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +1 -1
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +139 -58
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js +7 -0
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js +10 -2
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js +22 -4
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +21 -10
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js +8 -0
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js +25 -3
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js +21 -10
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js +10 -4
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js +3 -3
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +13 -0
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js +3 -3
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +12 -93
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +1 -1
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +2 -2
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +14 -2
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/Permissions.js +3 -3
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCDataChannel.js +4 -3
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +2 -2
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +135 -55
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js +7 -0
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js +10 -2
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js +22 -4
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +21 -10
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js +8 -0
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js +20 -3
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js +1 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js +18 -8
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js +10 -5
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js +3 -3
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCUtil.js +11 -0
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +8 -26
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/EventEmitter.d.ts +4 -3
- package/lib/typescript/MediaStreamTrack.d.ts +1 -0
- package/lib/typescript/Permissions.d.ts +1 -1
- package/lib/typescript/RTCDataChannel.d.ts +2 -1
- package/lib/typescript/RTCErrorEvent.d.ts +1 -1
- package/lib/typescript/RTCPeerConnection.d.ts +7 -8
- package/lib/typescript/RTCRtcpParameters.d.ts +6 -4
- package/lib/typescript/RTCRtpCodecParameters.d.ts +11 -9
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +13 -11
- package/lib/typescript/RTCRtpHeaderExtension.d.ts +7 -5
- package/lib/typescript/RTCRtpParameters.d.ts +9 -8
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +1 -1
- package/lib/typescript/RTCRtpReceiver.d.ts +9 -4
- package/lib/typescript/RTCRtpSendParameters.d.ts +9 -10
- package/lib/typescript/RTCRtpSender.d.ts +3 -3
- package/lib/typescript/RTCRtpTransceiver.d.ts +1 -1
- package/lib/typescript/RTCSessionDescription.d.ts +6 -8
- package/lib/typescript/RTCUtil.d.ts +7 -0
- package/lib/typescript/index.d.ts +6 -15
- package/package.json +7 -4
- package/react-native-webrtc.podspec +1 -2
- package/src/.eslintrc.cjs +67 -0
- package/src/EventEmitter.ts +5 -4
- package/src/Logger.ts +1 -1
- package/src/MediaDevices.ts +2 -2
- package/src/MediaStream.ts +13 -4
- package/src/MediaStreamTrack.ts +21 -5
- package/src/Permissions.ts +12 -5
- package/src/RTCDataChannel.ts +17 -5
- package/src/RTCErrorEvent.ts +9 -9
- package/src/RTCPeerConnection.ts +189 -91
- package/src/RTCRtcpParameters.ts +21 -12
- package/src/RTCRtpCapabilities.ts +15 -4
- package/src/RTCRtpCodecParameters.ts +34 -13
- package/src/RTCRtpEncodingParameters.ts +37 -23
- package/src/RTCRtpHeaderExtension.ts +15 -6
- package/src/RTCRtpParameters.ts +26 -11
- package/src/RTCRtpReceiveParameters.ts +3 -3
- package/src/RTCRtpReceiver.ts +26 -10
- package/src/RTCRtpSendParameters.ts +29 -17
- package/src/RTCRtpSender.ts +14 -13
- package/src/RTCRtpTransceiver.ts +11 -7
- package/src/RTCSessionDescription.ts +7 -2
- package/src/RTCUtil.ts +24 -4
- package/src/getDisplayMedia.ts +1 -1
- package/src/getUserMedia.ts +9 -2
- package/src/index.ts +9 -34
- package/tools/downloadWebRTC.js +7 -5
- package/.prettierignore +0 -9
- package/.prettierrc.json +0 -10
- package/lib/commonjs/typings.d.js +0 -2
- package/lib/commonjs/typings.d.js.map +0 -1
- package/lib/module/typings.d.js +0 -2
- package/lib/module/typings.d.js.map +0 -1
- package/src/typings.d.ts +0 -1
|
@@ -1,23 +1,44 @@
|
|
|
1
|
+
export interface RTCRtpCodecParametersInit {
|
|
2
|
+
payloadType: number;
|
|
3
|
+
clockRate: number;
|
|
4
|
+
mimeType: string;
|
|
5
|
+
channels?: number;
|
|
6
|
+
sdpFmtpLine?: string;
|
|
7
|
+
}
|
|
1
8
|
|
|
2
9
|
export default class RTCRtpCodecParameters {
|
|
3
10
|
readonly payloadType: number;
|
|
4
11
|
readonly clockRate: number;
|
|
5
|
-
readonly channels: number;
|
|
6
12
|
readonly mimeType: string;
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
clockRate: number,
|
|
12
|
-
channels: number,
|
|
13
|
-
mimeType: string,
|
|
14
|
-
sdpFmtpLine: Map<String, String>
|
|
15
|
-
}) {
|
|
13
|
+
readonly channels: number | null;
|
|
14
|
+
readonly sdpFmtpLine: string | null;
|
|
15
|
+
|
|
16
|
+
constructor(init: RTCRtpCodecParametersInit) {
|
|
16
17
|
this.payloadType = init.payloadType;
|
|
17
18
|
this.clockRate = init.clockRate;
|
|
18
|
-
this.channels = init.channels;
|
|
19
19
|
this.mimeType = init.mimeType;
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
this.channels = init.channels ? init.channels : null;
|
|
22
|
+
this.sdpFmtpLine = init.sdpFmtpLine ? init.sdpFmtpLine : null;
|
|
23
|
+
|
|
21
24
|
Object.freeze(this);
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
toJSON(): RTCRtpCodecParametersInit {
|
|
28
|
+
const obj = {
|
|
29
|
+
payloadType: this.payloadType,
|
|
30
|
+
clockRate: this.clockRate,
|
|
31
|
+
mimeType: this.mimeType
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (this.channels !== null) {
|
|
35
|
+
obj['channels'] = this.channels;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.sdpFmtpLine !== null) {
|
|
39
|
+
obj['sdpFmtpLine'] = this.sdpFmtpLine;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
+
export interface RTCRtpEncodingParametersInit {
|
|
2
|
+
active: boolean,
|
|
3
|
+
rid?: string;
|
|
4
|
+
maxFramerate?: number;
|
|
5
|
+
maxBitrate?: number;
|
|
6
|
+
scaleResolutionDownBy?: number;
|
|
7
|
+
}
|
|
1
8
|
|
|
2
9
|
export default class RTCRtpEncodingParameters {
|
|
3
10
|
readonly active: boolean;
|
|
11
|
+
_rid: string | null;
|
|
4
12
|
_maxFramerate: number | null;
|
|
5
13
|
_maxBitrate: number | null;
|
|
6
14
|
_scaleResolutionDownBy: number | null;
|
|
7
15
|
|
|
8
|
-
constructor(init: {
|
|
9
|
-
active: boolean,
|
|
10
|
-
maxFramerate?: number;
|
|
11
|
-
maxBitrate?: number;
|
|
12
|
-
scaleResolutionDownBy?: number;
|
|
13
|
-
}) {
|
|
16
|
+
constructor(init: RTCRtpEncodingParametersInit) {
|
|
14
17
|
this.active = init.active;
|
|
18
|
+
this._rid = init.rid ?? null;
|
|
15
19
|
this._maxBitrate = init.maxBitrate ?? null;
|
|
16
20
|
this._maxFramerate = init.maxFramerate ?? null;
|
|
17
21
|
this._scaleResolutionDownBy = init.scaleResolutionDownBy ?? null;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
get
|
|
21
|
-
return this.
|
|
24
|
+
get rid() {
|
|
25
|
+
return this._rid;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
get
|
|
25
|
-
return this.
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get scaleResolutionDownBy() {
|
|
29
|
-
return this._scaleResolutionDownBy;
|
|
28
|
+
get maxFramerate() {
|
|
29
|
+
return this._maxFramerate;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
set maxFramerate(framerate) {
|
|
@@ -34,34 +34,48 @@ export default class RTCRtpEncodingParameters {
|
|
|
34
34
|
this._maxFramerate = framerate;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
get maxBitrate() {
|
|
39
|
+
return this._maxBitrate;
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
set maxBitrate(bitrate) {
|
|
39
43
|
if (bitrate && bitrate > 0) {
|
|
40
44
|
this._maxBitrate = bitrate;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
|
|
48
|
+
get scaleResolutionDownBy() {
|
|
49
|
+
return this._scaleResolutionDownBy;
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
set scaleResolutionDownBy(resolutionScale) {
|
|
45
53
|
if (resolutionScale && resolutionScale >= 1) {
|
|
46
54
|
this._scaleResolutionDownBy = resolutionScale;
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
toJSON() {
|
|
51
|
-
|
|
58
|
+
toJSON(): RTCRtpEncodingParametersInit {
|
|
59
|
+
const obj = {
|
|
52
60
|
active: this.active,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (this._rid !== null) {
|
|
64
|
+
obj['rid'] = this._rid;
|
|
53
65
|
}
|
|
66
|
+
|
|
54
67
|
if (this._maxBitrate !== null) {
|
|
55
68
|
obj['maxBitrate'] = this._maxBitrate;
|
|
56
|
-
}
|
|
69
|
+
}
|
|
57
70
|
|
|
58
71
|
if (this._maxFramerate !== null) {
|
|
59
72
|
obj['maxFramerate'] = this._maxFramerate;
|
|
60
|
-
}
|
|
61
|
-
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
if (this._scaleResolutionDownBy !== null) {
|
|
63
76
|
obj['scaleResolutionDownBy'] = this._scaleResolutionDownBy;
|
|
64
|
-
}
|
|
77
|
+
}
|
|
78
|
+
|
|
65
79
|
return obj;
|
|
66
80
|
}
|
|
67
|
-
}
|
|
81
|
+
}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
+
export interface RTCRtpHeaderExtensionInit {
|
|
2
|
+
id: number;
|
|
3
|
+
uri: string;
|
|
4
|
+
encrypted: boolean;
|
|
5
|
+
}
|
|
1
6
|
|
|
2
7
|
export default class RTCRtpHeaderExtension {
|
|
3
8
|
readonly id: number;
|
|
4
9
|
readonly uri: string;
|
|
5
10
|
readonly encrypted: boolean;
|
|
6
11
|
|
|
7
|
-
constructor(init: {
|
|
8
|
-
id: number,
|
|
9
|
-
uri: string,
|
|
10
|
-
encrypted: boolean
|
|
11
|
-
}) {
|
|
12
|
+
constructor(init: RTCRtpHeaderExtensionInit) {
|
|
12
13
|
this.id = init.id;
|
|
13
14
|
this.uri = init.uri;
|
|
14
15
|
this.encrypted = init.encrypted;
|
|
16
|
+
|
|
15
17
|
Object.freeze(this);
|
|
16
18
|
}
|
|
17
|
-
}
|
|
18
19
|
|
|
20
|
+
toJSON(): RTCRtpHeaderExtensionInit {
|
|
21
|
+
return {
|
|
22
|
+
id: this.id,
|
|
23
|
+
uri: this.uri,
|
|
24
|
+
encrypted: this.encrypted
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/RTCRtpParameters.ts
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
import RTCRtcpParameters from
|
|
2
|
-
import RTCRtpCodecParameters from
|
|
3
|
-
import RTCRtpHeaderExtension from
|
|
1
|
+
import RTCRtcpParameters, { RTCRtcpParametersInit } from './RTCRtcpParameters';
|
|
2
|
+
import RTCRtpCodecParameters, { RTCRtpCodecParametersInit } from './RTCRtpCodecParameters';
|
|
3
|
+
import RTCRtpHeaderExtension, { RTCRtpHeaderExtensionInit } from './RTCRtpHeaderExtension';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
codecs:
|
|
8
|
-
headerExtensions:
|
|
9
|
-
rtcp:
|
|
6
|
+
export interface RTCRtpParametersInit {
|
|
7
|
+
codecs: RTCRtpCodecParametersInit[],
|
|
8
|
+
headerExtensions: RTCRtpHeaderExtensionInit[],
|
|
9
|
+
rtcp: RTCRtcpParametersInit
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export default class RTCRtpParameters {
|
|
13
13
|
readonly codecs: RTCRtpCodecParameters[] = [];
|
|
14
14
|
readonly headerExtensions: RTCRtpHeaderExtension[] = [];
|
|
15
15
|
readonly rtcp: RTCRtcpParameters;
|
|
16
|
+
|
|
16
17
|
constructor(init: RTCRtpParametersInit) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
for (const codec of init.codecs) {
|
|
19
|
+
this.codecs.push(new RTCRtpCodecParameters(codec));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
for (const ext of init.headerExtensions) {
|
|
23
|
+
this.headerExtensions.push(new RTCRtpHeaderExtension(ext));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.rtcp = new RTCRtcpParameters(init.rtcp);
|
|
20
27
|
}
|
|
21
|
-
|
|
28
|
+
|
|
29
|
+
toJSON(): RTCRtpParametersInit {
|
|
30
|
+
return {
|
|
31
|
+
codecs: this.codecs.map(c => c.toJSON()),
|
|
32
|
+
headerExtensions: this.headerExtensions.map(he => he.toJSON()),
|
|
33
|
+
rtcp: this.rtcp.toJSON()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import RTCRtpParameters, { RTCRtpParametersInit } from
|
|
2
|
-
export default class RTCRtpReceiveParameters extends RTCRtpParameters {
|
|
1
|
+
import RTCRtpParameters, { RTCRtpParametersInit } from './RTCRtpParameters';
|
|
3
2
|
|
|
3
|
+
export default class RTCRtpReceiveParameters extends RTCRtpParameters {
|
|
4
4
|
constructor(init: RTCRtpParametersInit) {
|
|
5
5
|
super(init);
|
|
6
6
|
}
|
|
7
|
-
}
|
|
7
|
+
}
|
package/src/RTCRtpReceiver.ts
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import MediaStreamTrack from './MediaStreamTrack';
|
|
3
|
-
import RTCRtpCapabilities, {DEFAULT_AUDIO_CAPABILITIES, receiverCapabilities } from './RTCRtpCapabilities';
|
|
2
|
+
import RTCRtpCapabilities, { DEFAULT_AUDIO_CAPABILITIES, receiverCapabilities } from './RTCRtpCapabilities';
|
|
3
|
+
import { RTCRtpParametersInit } from './RTCRtpParameters';
|
|
4
|
+
import RTCRtpReceiveParameters from './RTCRtpReceiveParameters';
|
|
4
5
|
|
|
5
|
-
const { WebRTCModule } = NativeModules;
|
|
6
6
|
|
|
7
7
|
export default class RTCRtpReceiver {
|
|
8
8
|
_id: string;
|
|
9
9
|
_peerConnectionId: number;
|
|
10
|
-
_track: MediaStreamTrack;
|
|
10
|
+
_track: MediaStreamTrack | null = null;
|
|
11
|
+
_rtpParameters: RTCRtpReceiveParameters;
|
|
11
12
|
|
|
12
|
-
constructor(info: {
|
|
13
|
+
constructor(info: {
|
|
14
|
+
peerConnectionId: number,
|
|
15
|
+
id: string,
|
|
16
|
+
track?: MediaStreamTrack,
|
|
17
|
+
rtpParameters: RTCRtpParametersInit
|
|
18
|
+
}) {
|
|
13
19
|
this._id = info.id;
|
|
14
20
|
this._peerConnectionId = info.peerConnectionId;
|
|
15
|
-
this.
|
|
21
|
+
this._rtpParameters = new RTCRtpReceiveParameters(info.rtpParameters);
|
|
22
|
+
|
|
23
|
+
if (info.track) {
|
|
24
|
+
this._track = info.track;
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
static getCapabilities(kind:
|
|
19
|
-
if (kind
|
|
20
|
-
|
|
28
|
+
static getCapabilities(kind: 'audio' | 'video'): RTCRtpCapabilities {
|
|
29
|
+
if (kind === 'audio') {
|
|
30
|
+
return DEFAULT_AUDIO_CAPABILITIES;
|
|
21
31
|
}
|
|
22
32
|
|
|
23
|
-
if (!receiverCapabilities)
|
|
33
|
+
if (!receiverCapabilities) {
|
|
24
34
|
throw new Error('Receiver Capabilities is null');
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
return receiverCapabilities;
|
|
26
38
|
}
|
|
27
39
|
|
|
40
|
+
getParameters(): RTCRtpReceiveParameters {
|
|
41
|
+
return this._rtpParameters;
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
get id() {
|
|
29
45
|
return this._id;
|
|
30
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import RTCRtpEncodingParameters, { RTCRtpEncodingParametersInit } from './RTCRtpEncodingParameters';
|
|
2
|
+
import RTCRtpParameters, { RTCRtpParametersInit } from './RTCRtpParameters';
|
|
3
3
|
|
|
4
|
-
type DegradationPreferenceType = 'maintain-framerate'
|
|
4
|
+
type DegradationPreferenceType = 'maintain-framerate'
|
|
5
5
|
| 'maintain-resolution'
|
|
6
6
|
| 'balanced'
|
|
7
7
|
| 'disabled'
|
|
@@ -14,38 +14,50 @@ type DegradationPreferenceType = 'maintain-framerate'
|
|
|
14
14
|
class DegradationPreference {
|
|
15
15
|
static fromNative(nativeFormat: string): DegradationPreferenceType {
|
|
16
16
|
const stringFormat = nativeFormat.toLowerCase().replace('_', '-');
|
|
17
|
+
|
|
17
18
|
return stringFormat as DegradationPreferenceType;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
static toNative(format: DegradationPreferenceType): string {
|
|
21
22
|
return format.toUpperCase().replace('-', '_');
|
|
22
23
|
}
|
|
23
|
-
}
|
|
24
|
+
}
|
|
24
25
|
|
|
25
|
-
export
|
|
26
|
+
export interface RTCRtpSendParametersInit extends RTCRtpParametersInit {
|
|
27
|
+
transactionId: string;
|
|
28
|
+
encodings: RTCRtpEncodingParametersInit[];
|
|
29
|
+
degradationPreference?: string;
|
|
30
|
+
}
|
|
26
31
|
|
|
32
|
+
export default class RTCRtpSendParameters extends RTCRtpParameters {
|
|
27
33
|
readonly transactionId: string;
|
|
28
34
|
readonly encodings: RTCRtpEncodingParameters[];
|
|
29
35
|
degradationPreference: DegradationPreferenceType | null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
encodings: RTCRtpEncodingParameters[],
|
|
33
|
-
degradationPreference?: string
|
|
34
|
-
}) {
|
|
36
|
+
|
|
37
|
+
constructor(init: RTCRtpSendParametersInit) {
|
|
35
38
|
super(init);
|
|
39
|
+
|
|
36
40
|
this.transactionId = init.transactionId;
|
|
37
|
-
this.encodings =
|
|
41
|
+
this.encodings = [];
|
|
38
42
|
this.degradationPreference = init.degradationPreference ?
|
|
39
43
|
DegradationPreference.fromNative(init.degradationPreference) : null;
|
|
44
|
+
|
|
45
|
+
for (const enc of init.encodings) {
|
|
46
|
+
this.encodings.push(new RTCRtpEncodingParameters(enc));
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
toJSON() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
toJSON(): RTCRtpSendParametersInit {
|
|
51
|
+
const obj = super.toJSON();
|
|
52
|
+
|
|
53
|
+
obj['transactionId'] = this.transactionId;
|
|
54
|
+
|
|
55
|
+
obj['encodings'] = this.encodings.map(e => e.toJSON());
|
|
56
|
+
|
|
46
57
|
if (this.degradationPreference !== null) {
|
|
47
58
|
obj['degradationPreference'] = DegradationPreference.toNative(this.degradationPreference);
|
|
48
59
|
}
|
|
49
|
-
|
|
60
|
+
|
|
61
|
+
return obj as RTCRtpSendParametersInit;
|
|
50
62
|
}
|
|
51
|
-
}
|
|
63
|
+
}
|
package/src/RTCRtpSender.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {NativeModules} from 'react-native';
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import MediaStreamTrack from './MediaStreamTrack';
|
|
3
4
|
import RTCRtpCapabilities, { senderCapabilities, DEFAULT_AUDIO_CAPABILITIES } from './RTCRtpCapabilities';
|
|
4
|
-
import RTCRtpSendParameters from './RTCRtpSendParameters';
|
|
5
|
+
import RTCRtpSendParameters, { RTCRtpSendParametersInit } from './RTCRtpSendParameters';
|
|
5
6
|
|
|
6
|
-
const {WebRTCModule} = NativeModules;
|
|
7
|
+
const { WebRTCModule } = NativeModules;
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
export default class RTCRtpSender {
|
|
@@ -16,11 +17,11 @@ export default class RTCRtpSender {
|
|
|
16
17
|
peerConnectionId: number,
|
|
17
18
|
id: string,
|
|
18
19
|
track?: MediaStreamTrack,
|
|
19
|
-
rtpParameters:
|
|
20
|
+
rtpParameters: RTCRtpSendParametersInit
|
|
20
21
|
}) {
|
|
21
22
|
this._peerConnectionId = info.peerConnectionId;
|
|
22
23
|
this._id = info.id;
|
|
23
|
-
this._rtpParameters = info.rtpParameters;
|
|
24
|
+
this._rtpParameters = new RTCRtpSendParameters(info.rtpParameters);
|
|
24
25
|
|
|
25
26
|
if (info.track) {
|
|
26
27
|
this._track = info.track;
|
|
@@ -30,21 +31,22 @@ export default class RTCRtpSender {
|
|
|
30
31
|
async replaceTrack(track: MediaStreamTrack | null): Promise<void> {
|
|
31
32
|
try {
|
|
32
33
|
await WebRTCModule.senderReplaceTrack(this._peerConnectionId, this._id, track ? track.id : null);
|
|
33
|
-
} catch(e) {
|
|
34
|
+
} catch (e) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
this._track = track;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
static getCapabilities(kind:
|
|
41
|
-
if (kind ===
|
|
41
|
+
static getCapabilities(kind: 'audio' | 'video'): RTCRtpCapabilities {
|
|
42
|
+
if (kind === 'audio') {
|
|
42
43
|
return DEFAULT_AUDIO_CAPABILITIES;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
if (!senderCapabilities) {
|
|
46
|
-
throw new Error(
|
|
47
|
+
throw new Error('sender Capabilities are null');
|
|
47
48
|
}
|
|
49
|
+
|
|
48
50
|
return senderCapabilities;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -54,14 +56,13 @@ export default class RTCRtpSender {
|
|
|
54
56
|
|
|
55
57
|
setParameters(parameters: RTCRtpSendParameters): Promise<void> {
|
|
56
58
|
return WebRTCModule.senderSetParameters(this._peerConnectionId,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.then(
|
|
59
|
+
this._id,
|
|
60
|
+
JSON.parse(JSON.stringify(parameters)))// This allows us to get rid of private "underscore properties"
|
|
61
|
+
.then(newParameters => {
|
|
60
62
|
this._rtpParameters = new RTCRtpSendParameters(newParameters);
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
|
|
65
66
|
get track() {
|
|
66
67
|
return this._track;
|
|
67
68
|
}
|
package/src/RTCRtpTransceiver.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { defineCustomEventTarget } from 'event-target-shim';
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
|
+
|
|
3
4
|
import { addListener, removeListener } from './EventEmitter';
|
|
4
|
-
import RTCRtpSender from './RTCRtpSender';
|
|
5
5
|
import RTCErrorEvent from './RTCErrorEvent';
|
|
6
6
|
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
7
|
+
import RTCRtpSender from './RTCRtpSender';
|
|
7
8
|
|
|
8
|
-
const {WebRTCModule} = NativeModules;
|
|
9
|
+
const { WebRTCModule } = NativeModules;
|
|
9
10
|
|
|
10
11
|
const TRANSCEIVER_EVENTS = [
|
|
11
12
|
'error'
|
|
@@ -61,7 +62,7 @@ export default class RTCRtpTransceiver extends defineCustomEventTarget(...TRANSC
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
set direction(val) {
|
|
64
|
-
if (!['sendonly', 'recvonly', 'sendrecv', 'inactive'].includes(val)) {
|
|
65
|
+
if (![ 'sendonly', 'recvonly', 'sendrecv', 'inactive' ].includes(val)) {
|
|
65
66
|
throw new TypeError('Invalid direction provided');
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -73,7 +74,7 @@ export default class RTCRtpTransceiver extends defineCustomEventTarget(...TRANSC
|
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
WebRTCModule.transceiverSetDirection(this._peerConnectionId, this.id, val)
|
|
77
|
+
WebRTCModule.transceiverSetDirection(this._peerConnectionId, this.id, val);
|
|
77
78
|
this._direction = val;
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -93,25 +94,28 @@ export default class RTCRtpTransceiver extends defineCustomEventTarget(...TRANSC
|
|
|
93
94
|
if (this._stopped) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
97
|
+
|
|
96
98
|
WebRTCModule.transceiverStop(this._peerConnectionId, this.id);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
_registerEvents(): void {
|
|
100
|
-
addListener(this, 'transceiverStopSuccessful', ev => {
|
|
102
|
+
addListener(this, 'transceiverStopSuccessful', (ev: any) => {
|
|
101
103
|
if (ev.peerConnectionId !== this._peerConnectionId || ev.transceiverId !== this._id) {
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
106
|
+
|
|
104
107
|
this._stopped = true;
|
|
105
|
-
this._direction = 'stopped'
|
|
108
|
+
this._direction = 'stopped';
|
|
106
109
|
this._currentDirection = 'stopped';
|
|
107
110
|
this._mid = null;
|
|
108
111
|
removeListener(this);
|
|
109
112
|
});
|
|
110
113
|
|
|
111
|
-
addListener(this, 'transceiverOnError', ev => {
|
|
114
|
+
addListener(this, 'transceiverOnError', (ev: any) => {
|
|
112
115
|
if (ev.info.peerConnectionId !== this._peerConnectionId || ev.info.transceiverId !== this._id) {
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
118
|
+
|
|
115
119
|
if (ev.func === 'stopTransceiver') {
|
|
116
120
|
this._stopped = false;
|
|
117
121
|
} else if (ev.func === 'setDirection') {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
export interface RTCSessionDescriptionInit {
|
|
3
|
+
sdp: string;
|
|
4
|
+
type: string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
export default class RTCSessionDescription {
|
|
3
8
|
_sdp: string;
|
|
4
9
|
_type: string | null;
|
|
5
10
|
|
|
6
|
-
constructor(info = { type: null, sdp: '' }) {
|
|
11
|
+
constructor(info: RTCSessionDescriptionInit = { type: null, sdp: '' }) {
|
|
7
12
|
this._sdp = info.sdp;
|
|
8
13
|
this._type = info.type;
|
|
9
14
|
}
|
|
@@ -16,7 +21,7 @@ export default class RTCSessionDescription {
|
|
|
16
21
|
return this._type;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
toJSON():
|
|
24
|
+
toJSON(): RTCSessionDescriptionInit {
|
|
20
25
|
return {
|
|
21
26
|
sdp: this._sdp,
|
|
22
27
|
type: this._type
|
package/src/RTCUtil.ts
CHANGED
|
@@ -19,6 +19,13 @@ const STANDARD_OFFER_OPTIONS = {
|
|
|
19
19
|
voiceactivitydetection: 'VoiceActivityDetection'
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const SDP_TYPES = [
|
|
23
|
+
'offer',
|
|
24
|
+
'pranswer',
|
|
25
|
+
'answer',
|
|
26
|
+
'rollback'
|
|
27
|
+
];
|
|
28
|
+
|
|
22
29
|
function getDefaultMediaConstraints(mediaType) {
|
|
23
30
|
switch (mediaType) {
|
|
24
31
|
case 'audio':
|
|
@@ -35,7 +42,7 @@ function extractString(constraints, prop) {
|
|
|
35
42
|
const type = typeof value;
|
|
36
43
|
|
|
37
44
|
if (type === 'object') {
|
|
38
|
-
for (const v of ['exact', 'ideal']) {
|
|
45
|
+
for (const v of [ 'exact', 'ideal' ]) {
|
|
39
46
|
if (value[v]) {
|
|
40
47
|
return value[v];
|
|
41
48
|
}
|
|
@@ -52,7 +59,7 @@ function extractNumber(constraints, prop) {
|
|
|
52
59
|
if (type === 'number') {
|
|
53
60
|
return Number.parseInt(value);
|
|
54
61
|
} else if (type === 'object') {
|
|
55
|
-
for (const v of ['exact', 'ideal', 'min', 'max']) {
|
|
62
|
+
for (const v of [ 'exact', 'ideal', 'min', 'max' ]) {
|
|
56
63
|
if (value[v]) {
|
|
57
64
|
return Number.parseInt(value[v]);
|
|
58
65
|
}
|
|
@@ -64,6 +71,7 @@ function normalizeMediaConstraints(constraints, mediaType) {
|
|
|
64
71
|
switch (mediaType) {
|
|
65
72
|
case 'audio':
|
|
66
73
|
return constraints;
|
|
74
|
+
|
|
67
75
|
case 'video': {
|
|
68
76
|
const c = {
|
|
69
77
|
deviceId: extractString(constraints, 'deviceId'),
|
|
@@ -96,6 +104,7 @@ function normalizeMediaConstraints(constraints, mediaType) {
|
|
|
96
104
|
|
|
97
105
|
return c;
|
|
98
106
|
}
|
|
107
|
+
|
|
99
108
|
default:
|
|
100
109
|
throw new TypeError(`Invalid media type: ${mediaType}`);
|
|
101
110
|
}
|
|
@@ -132,6 +141,16 @@ export function deepClone<T>(obj: T): T {
|
|
|
132
141
|
return JSON.parse(JSON.stringify(obj));
|
|
133
142
|
}
|
|
134
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Checks whether an SDP type is valid or not.
|
|
146
|
+
*
|
|
147
|
+
* @param type SDP type to check.
|
|
148
|
+
* @returns Whether the SDP type is valid or not.
|
|
149
|
+
*/
|
|
150
|
+
export function isSdpTypeValid(type: string): boolean {
|
|
151
|
+
return SDP_TYPES.includes(type);
|
|
152
|
+
}
|
|
153
|
+
|
|
135
154
|
/**
|
|
136
155
|
* Normalize options passed to createOffer().
|
|
137
156
|
*
|
|
@@ -147,8 +166,9 @@ export function normalizeOfferOptions(options: object = {}): object {
|
|
|
147
166
|
|
|
148
167
|
// Convert standard options into WebRTC internal constant names.
|
|
149
168
|
// See: https://github.com/jitsi/webrtc/blob/0cd6ce4de669bed94ba47b88cb71b9be0341bb81/sdk/media_constraints.cc#L113
|
|
150
|
-
for (const [key, value] of Object.entries(options)) {
|
|
169
|
+
for (const [ key, value ] of Object.entries(options)) {
|
|
151
170
|
const newKey = STANDARD_OFFER_OPTIONS[key.toLowerCase()];
|
|
171
|
+
|
|
152
172
|
if (newKey) {
|
|
153
173
|
newOptions[newKey] = String(Boolean(value));
|
|
154
174
|
}
|
|
@@ -163,7 +183,7 @@ export function normalizeOfferOptions(options: object = {}): object {
|
|
|
163
183
|
export function normalizeConstraints(constraints) {
|
|
164
184
|
const c = deepClone(constraints);
|
|
165
185
|
|
|
166
|
-
for (const mediaType of ['audio', 'video']) {
|
|
186
|
+
for (const mediaType of [ 'audio', 'video' ]) {
|
|
167
187
|
const mediaTypeConstraints = c[mediaType];
|
|
168
188
|
const typeofMediaTypeConstraints = typeof mediaTypeConstraints;
|
|
169
189
|
|
package/src/getDisplayMedia.ts
CHANGED