@techsee/techsee-media-service 9.0.0 → 11.0.0
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/lib/MultiParty/MultiPartyService.d.ts +3 -5
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -1
- package/lib/MultiParty/MultiPartyService.js +4 -7
- package/lib/MultiParty/MultiPartyService.js.map +1 -1
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -1
- package/lib/MultiParty/MultiPartyServiceFactory.js +2 -2
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -1
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts +11 -1
- package/lib/MultiParty/MultipartyServiceEventTypes.d.ts.map +1 -1
- package/lib/MultiParty/{OpentokMultiPartyService.d.ts → opentok/OpentokMultiPartyService.d.ts} +9 -13
- package/lib/MultiParty/opentok/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/{OpentokMultiPartyService.js → opentok/OpentokMultiPartyService.js} +109 -397
- package/lib/MultiParty/opentok/OpentokMultiPartyService.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts +25 -0
- package/lib/MultiParty/opentok/OpentokPublisher.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokPublisher.js +409 -0
- package/lib/MultiParty/opentok/OpentokPublisher.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.js +32 -0
- package/lib/MultiParty/opentok/OpentokSubscriber.js.map +1 -0
- package/lib/MultiParty/opentok/OpentokUtils.d.ts +2 -0
- package/lib/MultiParty/opentok/OpentokUtils.d.ts.map +1 -0
- package/lib/MultiParty/opentok/OpentokUtils.js +17 -0
- package/lib/MultiParty/opentok/OpentokUtils.js.map +1 -0
- package/lib/MultiParty/opentok/trace.d.ts +2 -0
- package/lib/MultiParty/opentok/trace.d.ts.map +1 -0
- package/lib/MultiParty/opentok/trace.js +31 -0
- package/lib/MultiParty/opentok/trace.js.map +1 -0
- package/package.json +8 -6
- package/lib/MultiParty/OpentokMultiPartyService.d.ts.map +0 -1
- package/lib/MultiParty/OpentokMultiPartyService.js.map +0 -1
- package/lib/oldCode/constants.js +0 -25
- package/lib/oldCode/constants.js.map +0 -1
- package/lib/oldCode/event-emitter.js +0 -62
- package/lib/oldCode/event-emitter.js.map +0 -1
- package/lib/oldCode/index.js +0 -60
- package/lib/oldCode/index.js.map +0 -1
- package/lib/oldCode/opentok/session.js +0 -335
- package/lib/oldCode/opentok/session.js.map +0 -1
- package/lib/oldCode/opentok/stream.js +0 -324
- package/lib/oldCode/opentok/stream.js.map +0 -1
- package/lib/oldCode/publisher.js +0 -168
- package/lib/oldCode/publisher.js.map +0 -1
- package/lib/oldCode/service.js +0 -417
- package/lib/oldCode/service.js.map +0 -1
- package/lib/oldCode/session.js +0 -132
- package/lib/oldCode/session.js.map +0 -1
- package/lib/oldCode/stream.js +0 -223
- package/lib/oldCode/stream.js.map +0 -1
- package/lib/oldCode/subscriber.js +0 -115
- package/lib/oldCode/subscriber.js.map +0 -1
- package/lib/oldCode/tracer.d.ts +0 -36
- package/lib/oldCode/tracer.d.ts.map +0 -1
- package/lib/oldCode/tracer.js +0 -202
- package/lib/oldCode/tracer.js.map +0 -1
- package/lib/oldCode/utils/ImageFixer.d.ts +0 -1
- package/lib/oldCode/utils/ImageFixer.d.ts.map +0 -1
- package/lib/oldCode/utils/ImageFixer.js +0 -83
- package/lib/oldCode/utils/ImageFixer.js.map +0 -1
- package/lib/oldCode/webrtc/constants.js +0 -106
- package/lib/oldCode/webrtc/constants.js.map +0 -1
- package/lib/oldCode/webrtc/helper.js +0 -225
- package/lib/oldCode/webrtc/helper.js.map +0 -1
- package/lib/oldCode/webrtc/session-kms.js +0 -573
- package/lib/oldCode/webrtc/session-kms.js.map +0 -1
- package/lib/oldCode/webrtc/session-loopback.js +0 -354
- package/lib/oldCode/webrtc/session-loopback.js.map +0 -1
- package/lib/oldCode/webrtc/session-turn.js +0 -927
- package/lib/oldCode/webrtc/session-turn.js.map +0 -1
- package/lib/oldCode/webrtc/session-turn.v2.js +0 -592
- package/lib/oldCode/webrtc/session-turn.v2.js.map +0 -1
- package/lib/oldCode/webrtc/session.js +0 -58
- package/lib/oldCode/webrtc/session.js.map +0 -1
- package/lib/oldCode/webrtc/stream.js +0 -696
- package/lib/oldCode/webrtc/stream.js.map +0 -1
- package/lib/oldCode/webrtc/temasys/adapter-loader.js +0 -11
- package/lib/oldCode/webrtc/temasys/adapter-loader.js.map +0 -1
- package/lib/oldCode/webrtc/temasys/adapter.js +0 -5933
- package/lib/oldCode/webrtc/temasys/adapter.js.map +0 -1
- package/lib/oldCode/webrtc/webrtc-ie-shim.js +0 -3437
- package/lib/oldCode/webrtc/webrtc-ie-shim.js.map +0 -1
|
@@ -204,41 +204,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
204
204
|
});
|
|
205
205
|
exports.OpentokMultiPartyService = void 0;
|
|
206
206
|
|
|
207
|
-
var
|
|
207
|
+
var __1 = require("..");
|
|
208
208
|
|
|
209
|
-
var MediaUtils_1 = require("
|
|
209
|
+
var MediaUtils_1 = require("../../MediaUtils");
|
|
210
210
|
|
|
211
|
-
var MediaCapabilitiesService_1 = require("
|
|
211
|
+
var MediaCapabilitiesService_1 = require("../MediaCapabilitiesService");
|
|
212
212
|
|
|
213
|
-
var MediaCapabilitiesUtils_1 = require("
|
|
213
|
+
var MediaCapabilitiesUtils_1 = require("../MediaCapabilitiesUtils");
|
|
214
214
|
|
|
215
|
-
var MultiPartyService_1 = require("
|
|
215
|
+
var MultiPartyService_1 = require("../MultiPartyService");
|
|
216
216
|
|
|
217
|
-
var MultipartyServiceEventTypes_1 = require("
|
|
217
|
+
var MultipartyServiceEventTypes_1 = require("../MultipartyServiceEventTypes");
|
|
218
218
|
|
|
219
|
-
var
|
|
220
|
-
|
|
219
|
+
var OpentokPublisher_1 = require("./OpentokPublisher");
|
|
220
|
+
|
|
221
|
+
var OpentokSubscriber_1 = require("./OpentokSubscriber");
|
|
222
|
+
|
|
223
|
+
var OpentokUtils_1 = require("./OpentokUtils");
|
|
221
224
|
|
|
222
|
-
var
|
|
225
|
+
var trace_1 = require("./trace");
|
|
223
226
|
|
|
224
|
-
|
|
225
|
-
OpentokFacingMode["USER"] = "user";
|
|
226
|
-
OpentokFacingMode["ENVIRONMENT"] = "environment";
|
|
227
|
-
})(OpentokFacingMode || (OpentokFacingMode = {}));
|
|
227
|
+
var trace = MediaUtils_1.getMediaTracer('Multiparty');
|
|
228
228
|
|
|
229
229
|
var OpentokMultiPartyService =
|
|
230
230
|
/** @class */
|
|
231
231
|
function (_super) {
|
|
232
232
|
__extends(OpentokMultiPartyService, _super);
|
|
233
233
|
|
|
234
|
-
function OpentokMultiPartyService(
|
|
235
|
-
var _this = _super.call(this
|
|
234
|
+
function OpentokMultiPartyService(getParticipantId) {
|
|
235
|
+
var _this = _super.call(this) || this;
|
|
236
236
|
|
|
237
237
|
_this.getParticipantId = getParticipantId;
|
|
238
|
+
_this.backgroundImageURI = __1.DEFAULT_AVATAR_URI;
|
|
238
239
|
_this.subscriberList = [];
|
|
239
|
-
_this.mirror = true;
|
|
240
240
|
|
|
241
|
-
_this.
|
|
241
|
+
_this.setBackgroundImageURI = function (uri) {
|
|
242
|
+
_this.backgroundImageURI = uri || __1.DEFAULT_AVATAR_URI;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
_this.connect = function (settings, credentials) {
|
|
242
246
|
try {
|
|
243
247
|
_this.session = OT.initSession(credentials.apiKey, credentials.sessionId);
|
|
244
248
|
|
|
@@ -260,31 +264,27 @@ function (_super) {
|
|
|
260
264
|
if (error) {
|
|
261
265
|
(_a = _this.session) === null || _a === void 0 ? void 0 : _a.off();
|
|
262
266
|
_this.session = undefined;
|
|
267
|
+
trace_1.traceError(error);
|
|
263
268
|
|
|
264
|
-
_this.
|
|
265
|
-
|
|
266
|
-
var e = {
|
|
269
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
267
270
|
meta: {
|
|
268
271
|
err: JSON.stringify(error)
|
|
269
272
|
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectFailed, e);
|
|
273
|
+
});
|
|
273
274
|
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
_this.
|
|
278
|
+
_this.initPublisher(settings);
|
|
278
279
|
});
|
|
279
280
|
} catch (err) {
|
|
280
281
|
trace.error(JSON.stringify(err));
|
|
281
|
-
|
|
282
|
+
|
|
283
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
282
284
|
meta: {
|
|
283
285
|
err: JSON.stringify(err)
|
|
284
286
|
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectFailed, e);
|
|
287
|
+
});
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
290
|
|
|
@@ -295,7 +295,7 @@ function (_super) {
|
|
|
295
295
|
trace.info('Disconnecting from session');
|
|
296
296
|
|
|
297
297
|
if (_this.session) {
|
|
298
|
-
(_a = _this.
|
|
298
|
+
(_a = _this.publisher) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
299
299
|
|
|
300
300
|
_this.session.disconnect();
|
|
301
301
|
|
|
@@ -314,7 +314,7 @@ function (_super) {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
if (connectionId === _this.ownConnectionId) {
|
|
317
|
-
return ((_a = _this.
|
|
317
|
+
return ((_a = _this.publisher) === null || _a === void 0 ? void 0 : _a.getImgData()) || null;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
return ((_b = _this.subscribers.find(function (s) {
|
|
@@ -322,14 +322,14 @@ function (_super) {
|
|
|
322
322
|
})) === null || _b === void 0 ? void 0 : _b.subscriber.getImgData()) || null;
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
-
_this.
|
|
325
|
+
_this.initPublisher = function (settings) {
|
|
326
326
|
return __awaiter(_this, void 0, void 0, function () {
|
|
327
|
-
var canStartWithAudio, canStartWithVideo;
|
|
327
|
+
var canStartWithAudio, canStartWithVideo, capabilitiesService, publisherOptions;
|
|
328
328
|
|
|
329
|
-
var
|
|
329
|
+
var _this = this;
|
|
330
330
|
|
|
331
|
-
return __generator(this, function (
|
|
332
|
-
switch (
|
|
331
|
+
return __generator(this, function (_a) {
|
|
332
|
+
switch (_a.label) {
|
|
333
333
|
case 0:
|
|
334
334
|
if (!this.session) {
|
|
335
335
|
return [2
|
|
@@ -342,43 +342,49 @@ function (_super) {
|
|
|
342
342
|
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
343
343
|
|
|
344
344
|
case 1:
|
|
345
|
-
canStartWithAudio =
|
|
345
|
+
canStartWithAudio = _a.sent();
|
|
346
346
|
return [4
|
|
347
347
|
/*yield*/
|
|
348
348
|
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
349
349
|
|
|
350
350
|
case 2:
|
|
351
|
-
canStartWithVideo =
|
|
352
|
-
|
|
353
|
-
if (!canStartWithAudio && !canStartWithVideo) {
|
|
354
|
-
// FIXME: use emitter
|
|
355
|
-
trace.error('Did not create publisher due to lack of media capabilities.');
|
|
356
|
-
return [2
|
|
357
|
-
/*return*/
|
|
358
|
-
];
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (!!this.currentPublisher) return [3
|
|
362
|
-
/*break*/
|
|
363
|
-
, 4];
|
|
351
|
+
canStartWithVideo = _a.sent();
|
|
364
352
|
return [4
|
|
365
353
|
/*yield*/
|
|
366
|
-
,
|
|
367
|
-
cameraEnabled: settings.cameraEnabled && canStartWithVideo,
|
|
368
|
-
startWithAudioMuted: settings.startWithAudioMuted && canStartWithAudio
|
|
369
|
-
}))];
|
|
354
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
370
355
|
|
|
371
356
|
case 3:
|
|
372
|
-
|
|
357
|
+
capabilitiesService = _a.sent();
|
|
373
358
|
|
|
374
|
-
if (!
|
|
359
|
+
if (!canStartWithAudio && !canStartWithVideo) {
|
|
375
360
|
throw new Error('Creating session requires initialized publisher');
|
|
376
361
|
}
|
|
377
362
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
363
|
+
publisherOptions = {
|
|
364
|
+
participantId: this.getParticipantId(this.ownConnectionId),
|
|
365
|
+
backgroundImageURI: this.backgroundImageURI
|
|
366
|
+
};
|
|
367
|
+
this.publisher = new OpentokPublisher_1.OpentokPublisher(__assign(__assign({}, settings), {
|
|
368
|
+
cameraEnabled: settings.cameraEnabled && canStartWithVideo,
|
|
369
|
+
startWithAudioMuted: settings.startWithAudioMuted && canStartWithAudio
|
|
370
|
+
}), publisherOptions, capabilitiesService); // forward publisher events
|
|
371
|
+
|
|
372
|
+
this.publisher.on('cameraSourceChanged', function (e) {
|
|
373
|
+
return _this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.cameraSourceChanged, e);
|
|
374
|
+
});
|
|
375
|
+
this.publisher.on('streamCreated', function (e) {
|
|
376
|
+
return _this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamCreated, e);
|
|
377
|
+
});
|
|
378
|
+
this.publisher.on('streamDestroyed', function (e) {
|
|
379
|
+
return _this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamDestroyed, e);
|
|
380
|
+
});
|
|
381
|
+
this.publisher.on('mediaDeviceAccessDenied', function (e) {
|
|
382
|
+
return _this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.mediaDeviceAccessDenied, e);
|
|
383
|
+
});
|
|
384
|
+
this.publisher.on('videoElementCreated', function () {
|
|
385
|
+
return _this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.videoElementCreated);
|
|
386
|
+
});
|
|
387
|
+
this.session.publish(this.publisher.get(), trace_1.traceError);
|
|
382
388
|
return [2
|
|
383
389
|
/*return*/
|
|
384
390
|
];
|
|
@@ -390,15 +396,18 @@ function (_super) {
|
|
|
390
396
|
_this.publishAudio = function (shouldMute) {
|
|
391
397
|
return __awaiter(_this, void 0, void 0, function () {
|
|
392
398
|
var canPublishAudio;
|
|
393
|
-
|
|
394
|
-
|
|
399
|
+
|
|
400
|
+
var _a;
|
|
401
|
+
|
|
402
|
+
return __generator(this, function (_b) {
|
|
403
|
+
switch (_b.label) {
|
|
395
404
|
case 0:
|
|
396
405
|
return [4
|
|
397
406
|
/*yield*/
|
|
398
407
|
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
399
408
|
|
|
400
409
|
case 1:
|
|
401
|
-
canPublishAudio =
|
|
410
|
+
canPublishAudio = _b.sent();
|
|
402
411
|
|
|
403
412
|
if (shouldMute && !canPublishAudio) {
|
|
404
413
|
trace.error('could not publish audio');
|
|
@@ -407,28 +416,7 @@ function (_super) {
|
|
|
407
416
|
];
|
|
408
417
|
}
|
|
409
418
|
|
|
410
|
-
|
|
411
|
-
/*break*/
|
|
412
|
-
, 3];
|
|
413
|
-
return [4
|
|
414
|
-
/*yield*/
|
|
415
|
-
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
416
|
-
// so if 'shouldMute' is true then we DON't mute?
|
|
417
|
-
startWithAudioMuted: !shouldMute
|
|
418
|
-
}))];
|
|
419
|
-
|
|
420
|
-
case 2:
|
|
421
|
-
_a.sent();
|
|
422
|
-
|
|
423
|
-
return [3
|
|
424
|
-
/*break*/
|
|
425
|
-
, 4];
|
|
426
|
-
|
|
427
|
-
case 3:
|
|
428
|
-
this.currentPublisher.publishAudio(shouldMute);
|
|
429
|
-
_a.label = 4;
|
|
430
|
-
|
|
431
|
-
case 4:
|
|
419
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.publishAudio(shouldMute);
|
|
432
420
|
return [2
|
|
433
421
|
/*return*/
|
|
434
422
|
];
|
|
@@ -440,15 +428,18 @@ function (_super) {
|
|
|
440
428
|
_this.publishVideo = function (shouldPublishVideo) {
|
|
441
429
|
return __awaiter(_this, void 0, void 0, function () {
|
|
442
430
|
var canPublishVideo;
|
|
443
|
-
|
|
444
|
-
|
|
431
|
+
|
|
432
|
+
var _a;
|
|
433
|
+
|
|
434
|
+
return __generator(this, function (_b) {
|
|
435
|
+
switch (_b.label) {
|
|
445
436
|
case 0:
|
|
446
437
|
return [4
|
|
447
438
|
/*yield*/
|
|
448
439
|
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
449
440
|
|
|
450
441
|
case 1:
|
|
451
|
-
canPublishVideo =
|
|
442
|
+
canPublishVideo = _b.sent();
|
|
452
443
|
|
|
453
444
|
if (shouldPublishVideo && !canPublishVideo) {
|
|
454
445
|
trace.error('could not publish video');
|
|
@@ -457,27 +448,7 @@ function (_super) {
|
|
|
457
448
|
];
|
|
458
449
|
}
|
|
459
450
|
|
|
460
|
-
|
|
461
|
-
/*break*/
|
|
462
|
-
, 3];
|
|
463
|
-
return [4
|
|
464
|
-
/*yield*/
|
|
465
|
-
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
466
|
-
cameraEnabled: shouldPublishVideo
|
|
467
|
-
}))];
|
|
468
|
-
|
|
469
|
-
case 2:
|
|
470
|
-
_a.sent();
|
|
471
|
-
|
|
472
|
-
return [3
|
|
473
|
-
/*break*/
|
|
474
|
-
, 4];
|
|
475
|
-
|
|
476
|
-
case 3:
|
|
477
|
-
this.currentPublisher.publishVideo(shouldPublishVideo);
|
|
478
|
-
_a.label = 4;
|
|
479
|
-
|
|
480
|
-
case 4:
|
|
451
|
+
(_a = this.publisher) === null || _a === void 0 ? void 0 : _a.publishVideo(shouldPublishVideo);
|
|
481
452
|
return [2
|
|
482
453
|
/*return*/
|
|
483
454
|
];
|
|
@@ -488,232 +459,21 @@ function (_super) {
|
|
|
488
459
|
|
|
489
460
|
_this.switchCamera = function () {
|
|
490
461
|
return __awaiter(_this, void 0, void 0, function () {
|
|
491
|
-
var mediaCapabilitiesService, deviceId, cameraSource_1, err_1;
|
|
492
|
-
|
|
493
|
-
var _this = this;
|
|
494
|
-
|
|
495
462
|
var _a;
|
|
496
463
|
|
|
497
464
|
return __generator(this, function (_b) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return [4
|
|
503
|
-
/*yield*/
|
|
504
|
-
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
505
|
-
|
|
506
|
-
case 1:
|
|
507
|
-
mediaCapabilitiesService = _b.sent();
|
|
508
|
-
|
|
509
|
-
if (!mediaCapabilitiesService.supportSwitchCamera) {
|
|
510
|
-
throw new Error('Not Support switch camera');
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
deviceId = '';
|
|
514
|
-
|
|
515
|
-
switch (this.settings.selectedCamera) {
|
|
516
|
-
case MediaConstants_1.MultiPartyCameraTypes.BACK:
|
|
517
|
-
cameraSource_1 = MediaConstants_1.MultiPartyCameraTypes.FRONT;
|
|
518
|
-
deviceId = mediaCapabilitiesService.frontCameraDeviceId;
|
|
519
|
-
this.mirror = true;
|
|
520
|
-
break;
|
|
521
|
-
|
|
522
|
-
case MediaConstants_1.MultiPartyCameraTypes.FRONT:
|
|
523
|
-
cameraSource_1 = MediaConstants_1.MultiPartyCameraTypes.BACK;
|
|
524
|
-
deviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
525
|
-
this.mirror = !MediaCapabilitiesUtils_1.checkIsMobile();
|
|
526
|
-
break;
|
|
527
|
-
|
|
528
|
-
default:
|
|
529
|
-
throw new Error("cameraType not valid: " + this.settings.selectedCamera);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return [4
|
|
533
|
-
/*yield*/
|
|
534
|
-
, (_a = this.currentPublisher) === null || _a === void 0 ? void 0 : _a.setVideoSource(deviceId).then(function () {
|
|
535
|
-
var _a, _b, _c, _d, _e, _f;
|
|
536
|
-
|
|
537
|
-
_this.settings.selectedCamera = cameraSource_1;
|
|
538
|
-
|
|
539
|
-
if (_this.mirror) {
|
|
540
|
-
(_b = (_a = _this.currentPublisher) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.classList.add(OPENTOK_MIRRORED_CSS_CLASS);
|
|
541
|
-
} else {
|
|
542
|
-
(_d = (_c = _this.currentPublisher) === null || _c === void 0 ? void 0 : _c.element) === null || _d === void 0 ? void 0 : _d.classList.remove(OPENTOK_MIRRORED_CSS_CLASS);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
var e = {
|
|
546
|
-
cameraSource: cameraSource_1,
|
|
547
|
-
mirror: _this.mirror,
|
|
548
|
-
videoDimensions: ((_f = (_e = _this.currentPublisher) === null || _e === void 0 ? void 0 : _e.stream) === null || _f === void 0 ? void 0 : _f.videoDimensions) || {
|
|
549
|
-
width: 0,
|
|
550
|
-
height: 0
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.cameraSourceChanged, e);
|
|
555
|
-
|
|
556
|
-
trace.info("Success to switch camera to cameraSource: " + cameraSource_1);
|
|
557
|
-
})];
|
|
558
|
-
|
|
559
|
-
case 2:
|
|
560
|
-
return [2
|
|
561
|
-
/*return*/
|
|
562
|
-
, _b.sent()];
|
|
563
|
-
|
|
564
|
-
case 3:
|
|
565
|
-
err_1 = _b.sent();
|
|
566
|
-
trace.error(JSON.stringify(err_1));
|
|
567
|
-
throw err_1;
|
|
568
|
-
|
|
569
|
-
case 4:
|
|
570
|
-
return [2
|
|
571
|
-
/*return*/
|
|
572
|
-
];
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
_this.initPublisher = function (settings) {
|
|
579
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
580
|
-
var selectedCamera, isMobile, mediaCapabilitiesService, frontCameraDeviceId, backCameraDeviceId, videoSourceId, mobileCameraType, err_2;
|
|
581
|
-
|
|
582
|
-
var _this = this;
|
|
583
|
-
|
|
584
|
-
var _a, _b, _c;
|
|
585
|
-
|
|
586
|
-
return __generator(this, function (_d) {
|
|
587
|
-
switch (_d.label) {
|
|
588
|
-
case 0:
|
|
589
|
-
_d.trys.push([0, 2,, 3]);
|
|
590
|
-
|
|
591
|
-
selectedCamera = settings.selectedCamera;
|
|
592
|
-
isMobile = MediaCapabilitiesUtils_1.checkIsMobile();
|
|
593
|
-
return [4
|
|
594
|
-
/*yield*/
|
|
595
|
-
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
596
|
-
|
|
597
|
-
case 1:
|
|
598
|
-
mediaCapabilitiesService = _d.sent();
|
|
599
|
-
frontCameraDeviceId = mediaCapabilitiesService.frontCameraDeviceId, backCameraDeviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
600
|
-
videoSourceId = (selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? frontCameraDeviceId : backCameraDeviceId) || undefined;
|
|
601
|
-
mobileCameraType = settings.selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? OpentokFacingMode.USER : OpentokFacingMode.ENVIRONMENT;
|
|
602
|
-
this.mirror = !isMobile || settings.selectedCamera !== MediaConstants_1.MultiPartyCameraTypes.BACK;
|
|
603
|
-
this.currentPublisher = OT.initPublisher(this.getParticipantId(((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b.connectionId) || ''), {
|
|
604
|
-
insertMode: 'append',
|
|
605
|
-
fitMode: 'cover',
|
|
606
|
-
width: '100%',
|
|
607
|
-
height: '100%',
|
|
608
|
-
style: {
|
|
609
|
-
buttonDisplayMode: 'off',
|
|
610
|
-
archiveStatusDisplayMode: 'off',
|
|
611
|
-
audioLevelDisplayMode: 'off',
|
|
612
|
-
backgroundImageURI: ((_c = this.branding) === null || _c === void 0 ? void 0 : _c.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
613
|
-
},
|
|
614
|
-
publishAudio: !settings.startWithAudioMuted,
|
|
615
|
-
publishVideo: settings.cameraEnabled,
|
|
616
|
-
videoSource: !isMobile ? videoSourceId : undefined,
|
|
617
|
-
facingMode: isMobile || !videoSourceId ? mobileCameraType : undefined,
|
|
618
|
-
mirror: this.mirror
|
|
619
|
-
}, this.traceErrorCallback);
|
|
620
|
-
|
|
621
|
-
if (!this.currentPublisher) {
|
|
622
|
-
trace.error('failed to init publisher');
|
|
623
|
-
} else {
|
|
624
|
-
this.currentPublisher.on('videoElementCreated', function (event) {
|
|
625
|
-
trace.info('videoElementCreated', event);
|
|
626
|
-
|
|
627
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.videoElementCreated);
|
|
628
|
-
});
|
|
629
|
-
this.currentPublisher.on('streamDestroyed', function (event) {
|
|
630
|
-
trace.info('Publisher stream destroyed', event);
|
|
631
|
-
var connection = event.stream.connection;
|
|
632
|
-
var connectionId = connection.connectionId;
|
|
633
|
-
var e = {
|
|
634
|
-
participantId: _this.getParticipantId(connectionId),
|
|
635
|
-
connectionId: connectionId,
|
|
636
|
-
isOwnConnection: true,
|
|
637
|
-
clientRole: _this.getClientRole(connection)
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamDestroyed, e);
|
|
641
|
-
});
|
|
642
|
-
this.currentPublisher.on('accessDenied', function () {
|
|
643
|
-
trace.info('Publisher denied media permissions');
|
|
644
|
-
var e = {
|
|
645
|
-
isOwnConnection: true
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.mediaDeviceAccessDenied, e);
|
|
649
|
-
});
|
|
650
|
-
this.currentPublisher.on('streamCreated', function (event) {
|
|
651
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
652
|
-
var _a, hasAudio, hasVideo, connectionId, participantId, clientRole, e;
|
|
653
|
-
|
|
654
|
-
return __generator(this, function (_b) {
|
|
655
|
-
switch (_b.label) {
|
|
656
|
-
case 0:
|
|
657
|
-
return [4
|
|
658
|
-
/*yield*/
|
|
659
|
-
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
660
|
-
|
|
661
|
-
case 1:
|
|
662
|
-
_b.sent();
|
|
663
|
-
|
|
664
|
-
_a = event.stream, hasAudio = _a.hasAudio, hasVideo = _a.hasVideo;
|
|
665
|
-
connectionId = event.stream.connection.connectionId;
|
|
666
|
-
participantId = this.getParticipantId(connectionId);
|
|
667
|
-
clientRole = this.getClientRole(event.stream.connection);
|
|
668
|
-
e = {
|
|
669
|
-
participantId: participantId,
|
|
670
|
-
clientRole: clientRole,
|
|
671
|
-
connectionId: connectionId,
|
|
672
|
-
hasVideo: hasVideo,
|
|
673
|
-
hasAudio: hasAudio,
|
|
674
|
-
isOwnConnection: true,
|
|
675
|
-
audioEnabled: !this.settings.startWithAudioMuted,
|
|
676
|
-
mirror: this.mirror,
|
|
677
|
-
videoDimensions: event.stream.videoDimensions
|
|
678
|
-
};
|
|
679
|
-
this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamCreated, e);
|
|
680
|
-
trace.info('publisher stream created', {
|
|
681
|
-
event: event,
|
|
682
|
-
hasAudio: hasAudio,
|
|
683
|
-
participantId: participantId
|
|
684
|
-
});
|
|
685
|
-
return [2
|
|
686
|
-
/*return*/
|
|
687
|
-
];
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
return [3
|
|
695
|
-
/*break*/
|
|
696
|
-
, 3];
|
|
697
|
-
|
|
698
|
-
case 2:
|
|
699
|
-
err_2 = _d.sent();
|
|
700
|
-
trace.error(JSON.stringify(err_2));
|
|
701
|
-
throw err_2;
|
|
702
|
-
|
|
703
|
-
case 3:
|
|
704
|
-
return [2
|
|
705
|
-
/*return*/
|
|
706
|
-
];
|
|
707
|
-
}
|
|
465
|
+
return [2
|
|
466
|
+
/*return*/
|
|
467
|
+
, (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.switchCamera()];
|
|
708
468
|
});
|
|
709
469
|
});
|
|
710
470
|
};
|
|
711
471
|
|
|
712
472
|
_this.reinitializeStreams = function (settings) {
|
|
713
473
|
return __awaiter(_this, void 0, void 0, function () {
|
|
714
|
-
var _a;
|
|
474
|
+
var _a, _b;
|
|
715
475
|
|
|
716
|
-
return __generator(this, function (
|
|
476
|
+
return __generator(this, function (_c) {
|
|
717
477
|
if (!this.session) {
|
|
718
478
|
return [2
|
|
719
479
|
/*return*/
|
|
@@ -724,22 +484,17 @@ function (_super) {
|
|
|
724
484
|
return s.subscriber;
|
|
725
485
|
}).forEach((_a = this.session) === null || _a === void 0 ? void 0 : _a.unsubscribe);
|
|
726
486
|
this.subscriberList = [];
|
|
727
|
-
|
|
728
|
-
if (this.currentPublisher) {
|
|
729
|
-
this.currentPublisher.destroy();
|
|
730
|
-
this.currentPublisher = undefined;
|
|
731
|
-
}
|
|
732
|
-
|
|
487
|
+
(_b = this.publisher) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
733
488
|
return [2
|
|
734
489
|
/*return*/
|
|
735
|
-
, this.
|
|
490
|
+
, this.initPublisher(settings)];
|
|
736
491
|
});
|
|
737
492
|
});
|
|
738
493
|
};
|
|
739
494
|
|
|
740
495
|
_this.streamCreatedHandler = function (event) {
|
|
741
496
|
return __awaiter(_this, void 0, void 0, function () {
|
|
742
|
-
var stream, connection, hasAudio, hasVideo, videoDimensions, connectionId, participantId, clientRole, subscriber
|
|
497
|
+
var stream, connection, hasAudio, hasVideo, videoDimensions, connectionId, participantId, clientRole, subscriber;
|
|
743
498
|
return __generator(this, function (_a) {
|
|
744
499
|
switch (_a.label) {
|
|
745
500
|
case 0:
|
|
@@ -748,7 +503,7 @@ function (_super) {
|
|
|
748
503
|
connection = stream.connection, hasAudio = stream.hasAudio, hasVideo = stream.hasVideo, videoDimensions = stream.videoDimensions;
|
|
749
504
|
connectionId = connection.connectionId;
|
|
750
505
|
participantId = this.getParticipantId(connectionId);
|
|
751
|
-
clientRole =
|
|
506
|
+
clientRole = OpentokUtils_1.getClientRole(connection);
|
|
752
507
|
return [4
|
|
753
508
|
/*yield*/
|
|
754
509
|
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
@@ -758,7 +513,7 @@ function (_super) {
|
|
|
758
513
|
|
|
759
514
|
if (this.ownConnectionId && stream && connectionId !== this.ownConnectionId) {
|
|
760
515
|
if (this.subscriberList.length < MultiPartyService_1.maxParticipantsNumber - 1) {
|
|
761
|
-
subscriber =
|
|
516
|
+
subscriber = OpentokSubscriber_1.createSubscriber(this.session, stream, this.getParticipantId(connectionId), this.backgroundImageURI);
|
|
762
517
|
this.subscriberList.push({
|
|
763
518
|
subscriber: subscriber,
|
|
764
519
|
connectionId: connectionId,
|
|
@@ -769,18 +524,16 @@ function (_super) {
|
|
|
769
524
|
}
|
|
770
525
|
}
|
|
771
526
|
|
|
772
|
-
|
|
527
|
+
this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
773
528
|
participantId: participantId,
|
|
774
529
|
clientRole: clientRole,
|
|
775
530
|
connectionId: connectionId,
|
|
776
531
|
hasVideo: hasVideo,
|
|
777
532
|
hasAudio: hasAudio,
|
|
778
533
|
isOwnConnection: false,
|
|
779
|
-
audioEnabled: !this.settings.startWithAudioMuted,
|
|
780
534
|
mirror: false,
|
|
781
535
|
videoDimensions: videoDimensions
|
|
782
|
-
};
|
|
783
|
-
this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamCreated, e);
|
|
536
|
+
});
|
|
784
537
|
return [2
|
|
785
538
|
/*return*/
|
|
786
539
|
];
|
|
@@ -793,17 +546,16 @@ function (_super) {
|
|
|
793
546
|
trace.info('streamDestroyedHandler', event);
|
|
794
547
|
var connection = event.stream.connection;
|
|
795
548
|
var connectionId = connection.connectionId;
|
|
796
|
-
var e = {
|
|
797
|
-
participantId: _this.getParticipantId(connectionId),
|
|
798
|
-
connectionId: connectionId,
|
|
799
|
-
isOwnConnection: false,
|
|
800
|
-
clientRole: _this.getClientRole(connection)
|
|
801
|
-
};
|
|
802
549
|
_this.subscriberList = _this.subscriberList.filter(function (subscriber) {
|
|
803
550
|
return subscriber.connectionId !== connectionId;
|
|
804
551
|
});
|
|
805
552
|
|
|
806
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamDestroyed,
|
|
553
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
554
|
+
participantId: _this.getParticipantId(connectionId),
|
|
555
|
+
connectionId: connectionId,
|
|
556
|
+
isOwnConnection: false,
|
|
557
|
+
clientRole: OpentokUtils_1.getClientRole(connection)
|
|
558
|
+
});
|
|
807
559
|
};
|
|
808
560
|
|
|
809
561
|
_this.connectionCreatedHandler = function (event) {
|
|
@@ -815,28 +567,25 @@ function (_super) {
|
|
|
815
567
|
return;
|
|
816
568
|
}
|
|
817
569
|
|
|
818
|
-
|
|
819
|
-
clientRole:
|
|
570
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectionCreated, {
|
|
571
|
+
clientRole: OpentokUtils_1.getClientRole(connection),
|
|
820
572
|
participantId: _this.getParticipantId(connectionId),
|
|
821
573
|
connectionId: connectionId,
|
|
822
574
|
isOwnConnection: _this.checkOwnConnection(connectionId)
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectionCreated, e);
|
|
575
|
+
});
|
|
826
576
|
};
|
|
827
577
|
|
|
828
578
|
_this.connectionDestroyedHandler = function (event) {
|
|
829
579
|
var connection = event.connection;
|
|
830
580
|
var connectionId = connection.connectionId;
|
|
831
581
|
trace.info('connectionDestroyedHandler', event);
|
|
832
|
-
|
|
833
|
-
|
|
582
|
+
|
|
583
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectionDestroyed, {
|
|
584
|
+
clientRole: OpentokUtils_1.getClientRole(connection),
|
|
834
585
|
participantId: _this.getParticipantId(connectionId),
|
|
835
586
|
connectionId: connectionId,
|
|
836
587
|
isOwnConnection: _this.checkOwnConnection(connectionId)
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.connectionDestroyed, e);
|
|
588
|
+
});
|
|
840
589
|
|
|
841
590
|
if (connectionId !== _this.ownConnectionId || !_this.ownConnectionId) {
|
|
842
591
|
return;
|
|
@@ -853,58 +602,26 @@ function (_super) {
|
|
|
853
602
|
connection = _a.connection,
|
|
854
603
|
videoDimensions = _a.videoDimensions;
|
|
855
604
|
var connectionId = connection.connectionId;
|
|
856
|
-
|
|
605
|
+
|
|
606
|
+
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamPropertyChanged, {
|
|
857
607
|
hasVideo: hasVideo,
|
|
858
608
|
hasAudio: hasAudio,
|
|
859
609
|
participantId: _this.getParticipantId(connectionId),
|
|
860
610
|
connectionId: connectionId,
|
|
861
611
|
isOwnConnection: _this.checkOwnConnection(connectionId),
|
|
862
|
-
clientRole:
|
|
612
|
+
clientRole: OpentokUtils_1.getClientRole(connection),
|
|
863
613
|
videoDimensions: videoDimensions
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
_this.emit(MultipartyServiceEventTypes_1.MULTI_PARTY_EVENTS.streamPropertyChanged, e);
|
|
867
|
-
};
|
|
868
|
-
|
|
869
|
-
_this.traceErrorCallback = function (error) {
|
|
870
|
-
trace.error(JSON.stringify(error));
|
|
614
|
+
});
|
|
871
615
|
};
|
|
872
616
|
|
|
873
617
|
_this.sessionDisconnectedHandler = function (event) {
|
|
874
|
-
trace.info('sessionDisconnectedHandler', event);
|
|
875
|
-
// this?.session?.signal({ retryAfterReconnect: true });
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
_this.createSubscriber = function (stream, connectionId) {
|
|
879
|
-
var _a; // ToDo: OT session can be undefined. This needs to be fixed.
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
var subscriber = _this.session.subscribe(stream, _this.getParticipantId(connectionId), {
|
|
883
|
-
insertMode: 'append',
|
|
884
|
-
fitMode: 'cover',
|
|
885
|
-
width: '100%',
|
|
886
|
-
height: '100%',
|
|
887
|
-
style: {
|
|
888
|
-
buttonDisplayMode: 'off',
|
|
889
|
-
audioLevelDisplayMode: 'off',
|
|
890
|
-
videoDisabledDisplayMode: 'off',
|
|
891
|
-
backgroundImageURI: ((_a = _this.branding) === null || _a === void 0 ? void 0 : _a.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
892
|
-
}
|
|
893
|
-
}, function (err) {
|
|
894
|
-
_this.traceErrorCallback(err);
|
|
895
|
-
});
|
|
896
|
-
|
|
897
|
-
subscriber.on('videoElementCreated', function (event) {
|
|
898
|
-
trace.info('videoElementCreated', event);
|
|
899
|
-
});
|
|
900
|
-
return subscriber;
|
|
618
|
+
trace.info('sessionDisconnectedHandler', event);
|
|
901
619
|
};
|
|
902
620
|
|
|
903
621
|
_this.checkOwnConnection = function (connectionId) {
|
|
904
622
|
return _this.ownConnectionId !== undefined && _this.ownConnectionId === connectionId;
|
|
905
623
|
};
|
|
906
624
|
|
|
907
|
-
_this.branding = settings.branding;
|
|
908
625
|
return _this;
|
|
909
626
|
}
|
|
910
627
|
|
|
@@ -924,11 +641,6 @@ function (_super) {
|
|
|
924
641
|
enumerable: false,
|
|
925
642
|
configurable: true
|
|
926
643
|
});
|
|
927
|
-
|
|
928
|
-
OpentokMultiPartyService.prototype.getClientRole = function (connection) {
|
|
929
|
-
return (connection === null || connection === void 0 ? void 0 : connection.data) && JSON.parse(connection.data).clientRole || MediaConstants_1.SessionClientRole.USER;
|
|
930
|
-
};
|
|
931
|
-
|
|
932
644
|
return OpentokMultiPartyService;
|
|
933
645
|
}(MultiPartyService_1.MultiPartyService);
|
|
934
646
|
|