@techsee/techsee-media-service 2.0.1 → 4.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/MediaConstants.d.ts +4 -0
- package/lib/MediaConstants.d.ts.map +1 -1
- package/lib/MediaConstants.js +8 -1
- package/lib/MediaConstants.js.map +1 -1
- package/lib/MediaUtils/index.d.ts +1 -0
- package/lib/MediaUtils/index.d.ts.map +1 -0
- package/lib/MediaUtils/index.js +16 -0
- package/lib/MediaUtils/index.js.map +1 -0
- package/lib/MultiParty/Contracts.d.ts +3 -2
- package/lib/MultiParty/Contracts.d.ts.map +1 -1
- package/lib/MultiParty/{MediaCapabilitiesHelper.d.ts → MediaCapabilitiesService.d.ts} +3 -3
- package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -0
- package/lib/MultiParty/{MediaCapabilitiesHelper.js → MediaCapabilitiesService.js} +70 -109
- package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +5 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js +305 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -0
- package/lib/MultiParty/{MultiParty.d.ts → MultiPartyService.d.ts} +4 -15
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/{MultiParty.js → MultiPartyService.js} +9 -192
- package/lib/MultiParty/MultiPartyService.js.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts +3 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js +21 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -0
- package/lib/MultiParty/{OpentokMultiparty.d.ts → OpentokMultiPartyService.d.ts} +6 -12
- package/lib/MultiParty/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/{OpentokMultiparty.js → OpentokMultiPartyService.js} +242 -285
- package/lib/MultiParty/OpentokMultiPartyService.js.map +1 -0
- package/lib/MultiParty/index.d.ts +3 -0
- package/lib/MultiParty/index.d.ts.map +1 -0
- package/lib/MultiParty/index.js +52 -0
- package/lib/MultiParty/index.js.map +1 -0
- package/package.json +2 -2
- package/lib/MultiParty/MediaCapabilitiesHelper.d.ts.map +0 -1
- package/lib/MultiParty/MediaCapabilitiesHelper.js.map +0 -1
- package/lib/MultiParty/MultiParty.d.ts.map +0 -1
- package/lib/MultiParty/MultiParty.js.map +0 -1
- package/lib/MultiParty/MultipartyFactory.d.ts +0 -4
- package/lib/MultiParty/MultipartyFactory.d.ts.map +0 -1
- package/lib/MultiParty/MultipartyFactory.js +0 -21
- package/lib/MultiParty/MultipartyFactory.js.map +0 -1
- package/lib/MultiParty/OpentokMultiparty.d.ts.map +0 -1
- package/lib/MultiParty/OpentokMultiparty.js.map +0 -1
|
@@ -26,6 +26,22 @@ var __extends = void 0 && (void 0).__extends || function () {
|
|
|
26
26
|
};
|
|
27
27
|
}();
|
|
28
28
|
|
|
29
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
30
|
+
__assign = Object.assign || function (t) {
|
|
31
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
32
|
+
s = arguments[i];
|
|
33
|
+
|
|
34
|
+
for (var p in s) {
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return __assign.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
|
|
29
45
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
30
46
|
function adopt(value) {
|
|
31
47
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -169,32 +185,22 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
|
169
185
|
}
|
|
170
186
|
};
|
|
171
187
|
|
|
172
|
-
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
173
|
-
return mod && mod.__esModule ? mod : {
|
|
174
|
-
"default": mod
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
|
|
178
188
|
Object.defineProperty(exports, "__esModule", {
|
|
179
189
|
value: true
|
|
180
190
|
});
|
|
181
|
-
exports.
|
|
191
|
+
exports.OpentokMultiPartyService = void 0;
|
|
182
192
|
|
|
183
|
-
var
|
|
193
|
+
var MultiPartyService_1 = require("./MultiPartyService");
|
|
184
194
|
|
|
185
195
|
var MediaConstants_1 = require("../MediaConstants");
|
|
186
196
|
|
|
187
|
-
var
|
|
197
|
+
var MediaUtils_1 = require("../MediaUtils");
|
|
188
198
|
|
|
189
|
-
var
|
|
199
|
+
var MediaCapabilitiesUtils_1 = require("./MediaCapabilitiesUtils");
|
|
190
200
|
|
|
191
|
-
var
|
|
201
|
+
var MediaCapabilitiesService_1 = require("./MediaCapabilitiesService");
|
|
192
202
|
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
var MediaCapabilitiesHelper_1 = require("./MediaCapabilitiesHelper");
|
|
196
|
-
|
|
197
|
-
var trace = MediaTracer_1.getMediaTracer('Multiparty'); // The preferred camera position to use for the video source
|
|
203
|
+
var trace = MediaUtils_1.getMediaTracer('Multiparty'); // The preferred camera position to use for the video source
|
|
198
204
|
|
|
199
205
|
var OpentokFacingMode;
|
|
200
206
|
|
|
@@ -203,26 +209,24 @@ var OpentokFacingMode;
|
|
|
203
209
|
OpentokFacingMode["ENVIRONMENT"] = "environment";
|
|
204
210
|
})(OpentokFacingMode || (OpentokFacingMode = {}));
|
|
205
211
|
|
|
206
|
-
var
|
|
212
|
+
var OpentokMultiPartyService =
|
|
207
213
|
/** @class */
|
|
208
214
|
function (_super) {
|
|
209
|
-
__extends(
|
|
215
|
+
__extends(OpentokMultiPartyService, _super);
|
|
210
216
|
|
|
211
|
-
function
|
|
217
|
+
function OpentokMultiPartyService(settings, getParticipantDomId) {
|
|
212
218
|
var _this = _super.call(this, settings) || this;
|
|
213
219
|
|
|
214
220
|
_this.subscribers = [];
|
|
215
221
|
_this.participantCount = 0;
|
|
216
222
|
|
|
217
223
|
_this.connect = function (credentials) {
|
|
218
|
-
_this.credentials = credentials;
|
|
219
|
-
|
|
220
224
|
try {
|
|
221
225
|
_this.session = window === null || window === void 0 ? void 0 : window.OT.initSession(credentials.apiKey, credentials.sessionId);
|
|
222
226
|
} catch (err) {
|
|
223
227
|
trace.error(JSON.stringify(err));
|
|
224
228
|
|
|
225
|
-
_this.emit(
|
|
229
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
226
230
|
meta: {
|
|
227
231
|
err: JSON.stringify(err)
|
|
228
232
|
}
|
|
@@ -254,7 +258,7 @@ function (_super) {
|
|
|
254
258
|
(_a = this.session) === null || _a === void 0 ? void 0 : _a.off();
|
|
255
259
|
this.session = null;
|
|
256
260
|
this.traceErrorCallback(error);
|
|
257
|
-
this.emit(
|
|
261
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
258
262
|
meta: {
|
|
259
263
|
err: JSON.stringify(error)
|
|
260
264
|
}
|
|
@@ -264,13 +268,6 @@ function (_super) {
|
|
|
264
268
|
];
|
|
265
269
|
}
|
|
266
270
|
|
|
267
|
-
if (this.settings.defaultCamera === MediaConstants_1.CameraTypes.NONE && this.settings.startWithAudioMuted) {
|
|
268
|
-
trace.info('camera is none, no need to create publisher');
|
|
269
|
-
return [2
|
|
270
|
-
/*return*/
|
|
271
|
-
];
|
|
272
|
-
}
|
|
273
|
-
|
|
274
271
|
return [4
|
|
275
272
|
/*yield*/
|
|
276
273
|
, this.createPublisher(this.settings)];
|
|
@@ -302,119 +299,57 @@ function (_super) {
|
|
|
302
299
|
}
|
|
303
300
|
};
|
|
304
301
|
|
|
305
|
-
_this.
|
|
302
|
+
_this.createPublisher = function (settings) {
|
|
306
303
|
return __awaiter(_this, void 0, void 0, function () {
|
|
307
|
-
var
|
|
308
|
-
return __generator(this, function (_a) {
|
|
309
|
-
switch (_a.label) {
|
|
310
|
-
case 0:
|
|
311
|
-
_a.trys.push([0, 2,, 3]);
|
|
312
|
-
|
|
313
|
-
return [4
|
|
314
|
-
/*yield*/
|
|
315
|
-
, MediaCapabilitiesHelper_1.MediaCapabilitiesHelper.getInstance()];
|
|
316
|
-
|
|
317
|
-
case 1:
|
|
318
|
-
mediaCapabilitiesHelper = _a.sent();
|
|
319
|
-
return [2
|
|
320
|
-
/*return*/
|
|
321
|
-
, settings.defaultCamera !== MediaConstants_1.CameraTypes.NONE ? mediaCapabilitiesHelper.hasCamera() : false];
|
|
322
|
-
|
|
323
|
-
case 2:
|
|
324
|
-
err_1 = _a.sent();
|
|
325
|
-
trace.error(JSON.stringify(err_1));
|
|
326
|
-
throw err_1;
|
|
327
|
-
|
|
328
|
-
case 3:
|
|
329
|
-
return [2
|
|
330
|
-
/*return*/
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
_this.couldStartPublishAudio = function (settings) {
|
|
338
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
339
|
-
var mediaCapabilitiesHelper, err_2;
|
|
340
|
-
return __generator(this, function (_a) {
|
|
341
|
-
switch (_a.label) {
|
|
342
|
-
case 0:
|
|
343
|
-
_a.trys.push([0, 2,, 3]);
|
|
344
|
-
|
|
345
|
-
return [4
|
|
346
|
-
/*yield*/
|
|
347
|
-
, MediaCapabilitiesHelper_1.MediaCapabilitiesHelper.getInstance()];
|
|
348
|
-
|
|
349
|
-
case 1:
|
|
350
|
-
mediaCapabilitiesHelper = _a.sent();
|
|
351
|
-
return [2
|
|
352
|
-
/*return*/
|
|
353
|
-
, !settings.startWithAudioMuted && mediaCapabilitiesHelper.hasMicrophone()];
|
|
354
|
-
|
|
355
|
-
case 2:
|
|
356
|
-
err_2 = _a.sent();
|
|
357
|
-
trace.error(JSON.stringify(err_2));
|
|
358
|
-
throw err_2;
|
|
359
|
-
|
|
360
|
-
case 3:
|
|
361
|
-
return [2
|
|
362
|
-
/*return*/
|
|
363
|
-
];
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
_this.createPublisher = function (settingsForPublisher) {
|
|
370
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
371
|
-
var settings, couldStartPublishVideo, couldStartPublishAudio;
|
|
304
|
+
var canStartWithAudio, canStartWithVideo;
|
|
372
305
|
|
|
373
306
|
var _a;
|
|
374
307
|
|
|
375
308
|
return __generator(this, function (_b) {
|
|
376
309
|
switch (_b.label) {
|
|
377
310
|
case 0:
|
|
378
|
-
settings = cloneDeep_1["default"](settingsForPublisher);
|
|
379
311
|
return [4
|
|
380
312
|
/*yield*/
|
|
381
|
-
,
|
|
313
|
+
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
382
314
|
|
|
383
315
|
case 1:
|
|
384
|
-
|
|
316
|
+
canStartWithAudio = _b.sent();
|
|
385
317
|
return [4
|
|
386
318
|
/*yield*/
|
|
387
|
-
,
|
|
319
|
+
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
388
320
|
|
|
389
321
|
case 2:
|
|
390
|
-
|
|
322
|
+
canStartWithVideo = _b.sent();
|
|
391
323
|
|
|
392
|
-
if (!
|
|
324
|
+
if (!canStartWithAudio && !canStartWithVideo) {
|
|
393
325
|
// FIXME: use emitter
|
|
394
|
-
trace.error('
|
|
326
|
+
trace.error('Did not create publisher due to lack of media capabilities.');
|
|
395
327
|
return [2
|
|
396
328
|
/*return*/
|
|
397
329
|
];
|
|
398
330
|
}
|
|
399
331
|
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
|
|
332
|
+
if (!!this.currentPublisher) return [3
|
|
333
|
+
/*break*/
|
|
334
|
+
, 4];
|
|
335
|
+
return [4
|
|
336
|
+
/*yield*/
|
|
337
|
+
, this.initPublisher(__assign(__assign({}, settings), {
|
|
338
|
+
cameraEnabled: settings.cameraEnabled && canStartWithVideo,
|
|
339
|
+
startWithAudioMuted: settings.startWithAudioMuted && canStartWithAudio
|
|
340
|
+
}))];
|
|
403
341
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
342
|
+
case 3:
|
|
343
|
+
_b.sent();
|
|
407
344
|
|
|
408
345
|
if (!this.currentPublisher) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (!this.currentPublisher) {
|
|
412
|
-
throw new Error('Creating session requires initialized publisher');
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
this.currentPublisher && ((_a = this.session) === null || _a === void 0 ? void 0 : _a.publish(this.currentPublisher, this.traceErrorCallback));
|
|
346
|
+
throw new Error('Creating session requires initialized publisher');
|
|
416
347
|
}
|
|
417
348
|
|
|
349
|
+
this.currentPublisher && ((_a = this.session) === null || _a === void 0 ? void 0 : _a.publish(this.currentPublisher, this.traceErrorCallback));
|
|
350
|
+
_b.label = 4;
|
|
351
|
+
|
|
352
|
+
case 4:
|
|
418
353
|
return [2
|
|
419
354
|
/*return*/
|
|
420
355
|
];
|
|
@@ -425,27 +360,18 @@ function (_super) {
|
|
|
425
360
|
|
|
426
361
|
_this.publishAudio = function (shouldMute) {
|
|
427
362
|
return __awaiter(_this, void 0, void 0, function () {
|
|
428
|
-
var
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
switch (_b.label) {
|
|
363
|
+
var canPublishAudio;
|
|
364
|
+
return __generator(this, function (_a) {
|
|
365
|
+
switch (_a.label) {
|
|
432
366
|
case 0:
|
|
433
|
-
settings = cloneDeep_1["default"](this.settings);
|
|
434
|
-
settings.startWithAudioMuted = !shouldMute;
|
|
435
|
-
_a = shouldMute;
|
|
436
|
-
if (!_a) return [3
|
|
437
|
-
/*break*/
|
|
438
|
-
, 2];
|
|
439
367
|
return [4
|
|
440
368
|
/*yield*/
|
|
441
|
-
,
|
|
369
|
+
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
442
370
|
|
|
443
371
|
case 1:
|
|
444
|
-
|
|
445
|
-
_b.label = 2;
|
|
372
|
+
canPublishAudio = _a.sent(); // why do we care about audio if 'shouldMute' is true?
|
|
446
373
|
|
|
447
|
-
|
|
448
|
-
if (_a) {
|
|
374
|
+
if (shouldMute && !canPublishAudio) {
|
|
449
375
|
trace.error('could not publish audio');
|
|
450
376
|
return [2
|
|
451
377
|
/*return*/
|
|
@@ -454,23 +380,26 @@ function (_super) {
|
|
|
454
380
|
|
|
455
381
|
if (!!this.currentPublisher) return [3
|
|
456
382
|
/*break*/
|
|
457
|
-
,
|
|
383
|
+
, 3];
|
|
458
384
|
return [4
|
|
459
385
|
/*yield*/
|
|
460
|
-
, this.createPublisher(settings)
|
|
386
|
+
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
387
|
+
// so if 'shouldMute' is true then we DON't mute?
|
|
388
|
+
startWithAudioMuted: !shouldMute
|
|
389
|
+
}))];
|
|
461
390
|
|
|
462
|
-
case
|
|
463
|
-
|
|
391
|
+
case 2:
|
|
392
|
+
_a.sent();
|
|
464
393
|
|
|
465
394
|
return [3
|
|
466
395
|
/*break*/
|
|
467
|
-
,
|
|
396
|
+
, 4];
|
|
468
397
|
|
|
469
|
-
case
|
|
398
|
+
case 3:
|
|
470
399
|
this.currentPublisher.publishAudio(shouldMute);
|
|
471
|
-
|
|
400
|
+
_a.label = 4;
|
|
472
401
|
|
|
473
|
-
case
|
|
402
|
+
case 4:
|
|
474
403
|
return [2
|
|
475
404
|
/*return*/
|
|
476
405
|
];
|
|
@@ -481,27 +410,18 @@ function (_super) {
|
|
|
481
410
|
|
|
482
411
|
_this.publishVideo = function (shouldPublishVideo) {
|
|
483
412
|
return __awaiter(_this, void 0, void 0, function () {
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
switch (_b.label) {
|
|
413
|
+
var canPublishVideo;
|
|
414
|
+
return __generator(this, function (_a) {
|
|
415
|
+
switch (_a.label) {
|
|
488
416
|
case 0:
|
|
489
|
-
settings = cloneDeep_1["default"](this.settings);
|
|
490
|
-
settings.defaultCamera = shouldPublishVideo ? this.settings.defaultCamera : MediaConstants_1.CameraTypes.NONE;
|
|
491
|
-
_a = shouldPublishVideo;
|
|
492
|
-
if (!_a) return [3
|
|
493
|
-
/*break*/
|
|
494
|
-
, 2];
|
|
495
417
|
return [4
|
|
496
418
|
/*yield*/
|
|
497
|
-
,
|
|
419
|
+
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
498
420
|
|
|
499
421
|
case 1:
|
|
500
|
-
|
|
501
|
-
_b.label = 2;
|
|
422
|
+
canPublishVideo = _a.sent();
|
|
502
423
|
|
|
503
|
-
|
|
504
|
-
if (_a) {
|
|
424
|
+
if (shouldPublishVideo && !canPublishVideo) {
|
|
505
425
|
trace.error('could not publish video');
|
|
506
426
|
return [2
|
|
507
427
|
/*return*/
|
|
@@ -510,23 +430,25 @@ function (_super) {
|
|
|
510
430
|
|
|
511
431
|
if (!!this.currentPublisher) return [3
|
|
512
432
|
/*break*/
|
|
513
|
-
,
|
|
433
|
+
, 3];
|
|
514
434
|
return [4
|
|
515
435
|
/*yield*/
|
|
516
|
-
, this.createPublisher(settings)
|
|
436
|
+
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
437
|
+
cameraEnabled: shouldPublishVideo
|
|
438
|
+
}))];
|
|
517
439
|
|
|
518
|
-
case
|
|
519
|
-
|
|
440
|
+
case 2:
|
|
441
|
+
_a.sent();
|
|
520
442
|
|
|
521
443
|
return [3
|
|
522
444
|
/*break*/
|
|
523
|
-
,
|
|
445
|
+
, 4];
|
|
524
446
|
|
|
525
|
-
case
|
|
447
|
+
case 3:
|
|
526
448
|
this.currentPublisher.publishVideo(shouldPublishVideo);
|
|
527
|
-
|
|
449
|
+
_a.label = 4;
|
|
528
450
|
|
|
529
|
-
case
|
|
451
|
+
case 4:
|
|
530
452
|
return [2
|
|
531
453
|
/*return*/
|
|
532
454
|
];
|
|
@@ -537,7 +459,7 @@ function (_super) {
|
|
|
537
459
|
|
|
538
460
|
_this.switchCamera = function () {
|
|
539
461
|
return __awaiter(_this, void 0, void 0, function () {
|
|
540
|
-
var
|
|
462
|
+
var mediaCapabilitiesService, deviceId, cameraType_1, err_1;
|
|
541
463
|
|
|
542
464
|
var _this = this;
|
|
543
465
|
|
|
@@ -550,44 +472,48 @@ function (_super) {
|
|
|
550
472
|
|
|
551
473
|
return [4
|
|
552
474
|
/*yield*/
|
|
553
|
-
,
|
|
475
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
554
476
|
|
|
555
477
|
case 1:
|
|
556
|
-
|
|
478
|
+
mediaCapabilitiesService = _b.sent();
|
|
557
479
|
|
|
558
|
-
if (!
|
|
480
|
+
if (!mediaCapabilitiesService.supportSwitchCamera) {
|
|
559
481
|
throw new Error('Not Support switch camera');
|
|
560
482
|
}
|
|
561
483
|
|
|
562
484
|
deviceId = '';
|
|
563
|
-
cameraType_1 = MediaConstants_1.CameraTypes.NONE;
|
|
564
485
|
|
|
565
|
-
switch (this.settings.
|
|
566
|
-
case MediaConstants_1.
|
|
567
|
-
cameraType_1 = MediaConstants_1.
|
|
568
|
-
deviceId =
|
|
486
|
+
switch (this.settings.selectedCamera) {
|
|
487
|
+
case MediaConstants_1.MultiPartyCameraTypes.BACK:
|
|
488
|
+
cameraType_1 = MediaConstants_1.MultiPartyCameraTypes.FRONT;
|
|
489
|
+
deviceId = mediaCapabilitiesService.frontCameraDeviceId;
|
|
569
490
|
break;
|
|
570
491
|
|
|
571
|
-
case MediaConstants_1.
|
|
572
|
-
cameraType_1 = MediaConstants_1.
|
|
573
|
-
deviceId =
|
|
492
|
+
case MediaConstants_1.MultiPartyCameraTypes.FRONT:
|
|
493
|
+
cameraType_1 = MediaConstants_1.MultiPartyCameraTypes.BACK;
|
|
494
|
+
deviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
574
495
|
break;
|
|
575
496
|
|
|
576
497
|
default:
|
|
577
|
-
throw new Error("cameraType not valid: " + this.settings.
|
|
498
|
+
throw new Error("cameraType not valid: " + this.settings.selectedCamera);
|
|
578
499
|
}
|
|
579
500
|
|
|
580
501
|
return [2
|
|
581
502
|
/*return*/
|
|
582
503
|
, (_a = this.currentPublisher) === null || _a === void 0 ? void 0 : _a.setVideoSource(deviceId).then(function () {
|
|
583
|
-
_this.settings.
|
|
504
|
+
_this.settings.selectedCamera = cameraType_1;
|
|
505
|
+
|
|
506
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.cameraSourceChanged, {
|
|
507
|
+
cameraSource: cameraType_1
|
|
508
|
+
});
|
|
509
|
+
|
|
584
510
|
trace.info("Success to switch camera to cameraType: " + cameraType_1);
|
|
585
511
|
})];
|
|
586
512
|
|
|
587
513
|
case 2:
|
|
588
|
-
|
|
589
|
-
trace.error(JSON.stringify(
|
|
590
|
-
throw
|
|
514
|
+
err_1 = _b.sent();
|
|
515
|
+
trace.error(JSON.stringify(err_1));
|
|
516
|
+
throw err_1;
|
|
591
517
|
|
|
592
518
|
case 3:
|
|
593
519
|
return [2
|
|
@@ -599,101 +525,137 @@ function (_super) {
|
|
|
599
525
|
};
|
|
600
526
|
|
|
601
527
|
_this.initPublisher = function (settings) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
var properties = {
|
|
605
|
-
insertMode: 'append',
|
|
606
|
-
fitMode: 'cover',
|
|
607
|
-
width: '100%',
|
|
608
|
-
height: '100%',
|
|
609
|
-
style: {
|
|
610
|
-
buttonDisplayMode: 'off',
|
|
611
|
-
archiveStatusDisplayMode: 'off',
|
|
612
|
-
audioLevelDisplayMode: 'off',
|
|
613
|
-
backgroundImageURI: ((_a = _this.branding) === null || _a === void 0 ? void 0 : _a.backgroundImageURI) || MultiParty_1.DEFAULT_AVATAR_URI
|
|
614
|
-
},
|
|
615
|
-
publishAudio: !settings.startWithAudioMuted,
|
|
616
|
-
publishVideo: settings.defaultCamera !== MediaConstants_1.CameraTypes.NONE,
|
|
617
|
-
facingMode: settings.defaultCamera === MediaConstants_1.CameraTypes.FRONT ? OpentokFacingMode.USER : OpentokFacingMode.ENVIRONMENT
|
|
618
|
-
};
|
|
619
|
-
_this.currentPublisher = window === null || window === void 0 ? void 0 : window.OT.initPublisher(_this.getParticipantIdForStream((_b = _this.session) === null || _b === void 0 ? void 0 : _b.connection), properties, _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(MultiParty_1.MULTI_PARTY_EVENTS.videoElementCreated, event);
|
|
628
|
-
});
|
|
528
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
529
|
+
var selectedCamera, isMobile, mediaCapabilitiesService, frontCameraDeviceId, backCameraDeviceId, videoSourceId, mobileCameraType, properties, err_2;
|
|
629
530
|
|
|
630
|
-
_this
|
|
631
|
-
var _a;
|
|
531
|
+
var _this = this;
|
|
632
532
|
|
|
633
|
-
|
|
533
|
+
var _a, _b;
|
|
634
534
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
});
|
|
535
|
+
return __generator(this, function (_c) {
|
|
536
|
+
switch (_c.label) {
|
|
537
|
+
case 0:
|
|
538
|
+
_c.trys.push([0, 2,, 3]);
|
|
640
539
|
|
|
641
|
-
|
|
642
|
-
|
|
540
|
+
selectedCamera = settings.selectedCamera;
|
|
541
|
+
isMobile = MediaCapabilitiesUtils_1.checkIsMobile();
|
|
542
|
+
return [4
|
|
543
|
+
/*yield*/
|
|
544
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
643
545
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
546
|
+
case 1:
|
|
547
|
+
mediaCapabilitiesService = _c.sent();
|
|
548
|
+
frontCameraDeviceId = mediaCapabilitiesService.frontCameraDeviceId, backCameraDeviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
549
|
+
videoSourceId = (selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? frontCameraDeviceId : backCameraDeviceId) || undefined;
|
|
550
|
+
mobileCameraType = settings.selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? OpentokFacingMode.USER : OpentokFacingMode.ENVIRONMENT;
|
|
551
|
+
properties = {
|
|
552
|
+
insertMode: 'append',
|
|
553
|
+
fitMode: 'cover',
|
|
554
|
+
width: '100%',
|
|
555
|
+
height: '100%',
|
|
556
|
+
style: {
|
|
557
|
+
buttonDisplayMode: 'off',
|
|
558
|
+
archiveStatusDisplayMode: 'off',
|
|
559
|
+
audioLevelDisplayMode: 'off',
|
|
560
|
+
backgroundImageURI: ((_a = this.branding) === null || _a === void 0 ? void 0 : _a.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
561
|
+
},
|
|
562
|
+
publishAudio: !settings.startWithAudioMuted,
|
|
563
|
+
publishVideo: settings.cameraEnabled,
|
|
564
|
+
videoSource: !isMobile ? videoSourceId : undefined,
|
|
565
|
+
facingMode: isMobile || !videoSourceId ? mobileCameraType : undefined
|
|
566
|
+
};
|
|
567
|
+
this.currentPublisher = window === null || window === void 0 ? void 0 : window.OT.initPublisher(this.getParticipantId((_b = this.session) === null || _b === void 0 ? void 0 : _b.connection.connectionId), properties, this.traceErrorCallback);
|
|
647
568
|
|
|
648
|
-
|
|
569
|
+
if (!this.currentPublisher) {
|
|
570
|
+
trace.error('failed to init publisher');
|
|
571
|
+
} else {
|
|
572
|
+
this.currentPublisher.on('videoElementCreated', function (event) {
|
|
573
|
+
trace.info('videoElementCreated', event);
|
|
649
574
|
|
|
650
|
-
|
|
575
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoElementCreated, event);
|
|
576
|
+
});
|
|
577
|
+
this.currentPublisher.on('streamDestroyed', function (event) {
|
|
578
|
+
var _a;
|
|
651
579
|
|
|
652
|
-
|
|
653
|
-
connectionId: connectionId,
|
|
654
|
-
isOwnConnection: isOwnConnection,
|
|
655
|
-
participantId: participantId
|
|
656
|
-
});
|
|
657
|
-
});
|
|
580
|
+
trace.info('Publisher stream destroyed', event);
|
|
658
581
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
582
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
583
|
+
event: event,
|
|
584
|
+
participantId: _this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId)
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
this.currentPublisher.on('accessDenied', function (event) {
|
|
588
|
+
var _a;
|
|
662
589
|
|
|
663
|
-
|
|
590
|
+
trace.info('Publisher denied media permissions', event);
|
|
591
|
+
var connection = (_a = _this.session) === null || _a === void 0 ? void 0 : _a.connection;
|
|
592
|
+
var connectionId = connection === null || connection === void 0 ? void 0 : connection.connectionId;
|
|
664
593
|
|
|
665
|
-
|
|
666
|
-
switch (_f.label) {
|
|
667
|
-
case 0:
|
|
668
|
-
return [4
|
|
669
|
-
/*yield*/
|
|
670
|
-
, MediaCapabilitiesHelper_1.MediaCapabilitiesHelper.setDevicesList()];
|
|
594
|
+
var participantId = _this.getParticipantId(connection.connectionId);
|
|
671
595
|
|
|
672
|
-
|
|
673
|
-
_f.sent();
|
|
596
|
+
var isOwnConnection = _this.ownConnectionId === connectionId;
|
|
674
597
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
participantId: participantId,
|
|
679
|
-
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
680
|
-
hasAudio: (_b = event === null || event === void 0 ? void 0 : event.stream) === null || _b === void 0 ? void 0 : _b.hasAudio,
|
|
681
|
-
hasVideo: (_c = event === null || event === void 0 ? void 0 : event.stream) === null || _c === void 0 ? void 0 : _c.hasVideo,
|
|
682
|
-
isOwnConnection: this.ownConnectionId === ((_e = (_d = event === null || event === void 0 ? void 0 : event.stream) === null || _d === void 0 ? void 0 : _d.connection) === null || _e === void 0 ? void 0 : _e.connectionId)
|
|
683
|
-
});
|
|
684
|
-
trace.info('publisher stream created', {
|
|
685
|
-
event: event,
|
|
686
|
-
hasAudio: get_1["default"](this.currentPublisher, 'stream.hasAudio'),
|
|
598
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.mediaDeviceAccessDenied, {
|
|
599
|
+
connectionId: connectionId,
|
|
600
|
+
isOwnConnection: isOwnConnection,
|
|
687
601
|
participantId: participantId
|
|
688
602
|
});
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
603
|
+
});
|
|
604
|
+
this.currentPublisher.on('streamCreated', function (event) {
|
|
605
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
606
|
+
var participantId;
|
|
607
|
+
|
|
608
|
+
var _a, _b, _c, _d, _e, _f;
|
|
609
|
+
|
|
610
|
+
return __generator(this, function (_g) {
|
|
611
|
+
switch (_g.label) {
|
|
612
|
+
case 0:
|
|
613
|
+
return [4
|
|
614
|
+
/*yield*/
|
|
615
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
616
|
+
|
|
617
|
+
case 1:
|
|
618
|
+
_g.sent();
|
|
619
|
+
|
|
620
|
+
participantId = this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId);
|
|
621
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
622
|
+
event: event,
|
|
623
|
+
participantId: participantId,
|
|
624
|
+
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
625
|
+
hasAudio: (_b = event === null || event === void 0 ? void 0 : event.stream) === null || _b === void 0 ? void 0 : _b.hasAudio,
|
|
626
|
+
hasVideo: (_c = event === null || event === void 0 ? void 0 : event.stream) === null || _c === void 0 ? void 0 : _c.hasVideo,
|
|
627
|
+
isOwnConnection: this.ownConnectionId === ((_e = (_d = event === null || event === void 0 ? void 0 : event.stream) === null || _d === void 0 ? void 0 : _d.connection) === null || _e === void 0 ? void 0 : _e.connectionId)
|
|
628
|
+
});
|
|
629
|
+
trace.info('publisher stream created', {
|
|
630
|
+
event: event,
|
|
631
|
+
hasAudio: (_f = this.currentPublisher) === null || _f === void 0 ? void 0 : _f['stream.hasAudio'],
|
|
632
|
+
participantId: participantId
|
|
633
|
+
});
|
|
634
|
+
return [2
|
|
635
|
+
/*return*/
|
|
636
|
+
];
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
});
|
|
692
641
|
}
|
|
693
|
-
|
|
694
|
-
|
|
642
|
+
|
|
643
|
+
return [3
|
|
644
|
+
/*break*/
|
|
645
|
+
, 3];
|
|
646
|
+
|
|
647
|
+
case 2:
|
|
648
|
+
err_2 = _c.sent();
|
|
649
|
+
trace.error(JSON.stringify(err_2));
|
|
650
|
+
throw err_2;
|
|
651
|
+
|
|
652
|
+
case 3:
|
|
653
|
+
return [2
|
|
654
|
+
/*return*/
|
|
655
|
+
];
|
|
656
|
+
}
|
|
695
657
|
});
|
|
696
|
-
}
|
|
658
|
+
});
|
|
697
659
|
};
|
|
698
660
|
|
|
699
661
|
_this.streamCreatedHandler = function (event) {
|
|
@@ -710,15 +672,15 @@ function (_super) {
|
|
|
710
672
|
trace.info('streamCreatedHandler', event.stream);
|
|
711
673
|
stream = event.stream;
|
|
712
674
|
connection = stream.connection;
|
|
713
|
-
participantId = this.
|
|
675
|
+
participantId = this.getParticipantId(connection.connectionId);
|
|
714
676
|
return [4
|
|
715
677
|
/*yield*/
|
|
716
|
-
,
|
|
678
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
717
679
|
|
|
718
680
|
case 1:
|
|
719
681
|
_f.sent();
|
|
720
682
|
|
|
721
|
-
this.emit(
|
|
683
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
722
684
|
event: event,
|
|
723
685
|
participantId: participantId,
|
|
724
686
|
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
@@ -733,8 +695,8 @@ function (_super) {
|
|
|
733
695
|
];
|
|
734
696
|
}
|
|
735
697
|
|
|
736
|
-
if (this.subscribers.length >=
|
|
737
|
-
trace.info("a new subscriber cannot be added, as the number of participants reached its limit: " +
|
|
698
|
+
if (this.subscribers.length >= MultiPartyService_1.maxParticipantsNumber - 1) {
|
|
699
|
+
trace.info("a new subscriber cannot be added, as the number of participants reached its limit: " + MultiPartyService_1.maxParticipantsNumber);
|
|
738
700
|
} else {
|
|
739
701
|
properties = {
|
|
740
702
|
insertMode: 'append',
|
|
@@ -744,7 +706,7 @@ function (_super) {
|
|
|
744
706
|
style: {
|
|
745
707
|
buttonDisplayMode: 'off',
|
|
746
708
|
audioLevelDisplayMode: 'off',
|
|
747
|
-
backgroundImageURI: ((_e = this.branding) === null || _e === void 0 ? void 0 : _e.backgroundImageURI) ||
|
|
709
|
+
backgroundImageURI: ((_e = this.branding) === null || _e === void 0 ? void 0 : _e.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
748
710
|
}
|
|
749
711
|
};
|
|
750
712
|
subscriber_1 = event.target.subscribe(event.stream, participantId, properties, function (err) {
|
|
@@ -775,10 +737,10 @@ function (_super) {
|
|
|
775
737
|
trace.info('streamPropertyChangedHandler', event);
|
|
776
738
|
var stream = event.stream;
|
|
777
739
|
|
|
778
|
-
_this.emit(
|
|
740
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoAudioStatus, {
|
|
779
741
|
hasVideo: stream === null || stream === void 0 ? void 0 : stream.hasVideo,
|
|
780
742
|
hasAudio: stream === null || stream === void 0 ? void 0 : stream.hasAudio,
|
|
781
|
-
participantId: _this.
|
|
743
|
+
participantId: _this.getParticipantId(stream === null || stream === void 0 ? void 0 : stream.connection.connectionId),
|
|
782
744
|
isOwnConnection: _this.ownConnectionId === ((_a = stream === null || stream === void 0 ? void 0 : stream.connection) === null || _a === void 0 ? void 0 : _a.connectionId),
|
|
783
745
|
stream: stream
|
|
784
746
|
});
|
|
@@ -791,12 +753,12 @@ function (_super) {
|
|
|
791
753
|
var stream = event.stream;
|
|
792
754
|
var destroyedConnectionId = stream && stream.connection && stream.connection.connectionId;
|
|
793
755
|
|
|
794
|
-
_this.emit(
|
|
756
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
795
757
|
event: event,
|
|
796
|
-
participantId: _this.
|
|
758
|
+
participantId: _this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId)
|
|
797
759
|
});
|
|
798
760
|
|
|
799
|
-
_this.subscribers =
|
|
761
|
+
_this.subscribers = _this.subscribers.filter(function (subscriber) {
|
|
800
762
|
return subscriber.connectionId !== destroyedConnectionId;
|
|
801
763
|
});
|
|
802
764
|
};
|
|
@@ -811,14 +773,14 @@ function (_super) {
|
|
|
811
773
|
|
|
812
774
|
++_this.participantCount;
|
|
813
775
|
|
|
814
|
-
_this.emit(
|
|
776
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.participantCount);
|
|
815
777
|
|
|
816
778
|
var clientRole = _this.getClientRole(connection);
|
|
817
779
|
|
|
818
|
-
_this.emit(
|
|
780
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionCreated, {
|
|
819
781
|
clientRole: clientRole,
|
|
820
782
|
event: event,
|
|
821
|
-
participantId: _this.
|
|
783
|
+
participantId: _this.getParticipantId(connection.connectionId),
|
|
822
784
|
isOwnConnection: _this.ownConnectionId === connection.connectionId
|
|
823
785
|
});
|
|
824
786
|
};
|
|
@@ -830,10 +792,10 @@ function (_super) {
|
|
|
830
792
|
|
|
831
793
|
trace.info('connectionDestroyedHandler', event);
|
|
832
794
|
|
|
833
|
-
_this.emit(
|
|
795
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionDestroyed, {
|
|
834
796
|
clientRole: clientRole,
|
|
835
797
|
event: event,
|
|
836
|
-
participantId: _this.
|
|
798
|
+
participantId: _this.getParticipantId(event === null || event === void 0 ? void 0 : event.connection.connectionId)
|
|
837
799
|
});
|
|
838
800
|
|
|
839
801
|
if (!_this.ownConnectionId || !connection || connection.connectionId !== _this.ownConnectionId) {
|
|
@@ -842,7 +804,7 @@ function (_super) {
|
|
|
842
804
|
|
|
843
805
|
--_this.participantCount;
|
|
844
806
|
|
|
845
|
-
_this.emit(
|
|
807
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.participantCount);
|
|
846
808
|
|
|
847
809
|
_this.session = null;
|
|
848
810
|
};
|
|
@@ -865,7 +827,7 @@ function (_super) {
|
|
|
865
827
|
return _this;
|
|
866
828
|
}
|
|
867
829
|
|
|
868
|
-
Object.defineProperty(
|
|
830
|
+
Object.defineProperty(OpentokMultiPartyService.prototype, "ownConnectionId", {
|
|
869
831
|
get: function get() {
|
|
870
832
|
var _a, _b;
|
|
871
833
|
|
|
@@ -875,17 +837,12 @@ function (_super) {
|
|
|
875
837
|
configurable: true
|
|
876
838
|
});
|
|
877
839
|
|
|
878
|
-
|
|
840
|
+
OpentokMultiPartyService.prototype.getClientRole = function (connection) {
|
|
879
841
|
return (connection === null || connection === void 0 ? void 0 : connection.data) && JSON.parse(connection.data).clientRole || MediaConstants_1.SessionClientRole.USER;
|
|
880
842
|
};
|
|
881
843
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return this.getParticipantId(clientRole, connection.connectionId);
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
return OpentokMultiparty;
|
|
888
|
-
}(MultiParty_1.MultiParty);
|
|
844
|
+
return OpentokMultiPartyService;
|
|
845
|
+
}(MultiPartyService_1.MultiPartyService);
|
|
889
846
|
|
|
890
|
-
exports.
|
|
891
|
-
//# sourceMappingURL=
|
|
847
|
+
exports.OpentokMultiPartyService = OpentokMultiPartyService;
|
|
848
|
+
//# sourceMappingURL=OpentokMultiPartyService.js.map
|