@rtsee/conference 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/conference/src/index.d.ts +3 -0
  2. package/dist/conference/src/index.d.ts.map +1 -0
  3. package/dist/conference/src/index.js +15 -0
  4. package/dist/conference/src/index.js.map +1 -0
  5. package/dist/conference/src/interfaces/DisplayMedia.d.ts +7 -0
  6. package/dist/conference/src/interfaces/DisplayMedia.d.ts.map +1 -0
  7. package/dist/conference/src/interfaces/DisplayMedia.js +3 -0
  8. package/dist/conference/src/interfaces/DisplayMedia.js.map +1 -0
  9. package/dist/conference/src/interfaces/Handshake.d.ts +31 -0
  10. package/dist/conference/src/interfaces/Handshake.d.ts.map +1 -0
  11. package/dist/conference/src/interfaces/Handshake.js +3 -0
  12. package/dist/conference/src/interfaces/Handshake.js.map +1 -0
  13. package/dist/conference/src/interfaces/PeerMessage.d.ts +23 -0
  14. package/dist/conference/src/interfaces/PeerMessage.d.ts.map +1 -0
  15. package/dist/conference/src/interfaces/PeerMessage.js +3 -0
  16. package/dist/conference/src/interfaces/PeerMessage.js.map +1 -0
  17. package/dist/conference/src/interfaces/RTSeeConferenceOptions.d.ts +12 -0
  18. package/dist/conference/src/interfaces/RTSeeConferenceOptions.d.ts.map +1 -0
  19. package/dist/conference/src/interfaces/RTSeeConferenceOptions.js +3 -0
  20. package/dist/conference/src/interfaces/RTSeeConferenceOptions.js.map +1 -0
  21. package/dist/conference/src/interfaces/RTSeeConferenceSignalingClient.d.ts +10 -0
  22. package/dist/conference/src/interfaces/RTSeeConferenceSignalingClient.d.ts.map +1 -0
  23. package/dist/conference/src/interfaces/RTSeeConferenceSignalingClient.js +3 -0
  24. package/dist/conference/src/interfaces/RTSeeConferenceSignalingClient.js.map +1 -0
  25. package/dist/conference/src/interfaces/RTSeeConferenceUiControlsOptions.d.ts +4 -0
  26. package/dist/conference/src/interfaces/RTSeeConferenceUiControlsOptions.d.ts.map +1 -0
  27. package/dist/conference/src/interfaces/RTSeeConferenceUiControlsOptions.js +3 -0
  28. package/dist/conference/src/interfaces/RTSeeConferenceUiControlsOptions.js.map +1 -0
  29. package/dist/conference/src/interfaces/SoundMeterOptions.d.ts +4 -0
  30. package/dist/conference/src/interfaces/SoundMeterOptions.d.ts.map +1 -0
  31. package/dist/conference/src/interfaces/SoundMeterOptions.js +3 -0
  32. package/dist/conference/src/interfaces/SoundMeterOptions.js.map +1 -0
  33. package/dist/conference/src/interfaces/index.d.ts +9 -0
  34. package/dist/conference/src/interfaces/index.d.ts.map +1 -0
  35. package/dist/conference/src/interfaces/index.js +21 -0
  36. package/dist/conference/src/interfaces/index.js.map +1 -0
  37. package/dist/conference/src/models/RTSeeConference.d.ts +80 -0
  38. package/dist/conference/src/models/RTSeeConference.d.ts.map +1 -0
  39. package/dist/conference/src/models/RTSeeConference.js +599 -0
  40. package/dist/conference/src/models/RTSeeConference.js.map +1 -0
  41. package/dist/conference/src/models/RTSeePeerConnection.d.ts +46 -0
  42. package/dist/conference/src/models/RTSeePeerConnection.d.ts.map +1 -0
  43. package/dist/conference/src/models/RTSeePeerConnection.js +131 -0
  44. package/dist/conference/src/models/RTSeePeerConnection.js.map +1 -0
  45. package/dist/conference/src/models/RTSeePeerConnectionsList.d.ts +21 -0
  46. package/dist/conference/src/models/RTSeePeerConnectionsList.d.ts.map +1 -0
  47. package/dist/conference/src/models/RTSeePeerConnectionsList.js +106 -0
  48. package/dist/conference/src/models/RTSeePeerConnectionsList.js.map +1 -0
  49. package/dist/conference/src/models/RTSeeUiControls.d.ts +9 -0
  50. package/dist/conference/src/models/RTSeeUiControls.d.ts.map +1 -0
  51. package/dist/conference/src/models/RTSeeUiControls.js +25 -0
  52. package/dist/conference/src/models/RTSeeUiControls.js.map +1 -0
  53. package/dist/conference/src/models/SoundMeter.d.ts +18 -0
  54. package/dist/conference/src/models/SoundMeter.d.ts.map +1 -0
  55. package/dist/conference/src/models/SoundMeter.js +61 -0
  56. package/dist/conference/src/models/SoundMeter.js.map +1 -0
  57. package/dist/conference/src/models/index.d.ts +6 -0
  58. package/dist/conference/src/models/index.d.ts.map +1 -0
  59. package/dist/conference/src/models/index.js +18 -0
  60. package/dist/conference/src/models/index.js.map +1 -0
  61. package/package.json +48 -0
