react-native-webrtc 1.100.1 → 106.0.0-beta.1
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/ISSUE_TEMPLATE.md +17 -13
- package/README.md +46 -129
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +160 -165
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +279 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +361 -56
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +5 -1
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +2 -6
- package/ios/RCTWebRTC/ScreenCapturer.m +0 -1
- package/ios/RCTWebRTC/SerializeUtils.h +25 -0
- package/ios/RCTWebRTC/SerializeUtils.m +219 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +284 -128
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +216 -0
- package/ios/RCTWebRTC/WebRTCModule.h +15 -4
- package/ios/RCTWebRTC/WebRTCModule.m +26 -6
- package/lib/commonjs/EventEmitter.js +24 -0
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js +65 -0
- package/lib/commonjs/Logger.js.map +1 -0
- package/lib/commonjs/MediaStream.js +1 -1
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +4 -2
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/Permissions.js +1 -1
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +33 -0
- package/lib/commonjs/RTCErrorEvent.js.map +1 -0
- package/lib/commonjs/RTCPeerConnection.js +354 -103
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js +24 -0
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpCapabilities.js +79 -0
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -0
- package/lib/commonjs/RTCRtpCodecCapability.js +25 -0
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -0
- package/lib/commonjs/RTCRtpCodecParameters.js +33 -0
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpEncodingParameters.js +81 -0
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpHeaderExtension.js +27 -0
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -0
- package/lib/commonjs/RTCRtpParameters.js +26 -0
- package/lib/commonjs/RTCRtpParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpReceiveParameters.js +20 -0
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpReceiver.js +51 -0
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -0
- package/lib/commonjs/RTCRtpSendParameters.js +60 -0
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -0
- package/lib/commonjs/RTCRtpSender.js +85 -0
- package/lib/commonjs/RTCRtpSender.js.map +1 -0
- package/lib/commonjs/RTCRtpTransceiver.js +141 -0
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -0
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +32 -0
- package/lib/commonjs/RTCTrackEvent.js.map +1 -0
- package/lib/commonjs/RTCUtil.js +20 -37
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +127 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/EventEmitter.js +21 -0
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js +53 -0
- package/lib/module/Logger.js.map +1 -0
- package/lib/module/MediaStream.js +1 -1
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +4 -2
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/Permissions.js +1 -1
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +22 -0
- package/lib/module/RTCErrorEvent.js.map +1 -0
- package/lib/module/RTCPeerConnection.js +348 -103
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js +15 -0
- package/lib/module/RTCRtcpParameters.js.map +1 -0
- package/lib/module/RTCRtpCapabilities.js +63 -0
- package/lib/module/RTCRtpCapabilities.js.map +1 -0
- package/lib/module/RTCRtpCodecCapability.js +16 -0
- package/lib/module/RTCRtpCodecCapability.js.map +1 -0
- package/lib/module/RTCRtpCodecParameters.js +24 -0
- package/lib/module/RTCRtpCodecParameters.js.map +1 -0
- package/lib/module/RTCRtpEncodingParameters.js +72 -0
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -0
- package/lib/module/RTCRtpHeaderExtension.js +18 -0
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -0
- package/lib/module/RTCRtpParameters.js +17 -0
- package/lib/module/RTCRtpParameters.js.map +1 -0
- package/lib/module/RTCRtpReceiveParameters.js +8 -0
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -0
- package/lib/module/RTCRtpReceiver.js +39 -0
- package/lib/module/RTCRtpReceiver.js.map +1 -0
- package/lib/module/RTCRtpSendParameters.js +49 -0
- package/lib/module/RTCRtpSendParameters.js.map +1 -0
- package/lib/module/RTCRtpSender.js +70 -0
- package/lib/module/RTCRtpSender.js.map +1 -0
- package/lib/module/RTCRtpTransceiver.js +125 -0
- package/lib/module/RTCRtpTransceiver.js.map +1 -0
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +23 -0
- package/lib/module/RTCTrackEvent.js.map +1 -0
- package/lib/module/RTCUtil.js +18 -36
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +35 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/EventEmitter.d.ts +3 -0
- package/lib/typescript/Logger.d.ts +13 -0
- package/lib/typescript/MediaDevices.d.ts +2 -2
- package/lib/typescript/MediaStream.d.ts +6 -6
- package/lib/typescript/MediaStreamTrack.d.ts +10 -9
- package/lib/typescript/RTCDataChannel.d.ts +4 -2
- package/lib/typescript/RTCErrorEvent.d.ts +12 -0
- package/lib/typescript/RTCPeerConnection.d.ts +42 -11
- package/lib/typescript/RTCRtcpParameters.d.ts +8 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts +19 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts +7 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts +14 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +21 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts +10 -0
- package/lib/typescript/RTCRtpParameters.d.ts +14 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +4 -0
- package/lib/typescript/RTCRtpReceiver.d.ts +15 -0
- package/lib/typescript/RTCRtpSendParameters.d.ts +17 -0
- package/lib/typescript/RTCRtpSender.d.ts +21 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts +35 -0
- package/lib/typescript/RTCTrackEvent.d.ts +15 -0
- package/lib/typescript/RTCUtil.d.ts +5 -9
- package/lib/typescript/getDisplayMedia.d.ts +2 -1
- package/lib/typescript/getUserMedia.d.ts +2 -1
- package/lib/typescript/index.d.ts +16 -3
- package/package.json +6 -4
- package/react-native-webrtc.podspec +1 -1
- package/src/EventEmitter.ts +21 -1
- package/src/Logger.ts +49 -0
- package/src/MediaStream.ts +11 -11
- package/src/MediaStreamTrack.ts +14 -13
- package/src/Permissions.ts +1 -1
- package/src/RTCDataChannel.ts +11 -8
- package/src/RTCErrorEvent.ts +21 -0
- package/src/RTCPeerConnection.ts +400 -158
- package/src/RTCRtcpParameters.ts +14 -0
- package/src/RTCRtpCapabilities.ts +54 -0
- package/src/RTCRtpCodecCapability.ts +13 -0
- package/src/RTCRtpCodecParameters.ts +23 -0
- package/src/RTCRtpEncodingParameters.ts +67 -0
- package/src/RTCRtpHeaderExtension.ts +18 -0
- package/src/RTCRtpParameters.ts +21 -0
- package/src/RTCRtpReceiveParameters.ts +7 -0
- package/src/RTCRtpReceiver.ts +35 -0
- package/src/RTCRtpSendParameters.ts +51 -0
- package/src/RTCRtpSender.ts +72 -0
- package/src/RTCRtpTransceiver.ts +125 -0
- package/src/RTCSessionDescription.ts +3 -3
- package/src/RTCTrackEvent.ts +21 -0
- package/src/RTCUtil.ts +20 -40
- package/src/getDisplayMedia.ts +1 -1
- package/src/getUserMedia.ts +2 -2
- package/src/index.ts +51 -6
- package/tools/build-webrtc.py +32 -33
- package/tools/downloadBitcode.sh +2 -12
- package/tools/downloadWebRTC.js +21 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import RTCEvent from "./RTCEvent";
|
|
2
|
+
declare type RTCPeerConnectionErrorFunc = 'addTransceiver' | 'getTransceivers' | 'addTrack' | 'removeTrack';
|
|
3
|
+
/**
|
|
4
|
+
* @brief This class Represents internal error happening on the native side as
|
|
5
|
+
* part of asynchronous invocations to synchronous web APIs.
|
|
6
|
+
*/
|
|
7
|
+
export default class RTCErrorEvent extends RTCEvent {
|
|
8
|
+
readonly func: RTCPeerConnectionErrorFunc;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
constructor(type: string, func: RTCPeerConnectionErrorFunc, message: string);
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { defineCustomEventTarget } from 'event-target-shim';
|
|
1
|
+
import { defineCustomEventTarget, Event } from 'event-target-shim';
|
|
2
2
|
import MediaStream from './MediaStream';
|
|
3
|
+
import MediaStreamTrack from './MediaStreamTrack';
|
|
4
|
+
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
3
5
|
import RTCDataChannel from './RTCDataChannel';
|
|
4
6
|
import RTCSessionDescription from './RTCSessionDescription';
|
|
7
|
+
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
8
|
+
import RTCRtpSender from './RTCRtpSender';
|
|
5
9
|
declare type RTCSignalingState = 'stable' | 'have-local-offer' | 'have-remote-offer' | 'have-local-pranswer' | 'have-remote-pranswer' | 'closed';
|
|
6
10
|
declare type RTCIceGatheringState = 'new' | 'gathering' | 'complete';
|
|
7
11
|
declare type RTCPeerConnectionState = 'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed';
|
|
@@ -14,7 +18,7 @@ declare type RTCDataChannelInit = {
|
|
|
14
18
|
negotiated?: boolean;
|
|
15
19
|
id?: number;
|
|
16
20
|
};
|
|
17
|
-
declare const RTCPeerConnection_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string,
|
|
21
|
+
declare const RTCPeerConnection_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, Event<string>>, "standard">;
|
|
18
22
|
export default class RTCPeerConnection extends RTCPeerConnection_base {
|
|
19
23
|
localDescription: RTCSessionDescription | null;
|
|
20
24
|
remoteDescription: RTCSessionDescription | null;
|
|
@@ -23,24 +27,36 @@ export default class RTCPeerConnection extends RTCPeerConnection_base {
|
|
|
23
27
|
connectionState: RTCPeerConnectionState;
|
|
24
28
|
iceConnectionState: RTCIceConnectionState;
|
|
25
29
|
_peerConnectionId: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
_subscriptions: any[];
|
|
31
|
+
_transceivers: {
|
|
32
|
+
order: number;
|
|
33
|
+
transceiver: RTCRtpTransceiver;
|
|
34
|
+
}[];
|
|
35
|
+
_remoteStreams: Map<string, MediaStream>;
|
|
29
36
|
constructor(configuration: any);
|
|
30
|
-
addStream(stream: MediaStream): void;
|
|
31
|
-
removeStream(stream: MediaStream): void;
|
|
32
37
|
createOffer(options: any): Promise<unknown>;
|
|
33
|
-
createAnswer(
|
|
38
|
+
createAnswer(): Promise<unknown>;
|
|
34
39
|
setConfiguration(configuration: any): void;
|
|
35
40
|
setLocalDescription(sessionDescription?: RTCSessionDescription): Promise<void>;
|
|
36
41
|
setRemoteDescription(sessionDescription: RTCSessionDescription): Promise<void>;
|
|
37
42
|
addIceCandidate(candidate: any): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* @brief Adds a new track to the {@link RTCPeerConnection},
|
|
45
|
+
* and indicates that it is contained in the specified {@link MediaStream} array.
|
|
46
|
+
* This method has to be synchronous as the W3C API expects a track to be return
|
|
47
|
+
* @param {MediaStreamTrack} track The track to be added
|
|
48
|
+
* @param {MediaStream[]} streams An array of streams the track needs to be added to
|
|
49
|
+
* https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack
|
|
50
|
+
*/
|
|
51
|
+
addTrack(track: MediaStreamTrack, streams?: MediaStream[]): RTCRtpSender;
|
|
52
|
+
addTransceiver(source: 'audio' | 'video' | MediaStreamTrack, init: any): RTCRtpTransceiver;
|
|
53
|
+
removeTrack(sender: RTCRtpSender): void;
|
|
38
54
|
getStats(): any;
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
getTransceivers(): RTCRtpTransceiver[];
|
|
56
|
+
getSenders(): RTCRtpSender[];
|
|
57
|
+
getReceivers(): RTCRtpReceiver[];
|
|
41
58
|
close(): void;
|
|
42
59
|
restartIce(): void;
|
|
43
|
-
_unregisterEvents(): void;
|
|
44
60
|
_registerEvents(): void;
|
|
45
61
|
/**
|
|
46
62
|
* Creates a new RTCDataChannel object with the given label. The
|
|
@@ -54,5 +70,20 @@ export default class RTCPeerConnection extends RTCPeerConnection_base {
|
|
|
54
70
|
* instance such as id
|
|
55
71
|
*/
|
|
56
72
|
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
73
|
+
/**
|
|
74
|
+
* Check whether a media stream track exists already in a sender.
|
|
75
|
+
* See https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack for more information
|
|
76
|
+
*/
|
|
77
|
+
_trackExists(track: MediaStreamTrack): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* updates transceivers after offer/answer updates if necessary
|
|
80
|
+
*/
|
|
81
|
+
_updateTransceivers(transceiverUpdates: any): void;
|
|
82
|
+
/**
|
|
83
|
+
* Inserts transceiver into the transceiver array in the order they are created (timestamp).
|
|
84
|
+
* @param order an index that refers to when it it was created relatively.
|
|
85
|
+
* @param transceiver the transceiver object to be inserted.
|
|
86
|
+
*/
|
|
87
|
+
_insertTransceiverSorted(order: number, transceiver: RTCRtpTransceiver): void;
|
|
57
88
|
}
|
|
58
89
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import RTCRtpCodecCapability from './RTCRtpCodecCapability';
|
|
2
|
+
/**
|
|
3
|
+
* @brief represents codec capabilities for senders and receivers. Currently
|
|
4
|
+
* this only supports codec names and does not have other
|
|
5
|
+
* fields like clockRate and numChannels and such.
|
|
6
|
+
*/
|
|
7
|
+
export default class RTCRtpCapabilities {
|
|
8
|
+
_codecs: RTCRtpCodecCapability[];
|
|
9
|
+
constructor(codecs: RTCRtpCodecCapability[]);
|
|
10
|
+
get codecs(): RTCRtpCodecCapability[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hardcoded audio capabilities based on the WebRTC native documentation:
|
|
14
|
+
* https://webrtc.github.io/webrtc-org/faq/. The mime type is specified in
|
|
15
|
+
* https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-2.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_AUDIO_CAPABILITIES: RTCRtpCapabilities;
|
|
18
|
+
export declare const senderCapabilities: RTCRtpCapabilities | null;
|
|
19
|
+
export declare const receiverCapabilities: RTCRtpCapabilities | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default class RTCRtpCodecParameters {
|
|
2
|
+
readonly payloadType: number;
|
|
3
|
+
readonly clockRate: number;
|
|
4
|
+
readonly channels: number;
|
|
5
|
+
readonly mimeType: string;
|
|
6
|
+
readonly sdpFmtpLine: Map<String, String>;
|
|
7
|
+
constructor(init: {
|
|
8
|
+
payloadType: number;
|
|
9
|
+
clockRate: number;
|
|
10
|
+
channels: number;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
sdpFmtpLine: Map<String, String>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default class RTCRtpEncodingParameters {
|
|
2
|
+
readonly active: boolean;
|
|
3
|
+
_maxFramerate: number | null;
|
|
4
|
+
_maxBitrate: number | null;
|
|
5
|
+
_scaleResolutionDownBy: number | null;
|
|
6
|
+
constructor(init: {
|
|
7
|
+
active: boolean;
|
|
8
|
+
maxFramerate?: number;
|
|
9
|
+
maxBitrate?: number;
|
|
10
|
+
scaleResolutionDownBy?: number;
|
|
11
|
+
});
|
|
12
|
+
get maxFramerate(): number | null;
|
|
13
|
+
get maxBitrate(): number | null;
|
|
14
|
+
get scaleResolutionDownBy(): number | null;
|
|
15
|
+
set maxFramerate(framerate: number | null);
|
|
16
|
+
set maxBitrate(bitrate: number | null);
|
|
17
|
+
set scaleResolutionDownBy(resolutionScale: number | null);
|
|
18
|
+
toJSON(): {
|
|
19
|
+
active: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import RTCRtcpParameters from "./RTCRtcpParameters";
|
|
2
|
+
import RTCRtpCodecParameters from "./RTCRtpCodecParameters";
|
|
3
|
+
import RTCRtpHeaderExtension from "./RTCRtpHeaderExtension";
|
|
4
|
+
export declare type RTCRtpParametersInit = {
|
|
5
|
+
codecs: RTCRtpCodecParameters[];
|
|
6
|
+
headerExtensions: RTCRtpHeaderExtension[];
|
|
7
|
+
rtcp: RTCRtcpParameters;
|
|
8
|
+
};
|
|
9
|
+
export default class RTCRtpParameters {
|
|
10
|
+
readonly codecs: RTCRtpCodecParameters[];
|
|
11
|
+
readonly headerExtensions: RTCRtpHeaderExtension[];
|
|
12
|
+
readonly rtcp: RTCRtcpParameters;
|
|
13
|
+
constructor(init: RTCRtpParametersInit);
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import MediaStreamTrack from './MediaStreamTrack';
|
|
2
|
+
import RTCRtpCapabilities from './RTCRtpCapabilities';
|
|
3
|
+
export default class RTCRtpReceiver {
|
|
4
|
+
_id: string;
|
|
5
|
+
_peerConnectionId: number;
|
|
6
|
+
_track: MediaStreamTrack;
|
|
7
|
+
constructor(info: {
|
|
8
|
+
peerConnectionId: number;
|
|
9
|
+
id: string;
|
|
10
|
+
track: MediaStreamTrack;
|
|
11
|
+
});
|
|
12
|
+
static getCapabilities(kind: "audio" | "video"): RTCRtpCapabilities;
|
|
13
|
+
get id(): string;
|
|
14
|
+
get track(): MediaStreamTrack;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import RTCRtpParameters, { RTCRtpParametersInit } from "./RTCRtpParameters";
|
|
2
|
+
import RTCRtpEncodingParameters from "./RTCRtpEncodingParameters";
|
|
3
|
+
declare type DegradationPreferenceType = 'maintain-framerate' | 'maintain-resolution' | 'balanced' | 'disabled';
|
|
4
|
+
export default class RTCRtpSendParameters extends RTCRtpParameters {
|
|
5
|
+
readonly transactionId: string;
|
|
6
|
+
readonly encodings: RTCRtpEncodingParameters[];
|
|
7
|
+
degradationPreference: DegradationPreferenceType | null;
|
|
8
|
+
constructor(init: RTCRtpParametersInit & {
|
|
9
|
+
transactionId: string;
|
|
10
|
+
encodings: RTCRtpEncodingParameters[];
|
|
11
|
+
degradationPreference?: string;
|
|
12
|
+
});
|
|
13
|
+
toJSON(): {
|
|
14
|
+
encodings: RTCRtpEncodingParameters[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import MediaStreamTrack from './MediaStreamTrack';
|
|
2
|
+
import RTCRtpCapabilities from './RTCRtpCapabilities';
|
|
3
|
+
import RTCRtpSendParameters from './RTCRtpSendParameters';
|
|
4
|
+
export default class RTCRtpSender {
|
|
5
|
+
_id: string;
|
|
6
|
+
_track: MediaStreamTrack | null;
|
|
7
|
+
_peerConnectionId: number;
|
|
8
|
+
_rtpParameters: RTCRtpSendParameters;
|
|
9
|
+
constructor(info: {
|
|
10
|
+
peerConnectionId: number;
|
|
11
|
+
id: string;
|
|
12
|
+
track?: MediaStreamTrack;
|
|
13
|
+
rtpParameters: RTCRtpSendParameters;
|
|
14
|
+
});
|
|
15
|
+
replaceTrack(track: MediaStreamTrack | null): Promise<void>;
|
|
16
|
+
static getCapabilities(kind: "audio" | "video"): RTCRtpCapabilities;
|
|
17
|
+
getParameters(): RTCRtpSendParameters;
|
|
18
|
+
setParameters(parameters: RTCRtpSendParameters): Promise<void>;
|
|
19
|
+
get track(): MediaStreamTrack | null;
|
|
20
|
+
get id(): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineCustomEventTarget } from 'event-target-shim';
|
|
2
|
+
import RTCRtpSender from './RTCRtpSender';
|
|
3
|
+
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
4
|
+
declare const RTCRtpTransceiver_base: defineCustomEventTarget.CustomEventTargetConstructor<Record<string, import("event-target-shim").Event<string>>, "standard">;
|
|
5
|
+
export default class RTCRtpTransceiver extends RTCRtpTransceiver_base {
|
|
6
|
+
_peerConnectionId: number;
|
|
7
|
+
_sender: RTCRtpSender;
|
|
8
|
+
_receiver: RTCRtpReceiver;
|
|
9
|
+
_id: string;
|
|
10
|
+
_mid: string | null;
|
|
11
|
+
_direction: string;
|
|
12
|
+
_currentDirection: string;
|
|
13
|
+
_stopped: boolean;
|
|
14
|
+
constructor(args: {
|
|
15
|
+
peerConnectionId: number;
|
|
16
|
+
id: string;
|
|
17
|
+
isStopped: boolean;
|
|
18
|
+
direction: string;
|
|
19
|
+
currentDirection: string;
|
|
20
|
+
mid?: string;
|
|
21
|
+
sender: RTCRtpSender;
|
|
22
|
+
receiver: RTCRtpReceiver;
|
|
23
|
+
});
|
|
24
|
+
get id(): string;
|
|
25
|
+
get mid(): string | null;
|
|
26
|
+
get stopped(): boolean;
|
|
27
|
+
get direction(): string;
|
|
28
|
+
set direction(val: string);
|
|
29
|
+
get currentDirection(): string;
|
|
30
|
+
get sender(): RTCRtpSender;
|
|
31
|
+
get receiver(): RTCRtpReceiver;
|
|
32
|
+
stop(): void;
|
|
33
|
+
_registerEvents(): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import MediaStream from './MediaStream';
|
|
2
|
+
import type MediaStreamTrack from './MediaStreamTrack';
|
|
3
|
+
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
4
|
+
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
5
|
+
export default class RTCTrackEvent {
|
|
6
|
+
type: string;
|
|
7
|
+
readonly streams: MediaStream[];
|
|
8
|
+
readonly transceiver: RTCRtpTransceiver;
|
|
9
|
+
readonly receiver: RTCRtpReceiver | null;
|
|
10
|
+
readonly track: MediaStreamTrack | null;
|
|
11
|
+
constructor(type: string, eventInitDict: {
|
|
12
|
+
streams: MediaStream[];
|
|
13
|
+
transceiver: RTCRtpTransceiver;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -10,19 +10,15 @@ export declare function uniqueID(): string;
|
|
|
10
10
|
* @param {Object} obj - object to be cloned
|
|
11
11
|
* @return {Object} cloned obj
|
|
12
12
|
*/
|
|
13
|
-
export declare function deepClone(obj:
|
|
14
|
-
interface Constraints {
|
|
15
|
-
mandatory?: object;
|
|
16
|
-
}
|
|
13
|
+
export declare function deepClone<T>(obj: T): T;
|
|
17
14
|
/**
|
|
18
|
-
* Normalize options passed to createOffer()
|
|
15
|
+
* Normalize options passed to createOffer().
|
|
19
16
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @return
|
|
17
|
+
* @param options - user supplied options
|
|
18
|
+
* @return Normalized options
|
|
22
19
|
*/
|
|
23
|
-
export declare function
|
|
20
|
+
export declare function normalizeOfferOptions(options?: object): object;
|
|
24
21
|
/**
|
|
25
22
|
* Normalize the given constraints in something we can work with.
|
|
26
23
|
*/
|
|
27
24
|
export declare function normalizeConstraints(constraints: any): any;
|
|
28
|
-
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import MediaStream from './MediaStream';
|
|
2
|
+
export default function getDisplayMedia(): Promise<MediaStream>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import MediaStream from './MediaStream';
|
|
1
2
|
interface Constraints {
|
|
2
3
|
audio?: boolean | object;
|
|
3
4
|
video?: boolean | object;
|
|
4
5
|
}
|
|
5
|
-
export default function getUserMedia(constraints?: Constraints): Promise<
|
|
6
|
+
export default function getUserMedia(constraints?: Constraints): Promise<MediaStream>;
|
|
6
7
|
export {};
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
2
|
-
import RTCPeerConnection from './RTCPeerConnection';
|
|
3
1
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
2
|
+
import RTCPeerConnection from './RTCPeerConnection';
|
|
3
|
+
import RTCRtpReceiver from './RTCRtpReceiver';
|
|
4
|
+
import RTCRtpSender from './RTCRtpSender';
|
|
5
|
+
import RTCRtpTransceiver from './RTCRtpTransceiver';
|
|
6
|
+
import RTCRtpCapabilities from './RTCRtpCapabilities';
|
|
7
|
+
import RTCRtpCodecCapability from './RTCRtpCodecCapability';
|
|
8
|
+
import RTCRtpEncodingParameters from './RTCRtpEncodingParameters';
|
|
9
|
+
import RTCRtpCodecParameters from './RTCRtpCodecParameters';
|
|
10
|
+
import RTCRtpParameters from './RTCRtpParameters';
|
|
11
|
+
import RTCRtcpParameters from './RTCRtcpParameters';
|
|
12
|
+
import RTCRtpHeaderExtension from './RTCRtpHeaderExtension';
|
|
13
|
+
import RTCRtpSendParameters from './RTCRtpSendParameters';
|
|
14
|
+
import RTCRtpReceiveParameters from './RTCRtpReceiveParameters';
|
|
4
15
|
import RTCSessionDescription from './RTCSessionDescription';
|
|
16
|
+
import RTCErrorEvent from './RTCErrorEvent';
|
|
5
17
|
import RTCView from './RTCView';
|
|
18
|
+
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
6
19
|
import MediaStream from './MediaStream';
|
|
7
20
|
import MediaStreamTrack from './MediaStreamTrack';
|
|
8
21
|
import mediaDevices from './MediaDevices';
|
|
9
22
|
import permissions from './Permissions';
|
|
10
|
-
export {
|
|
23
|
+
export { RTCIceCandidate, RTCPeerConnection, RTCSessionDescription, RTCView, ScreenCapturePickerView, RTCRtpTransceiver, RTCRtpReceiver, RTCRtpSender, RTCErrorEvent, RTCRtpCapabilities, RTCRtpCodecCapability, RTCRtpCodecParameters, RTCRtpEncodingParameters, RTCRtpParameters, RTCRtpSendParameters, RTCRtpReceiveParameters, RTCRtcpParameters, RTCRtpHeaderExtension, MediaStream, MediaStreamTrack, mediaDevices, permissions, registerGlobals };
|
|
11
24
|
declare function registerGlobals(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webrtc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "106.0.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"main": "lib/commonjs/index.js",
|
|
21
21
|
"module": "lib/module/index.js",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"adm-zip": "0.5.9",
|
|
23
24
|
"base64-js": "1.5.1",
|
|
25
|
+
"debug": "4.3.4",
|
|
24
26
|
"event-target-shim": "6.0.2",
|
|
25
27
|
"tar": "6.1.11"
|
|
26
28
|
},
|
|
@@ -36,6 +38,7 @@
|
|
|
36
38
|
"url": "https://github.com/react-native-webrtc/react-native-webrtc/issues"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
41
|
+
"@types/debug": "4.1.7",
|
|
39
42
|
"@types/react": "17.0.40",
|
|
40
43
|
"@types/react-native": "0.67.3",
|
|
41
44
|
"husky": "7.0.2",
|
|
@@ -57,8 +60,7 @@
|
|
|
57
60
|
]
|
|
58
61
|
},
|
|
59
62
|
"webrtc-builds": {
|
|
60
|
-
"android": "https://github.com/jitsi/webrtc/releases/download/
|
|
61
|
-
"ios": "https://github.com/jitsi/webrtc/releases/download/
|
|
62
|
-
"ios-bitcode": "https://github.com/jitsi/webrtc/releases/download/v100.0.0/WebRTC.xcframework-bitcode.tgz"
|
|
63
|
+
"android": "https://github.com/jitsi/webrtc/releases/download/v106.0.0-rc.1/android-webrtc.zip",
|
|
64
|
+
"ios": "https://github.com/jitsi/webrtc/releases/download/v106.0.0-rc.1/WebRTC.xcframework.zip"
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.source = { :git => 'git@github.com:react-native-webrtc/react-native-webrtc.git', :tag => 'release #{s.version}' }
|
|
13
13
|
s.requires_arc = true
|
|
14
14
|
|
|
15
|
-
s.platforms = { :ios => '
|
|
15
|
+
s.platforms = { :ios => '12.0', :osx => '10.13' }
|
|
16
16
|
|
|
17
17
|
s.preserve_paths = 'ios/**/*'
|
|
18
18
|
s.source_files = 'ios/**/*.{h,m}'
|
package/src/EventEmitter.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
1
|
+
import { NativeModules, NativeEventEmitter, EmitterSubscription } from 'react-native';
|
|
2
2
|
|
|
3
3
|
const { WebRTCModule } = NativeModules;
|
|
4
4
|
|
|
5
5
|
const EventEmitter = new NativeEventEmitter(WebRTCModule);
|
|
6
6
|
|
|
7
7
|
export default EventEmitter;
|
|
8
|
+
|
|
9
|
+
const _subscriptions: Map<any, EmitterSubscription[]> = new Map();
|
|
10
|
+
|
|
11
|
+
type EventHandler = (event: any) => void;
|
|
12
|
+
|
|
13
|
+
export function addListener(listener: any, eventName: string, eventHandler: EventHandler): void {
|
|
14
|
+
if (!_subscriptions.has(listener)) {
|
|
15
|
+
_subscriptions.set(listener, []);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_subscriptions.get(listener)?.push(EventEmitter.addListener(eventName, eventHandler));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function removeListener(listener: any): void {
|
|
22
|
+
_subscriptions.get(listener)?.forEach(sub => {
|
|
23
|
+
sub.remove();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
_subscriptions.delete(listener);
|
|
27
|
+
}
|
package/src/Logger.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default class Logger {
|
|
5
|
+
static ROOT_PREFIX = 'rn-webrtc';
|
|
6
|
+
|
|
7
|
+
private _debug: debug.Debugger;
|
|
8
|
+
private _info: debug.Debugger;
|
|
9
|
+
private _warn: debug.Debugger;
|
|
10
|
+
private _error: debug.Debugger;
|
|
11
|
+
|
|
12
|
+
static enable(ns: string): void {
|
|
13
|
+
debug.enable(ns);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor(prefix: string) {
|
|
17
|
+
const _prefix = `${Logger.ROOT_PREFIX}:${prefix}`;
|
|
18
|
+
|
|
19
|
+
this._debug = debug(`${_prefix}:DEBUG`);
|
|
20
|
+
this._info = debug(`${_prefix}:INFO`);
|
|
21
|
+
this._warn = debug(`${_prefix}:WARN`);
|
|
22
|
+
this._error = debug(`${_prefix}:ERROR`);
|
|
23
|
+
|
|
24
|
+
const log = console.log.bind(console);
|
|
25
|
+
|
|
26
|
+
this._debug.log = log;
|
|
27
|
+
this._info.log = log;
|
|
28
|
+
this._warn.log = log;
|
|
29
|
+
this._error.log = log;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
debug(msg: string): void {
|
|
33
|
+
this._debug(msg);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
info(msg: string): void {
|
|
37
|
+
this._info(msg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
warn(msg: string): void {
|
|
41
|
+
this._warn(msg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
error(msg: string, err?: Error): void {
|
|
45
|
+
const trace = err?.stack ?? 'N/A';
|
|
46
|
+
|
|
47
|
+
this._error(`${msg} Trace: ${trace}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/MediaStream.ts
CHANGED
|
@@ -11,9 +11,9 @@ const MEDIA_STREAM_EVENTS = ['active', 'inactive', 'addtrack', 'removetrack'];
|
|
|
11
11
|
|
|
12
12
|
export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {
|
|
13
13
|
id: string;
|
|
14
|
-
active
|
|
14
|
+
active = true;
|
|
15
15
|
|
|
16
|
-
_tracks:
|
|
16
|
+
_tracks: MediaStreamTrack[] = [];
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The identifier of this MediaStream unique within the associated
|
|
@@ -26,7 +26,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
26
26
|
_reactTag: string;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* A MediaStream can be constructed in several ways, depending on the
|
|
29
|
+
* A MediaStream can be constructed in several ways, depending on the parameters
|
|
30
30
|
* that are passed here.
|
|
31
31
|
*
|
|
32
32
|
* - undefined: just a new stream, with no tracks.
|
|
@@ -72,7 +72,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
addTrack(track: MediaStreamTrack) {
|
|
75
|
+
addTrack(track: MediaStreamTrack): void {
|
|
76
76
|
const index = this._tracks.indexOf(track);
|
|
77
77
|
if (index !== -1) {
|
|
78
78
|
return;
|
|
@@ -81,7 +81,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
81
81
|
WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
removeTrack(track: MediaStreamTrack) {
|
|
84
|
+
removeTrack(track: MediaStreamTrack): void {
|
|
85
85
|
const index = this._tracks.indexOf(track);
|
|
86
86
|
if (index === -1) {
|
|
87
87
|
return;
|
|
@@ -90,7 +90,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
90
90
|
WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
getTracks():
|
|
93
|
+
getTracks(): MediaStreamTrack[] {
|
|
94
94
|
return this._tracks.slice();
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -98,23 +98,23 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
98
98
|
return this._tracks.find(track => track.id === trackId);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
getAudioTracks():
|
|
101
|
+
getAudioTracks(): MediaStreamTrack[] {
|
|
102
102
|
return this._tracks.filter(track => track.kind === 'audio');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
getVideoTracks():
|
|
105
|
+
getVideoTracks(): MediaStreamTrack[] {
|
|
106
106
|
return this._tracks.filter(track => track.kind === 'video');
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
clone() {
|
|
109
|
+
clone(): never {
|
|
110
110
|
throw new Error('Not implemented.');
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
toURL() {
|
|
113
|
+
toURL(): string {
|
|
114
114
|
return this._reactTag;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
release(releaseTracks = true) {
|
|
117
|
+
release(releaseTracks = true): void {
|
|
118
118
|
const tracks = [...this._tracks];
|
|
119
119
|
for (const track of tracks) {
|
|
120
120
|
this.removeTrack(track);
|