react-native-webrtc 111.0.1 → 111.0.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/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -1
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +19 -14
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +27 -5
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +21 -21
- package/ios/RCTWebRTC/SerializeUtils.m +12 -10
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +0 -3
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +19 -9
- package/lib/commonjs/EventEmitter.js +4 -16
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js +2 -26
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +2 -14
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +15 -44
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamError.js +0 -11
- package/lib/commonjs/MediaStreamError.js.map +1 -1
- package/lib/commonjs/MediaStreamErrorEvent.js +0 -9
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamEvent.js +0 -9
- package/lib/commonjs/MediaStreamEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +6 -65
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/MediaStreamTrackEvent.js +0 -9
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
- package/lib/commonjs/MessageEvent.js +0 -9
- package/lib/commonjs/MessageEvent.js.map +1 -1
- package/lib/commonjs/Permissions.js +19 -29
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCDataChannel.js +8 -71
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCDataChannelEvent.js +0 -9
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +0 -12
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCEvent.js +0 -7
- package/lib/commonjs/RTCEvent.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js +0 -14
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCIceCandidateEvent.js +1 -12
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +116 -221
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js +0 -10
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js +5 -22
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecCapability.js +0 -8
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js +0 -19
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +4 -34
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js +0 -12
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js +2 -18
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js +0 -5
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js +1 -26
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js +0 -22
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js +1 -30
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +3 -36
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js +0 -13
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +1 -15
- package/lib/commonjs/RTCTrackEvent.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +9 -36
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js +6 -3
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/ScreenCapturePickerView.js +0 -3
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js +0 -6
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js +7 -28
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +1 -26
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/EventEmitter.js +5 -12
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js +2 -22
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +2 -7
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +15 -36
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamError.js +0 -9
- package/lib/module/MediaStreamError.js.map +1 -1
- package/lib/module/MediaStreamErrorEvent.js +0 -7
- package/lib/module/MediaStreamErrorEvent.js.map +1 -1
- package/lib/module/MediaStreamEvent.js +0 -7
- package/lib/module/MediaStreamEvent.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +6 -58
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/MediaStreamTrackEvent.js +0 -7
- package/lib/module/MediaStreamTrackEvent.js.map +1 -1
- package/lib/module/MessageEvent.js +0 -7
- package/lib/module/MessageEvent.js.map +1 -1
- package/lib/module/Permissions.js +19 -26
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCDataChannel.js +8 -59
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCDataChannelEvent.js +0 -7
- package/lib/module/RTCDataChannelEvent.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +0 -9
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCEvent.js +0 -5
- package/lib/module/RTCEvent.js.map +1 -1
- package/lib/module/RTCIceCandidate.js +0 -12
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCIceCandidateEvent.js +1 -10
- package/lib/module/RTCIceCandidateEvent.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +116 -195
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js +0 -8
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js +5 -17
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecCapability.js +0 -6
- package/lib/module/RTCRtpCodecCapability.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js +0 -17
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +4 -32
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js +0 -10
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js +2 -12
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js +0 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js +1 -19
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js +0 -18
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js +1 -23
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +3 -32
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js +0 -11
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +1 -13
- package/lib/module/RTCTrackEvent.js.map +1 -1
- package/lib/module/RTCUtil.js +9 -32
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js +1 -0
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/ScreenCapturePickerView.js.map +1 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js +7 -18
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +2 -7
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/EventEmitter.d.ts +3 -2
- package/lib/typescript/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/Logger.d.ts +1 -0
- package/lib/typescript/Logger.d.ts.map +1 -0
- package/lib/typescript/MediaDevices.d.ts +1 -0
- package/lib/typescript/MediaDevices.d.ts.map +1 -0
- package/lib/typescript/MediaStream.d.ts +4 -2
- package/lib/typescript/MediaStream.d.ts.map +1 -0
- package/lib/typescript/MediaStreamError.d.ts +1 -0
- package/lib/typescript/MediaStreamError.d.ts.map +1 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts +1 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts.map +1 -0
- package/lib/typescript/MediaStreamEvent.d.ts +1 -0
- package/lib/typescript/MediaStreamEvent.d.ts.map +1 -0
- package/lib/typescript/MediaStreamTrack.d.ts +2 -1
- package/lib/typescript/MediaStreamTrack.d.ts.map +1 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts +1 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts.map +1 -0
- package/lib/typescript/MessageEvent.d.ts +2 -1
- package/lib/typescript/MessageEvent.d.ts.map +1 -0
- package/lib/typescript/Permissions.d.ts +2 -1
- package/lib/typescript/Permissions.d.ts.map +1 -0
- package/lib/typescript/RTCDataChannel.d.ts +2 -1
- package/lib/typescript/RTCDataChannel.d.ts.map +1 -0
- package/lib/typescript/RTCDataChannelEvent.d.ts +1 -0
- package/lib/typescript/RTCDataChannelEvent.d.ts.map +1 -0
- package/lib/typescript/RTCErrorEvent.d.ts +2 -1
- package/lib/typescript/RTCErrorEvent.d.ts.map +1 -0
- package/lib/typescript/RTCEvent.d.ts +1 -0
- package/lib/typescript/RTCEvent.d.ts.map +1 -0
- package/lib/typescript/RTCIceCandidate.d.ts +1 -0
- package/lib/typescript/RTCIceCandidate.d.ts.map +1 -0
- package/lib/typescript/RTCIceCandidateEvent.d.ts +1 -0
- package/lib/typescript/RTCIceCandidateEvent.d.ts.map +1 -0
- package/lib/typescript/RTCPeerConnection.d.ts +6 -5
- package/lib/typescript/RTCPeerConnection.d.ts.map +1 -0
- package/lib/typescript/RTCRtcpParameters.d.ts +1 -0
- package/lib/typescript/RTCRtcpParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts +1 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts +1 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts +1 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts.map +1 -0
- package/lib/typescript/RTCRtpParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpReceiver.d.ts +1 -0
- package/lib/typescript/RTCRtpReceiver.d.ts.map +1 -0
- package/lib/typescript/RTCRtpSendParameters.d.ts +2 -1
- package/lib/typescript/RTCRtpSendParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpSender.d.ts +1 -0
- package/lib/typescript/RTCRtpSender.d.ts.map +1 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts +1 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts.map +1 -0
- package/lib/typescript/RTCSessionDescription.d.ts +1 -0
- package/lib/typescript/RTCSessionDescription.d.ts.map +1 -0
- package/lib/typescript/RTCTrackEvent.d.ts +1 -0
- package/lib/typescript/RTCTrackEvent.d.ts.map +1 -0
- package/lib/typescript/RTCUtil.d.ts +1 -0
- package/lib/typescript/RTCUtil.d.ts.map +1 -0
- package/lib/typescript/RTCView.d.ts +1 -0
- package/lib/typescript/RTCView.d.ts.map +1 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts +1 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts.map +1 -0
- package/lib/typescript/getDisplayMedia.d.ts +1 -0
- package/lib/typescript/getDisplayMedia.d.ts.map +1 -0
- package/lib/typescript/getUserMedia.d.ts +1 -0
- package/lib/typescript/getUserMedia.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +2 -4
- package/src/MediaStream.ts +17 -7
- package/src/RTCPeerConnection.ts +20 -1
- package/src/RTCRtpTransceiver.ts +2 -2
- package/src/index.ts +1 -2
|
@@ -4,234 +4,185 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _eventTargetShim = require("event-target-shim");
|
|
9
|
-
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
9
|
var _EventEmitter = require("./EventEmitter");
|
|
13
|
-
|
|
14
10
|
var _Logger = _interopRequireDefault(require("./Logger"));
|
|
15
|
-
|
|
16
11
|
var _MediaStream = _interopRequireDefault(require("./MediaStream"));
|
|
17
|
-
|
|
18
12
|
var _MediaStreamTrack = _interopRequireDefault(require("./MediaStreamTrack"));
|
|
19
|
-
|
|
20
13
|
var _MediaStreamTrackEvent = _interopRequireDefault(require("./MediaStreamTrackEvent"));
|
|
21
|
-
|
|
22
14
|
var _RTCDataChannel = _interopRequireDefault(require("./RTCDataChannel"));
|
|
23
|
-
|
|
24
15
|
var _RTCDataChannelEvent = _interopRequireDefault(require("./RTCDataChannelEvent"));
|
|
25
|
-
|
|
26
16
|
var _RTCEvent = _interopRequireDefault(require("./RTCEvent"));
|
|
27
|
-
|
|
28
17
|
var _RTCIceCandidate = _interopRequireDefault(require("./RTCIceCandidate"));
|
|
29
|
-
|
|
30
18
|
var _RTCIceCandidateEvent = _interopRequireDefault(require("./RTCIceCandidateEvent"));
|
|
31
|
-
|
|
32
19
|
var _RTCRtpReceiveParameters = _interopRequireDefault(require("./RTCRtpReceiveParameters"));
|
|
33
|
-
|
|
34
20
|
var _RTCRtpReceiver = _interopRequireDefault(require("./RTCRtpReceiver"));
|
|
35
|
-
|
|
36
21
|
var _RTCRtpSendParameters = _interopRequireDefault(require("./RTCRtpSendParameters"));
|
|
37
|
-
|
|
38
22
|
var _RTCRtpSender = _interopRequireDefault(require("./RTCRtpSender"));
|
|
39
|
-
|
|
40
23
|
var _RTCRtpTransceiver = _interopRequireDefault(require("./RTCRtpTransceiver"));
|
|
41
|
-
|
|
42
24
|
var _RTCSessionDescription = _interopRequireDefault(require("./RTCSessionDescription"));
|
|
43
|
-
|
|
44
25
|
var _RTCTrackEvent = _interopRequireDefault(require("./RTCTrackEvent"));
|
|
45
|
-
|
|
46
26
|
var RTCUtil = _interopRequireWildcard(require("./RTCUtil"));
|
|
47
|
-
|
|
48
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
49
|
-
|
|
50
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
51
|
-
|
|
52
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
|
-
|
|
54
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
55
|
-
|
|
56
30
|
const log = new _Logger.default('pc');
|
|
57
31
|
const {
|
|
58
32
|
WebRTCModule
|
|
59
33
|
} = _reactNative.NativeModules;
|
|
60
34
|
const PEER_CONNECTION_EVENTS = ['connectionstatechange', 'icecandidate', 'icecandidateerror', 'iceconnectionstatechange', 'icegatheringstatechange', 'negotiationneeded', 'signalingstatechange', 'datachannel', 'track', 'error'];
|
|
61
35
|
let nextPeerConnectionId = 0;
|
|
62
|
-
|
|
63
36
|
class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(...PEER_CONNECTION_EVENTS) {
|
|
37
|
+
localDescription = null;
|
|
38
|
+
remoteDescription = null;
|
|
39
|
+
signalingState = 'stable';
|
|
40
|
+
iceGatheringState = 'new';
|
|
41
|
+
connectionState = 'new';
|
|
42
|
+
iceConnectionState = 'new';
|
|
64
43
|
constructor(configuration) {
|
|
65
44
|
super();
|
|
66
|
-
|
|
67
|
-
_defineProperty(this, "localDescription", null);
|
|
68
|
-
|
|
69
|
-
_defineProperty(this, "remoteDescription", null);
|
|
70
|
-
|
|
71
|
-
_defineProperty(this, "signalingState", 'stable');
|
|
72
|
-
|
|
73
|
-
_defineProperty(this, "iceGatheringState", 'new');
|
|
74
|
-
|
|
75
|
-
_defineProperty(this, "connectionState", 'new');
|
|
76
|
-
|
|
77
|
-
_defineProperty(this, "iceConnectionState", 'new');
|
|
78
|
-
|
|
79
|
-
_defineProperty(this, "_pcId", void 0);
|
|
80
|
-
|
|
81
|
-
_defineProperty(this, "_transceivers", void 0);
|
|
82
|
-
|
|
83
|
-
_defineProperty(this, "_remoteStreams", void 0);
|
|
84
|
-
|
|
85
|
-
_defineProperty(this, "_pendingTrackEvents", void 0);
|
|
86
|
-
|
|
87
45
|
this._pcId = nextPeerConnectionId++;
|
|
88
46
|
WebRTCModule.peerConnectionInit(configuration, this._pcId);
|
|
89
47
|
this._transceivers = [];
|
|
90
48
|
this._remoteStreams = new Map();
|
|
91
49
|
this._pendingTrackEvents = [];
|
|
92
|
-
|
|
93
50
|
this._registerEvents();
|
|
94
|
-
|
|
95
51
|
log.debug(`${this._pcId} ctor`);
|
|
96
52
|
}
|
|
97
|
-
|
|
98
53
|
async createOffer(options) {
|
|
99
54
|
log.debug(`${this._pcId} createOffer`);
|
|
100
55
|
const {
|
|
101
56
|
sdpInfo,
|
|
57
|
+
newTransceivers,
|
|
102
58
|
transceiversInfo
|
|
103
59
|
} = await WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options));
|
|
104
60
|
log.debug(`${this._pcId} createOffer OK`);
|
|
105
|
-
|
|
61
|
+
newTransceivers === null || newTransceivers === void 0 ? void 0 : newTransceivers.forEach(t => {
|
|
62
|
+
const {
|
|
63
|
+
transceiverOrder,
|
|
64
|
+
transceiver
|
|
65
|
+
} = t;
|
|
66
|
+
const newSender = new _RTCRtpSender.default({
|
|
67
|
+
...transceiver.sender,
|
|
68
|
+
track: null
|
|
69
|
+
});
|
|
70
|
+
const remoteTrack = transceiver.receiver.track ? new _MediaStreamTrack.default(transceiver.receiver.track) : null;
|
|
71
|
+
const newReceiver = new _RTCRtpReceiver.default({
|
|
72
|
+
...transceiver.receiver,
|
|
73
|
+
track: remoteTrack
|
|
74
|
+
});
|
|
75
|
+
const newTransceiver = new _RTCRtpTransceiver.default({
|
|
76
|
+
...transceiver,
|
|
77
|
+
sender: newSender,
|
|
78
|
+
receiver: newReceiver
|
|
79
|
+
});
|
|
80
|
+
this._insertTransceiverSorted(transceiverOrder, newTransceiver);
|
|
81
|
+
});
|
|
106
82
|
this._updateTransceivers(transceiversInfo);
|
|
107
|
-
|
|
108
83
|
return sdpInfo;
|
|
109
84
|
}
|
|
110
|
-
|
|
111
85
|
async createAnswer() {
|
|
112
86
|
log.debug(`${this._pcId} createAnswer`);
|
|
113
87
|
const {
|
|
114
88
|
sdpInfo,
|
|
115
89
|
transceiversInfo
|
|
116
90
|
} = await WebRTCModule.peerConnectionCreateAnswer(this._pcId, {});
|
|
117
|
-
|
|
118
91
|
this._updateTransceivers(transceiversInfo);
|
|
119
|
-
|
|
120
92
|
return sdpInfo;
|
|
121
93
|
}
|
|
122
|
-
|
|
123
94
|
setConfiguration(configuration) {
|
|
124
95
|
WebRTCModule.peerConnectionSetConfiguration(configuration, this._pcId);
|
|
125
96
|
}
|
|
126
|
-
|
|
127
97
|
async setLocalDescription(sessionDescription) {
|
|
128
98
|
var _desc;
|
|
129
|
-
|
|
130
99
|
log.debug(`${this._pcId} setLocalDescription`);
|
|
131
100
|
let desc;
|
|
132
|
-
|
|
133
101
|
if (sessionDescription) {
|
|
134
|
-
var _sessionDescription$s;
|
|
135
|
-
|
|
136
102
|
desc = {
|
|
137
103
|
type: sessionDescription.type,
|
|
138
|
-
sdp:
|
|
104
|
+
sdp: sessionDescription.sdp ?? ''
|
|
139
105
|
};
|
|
140
|
-
|
|
141
106
|
if (!RTCUtil.isSdpTypeValid(desc.type)) {
|
|
142
107
|
throw new Error(`Invalid session description: invalid type: ${desc.type}`);
|
|
143
108
|
}
|
|
144
109
|
} else {
|
|
145
110
|
desc = null;
|
|
146
111
|
}
|
|
147
|
-
|
|
148
112
|
const {
|
|
149
113
|
sdpInfo,
|
|
150
114
|
transceiversInfo
|
|
151
115
|
} = await WebRTCModule.peerConnectionSetLocalDescription(this._pcId, desc);
|
|
152
|
-
|
|
153
116
|
if (sdpInfo.type && sdpInfo.sdp) {
|
|
154
117
|
this.localDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
155
118
|
} else {
|
|
156
119
|
this.localDescription = null;
|
|
157
120
|
}
|
|
158
|
-
|
|
159
|
-
this._updateTransceivers(transceiversInfo,
|
|
160
|
-
/* removeStopped */
|
|
161
|
-
((_desc = desc) === null || _desc === void 0 ? void 0 : _desc.type) === 'answer');
|
|
162
|
-
|
|
121
|
+
this._updateTransceivers(transceiversInfo, /* removeStopped */((_desc = desc) === null || _desc === void 0 ? void 0 : _desc.type) === 'answer');
|
|
163
122
|
log.debug(`${this._pcId} setLocalDescription OK`);
|
|
164
123
|
}
|
|
165
|
-
|
|
166
124
|
async setRemoteDescription(sessionDescription) {
|
|
167
|
-
var _sessionDescription$s2, _desc$type;
|
|
168
|
-
|
|
169
125
|
log.debug(`${this._pcId} setRemoteDescription`);
|
|
170
|
-
|
|
171
126
|
if (!sessionDescription) {
|
|
172
127
|
return Promise.reject(new Error('No session description provided'));
|
|
173
128
|
}
|
|
174
|
-
|
|
175
129
|
const desc = {
|
|
176
130
|
type: sessionDescription.type,
|
|
177
|
-
sdp:
|
|
131
|
+
sdp: sessionDescription.sdp ?? ''
|
|
178
132
|
};
|
|
179
|
-
|
|
180
|
-
if (!RTCUtil.isSdpTypeValid((_desc$type = desc.type) !== null && _desc$type !== void 0 ? _desc$type : '')) {
|
|
133
|
+
if (!RTCUtil.isSdpTypeValid(desc.type ?? '')) {
|
|
181
134
|
throw new Error(`Invalid session description: invalid type: ${desc.type}`);
|
|
182
135
|
}
|
|
183
|
-
|
|
184
136
|
const {
|
|
185
137
|
sdpInfo,
|
|
186
138
|
newTransceivers,
|
|
187
139
|
transceiversInfo
|
|
188
140
|
} = await WebRTCModule.peerConnectionSetRemoteDescription(this._pcId, desc);
|
|
189
|
-
|
|
190
141
|
if (sdpInfo.type && sdpInfo.sdp) {
|
|
191
142
|
this.remoteDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
192
143
|
} else {
|
|
193
144
|
this.remoteDescription = null;
|
|
194
145
|
}
|
|
195
|
-
|
|
196
146
|
newTransceivers === null || newTransceivers === void 0 ? void 0 : newTransceivers.forEach(t => {
|
|
197
147
|
const {
|
|
198
148
|
transceiverOrder,
|
|
199
149
|
transceiver
|
|
200
150
|
} = t;
|
|
201
|
-
const newSender = new _RTCRtpSender.default({
|
|
151
|
+
const newSender = new _RTCRtpSender.default({
|
|
152
|
+
...transceiver.sender,
|
|
202
153
|
track: null
|
|
203
154
|
});
|
|
204
155
|
const remoteTrack = transceiver.receiver.track ? new _MediaStreamTrack.default(transceiver.receiver.track) : null;
|
|
205
|
-
const newReceiver = new _RTCRtpReceiver.default({
|
|
156
|
+
const newReceiver = new _RTCRtpReceiver.default({
|
|
157
|
+
...transceiver.receiver,
|
|
206
158
|
track: remoteTrack
|
|
207
159
|
});
|
|
208
|
-
const newTransceiver = new _RTCRtpTransceiver.default({
|
|
160
|
+
const newTransceiver = new _RTCRtpTransceiver.default({
|
|
161
|
+
...transceiver,
|
|
209
162
|
sender: newSender,
|
|
210
163
|
receiver: newReceiver
|
|
211
164
|
});
|
|
212
|
-
|
|
213
165
|
this._insertTransceiverSorted(transceiverOrder, newTransceiver);
|
|
214
166
|
});
|
|
167
|
+
this._updateTransceivers(transceiversInfo, /* removeStopped */desc.type === 'answer');
|
|
215
168
|
|
|
216
|
-
|
|
217
|
-
/* removeStopped */
|
|
218
|
-
desc.type === 'answer'); // Fire track events. They must fire before sRD resolves.
|
|
219
|
-
|
|
220
|
-
|
|
169
|
+
// Fire track events. They must fire before sRD resolves.
|
|
221
170
|
const pendingTrackEvents = this._pendingTrackEvents;
|
|
222
171
|
this._pendingTrackEvents = [];
|
|
223
|
-
|
|
224
172
|
for (const ev of pendingTrackEvents) {
|
|
225
|
-
const [transceiver] = this.getTransceivers().filter(t => t.receiver.id === ev.receiver.id);
|
|
173
|
+
const [transceiver] = this.getTransceivers().filter(t => t.receiver.id === ev.receiver.id);
|
|
174
|
+
|
|
175
|
+
// We need to fire this event for an existing track sometimes, like
|
|
226
176
|
// when the transceiver direction (on the sending side) switches from
|
|
227
177
|
// sendrecv to recvonly and then back.
|
|
228
|
-
// @ts-ignore
|
|
229
178
|
|
|
179
|
+
// @ts-ignore
|
|
230
180
|
const track = transceiver.receiver.track;
|
|
231
181
|
transceiver._mid = ev.transceiver.mid;
|
|
232
182
|
transceiver._currentDirection = ev.transceiver.currentDirection;
|
|
233
|
-
transceiver._direction = ev.transceiver.direction;
|
|
183
|
+
transceiver._direction = ev.transceiver.direction;
|
|
234
184
|
|
|
185
|
+
// Get the stream object from the event. Create if necessary.
|
|
235
186
|
const streams = ev.streams.map(streamInfo => {
|
|
236
187
|
// Here we are making sure that we don't create stream objects that already exist
|
|
237
188
|
// So that event listeners do get the same object if it has been created before.
|
|
@@ -241,16 +192,12 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
241
192
|
streamReactTag: streamInfo.streamReactTag,
|
|
242
193
|
tracks: []
|
|
243
194
|
});
|
|
244
|
-
|
|
245
195
|
this._remoteStreams.set(streamInfo.streamId, stream);
|
|
246
196
|
}
|
|
247
|
-
|
|
248
197
|
const stream = this._remoteStreams.get(streamInfo.streamId);
|
|
249
|
-
|
|
250
198
|
if (!(stream !== null && stream !== void 0 && stream._tracks.includes(track))) {
|
|
251
199
|
stream === null || stream === void 0 ? void 0 : stream._tracks.push(track);
|
|
252
200
|
}
|
|
253
|
-
|
|
254
201
|
return stream;
|
|
255
202
|
});
|
|
256
203
|
const eventData = {
|
|
@@ -258,37 +205,35 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
258
205
|
transceiver,
|
|
259
206
|
track,
|
|
260
207
|
receiver: transceiver.receiver
|
|
261
|
-
};
|
|
208
|
+
};
|
|
262
209
|
|
|
210
|
+
// @ts-ignore
|
|
263
211
|
this.dispatchEvent(new _RTCTrackEvent.default('track', eventData));
|
|
264
212
|
streams.forEach(stream => {
|
|
265
213
|
// @ts-ignore
|
|
266
214
|
stream.dispatchEvent(new _MediaStreamTrackEvent.default('addtrack', {
|
|
267
215
|
track
|
|
268
216
|
}));
|
|
269
|
-
});
|
|
217
|
+
});
|
|
270
218
|
|
|
219
|
+
// Dispatch an unmute event for the track.
|
|
271
220
|
track._setMutedInternal(false);
|
|
272
221
|
}
|
|
273
|
-
|
|
274
222
|
log.debug(`${this._pcId} setRemoteDescription OK`);
|
|
275
223
|
}
|
|
276
|
-
|
|
277
224
|
async addIceCandidate(candidate) {
|
|
278
225
|
log.debug(`${this._pcId} addIceCandidate`);
|
|
279
|
-
|
|
280
226
|
if (!candidate || !candidate.candidate) {
|
|
281
227
|
// XXX end-of candidates is not implemented: https://bugs.chromium.org/p/webrtc/issues/detail?id=9218
|
|
282
228
|
return;
|
|
283
229
|
}
|
|
284
|
-
|
|
285
230
|
if (candidate.sdpMLineIndex === null || candidate.sdpMLineIndex === undefined || candidate.sdpMid === null || candidate.sdpMid === undefined) {
|
|
286
231
|
throw new TypeError('`sdpMLineIndex` and `sdpMid` must not null or undefined');
|
|
287
232
|
}
|
|
288
|
-
|
|
289
233
|
const newSdp = await WebRTCModule.peerConnectionAddICECandidate(this._pcId, candidate.toJSON ? candidate.toJSON() : candidate);
|
|
290
234
|
this.remoteDescription = new _RTCSessionDescription.default(newSdp);
|
|
291
235
|
}
|
|
236
|
+
|
|
292
237
|
/**
|
|
293
238
|
* @brief Adds a new track to the {@link RTCPeerConnection},
|
|
294
239
|
* and indicates that it is contained in the specified {@link MediaStream}s.
|
|
@@ -297,73 +242,65 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
297
242
|
* @param {...MediaStream} streams One or more {@link MediaStream}s the track needs to be added to
|
|
298
243
|
* https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack
|
|
299
244
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
245
|
addTrack(track) {
|
|
303
246
|
log.debug(`${this._pcId} addTrack`);
|
|
304
|
-
|
|
305
247
|
if (this.connectionState === 'closed') {
|
|
306
248
|
throw new Error('Peer Connection is closed');
|
|
307
249
|
}
|
|
308
|
-
|
|
309
250
|
if (this._trackExists(track)) {
|
|
310
251
|
throw new Error('Track already exists in a sender');
|
|
311
252
|
}
|
|
312
|
-
|
|
313
253
|
for (var _len = arguments.length, streams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
314
254
|
streams[_key - 1] = arguments[_key];
|
|
315
255
|
}
|
|
316
|
-
|
|
317
256
|
const streamIds = streams.map(s => s.id);
|
|
318
257
|
const result = WebRTCModule.peerConnectionAddTrack(this._pcId, track.id, {
|
|
319
258
|
streamIds
|
|
320
259
|
});
|
|
321
|
-
|
|
322
260
|
if (result === null) {
|
|
323
261
|
throw new Error('Could not add sender');
|
|
324
262
|
}
|
|
325
|
-
|
|
326
263
|
const {
|
|
327
264
|
transceiverOrder,
|
|
328
265
|
transceiver,
|
|
329
266
|
sender
|
|
330
|
-
} = result;
|
|
331
|
-
// so we check if that is the case, and update accordingly.
|
|
267
|
+
} = result;
|
|
332
268
|
|
|
269
|
+
// According to the W3C docs, the sender could have been reused, and
|
|
270
|
+
// so we check if that is the case, and update accordingly.
|
|
333
271
|
const [existingSender] = this.getSenders().filter(s => s.id === sender.id);
|
|
334
|
-
|
|
335
272
|
if (existingSender) {
|
|
336
273
|
// Update sender
|
|
337
|
-
existingSender._track = track;
|
|
274
|
+
existingSender._track = track;
|
|
338
275
|
|
|
276
|
+
// Update the corresponding transceiver as well
|
|
339
277
|
const [existingTransceiver] = this.getTransceivers().filter(t => t.sender.id === existingSender.id);
|
|
340
278
|
existingTransceiver._direction = transceiver.direction;
|
|
341
279
|
existingTransceiver._currentDirection = transceiver.currentDirection;
|
|
342
280
|
return existingSender;
|
|
343
|
-
}
|
|
344
|
-
|
|
281
|
+
}
|
|
345
282
|
|
|
346
|
-
|
|
283
|
+
// This is a new transceiver, should create a transceiver for it and add it
|
|
284
|
+
const newSender = new _RTCRtpSender.default({
|
|
285
|
+
...transceiver.sender,
|
|
347
286
|
track
|
|
348
287
|
});
|
|
349
288
|
const remoteTrack = transceiver.receiver.track ? new _MediaStreamTrack.default(transceiver.receiver.track) : null;
|
|
350
|
-
const newReceiver = new _RTCRtpReceiver.default({
|
|
289
|
+
const newReceiver = new _RTCRtpReceiver.default({
|
|
290
|
+
...transceiver.receiver,
|
|
351
291
|
track: remoteTrack
|
|
352
292
|
});
|
|
353
|
-
const newTransceiver = new _RTCRtpTransceiver.default({
|
|
293
|
+
const newTransceiver = new _RTCRtpTransceiver.default({
|
|
294
|
+
...transceiver,
|
|
354
295
|
sender: newSender,
|
|
355
296
|
receiver: newReceiver
|
|
356
297
|
});
|
|
357
|
-
|
|
358
298
|
this._insertTransceiverSorted(transceiverOrder, newTransceiver);
|
|
359
|
-
|
|
360
299
|
return newSender;
|
|
361
300
|
}
|
|
362
|
-
|
|
363
301
|
addTransceiver(source, init) {
|
|
364
302
|
log.debug(`${this._pcId} addTransceiver`);
|
|
365
303
|
let src = {};
|
|
366
|
-
|
|
367
304
|
if (source === 'audio') {
|
|
368
305
|
src = {
|
|
369
306
|
type: 'audio'
|
|
@@ -376,25 +313,23 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
376
313
|
src = {
|
|
377
314
|
trackId: source.id
|
|
378
315
|
};
|
|
379
|
-
}
|
|
380
|
-
|
|
316
|
+
}
|
|
381
317
|
|
|
318
|
+
// Extract the stream ids
|
|
382
319
|
if (init && init.streams) {
|
|
383
320
|
init.streamIds = init.streams.map(stream => stream.id);
|
|
384
321
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
init: {
|
|
322
|
+
const result = WebRTCModule.peerConnectionAddTransceiver(this._pcId, {
|
|
323
|
+
...src,
|
|
324
|
+
init: {
|
|
325
|
+
...init
|
|
388
326
|
}
|
|
389
327
|
});
|
|
390
|
-
|
|
391
328
|
if (result === null) {
|
|
392
329
|
throw new Error('Transceiver could not be added');
|
|
393
330
|
}
|
|
394
|
-
|
|
395
331
|
const t = result.transceiver;
|
|
396
332
|
let track = null;
|
|
397
|
-
|
|
398
333
|
if (typeof source === 'string') {
|
|
399
334
|
if (t.sender.track) {
|
|
400
335
|
track = new _MediaStreamTrack.default(t.sender.track);
|
|
@@ -403,57 +338,50 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
403
338
|
// 'source' is a MediaStreamTrack
|
|
404
339
|
track = source;
|
|
405
340
|
}
|
|
406
|
-
|
|
407
|
-
|
|
341
|
+
const sender = new _RTCRtpSender.default({
|
|
342
|
+
...t.sender,
|
|
408
343
|
track
|
|
409
344
|
});
|
|
410
345
|
const remoteTrack = t.receiver.track ? new _MediaStreamTrack.default(t.receiver.track) : null;
|
|
411
|
-
const receiver = new _RTCRtpReceiver.default({
|
|
346
|
+
const receiver = new _RTCRtpReceiver.default({
|
|
347
|
+
...t.receiver,
|
|
412
348
|
track: remoteTrack
|
|
413
349
|
});
|
|
414
|
-
const transceiver = new _RTCRtpTransceiver.default({
|
|
350
|
+
const transceiver = new _RTCRtpTransceiver.default({
|
|
351
|
+
...result.transceiver,
|
|
415
352
|
sender,
|
|
416
353
|
receiver
|
|
417
354
|
});
|
|
418
|
-
|
|
419
355
|
this._insertTransceiverSorted(result.transceiverOrder, transceiver);
|
|
420
|
-
|
|
421
356
|
return transceiver;
|
|
422
357
|
}
|
|
423
|
-
|
|
424
358
|
removeTrack(sender) {
|
|
425
359
|
log.debug(`${this._pcId} removeTrack`);
|
|
426
|
-
|
|
427
360
|
if (this._pcId !== sender._peerConnectionId) {
|
|
428
361
|
throw new Error('Sender does not belong to this peer connection');
|
|
429
362
|
}
|
|
430
|
-
|
|
431
363
|
if (this.connectionState === 'closed') {
|
|
432
364
|
throw new Error('Peer Connection is closed');
|
|
433
365
|
}
|
|
434
|
-
|
|
435
366
|
const existingSender = this.getSenders().find(s => s === sender);
|
|
436
|
-
|
|
437
367
|
if (!existingSender) {
|
|
438
368
|
throw new Error('Sender does not exist');
|
|
439
369
|
}
|
|
440
|
-
|
|
441
370
|
if (existingSender.track === null) {
|
|
442
371
|
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
372
|
+
}
|
|
445
373
|
|
|
374
|
+
// Blocking!
|
|
446
375
|
WebRTCModule.peerConnectionRemoveTrack(this._pcId, sender.id);
|
|
447
376
|
existingSender._track = null;
|
|
448
377
|
const [existingTransceiver] = this.getTransceivers().filter(t => t.sender.id === existingSender.id);
|
|
449
378
|
existingTransceiver._direction = existingTransceiver.direction === 'sendrecv' ? 'recvonly' : 'inactive';
|
|
450
379
|
}
|
|
451
|
-
|
|
452
380
|
async getStats(selector) {
|
|
453
381
|
log.debug(`${this._pcId} getStats`);
|
|
454
|
-
|
|
455
382
|
if (!selector) {
|
|
456
383
|
const data = await WebRTCModule.peerConnectionGetStats(this._pcId);
|
|
384
|
+
|
|
457
385
|
/**
|
|
458
386
|
* On both Android and iOS it is faster to construct a single
|
|
459
387
|
* JSON string representing the Map of StatsReports and have it
|
|
@@ -463,13 +391,11 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
463
391
|
* Native bridge which is a bottleneck that tends to be visible in
|
|
464
392
|
* the UI when there is congestion involving UI-related passing.
|
|
465
393
|
*/
|
|
466
|
-
|
|
467
394
|
return new Map(JSON.parse(data));
|
|
468
395
|
} else {
|
|
469
396
|
const senders = this.getSenders().filter(s => s.track === selector);
|
|
470
397
|
const receivers = this.getReceivers().filter(r => r.track === selector);
|
|
471
398
|
const matches = senders.length + receivers.length;
|
|
472
|
-
|
|
473
399
|
if (matches === 0) {
|
|
474
400
|
throw new Error('Invalid selector: could not find matching sender / receiver');
|
|
475
401
|
} else if (matches > 1) {
|
|
@@ -480,70 +406,61 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
480
406
|
}
|
|
481
407
|
}
|
|
482
408
|
}
|
|
483
|
-
|
|
484
409
|
getTransceivers() {
|
|
485
410
|
return this._transceivers.map(e => e.transceiver);
|
|
486
411
|
}
|
|
487
|
-
|
|
488
412
|
getSenders() {
|
|
489
413
|
// @ts-ignore
|
|
490
414
|
return this._transceivers.map(e => !e.transceiver.stopped && e.transceiver.sender).filter(Boolean);
|
|
491
415
|
}
|
|
492
|
-
|
|
493
416
|
getReceivers() {
|
|
494
417
|
// @ts-ignore
|
|
495
418
|
return this._transceivers.map(e => !e.transceiver.stopped && e.transceiver.receiver).filter(Boolean);
|
|
496
419
|
}
|
|
497
|
-
|
|
498
420
|
close() {
|
|
499
421
|
log.debug(`${this._pcId} close`);
|
|
500
|
-
|
|
501
422
|
if (this.connectionState === 'closed') {
|
|
502
423
|
return;
|
|
503
424
|
}
|
|
425
|
+
WebRTCModule.peerConnectionClose(this._pcId);
|
|
504
426
|
|
|
505
|
-
|
|
506
|
-
|
|
427
|
+
// Mark transceivers as stopped.
|
|
507
428
|
this._transceivers.forEach(_ref => {
|
|
508
429
|
let {
|
|
509
430
|
transceiver
|
|
510
431
|
} = _ref;
|
|
511
|
-
|
|
512
432
|
transceiver._setStopped();
|
|
513
433
|
});
|
|
514
434
|
}
|
|
515
|
-
|
|
516
435
|
restartIce() {
|
|
517
436
|
WebRTCModule.peerConnectionRestartIce(this._pcId);
|
|
518
437
|
}
|
|
519
|
-
|
|
520
438
|
_registerEvents() {
|
|
521
439
|
(0, _EventEmitter.addListener)(this, 'peerConnectionOnRenegotiationNeeded', ev => {
|
|
522
440
|
if (ev.pcId !== this._pcId) {
|
|
523
441
|
return;
|
|
524
|
-
}
|
|
525
|
-
|
|
442
|
+
}
|
|
526
443
|
|
|
444
|
+
// @ts-ignore
|
|
527
445
|
this.dispatchEvent(new _RTCEvent.default('negotiationneeded'));
|
|
528
446
|
});
|
|
529
447
|
(0, _EventEmitter.addListener)(this, 'peerConnectionIceConnectionChanged', ev => {
|
|
530
448
|
if (ev.pcId !== this._pcId) {
|
|
531
449
|
return;
|
|
532
450
|
}
|
|
451
|
+
this.iceConnectionState = ev.iceConnectionState;
|
|
533
452
|
|
|
534
|
-
|
|
535
|
-
|
|
453
|
+
// @ts-ignore
|
|
536
454
|
this.dispatchEvent(new _RTCEvent.default('iceconnectionstatechange'));
|
|
537
455
|
});
|
|
538
456
|
(0, _EventEmitter.addListener)(this, 'peerConnectionStateChanged', ev => {
|
|
539
457
|
if (ev.pcId !== this._pcId) {
|
|
540
458
|
return;
|
|
541
459
|
}
|
|
460
|
+
this.connectionState = ev.connectionState;
|
|
542
461
|
|
|
543
|
-
|
|
544
|
-
|
|
462
|
+
// @ts-ignore
|
|
545
463
|
this.dispatchEvent(new _RTCEvent.default('connectionstatechange'));
|
|
546
|
-
|
|
547
464
|
if (ev.connectionState === 'closed') {
|
|
548
465
|
// This PeerConnection is done, clean up.
|
|
549
466
|
(0, _EventEmitter.removeListener)(this);
|
|
@@ -554,32 +471,30 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
554
471
|
if (ev.pcId !== this._pcId) {
|
|
555
472
|
return;
|
|
556
473
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
474
|
+
this.signalingState = ev.signalingState;
|
|
475
|
+
// @ts-ignore
|
|
560
476
|
this.dispatchEvent(new _RTCEvent.default('signalingstatechange'));
|
|
561
|
-
});
|
|
477
|
+
});
|
|
562
478
|
|
|
479
|
+
// Consider moving away from this event: https://github.com/WebKit/WebKit/pull/3953
|
|
563
480
|
(0, _EventEmitter.addListener)(this, 'peerConnectionOnTrack', ev => {
|
|
564
481
|
if (ev.pcId !== this._pcId) {
|
|
565
482
|
return;
|
|
566
483
|
}
|
|
484
|
+
log.debug(`${this._pcId} ontrack`);
|
|
567
485
|
|
|
568
|
-
|
|
486
|
+
// NOTE: We need to make sure the track event fires right before sRD completes,
|
|
569
487
|
// so we queue them up here and dispatch the events when sRD fires, but before completing it.
|
|
570
488
|
// In the future we should probably implement out own logic and drop this event altogether.
|
|
571
|
-
|
|
572
489
|
this._pendingTrackEvents.push(ev);
|
|
573
490
|
});
|
|
574
491
|
(0, _EventEmitter.addListener)(this, 'peerConnectionOnRemoveTrack', ev => {
|
|
575
492
|
if (ev.pcId !== this._pcId) {
|
|
576
493
|
return;
|
|
577
494
|
}
|
|
578
|
-
|
|
579
495
|
log.debug(`${this._pcId} onremovetrack ${ev.receiverId}`);
|
|
580
496
|
const receiver = this.getReceivers().find(r => r.id === ev.receiverId);
|
|
581
497
|
const track = receiver === null || receiver === void 0 ? void 0 : receiver.track;
|
|
582
|
-
|
|
583
498
|
if (receiver && track) {
|
|
584
499
|
// As per the spec:
|
|
585
500
|
// - Remove the track from any media streams that were previously passed to the `track` event.
|
|
@@ -589,16 +504,15 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
589
504
|
for (const stream of this._remoteStreams.values()) {
|
|
590
505
|
if (stream._tracks.includes(track)) {
|
|
591
506
|
const trackIdx = stream._tracks.indexOf(track);
|
|
592
|
-
|
|
593
507
|
log.debug(`${this._pcId} removetrack ${track.id}`);
|
|
508
|
+
stream._tracks.splice(trackIdx, 1);
|
|
594
509
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
510
|
+
// @ts-ignore
|
|
598
511
|
stream.dispatchEvent(new _MediaStreamTrackEvent.default('removetrack', {
|
|
599
512
|
track
|
|
600
|
-
}));
|
|
513
|
+
}));
|
|
601
514
|
|
|
515
|
+
// Dispatch a mute event for the track.
|
|
602
516
|
track._setMutedInternal(true);
|
|
603
517
|
}
|
|
604
518
|
}
|
|
@@ -608,17 +522,17 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
608
522
|
if (ev.pcId !== this._pcId) {
|
|
609
523
|
return;
|
|
610
524
|
}
|
|
525
|
+
const sdpInfo = ev.sdp;
|
|
611
526
|
|
|
612
|
-
|
|
613
|
-
|
|
527
|
+
// Can happen when doing a rollback.
|
|
614
528
|
if (sdpInfo.type && sdpInfo.sdp) {
|
|
615
529
|
this.localDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
616
530
|
} else {
|
|
617
531
|
this.localDescription = null;
|
|
618
532
|
}
|
|
533
|
+
const candidate = new _RTCIceCandidate.default(ev.candidate);
|
|
619
534
|
|
|
620
|
-
|
|
621
|
-
|
|
535
|
+
// @ts-ignore
|
|
622
536
|
this.dispatchEvent(new _RTCIceCandidateEvent.default('icecandidate', {
|
|
623
537
|
candidate
|
|
624
538
|
}));
|
|
@@ -627,34 +541,33 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
627
541
|
if (ev.pcId !== this._pcId) {
|
|
628
542
|
return;
|
|
629
543
|
}
|
|
630
|
-
|
|
631
544
|
this.iceGatheringState = ev.iceGatheringState;
|
|
632
|
-
|
|
633
545
|
if (this.iceGatheringState === 'complete') {
|
|
634
|
-
const sdpInfo = ev.sdp;
|
|
546
|
+
const sdpInfo = ev.sdp;
|
|
635
547
|
|
|
548
|
+
// Can happen when doing a rollback.
|
|
636
549
|
if (sdpInfo.type && sdpInfo.sdp) {
|
|
637
550
|
this.localDescription = new _RTCSessionDescription.default(sdpInfo);
|
|
638
551
|
} else {
|
|
639
552
|
this.localDescription = null;
|
|
640
|
-
}
|
|
641
|
-
|
|
553
|
+
}
|
|
642
554
|
|
|
555
|
+
// @ts-ignore
|
|
643
556
|
this.dispatchEvent(new _RTCIceCandidateEvent.default('icecandidate', {
|
|
644
557
|
candidate: null
|
|
645
558
|
}));
|
|
646
|
-
}
|
|
647
|
-
|
|
559
|
+
}
|
|
648
560
|
|
|
561
|
+
// @ts-ignore
|
|
649
562
|
this.dispatchEvent(new _RTCEvent.default('icegatheringstatechange'));
|
|
650
563
|
});
|
|
651
564
|
(0, _EventEmitter.addListener)(this, 'peerConnectionDidOpenDataChannel', ev => {
|
|
652
565
|
if (ev.pcId !== this._pcId) {
|
|
653
566
|
return;
|
|
654
567
|
}
|
|
568
|
+
const channel = new _RTCDataChannel.default(ev.dataChannel);
|
|
655
569
|
|
|
656
|
-
|
|
657
|
-
|
|
570
|
+
// @ts-ignore
|
|
658
571
|
this.dispatchEvent(new _RTCDataChannelEvent.default('datachannel', {
|
|
659
572
|
channel
|
|
660
573
|
}));
|
|
@@ -663,14 +576,13 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
663
576
|
if (ev.pcId !== this._pcId) {
|
|
664
577
|
return;
|
|
665
578
|
}
|
|
666
|
-
|
|
667
579
|
const [track] = this.getReceivers().map(r => r.track).filter(t => (t === null || t === void 0 ? void 0 : t.id) === ev.trackId);
|
|
668
|
-
|
|
669
580
|
if (track) {
|
|
670
581
|
track._setMutedInternal(ev.muted);
|
|
671
582
|
}
|
|
672
583
|
});
|
|
673
584
|
}
|
|
585
|
+
|
|
674
586
|
/**
|
|
675
587
|
* Creates a new RTCDataChannel object with the given label. The
|
|
676
588
|
* RTCDataChannelInit dictionary can be used to configure properties of the
|
|
@@ -682,86 +594,69 @@ class RTCPeerConnection extends (0, _eventTargetShim.defineCustomEventTarget)(..
|
|
|
682
594
|
* values with which to initialize corresponding attributes of the new
|
|
683
595
|
* instance such as id
|
|
684
596
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
597
|
createDataChannel(label, dataChannelDict) {
|
|
688
598
|
if (dataChannelDict && 'id' in dataChannelDict) {
|
|
689
599
|
const id = dataChannelDict.id;
|
|
690
|
-
|
|
691
600
|
if (typeof id !== 'number') {
|
|
692
601
|
throw new TypeError('DataChannel id must be a number: ' + id);
|
|
693
602
|
}
|
|
694
603
|
}
|
|
695
|
-
|
|
696
604
|
const channelInfo = WebRTCModule.createDataChannel(this._pcId, label, dataChannelDict);
|
|
697
|
-
|
|
698
605
|
if (channelInfo === null) {
|
|
699
606
|
throw new TypeError('Failed to create new DataChannel');
|
|
700
607
|
}
|
|
701
|
-
|
|
702
608
|
return new _RTCDataChannel.default(channelInfo);
|
|
703
609
|
}
|
|
610
|
+
|
|
704
611
|
/**
|
|
705
612
|
* Check whether a media stream track exists already in a sender.
|
|
706
613
|
* See https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack for more information
|
|
707
614
|
*/
|
|
708
|
-
|
|
709
|
-
|
|
710
615
|
_trackExists(track) {
|
|
711
616
|
const [sender] = this.getSenders().filter(sender => {
|
|
712
617
|
var _sender$track;
|
|
713
|
-
|
|
714
618
|
return ((_sender$track = sender.track) === null || _sender$track === void 0 ? void 0 : _sender$track.id) === track.id;
|
|
715
619
|
});
|
|
716
620
|
return sender ? true : false;
|
|
717
621
|
}
|
|
622
|
+
|
|
718
623
|
/**
|
|
719
624
|
* Updates transceivers after offer/answer updates if necessary.
|
|
720
625
|
*/
|
|
721
|
-
|
|
722
|
-
|
|
723
626
|
_updateTransceivers(transceiverUpdates) {
|
|
724
627
|
let removeStopped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
725
|
-
|
|
726
628
|
for (const update of transceiverUpdates) {
|
|
727
629
|
const [transceiver] = this.getTransceivers().filter(t => t.sender.id === update.transceiverId);
|
|
728
|
-
|
|
729
630
|
if (!transceiver) {
|
|
730
631
|
continue;
|
|
731
632
|
}
|
|
732
|
-
|
|
733
|
-
|
|
633
|
+
if (update.currentDirection) {
|
|
634
|
+
transceiver._currentDirection = update.currentDirection;
|
|
635
|
+
}
|
|
734
636
|
transceiver._mid = update.mid;
|
|
735
637
|
transceiver._stopped = Boolean(update.isStopped);
|
|
736
638
|
transceiver._sender._rtpParameters = new _RTCRtpSendParameters.default(update.senderRtpParameters);
|
|
737
639
|
transceiver._receiver._rtpParameters = new _RTCRtpReceiveParameters.default(update.receiverRtpParameters);
|
|
738
640
|
}
|
|
739
|
-
|
|
740
641
|
if (removeStopped) {
|
|
741
642
|
const stopped = this.getTransceivers().filter(t => t.stopped);
|
|
742
|
-
|
|
743
643
|
const newTransceivers = this._transceivers.filter(t => !stopped.includes(t.transceiver));
|
|
744
|
-
|
|
745
644
|
this._transceivers = newTransceivers;
|
|
746
645
|
}
|
|
747
646
|
}
|
|
647
|
+
|
|
748
648
|
/**
|
|
749
649
|
* Inserts transceiver into the transceiver array in the order they are created (timestamp).
|
|
750
650
|
* @param order an index that refers to when it it was created relatively.
|
|
751
651
|
* @param transceiver the transceiver object to be inserted.
|
|
752
652
|
*/
|
|
753
|
-
|
|
754
|
-
|
|
755
653
|
_insertTransceiverSorted(order, transceiver) {
|
|
756
654
|
this._transceivers.push({
|
|
757
655
|
order,
|
|
758
656
|
transceiver
|
|
759
657
|
});
|
|
760
|
-
|
|
761
658
|
this._transceivers.sort((a, b) => a.order - b.order);
|
|
762
659
|
}
|
|
763
|
-
|
|
764
660
|
}
|
|
765
|
-
|
|
766
661
|
exports.default = RTCPeerConnection;
|
|
767
662
|
//# sourceMappingURL=RTCPeerConnection.js.map
|