@@ -0,0 +1,599 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.RTSeeConference = void 0;
66
+ var core_1 = require("@rtsee/core");
67
+ var RTSeeUiControls_1 = require("./RTSeeUiControls");
68
+ var conference_1 = require("@rtsee/conference");
69
+ var RTSeeConference = /** @class */ (function (_super) {
70
+ __extends(RTSeeConference, _super);
71
+ function RTSeeConference(options) {
72
+ var _this = _super.call(this, options) || this;
73
+ _this.rtcPeerConnections = new conference_1.RTSeePeerConnectionsList();
74
+ _this.screenSharePeers = new conference_1.RTSeePeerConnectionsList();
75
+ _this.localScreenStream = null;
76
+ _this.microphone = true;
77
+ _this.camera = true;
78
+ _this.isPresenter = false;
79
+ if (options) {
80
+ _this.init(options);
81
+ }
82
+ _this.signalingClient.connect({
83
+ rtSee: _this,
84
+ });
85
+ return _this;
86
+ }
87
+ RTSeeConference.prototype.init = function (options) {
88
+ this.clientId = options.clientId || RTSeeConference.uuidv4();
89
+ // this.clientId = RTSeeVideoChat.uuidv4();
90
+ if (options.rtcConfiguration) {
91
+ this.rtcConfiguration = options.rtcConfiguration;
92
+ }
93
+ if (options.constraints) {
94
+ this.applyConstraints(options.constraints);
95
+ }
96
+ if (options.messengerClient) {
97
+ this.attachMessenger(options.messengerClient);
98
+ }
99
+ this.initControls(options.uiControls);
100
+ };
101
+ RTSeeConference.prototype.attachMessenger = function (messengerClient) {
102
+ this.messengerClient = messengerClient;
103
+ };
104
+ RTSeeConference.prototype.onReady = function () {
105
+ this.startActiveSpeakerInterval();
106
+ };
107
+ RTSeeConference.prototype.startActiveSpeakerInterval = function () {
108
+ var _this = this;
109
+ setInterval(function () {
110
+ if (!_this.rtcPeerConnections.connections.length) {
111
+ return;
112
+ }
113
+ if (_this.rtcPeerConnections.connections.length === 1) {
114
+ _this.rtcPeerConnections.connections[0].setAsActiveSpeaker();
115
+ }
116
+ _this.rtcPeerConnections.setActiveSpeaker();
117
+ }, 1000 / 15);
118
+ };
119
+ RTSeeConference.prototype.stopActiveSpeakerInterval = function () {
120
+ if (!this.activeSpeakerIntervalId) {
121
+ return;
122
+ }
123
+ clearInterval(this.activeSpeakerIntervalId);
124
+ };
125
+ RTSeeConference.prototype.initControls = function (uiControls) {
126
+ this.uiControls = new RTSeeUiControls_1.RTSeeUiControls(uiControls);
127
+ };
128
+ RTSeeConference.prototype.applyConstraints = function (constraints) {
129
+ this.constraints = constraints;
130
+ if (!this.constraints.video) {
131
+ this.camera = false;
132
+ }
133
+ if (!this.constraints.audio) {
134
+ this.microphone = false;
135
+ }
136
+ };
137
+ RTSeeConference.prototype.getUserMedia = function () {
138
+ return navigator.mediaDevices
139
+ .getUserMedia(this.constraints)
140
+ .catch(this.onGetUserMediaError.bind(this))
141
+ .then(this.onGetUserMediaSuccess.bind(this));
142
+ };
143
+ RTSeeConference.prototype.getScreenMedia = function () {
144
+ var extNavigator = navigator.mediaDevices;
145
+ return extNavigator
146
+ .getDisplayMedia()
147
+ .catch(this.onGetUserMediaError.bind(this))
148
+ .then(this.onGetDisplayMediaSuccess.bind(this));
149
+ };
150
+ RTSeeConference.prototype.offer = function (peerOptions) {
151
+ this.rtcPeerConnections.removeByPeerId(peerOptions.clientId);
152
+ this.screenSharePeers.removeByPeerId(peerOptions.clientId);
153
+ if (this.screenSharePeer &&
154
+ this.screenSharePeer.connection &&
155
+ this.screenSharePeer.clientId === peerOptions.clientId) {
156
+ this.screenSharePeer.connection.close();
157
+ this.screenSharePeer = null;
158
+ }
159
+ var peer = this.rtcPeerConnections.add(new conference_1.RTSeePeerConnection(__assign(__assign({}, peerOptions), { connection: new RTCPeerConnection(this.rtcConfiguration) })));
160
+ this.addLocalTracks(peer);
161
+ this.attachPeerConnectionEvents(peer);
162
+ if (this.isPresenter) {
163
+ void this.shareScreenToPeer(peer);
164
+ }
165
+ return this.createOffer(peer);
166
+ };
167
+ RTSeeConference.prototype.answer = function (options) {
168
+ var _this = this;
169
+ var peer;
170
+ var existingConnection = null;
171
+ if (options.isScreenShare) {
172
+ if (this.screenSharePeer) {
173
+ peer = this.screenSharePeer;
174
+ existingConnection = peer.clientId === options.clientId ? peer : null;
175
+ }
176
+ else {
177
+ this.screenSharePeer = new conference_1.RTSeePeerConnection(__assign(__assign({}, options), { isScreenShare: true, connection: new RTCPeerConnection(this.rtcConfiguration) }));
178
+ peer = this.screenSharePeer;
179
+ }
180
+ }
181
+ else {
182
+ existingConnection = this.rtcPeerConnections.getByPeerId(options.clientId);
183
+ peer =
184
+ existingConnection ||
185
+ this.rtcPeerConnections.add(new conference_1.RTSeePeerConnection(__assign(__assign({}, options), { connection: new RTCPeerConnection(this.rtcConfiguration) })));
186
+ }
187
+ if (!existingConnection) {
188
+ if (options.isScreenShare) {
189
+ console.log("No Need For Adding Screen Tracks");
190
+ }
191
+ else {
192
+ this.addLocalTracks(peer);
193
+ }
194
+ this.attachPeerConnectionEvents(peer);
195
+ }
196
+ var success = this.setRemoteDescription(options.clientId, options.sdp, "offer", options.isScreenShare);
197
+ if (success) {
198
+ return success
199
+ .then(function () {
200
+ return _this.createAnswer(peer, options.isScreenShare);
201
+ })
202
+ .catch(function (e) { return console.log(e); });
203
+ }
204
+ else {
205
+ return;
206
+ }
207
+ };
208
+ RTSeeConference.prototype.addIceCandidate = function (options, isScreenShare) {
209
+ if (isScreenShare) {
210
+ return this.isPresenter
211
+ ? this.screenSharePeers.addIceCandidate(options.clientId, new RTCIceCandidate({
212
+ sdpMLineIndex: options.sdpMLineIndex,
213
+ candidate: options.candidate,
214
+ }))
215
+ : this.screenSharePeer.connection.addIceCandidate(new RTCIceCandidate({
216
+ sdpMLineIndex: options.sdpMLineIndex,
217
+ candidate: options.candidate,
218
+ }));
219
+ }
220
+ else {
221
+ return this.rtcPeerConnections.addIceCandidate(options.clientId, new RTCIceCandidate({
222
+ sdpMLineIndex: options.sdpMLineIndex,
223
+ candidate: options.candidate,
224
+ }));
225
+ }
226
+ };
227
+ RTSeeConference.prototype.onPeerCameraToggled = function (peerId, isEnabled) {
228
+ this.rtcPeerConnections.onPeerCameraToggled(peerId, isEnabled);
229
+ };
230
+ RTSeeConference.prototype.onPeerMicrophoneToggled = function (peerId, isEnabled) {
231
+ this.rtcPeerConnections.onPeerMicrophoneToggled(peerId, isEnabled);
232
+ };
233
+ RTSeeConference.prototype.onRemoteScreenShareStop = function (peer) {
234
+ if (this.screenSharePeer &&
235
+ this.screenSharePeer.clientId === peer.clientId) {
236
+ this.screenSharePeer.connection.close();
237
+ this.screenSharePeer = null;
238
+ }
239
+ };
240
+ RTSeeConference.prototype.setRemoteDescription = function (clientId, sdp, type, isScreenShare) {
241
+ var promise;
242
+ if (isScreenShare) {
243
+ promise = this.isPresenter
244
+ ? this.screenSharePeers.setRemoteDescription(clientId, new RTCSessionDescription({ sdp: sdp, type: type }))
245
+ : this.screenSharePeer.connection.setRemoteDescription(new RTCSessionDescription({ sdp: sdp, type: type }));
246
+ }
247
+ else {
248
+ promise = this.rtcPeerConnections.setRemoteDescription(clientId, new RTCSessionDescription({ sdp: sdp, type: type }));
249
+ }
250
+ if (!promise) {
251
+ return false;
252
+ }
253
+ return promise.then(function () {
254
+ console.log("applied");
255
+ });
256
+ };
257
+ RTSeeConference.prototype.getClientId = function () {
258
+ return this.clientId;
259
+ };
260
+ RTSeeConference.prototype.call = function (calleeId, options) {
261
+ return __awaiter(this, void 0, void 0, function () {
262
+ var roomId, connected;
263
+ return __generator(this, function (_a) {
264
+ switch (_a.label) {
265
+ case 0:
266
+ this.end();
267
+ if (!this.signalingClient) {
268
+ return [2 /*return*/];
269
+ }
270
+ roomId = RTSeeConference.uuidv4();
271
+ return [4 /*yield*/, this.connect(roomId, this.signalingClient.getMyPeer())];
272
+ case 1:
273
+ connected = _a.sent();
274
+ if (!connected) {
275
+ return [2 /*return*/];
276
+ }
277
+ if (this.messengerClient) {
278
+ this.messengerClient.onCallCreated({
279
+ roomId: roomId,
280
+ calleeId: calleeId,
281
+ callerId: this.signalingClient.getMyPeerId(),
282
+ caller: this.signalingClient.getMyPeer(),
283
+ }, {
284
+ chatId: options.chatId,
285
+ });
286
+ }
287
+ return [2 /*return*/];
288
+ }
289
+ });
290
+ });
291
+ };
292
+ RTSeeConference.prototype.connect = function (roomId, data) {
293
+ var _this = this;
294
+ this.end();
295
+ return new Promise(function (resolve, reject) {
296
+ if (!roomId || !(data === null || data === void 0 ? void 0 : data.clientId)) {
297
+ reject("roomId and Peer.clientId are required in order to make calls");
298
+ }
299
+ if (!_this.signalingClient) {
300
+ reject("Signaling Client is Required in order to make calls!");
301
+ }
302
+ _this.roomId = roomId;
303
+ if (_this.localStream) {
304
+ _this.signalingClient.joinCall(_this.roomId, {
305
+ clientId: data.clientId,
306
+ roomId: _this.roomId,
307
+ });
308
+ return resolve(true);
309
+ }
310
+ void _this.getUserMedia().then(function () {
311
+ _this.signalingClient.joinCall(_this.roomId, {
312
+ clientId: data.clientId,
313
+ roomId: _this.roomId,
314
+ });
315
+ resolve(true);
316
+ });
317
+ });
318
+ };
319
+ RTSeeConference.prototype.startScreenShare = function () {
320
+ var _this = this;
321
+ void this.getScreenMedia().then(function () {
322
+ _this.rtcPeerConnections.connections.forEach(function (peer) {
323
+ _this.shareScreenToPeer(peer);
324
+ });
325
+ _this.isPresenter = true;
326
+ });
327
+ };
328
+ RTSeeConference.prototype.shareScreenToPeer = function (peer) {
329
+ var shareScreenPeer = this.screenSharePeers.add(new conference_1.RTSeePeerConnection(__assign(__assign({}, peer), { isScreenShare: true, connection: new RTCPeerConnection(this.rtcConfiguration) })));
330
+ this.addScreenTracks(shareScreenPeer);
331
+ this.attachPeerConnectionEvents(shareScreenPeer);
332
+ void this.createOffer(shareScreenPeer, true);
333
+ };
334
+ RTSeeConference.prototype.stopScreenShare = function () {
335
+ this.screenSharePeers.eraseAll();
336
+ this.isPresenter = false;
337
+ this.emit(core_1.RTSeeEvents["SHARE_SCREEN_STOP"], {
338
+ clientId: this.clientId,
339
+ roomId: this.roomId,
340
+ });
341
+ };
342
+ RTSeeConference.prototype.disableMicrophone = function () {
343
+ this.microphone = false;
344
+ this.localStream.getAudioTracks()[0].enabled = false;
345
+ this.onMicrophoneToggled();
346
+ };
347
+ RTSeeConference.prototype.enableMicrophone = function () {
348
+ this.localStream.getAudioTracks()[0].enabled = true;
349
+ this.microphone = true;
350
+ this.onMicrophoneToggled();
351
+ };
352
+ RTSeeConference.prototype.disableCamera = function () {
353
+ this.localStream.getVideoTracks()[0].enabled = false;
354
+ this.camera = false;
355
+ this.onCameraToggled();
356
+ };
357
+ RTSeeConference.prototype.enableCamera = function () {
358
+ this.localStream.getVideoTracks()[0].enabled = true;
359
+ this.camera = true;
360
+ this.onCameraToggled();
361
+ };
362
+ RTSeeConference.prototype.onCameraToggled = function () {
363
+ var toggleEvent = {
364
+ name: core_1.RTSeeEvents["CAMERA_TOGGLED"],
365
+ data: {
366
+ from: this.clientId,
367
+ roomId: this.roomId,
368
+ deviceOn: this.camera,
369
+ },
370
+ };
371
+ this.emit(toggleEvent.name, toggleEvent.data);
372
+ };
373
+ RTSeeConference.prototype.onMicrophoneToggled = function () {
374
+ var toggleEvent = {
375
+ name: core_1.RTSeeEvents["MICROPHONE_TOGGLED"],
376
+ data: {
377
+ from: this.clientId,
378
+ roomId: this.roomId,
379
+ deviceOn: this.camera,
380
+ },
381
+ };
382
+ this.emit(toggleEvent.name, toggleEvent.data);
383
+ };
384
+ RTSeeConference.prototype.setRTConfiguration = function (configuration, applyImmediately) {
385
+ this.rtcConfiguration = configuration;
386
+ if (this.localStream && applyImmediately) {
387
+ void this.getUserMedia().then(function () {
388
+ console.log("User Media success");
389
+ });
390
+ }
391
+ };
392
+ RTSeeConference.prototype.getRTCConfiguration = function () {
393
+ return this.rtcConfiguration;
394
+ };
395
+ RTSeeConference.prototype.getDevices = function () {
396
+ return navigator.mediaDevices.enumerateDevices();
397
+ };
398
+ RTSeeConference.prototype.setAudioInputDevicesList = function () {
399
+ var _this = this;
400
+ return this.getDevices().then(function (devices) {
401
+ _this.audioInputDevices = devices.filter(function (elem) { return elem.kind === "audioinput"; });
402
+ });
403
+ };
404
+ RTSeeConference.prototype.setAudioOutputDevicesList = function () {
405
+ var _this = this;
406
+ return this.getDevices().then(function (devices) {
407
+ _this.audioOutputDevices = devices.filter(function (elem) { return elem.kind === "audiooutput"; });
408
+ });
409
+ };
410
+ RTSeeConference.prototype.setVideoInputDevicesList = function () {
411
+ var _this = this;
412
+ return this.getDevices().then(function (devices) {
413
+ _this.videoInputDevices = devices.filter(function (elem) { return elem.kind === "videoinput"; });
414
+ });
415
+ };
416
+ RTSeeConference.prototype.setAudioInputDevice = function (deviceId) {
417
+ var _this = this;
418
+ this.stopLocalStream();
419
+ if (typeof this.constraints.audio === "object") {
420
+ this.constraints.audio.deviceId = deviceId;
421
+ }
422
+ else {
423
+ this.constraints.audio = { deviceId: deviceId };
424
+ }
425
+ void this.getUserMedia().then(function () {
426
+ _this.rtcPeerConnections.connections.forEach(function (elem) {
427
+ elem.connection.getSenders().forEach(function (sender) {
428
+ elem.connection.removeTrack(sender);
429
+ });
430
+ _this.addLocalTracks(elem);
431
+ void _this.createOffer(elem);
432
+ });
433
+ });
434
+ };
435
+ RTSeeConference.prototype.setVideoInputDevice = function (deviceId) {
436
+ var _this = this;
437
+ this.stopLocalStream();
438
+ if (typeof this.constraints.video === "object") {
439
+ this.constraints.video.deviceId = deviceId;
440
+ }
441
+ else {
442
+ this.constraints.video = { deviceId: deviceId };
443
+ }
444
+ void this.getUserMedia().then(function () {
445
+ _this.rtcPeerConnections.connections.forEach(function (elem) {
446
+ elem.connection.getSenders().forEach(function (sender) {
447
+ elem.connection.removeTrack(sender);
448
+ });
449
+ _this.addLocalTracks(elem);
450
+ void _this.createOffer(elem);
451
+ });
452
+ });
453
+ };
454
+ RTSeeConference.prototype.setAudioOutputDevice = function (deviceId) {
455
+ void this.rtcPeerConnections.setAudioOutputDevice(deviceId);
456
+ };
457
+ RTSeeConference.prototype.refreshMediaDevicesList = function () {
458
+ return Promise.all([
459
+ this.setAudioInputDevicesList(),
460
+ this.setVideoInputDevicesList(),
461
+ this.setAudioOutputDevicesList(),
462
+ ]);
463
+ };
464
+ RTSeeConference.prototype.end = function () {
465
+ if (this.screenSharePeer) {
466
+ this.screenSharePeer.connection.close();
467
+ this.screenSharePeer = null;
468
+ }
469
+ this.isPresenter = false;
470
+ this.rtcPeerConnections.eraseAll();
471
+ this.screenSharePeers.eraseAll();
472
+ };
473
+ RTSeeConference.prototype.createAnswer = function (peer, isScreenShare) {
474
+ var _this = this;
475
+ return this.getAnswer(peer.connection).then(function (result) {
476
+ return peer.connection.setLocalDescription(result).then(function () {
477
+ var answerMessage = {
478
+ name: core_1.RTSeeEvents.ANSWER,
479
+ data: {
480
+ sdp: result.sdp,
481
+ roomId: _this.roomId,
482
+ from: _this.clientId,
483
+ to: peer.clientId,
484
+ isScreenShare: isScreenShare,
485
+ },
486
+ };
487
+ _this.emit(answerMessage.name, answerMessage.data);
488
+ });
489
+ });
490
+ };
491
+ RTSeeConference.prototype.createOffer = function (peer, isScreenShare) {
492
+ var _this = this;
493
+ return this.setLocalDescription(peer).then(function (result) {
494
+ if (result) {
495
+ var offerMessage = {
496
+ name: core_1.RTSeeEvents.OFFER,
497
+ data: {
498
+ sdp: result.sdp,
499
+ roomId: _this.roomId,
500
+ from: _this.clientId,
501
+ to: peer.clientId,
502
+ isScreenShare: isScreenShare,
503
+ },
504
+ };
505
+ _this.emit(offerMessage.name, offerMessage.data);
506
+ }
507
+ });
508
+ };
509
+ RTSeeConference.prototype.attachPeerConnectionEvents = function (peer) {
510
+ peer.on(core_1.RTSeeEvents["ICE_CANDIDATE"], this.onIceCandidate.bind(this));
511
+ peer.connection.onconnectionstatechange =
512
+ this.connectionStateChangeEnclosure(peer).bind(this);
513
+ };
514
+ RTSeeConference.prototype.connectionStateChangeEnclosure = function (peer) {
515
+ var _this = this;
516
+ return function (event) {
517
+ var evTarget = event.target;
518
+ if (evTarget.connectionState === "disconnected" ||
519
+ evTarget.connectionState === "closed" ||
520
+ evTarget.connectionState === "failed") {
521
+ _this.rtcPeerConnections.removeByPeerId(peer.clientId);
522
+ _this.screenSharePeers.removeByPeerId(peer.clientId);
523
+ if (_this.screenSharePeer &&
524
+ _this.screenSharePeer.clientId === peer.clientId) {
525
+ _this.screenSharePeer.connection.close();
526
+ _this.screenSharePeer = null;
527
+ }
528
+ }
529
+ };
530
+ };
531
+ RTSeeConference.prototype.setLocalDescription = function (peer, sdp) {
532
+ if (sdp) {
533
+ return peer.connection
534
+ .setLocalDescription({ sdp: sdp, type: "answer" })
535
+ .then(function (result) {
536
+ return result;
537
+ });
538
+ }
539
+ return this.getOffer(peer.connection).then(function (result) {
540
+ return peer.connection.setLocalDescription(result).then(function () {
541
+ return result;
542
+ });
543
+ });
544
+ };
545
+ RTSeeConference.prototype.onIceCandidate = function (data) {
546
+ if (!data.event.candidate) {
547
+ return false;
548
+ }
549
+ this.emit(core_1.RTSeeEvents["ICE_CANDIDATE"], {
550
+ name: core_1.RTSeeEvents["ICE_CANDIDATE"],
551
+ data: {
552
+ sdpMLineIndex: data.event.candidate.sdpMLineIndex,
553
+ candidate: data.event.candidate.candidate,
554
+ roomId: this.roomId,
555
+ from: this.clientId,
556
+ to: data.clientId,
557
+ isScreenShare: data.isScreenShare,
558
+ },
559
+ });
560
+ };
561
+ RTSeeConference.prototype.addLocalTracks = function (peer) {
562
+ peer.addLocalTracks(this.localStream);
563
+ };
564
+ RTSeeConference.prototype.addScreenTracks = function (peer) {
565
+ peer.addLocalTracks(this.localScreenStream);
566
+ };
567
+ RTSeeConference.prototype.onGetUserMediaError = function (e) {
568
+ console.log(e);
569
+ };
570
+ RTSeeConference.prototype.onGetUserMediaSuccess = function (stream) {
571
+ if (!stream) {
572
+ return;
573
+ }
574
+ this.localStream = stream;
575
+ void this.refreshMediaDevicesList();
576
+ };
577
+ RTSeeConference.prototype.onGetDisplayMediaSuccess = function (stream) {
578
+ if (!stream) {
579
+ return;
580
+ }
581
+ this.localScreenStream = stream;
582
+ };
583
+ RTSeeConference.prototype.getAnswer = function (peerConnection) {
584
+ return peerConnection.createAnswer();
585
+ };
586
+ RTSeeConference.prototype.getOffer = function (peerConnection) {
587
+ return peerConnection.createOffer();
588
+ };
589
+ RTSeeConference.prototype.stopLocalStream = function () {
590
+ if (!this.localStream) {
591
+ return;
592
+ }
593
+ this.localStream.getTracks().forEach(function (track) { return track.stop(); });
594
+ this.localStream = null;
595
+ };
596
+ return RTSeeConference;
597
+ }(core_1.RTSeeCore));
598
+ exports.RTSeeConference = RTSeeConference;
599
+ //# sourceMappingURL=RTSeeConference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RTSeeConference.js","sourceRoot":"","sources":["../../../../src/models/RTSeeConference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,oCAOqB;AAErB,qDAAoD;AACpD,gDAW2B;AAE3B;IAAqC,mCAAS;IAuB5C,yBAAY,OAAiC;QAA7C,YACE,kBAAM,OAAO,CAAC,SAQf;QA/BD,wBAAkB,GAA6B,IAAI,qCAAwB,EAAE,CAAC;QAC9E,sBAAgB,GAA6B,IAAI,qCAAwB,EAAE,CAAC;QAG5E,uBAAiB,GAAiB,IAAI,CAAC;QACvC,gBAAU,GAAa,IAAI,CAAC;QAC5B,YAAM,GAAa,IAAI,CAAC;QAIxB,iBAAW,GAAa,KAAK,CAAC;QAc5B,IAAI,OAAO,EAAE;YACX,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACpB;QAED,KAAI,CAAC,eAAe,CAAC,OAAO,CAAC;YAC3B,KAAK,EAAE,KAAI;SACZ,CAAC,CAAC;;IACL,CAAC;IAED,8BAAI,GAAJ,UAAK,OAAgC;QACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC7D,2CAA2C;QAC3C,IAAI,OAAO,CAAC,gBAAgB,EAAE;YAC5B,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;SAClD;QACD,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SAC5C;QACD,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;SAC/C;QAED,IAAI,CAAC,YA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AC,CAAC,CAAC,CAAC;IACjB,CAAC;IAEO,+CAAqB,GAA7B,UAA8B,MAA0B;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QACD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,KAAK,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACtC,CAAC;IAEO,kDAAwB,GAAhC,UAAiC,MAA0B;QACzD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QACD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAClC,CAAC;IAEO,mCAAS,GAAjB,UACE,cAAiC;QAEjC,OAAO,cAAc,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IAEO,kCAAQ,GAAhB,UACE,cAAiC;QAEjC,OAAO,cAAc,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAEO,yCAAe,GAAvB;QACE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO;SACR;QACD,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,IAAI,EAAE,EAAZ,CAAY,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IACH,sBAAC;AAAD,CAAC,AAhrBD,CAAqC,gBAAS,GAgrB7C;AAhrBY,0CAAe"}
@@ -0,0 +1,46 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "events";
3
+ import { IPeerInfo } from "@rtsee/core";
4
+ import { SoundMeter } from "./SoundMeter";
5
+ export interface IRTSeePeerConnection extends IPeerInfo {
6
+ clientId: string;
7
+ connection: RTCPeerConnection;
8
+ isScreenShare?: boolean;
9
+ }
10
+ export declare class RTSeePeerConnection extends EventEmitter {
11
+ clientId: string;
12
+ connection: RTCPeerConnection;
13
+ localVideoTrack?: MediaStreamTrack;
14
+ localAudioTrack?: MediaStreamTrack;
15
+ remoteVideoStream?: MediaStream;
16
+ remoteAudioStream?: MediaStream;
17
+ sender?: RTCRtpSender;
18
+ icePool: RTCIceCandidate[];
19
+ name?: string;
20
+ imageUrl?: string;
21
+ url?: string;
22
+ camera?: boolean;
23
+ microphone?: boolean;
24
+ soundMeter?: SoundMeter;
25
+ isScreenShare?: boolean;
26
+ audioOutputElement?: HTMLAudioElement;
27
+ isActiveSpeaker?: boolean;
28
+ constructor(options: IRTSeePeerConnection);
29
+ init(options: IRTSeePeerConnection): void;
30
+ attachConnectionEvents(): void;
31
+ attachTrackEvents(track: MediaStreamTrack): void;
32
+ emitOnTrackEvent(event: RTCTrackEvent): void;
33
+ emitOnIceCandidateEvent(event: RTCPeerConnectionIceEvent): void;
34
+ addLocalTracks(stream: MediaStream, config?: {
35
+ audio: boolean;
36
+ video: boolean;
37
+ }): void;
38
+ setMicrophoneState(value: boolean): void;
39
+ setCameraState(value: boolean): void;
40
+ setAudioOutputElement(el: HTMLAudioElement): void;
41
+ setAudioOutputDevice(deviceId: string): Promise<void>;
42
+ setAsActiveSpeaker(): void;
43
+ unsetAsActiveSpeaker(): void;
44
+ endCall(): void;
45
+ }
46
+ //# sourceMappingURL=RTSeePeerConnection.d.ts.map