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