react-native-webrtc 106.0.0-beta.2 → 106.0.0-beta.3
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/WebRTCModule.java +27 -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/WebRTCModule+RTCPeerConnection.m +19 -3
- 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 +135 -57
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- 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.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +9 -9
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js +5 -8
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js +2 -2
- 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 +22 -22
- 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 +132 -54
- package/lib/module/RTCPeerConnection.js.map +1 -1
- 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.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +9 -9
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- 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 +5 -6
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js +2 -2
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js +2 -2
- 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 +14 -14
- 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 +6 -7
- package/lib/typescript/RTCRtpCodecParameters.d.ts +2 -2
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +2 -2
- package/lib/typescript/RTCRtpParameters.d.ts +3 -3
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +1 -1
- package/lib/typescript/RTCRtpReceiver.d.ts +1 -1
- package/lib/typescript/RTCRtpSendParameters.d.ts +2 -2
- package/lib/typescript/RTCRtpSender.d.ts +1 -1
- 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 +12 -12
- 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 +186 -90
- package/src/RTCRtcpParameters.ts +7 -7
- package/src/RTCRtpCapabilities.ts +15 -4
- package/src/RTCRtpCodecParameters.ts +2 -2
- package/src/RTCRtpEncodingParameters.ts +19 -17
- package/src/RTCRtpParameters.ts +3 -3
- package/src/RTCRtpReceiveParameters.ts +1 -2
- package/src/RTCRtpReceiver.ts +7 -7
- package/src/RTCRtpSendParameters.ts +10 -8
- package/src/RTCRtpSender.ts +11 -9
- 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 +16 -14
- 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,4 +1,5 @@
|
|
|
1
|
-
import {NativeModules} from 'react-native';
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import RTCRtpCodecCapability from './RTCRtpCodecCapability';
|
|
3
4
|
const { WebRTCModule } = NativeModules;
|
|
4
5
|
|
|
@@ -13,7 +14,7 @@ export default class RTCRtpCapabilities {
|
|
|
13
14
|
this._codecs = codecs;
|
|
14
15
|
Object.freeze(this);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
get codecs() {
|
|
18
19
|
return this._codecs;
|
|
19
20
|
}
|
|
@@ -24,14 +25,24 @@ function getCapabilities(endpoint: 'sender' | 'receiver'): RTCRtpCapabilities |
|
|
|
24
25
|
switch (endpoint) {
|
|
25
26
|
case 'sender': {
|
|
26
27
|
const capabilities = WebRTCModule.senderGetCapabilities();
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
if (!capabilities) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
return new RTCRtpCapabilities(capabilities.codecs);
|
|
29
34
|
}
|
|
35
|
+
|
|
30
36
|
case 'receiver': {
|
|
31
37
|
const capabilities = WebRTCModule.receiverGetCapabilities();
|
|
32
|
-
|
|
38
|
+
|
|
39
|
+
if (!capabilities) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
return new RTCRtpCapabilities(capabilities.codecs);
|
|
34
44
|
}
|
|
45
|
+
|
|
35
46
|
default:
|
|
36
47
|
throw new TypeError('Invalid endpoint: ' + endpoint);
|
|
37
48
|
}
|
|
@@ -4,14 +4,14 @@ export default class RTCRtpCodecParameters {
|
|
|
4
4
|
readonly clockRate: number;
|
|
5
5
|
readonly channels: number;
|
|
6
6
|
readonly mimeType: string;
|
|
7
|
-
readonly sdpFmtpLine: Map<
|
|
7
|
+
readonly sdpFmtpLine: Map<string, string>;
|
|
8
8
|
|
|
9
9
|
constructor(init: {
|
|
10
10
|
payloadType: number,
|
|
11
11
|
clockRate: number,
|
|
12
12
|
channels: number,
|
|
13
13
|
mimeType: string,
|
|
14
|
-
sdpFmtpLine: Map<
|
|
14
|
+
sdpFmtpLine: Map<string, string>
|
|
15
15
|
}) {
|
|
16
16
|
this.payloadType = init.payloadType;
|
|
17
17
|
this.clockRate = init.clockRate;
|
|
@@ -21,26 +21,26 @@ export default class RTCRtpEncodingParameters {
|
|
|
21
21
|
return this._maxFramerate;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
get maxBitrate() {
|
|
25
|
-
return this._maxBitrate;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get scaleResolutionDownBy() {
|
|
29
|
-
return this._scaleResolutionDownBy;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
set maxFramerate(framerate) {
|
|
33
25
|
if (framerate && framerate > 0) {
|
|
34
26
|
this._maxFramerate = framerate;
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
|
-
|
|
29
|
+
|
|
30
|
+
get maxBitrate() {
|
|
31
|
+
return this._maxBitrate;
|
|
32
|
+
}
|
|
33
|
+
|
|
38
34
|
set maxBitrate(bitrate) {
|
|
39
35
|
if (bitrate && bitrate > 0) {
|
|
40
36
|
this._maxBitrate = bitrate;
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
get scaleResolutionDownBy() {
|
|
41
|
+
return this._scaleResolutionDownBy;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
44
|
set scaleResolutionDownBy(resolutionScale) {
|
|
45
45
|
if (resolutionScale && resolutionScale >= 1) {
|
|
46
46
|
this._scaleResolutionDownBy = resolutionScale;
|
|
@@ -48,20 +48,22 @@ export default class RTCRtpEncodingParameters {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
toJSON() {
|
|
51
|
-
|
|
51
|
+
const obj = {
|
|
52
52
|
active: this.active,
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
|
+
|
|
54
55
|
if (this._maxBitrate !== null) {
|
|
55
56
|
obj['maxBitrate'] = this._maxBitrate;
|
|
56
|
-
}
|
|
57
|
+
}
|
|
57
58
|
|
|
58
59
|
if (this._maxFramerate !== null) {
|
|
59
60
|
obj['maxFramerate'] = this._maxFramerate;
|
|
60
|
-
}
|
|
61
|
-
|
|
61
|
+
}
|
|
62
|
+
|
|
62
63
|
if (this._scaleResolutionDownBy !== null) {
|
|
63
64
|
obj['scaleResolutionDownBy'] = this._scaleResolutionDownBy;
|
|
64
|
-
}
|
|
65
|
+
}
|
|
66
|
+
|
|
65
67
|
return obj;
|
|
66
68
|
}
|
|
67
|
-
}
|
|
69
|
+
}
|
package/src/RTCRtpParameters.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import RTCRtcpParameters from
|
|
2
|
-
import RTCRtpCodecParameters from
|
|
3
|
-
import RTCRtpHeaderExtension from
|
|
1
|
+
import RTCRtcpParameters from './RTCRtcpParameters';
|
|
2
|
+
import RTCRtpCodecParameters from './RTCRtpCodecParameters';
|
|
3
|
+
import RTCRtpHeaderExtension from './RTCRtpHeaderExtension';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export type RTCRtpParametersInit = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import RTCRtpParameters, { RTCRtpParametersInit } from
|
|
1
|
+
import RTCRtpParameters, { RTCRtpParametersInit } from './RTCRtpParameters';
|
|
2
2
|
export default class RTCRtpReceiveParameters extends RTCRtpParameters {
|
|
3
|
-
|
|
4
3
|
constructor(init: RTCRtpParametersInit) {
|
|
5
4
|
super(init);
|
|
6
5
|
}
|
package/src/RTCRtpReceiver.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
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';
|
|
4
3
|
|
|
5
|
-
const { WebRTCModule } = NativeModules;
|
|
6
4
|
|
|
7
5
|
export default class RTCRtpReceiver {
|
|
8
6
|
_id: string;
|
|
@@ -15,13 +13,15 @@ export default class RTCRtpReceiver {
|
|
|
15
13
|
this._track = info.track;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
static getCapabilities(kind:
|
|
19
|
-
if (kind
|
|
20
|
-
|
|
16
|
+
static getCapabilities(kind: 'audio' | 'video'): RTCRtpCapabilities {
|
|
17
|
+
if (kind === 'audio') {
|
|
18
|
+
return DEFAULT_AUDIO_CAPABILITIES;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
if (!receiverCapabilities)
|
|
21
|
+
if (!receiverCapabilities) {
|
|
24
22
|
throw new Error('Receiver Capabilities is null');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
25
|
return receiverCapabilities;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import RTCRtpEncodingParameters 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,16 +14,16 @@ 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
26
|
export default class RTCRtpSendParameters extends RTCRtpParameters {
|
|
26
|
-
|
|
27
27
|
readonly transactionId: string;
|
|
28
28
|
readonly encodings: RTCRtpEncodingParameters[];
|
|
29
29
|
degradationPreference: DegradationPreferenceType | null;
|
|
@@ -40,12 +40,14 @@ export default class RTCRtpSendParameters extends RTCRtpParameters {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
toJSON() {
|
|
43
|
-
|
|
43
|
+
const obj = {
|
|
44
44
|
encodings: this.encodings,
|
|
45
45
|
};
|
|
46
|
+
|
|
46
47
|
if (this.degradationPreference !== null) {
|
|
47
48
|
obj['degradationPreference'] = DegradationPreference.toNative(this.degradationPreference);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
return obj;
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
}
|
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
5
|
import RTCRtpSendParameters from './RTCRtpSendParameters';
|
|
5
6
|
|
|
6
|
-
const {WebRTCModule} = NativeModules;
|
|
7
|
+
const { WebRTCModule } = NativeModules;
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
export default class RTCRtpSender {
|
|
@@ -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,9 +56,9 @@ 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
|
}
|
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
package/src/getUserMedia.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { NativeModules } from 'react-native';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import MediaStream from './MediaStream';
|
|
6
6
|
import MediaStreamError from './MediaStreamError';
|
|
7
7
|
import permissions from './Permissions';
|
|
8
|
+
import * as RTCUtil from './RTCUtil';
|
|
8
9
|
|
|
9
10
|
const { WebRTCModule } = NativeModules;
|
|
10
11
|
|
|
@@ -33,11 +34,13 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
33
34
|
|
|
34
35
|
// Request required permissions
|
|
35
36
|
const reqPermissions: Promise<boolean>[] = [];
|
|
37
|
+
|
|
36
38
|
if (constraints.audio) {
|
|
37
39
|
reqPermissions.push(permissions.request({ name: 'microphone' }));
|
|
38
40
|
} else {
|
|
39
41
|
reqPermissions.push(Promise.resolve(false));
|
|
40
42
|
}
|
|
43
|
+
|
|
41
44
|
if (constraints.video) {
|
|
42
45
|
reqPermissions.push(permissions.request({ name: 'camera' }));
|
|
43
46
|
} else {
|
|
@@ -46,7 +49,7 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
46
49
|
|
|
47
50
|
return new Promise((resolve, reject) => {
|
|
48
51
|
Promise.all(reqPermissions).then(results => {
|
|
49
|
-
const [audioPerm, videoPerm] = results;
|
|
52
|
+
const [ audioPerm, videoPerm ] = results;
|
|
50
53
|
|
|
51
54
|
// Check permission results and remove unneeded permissions.
|
|
52
55
|
|
|
@@ -57,6 +60,7 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
57
60
|
message: 'Permission denied.',
|
|
58
61
|
name: 'SecurityError'
|
|
59
62
|
};
|
|
63
|
+
|
|
60
64
|
reject(new MediaStreamError(error));
|
|
61
65
|
|
|
62
66
|
return;
|
|
@@ -69,6 +73,7 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
69
73
|
// Store initial constraints.
|
|
70
74
|
for (const trackInfo of tracks) {
|
|
71
75
|
const c = constraints[trackInfo.kind];
|
|
76
|
+
|
|
72
77
|
if (typeof c === 'object') {
|
|
73
78
|
trackInfo.constraints = RTCUtil.deepClone(c);
|
|
74
79
|
}
|
|
@@ -85,11 +90,13 @@ export default function getUserMedia(constraints: Constraints = {}): Promise<Med
|
|
|
85
90
|
|
|
86
91
|
const failure = (type, message) => {
|
|
87
92
|
let error;
|
|
93
|
+
|
|
88
94
|
switch (type) {
|
|
89
95
|
case 'TypeError':
|
|
90
96
|
error = new TypeError(message);
|
|
91
97
|
break;
|
|
92
98
|
}
|
|
99
|
+
|
|
93
100
|
if (!error) {
|
|
94
101
|
error = new MediaStreamError({ message, name: type });
|
|
95
102
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
+
import Logger from './Logger';
|
|
2
|
+
import mediaDevices from './MediaDevices';
|
|
3
|
+
import MediaStream from './MediaStream';
|
|
4
|
+
import MediaStreamTrack from './MediaStreamTrack';
|
|
5
|
+
import permissions from './Permissions';
|
|
6
|
+
import RTCErrorEvent from './RTCErrorEvent';
|
|
1
7
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
2
8
|
import RTCPeerConnection from './RTCPeerConnection';
|
|
3
|
-
import
|
|
4
|
-
import RTCRtpSender from './RTCRtpSender';
|
|
5
|
-
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
9
|
+
import RTCRtcpParameters from './RTCRtcpParameters';
|
|
6
10
|
import RTCRtpCapabilities from './RTCRtpCapabilities';
|
|
7
11
|
import RTCRtpCodecCapability from './RTCRtpCodecCapability';
|
|
8
|
-
import RTCRtpEncodingParameters from './RTCRtpEncodingParameters';
|
|
9
12
|
import RTCRtpCodecParameters from './RTCRtpCodecParameters';
|
|
10
|
-
import
|
|
11
|
-
import RTCRtcpParameters from './RTCRtcpParameters';
|
|
13
|
+
import RTCRtpEncodingParameters from './RTCRtpEncodingParameters';
|
|
12
14
|
import RTCRtpHeaderExtension from './RTCRtpHeaderExtension';
|
|
13
|
-
import
|
|
15
|
+
import RTCRtpParameters from './RTCRtpParameters';
|
|
14
16
|
import RTCRtpReceiveParameters from './RTCRtpReceiveParameters';
|
|
17
|
+
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
18
|
+
import RTCRtpSendParameters from './RTCRtpSendParameters';
|
|
19
|
+
import RTCRtpSender from './RTCRtpSender';
|
|
20
|
+
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
15
21
|
import RTCSessionDescription from './RTCSessionDescription';
|
|
16
|
-
import RTCErrorEvent from './RTCErrorEvent';
|
|
17
22
|
import RTCView from './RTCView';
|
|
18
23
|
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
19
|
-
import MediaStream from './MediaStream';
|
|
20
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
21
|
-
import mediaDevices from './MediaDevices';
|
|
22
|
-
import permissions from './Permissions';
|
|
23
|
-
import Logger from './Logger';
|
|
24
24
|
|
|
25
25
|
Logger.enable('*');
|
|
26
|
-
//Logger.enable(`*,-${Logger.ROOT_PREFIX}:*:DEBUG`);
|
|
26
|
+
// Logger.enable(`*,-${Logger.ROOT_PREFIX}:*:DEBUG`);
|
|
27
27
|
|
|
28
28
|
export {
|
|
29
29
|
RTCIceCandidate,
|
|
@@ -51,6 +51,8 @@ export {
|
|
|
51
51
|
registerGlobals
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
declare const global: any;
|
|
55
|
+
|
|
54
56
|
function registerGlobals(): void {
|
|
55
57
|
// Should not happen. React Native has a global navigator object.
|
|
56
58
|
if (typeof global.navigator !== 'object') {
|
package/tools/downloadWebRTC.js
CHANGED
|
@@ -57,11 +57,13 @@ async function download(url, filePath) {
|
|
|
57
57
|
if (process.platform === 'darwin') {
|
|
58
58
|
const iosUrl = builds['ios'];
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (iosUrl) {
|
|
61
|
+
items.push({
|
|
62
|
+
url: iosUrl,
|
|
63
|
+
dstFileName: path.basename(iosUrl),
|
|
64
|
+
dstDir: `${__dirname}/../apple/`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
// Android
|
package/.prettierignore
DELETED
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/lib/module/typings.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/src/typings.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare var global: any;
|