@techsee/techsee-media-service 2.0.0 → 3.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 +4 -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} +4 -8
- package/lib/MultiParty/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/{OpentokMultiparty.js → OpentokMultiPartyService.js} +240 -266
- 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.
|
|
306
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
307
|
-
var mediaCapabilitiesHelper, err_1;
|
|
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) {
|
|
302
|
+
_this.createPublisher = function (settings) {
|
|
338
303
|
return __awaiter(_this, void 0, void 0, function () {
|
|
339
|
-
var
|
|
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,89 +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
|
-
});
|
|
629
|
-
|
|
630
|
-
_this.currentPublisher.on('streamDestroyed', function (event) {
|
|
631
|
-
var _a;
|
|
528
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
529
|
+
var selectedCamera, isMobile, mediaCapabilitiesService, frontCameraDeviceId, backCameraDeviceId, videoSourceId, mobileCameraType, properties, err_2;
|
|
632
530
|
|
|
633
|
-
|
|
531
|
+
var _this = this;
|
|
634
532
|
|
|
635
|
-
|
|
636
|
-
event: event,
|
|
637
|
-
participantId: _this.getParticipantIdForStream((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection)
|
|
638
|
-
});
|
|
639
|
-
});
|
|
533
|
+
var _a, _b;
|
|
640
534
|
|
|
641
|
-
|
|
642
|
-
|
|
535
|
+
return __generator(this, function (_c) {
|
|
536
|
+
switch (_c.label) {
|
|
537
|
+
case 0:
|
|
538
|
+
_c.trys.push([0, 2,, 3]);
|
|
643
539
|
|
|
644
|
-
|
|
645
|
-
|
|
540
|
+
selectedCamera = settings.selectedCamera;
|
|
541
|
+
isMobile = MediaCapabilitiesUtils_1.checkIsMobile();
|
|
542
|
+
return [4
|
|
543
|
+
/*yield*/
|
|
544
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
646
545
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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.getParticipantIdForStream((_b = this.session) === null || _b === void 0 ? void 0 : _b.connection), properties, this.traceErrorCallback);
|
|
650
568
|
|
|
651
|
-
|
|
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);
|
|
652
574
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
/*yield*/
|
|
658
|
-
, MediaCapabilitiesHelper_1.MediaCapabilitiesHelper.setDevicesList()];
|
|
575
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoElementCreated, event);
|
|
576
|
+
});
|
|
577
|
+
this.currentPublisher.on('streamDestroyed', function (event) {
|
|
578
|
+
var _a;
|
|
659
579
|
|
|
660
|
-
|
|
661
|
-
_f.sent();
|
|
580
|
+
trace.info('Publisher stream destroyed', event);
|
|
662
581
|
|
|
663
|
-
|
|
664
|
-
this.emit(MultiParty_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
582
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
665
583
|
event: event,
|
|
666
|
-
participantId:
|
|
667
|
-
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
668
|
-
hasAudio: (_b = event === null || event === void 0 ? void 0 : event.stream) === null || _b === void 0 ? void 0 : _b.hasAudio,
|
|
669
|
-
hasVideo: (_c = event === null || event === void 0 ? void 0 : event.stream) === null || _c === void 0 ? void 0 : _c.hasVideo,
|
|
670
|
-
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)
|
|
584
|
+
participantId: _this.getParticipantIdForStream((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection)
|
|
671
585
|
});
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
586
|
+
});
|
|
587
|
+
this.currentPublisher.on('accessDenied', function (event) {
|
|
588
|
+
var _a;
|
|
589
|
+
|
|
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;
|
|
593
|
+
|
|
594
|
+
var participantId = _this.getParticipantIdForStream(connection);
|
|
595
|
+
|
|
596
|
+
var isOwnConnection = _this.ownConnectionId === connectionId;
|
|
597
|
+
|
|
598
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.mediaDeviceAccessDenied, {
|
|
599
|
+
connectionId: connectionId,
|
|
600
|
+
isOwnConnection: isOwnConnection,
|
|
675
601
|
participantId: participantId
|
|
676
602
|
});
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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.getParticipantIdForStream((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection);
|
|
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
|
+
});
|
|
680
641
|
}
|
|
681
|
-
|
|
682
|
-
|
|
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
|
+
}
|
|
683
657
|
});
|
|
684
|
-
}
|
|
658
|
+
});
|
|
685
659
|
};
|
|
686
660
|
|
|
687
661
|
_this.streamCreatedHandler = function (event) {
|
|
@@ -701,12 +675,12 @@ function (_super) {
|
|
|
701
675
|
participantId = this.getParticipantIdForStream(connection);
|
|
702
676
|
return [4
|
|
703
677
|
/*yield*/
|
|
704
|
-
,
|
|
678
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
705
679
|
|
|
706
680
|
case 1:
|
|
707
681
|
_f.sent();
|
|
708
682
|
|
|
709
|
-
this.emit(
|
|
683
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
710
684
|
event: event,
|
|
711
685
|
participantId: participantId,
|
|
712
686
|
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
@@ -721,8 +695,8 @@ function (_super) {
|
|
|
721
695
|
];
|
|
722
696
|
}
|
|
723
697
|
|
|
724
|
-
if (this.subscribers.length >=
|
|
725
|
-
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);
|
|
726
700
|
} else {
|
|
727
701
|
properties = {
|
|
728
702
|
insertMode: 'append',
|
|
@@ -732,7 +706,7 @@ function (_super) {
|
|
|
732
706
|
style: {
|
|
733
707
|
buttonDisplayMode: 'off',
|
|
734
708
|
audioLevelDisplayMode: 'off',
|
|
735
|
-
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
|
|
736
710
|
}
|
|
737
711
|
};
|
|
738
712
|
subscriber_1 = event.target.subscribe(event.stream, participantId, properties, function (err) {
|
|
@@ -763,7 +737,7 @@ function (_super) {
|
|
|
763
737
|
trace.info('streamPropertyChangedHandler', event);
|
|
764
738
|
var stream = event.stream;
|
|
765
739
|
|
|
766
|
-
_this.emit(
|
|
740
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoAudioStatus, {
|
|
767
741
|
hasVideo: stream === null || stream === void 0 ? void 0 : stream.hasVideo,
|
|
768
742
|
hasAudio: stream === null || stream === void 0 ? void 0 : stream.hasAudio,
|
|
769
743
|
participantId: _this.getParticipantIdForStream(stream === null || stream === void 0 ? void 0 : stream.connection),
|
|
@@ -779,12 +753,12 @@ function (_super) {
|
|
|
779
753
|
var stream = event.stream;
|
|
780
754
|
var destroyedConnectionId = stream && stream.connection && stream.connection.connectionId;
|
|
781
755
|
|
|
782
|
-
_this.emit(
|
|
756
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
783
757
|
event: event,
|
|
784
758
|
participantId: _this.getParticipantIdForStream((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection)
|
|
785
759
|
});
|
|
786
760
|
|
|
787
|
-
_this.subscribers =
|
|
761
|
+
_this.subscribers = _this.subscribers.filter(function (subscriber) {
|
|
788
762
|
return subscriber.connectionId !== destroyedConnectionId;
|
|
789
763
|
});
|
|
790
764
|
};
|
|
@@ -799,11 +773,11 @@ function (_super) {
|
|
|
799
773
|
|
|
800
774
|
++_this.participantCount;
|
|
801
775
|
|
|
802
|
-
_this.emit(
|
|
776
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.participantCount);
|
|
803
777
|
|
|
804
778
|
var clientRole = _this.getClientRole(connection);
|
|
805
779
|
|
|
806
|
-
_this.emit(
|
|
780
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionCreated, {
|
|
807
781
|
clientRole: clientRole,
|
|
808
782
|
event: event,
|
|
809
783
|
participantId: _this.getParticipantIdForStream(connection),
|
|
@@ -818,7 +792,7 @@ function (_super) {
|
|
|
818
792
|
|
|
819
793
|
trace.info('connectionDestroyedHandler', event);
|
|
820
794
|
|
|
821
|
-
_this.emit(
|
|
795
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionDestroyed, {
|
|
822
796
|
clientRole: clientRole,
|
|
823
797
|
event: event,
|
|
824
798
|
participantId: _this.getParticipantIdForStream(event === null || event === void 0 ? void 0 : event.connection)
|
|
@@ -830,7 +804,7 @@ function (_super) {
|
|
|
830
804
|
|
|
831
805
|
--_this.participantCount;
|
|
832
806
|
|
|
833
|
-
_this.emit(
|
|
807
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.participantCount);
|
|
834
808
|
|
|
835
809
|
_this.session = null;
|
|
836
810
|
};
|
|
@@ -853,7 +827,7 @@ function (_super) {
|
|
|
853
827
|
return _this;
|
|
854
828
|
}
|
|
855
829
|
|
|
856
|
-
Object.defineProperty(
|
|
830
|
+
Object.defineProperty(OpentokMultiPartyService.prototype, "ownConnectionId", {
|
|
857
831
|
get: function get() {
|
|
858
832
|
var _a, _b;
|
|
859
833
|
|
|
@@ -863,17 +837,17 @@ function (_super) {
|
|
|
863
837
|
configurable: true
|
|
864
838
|
});
|
|
865
839
|
|
|
866
|
-
|
|
840
|
+
OpentokMultiPartyService.prototype.getClientRole = function (connection) {
|
|
867
841
|
return (connection === null || connection === void 0 ? void 0 : connection.data) && JSON.parse(connection.data).clientRole || MediaConstants_1.SessionClientRole.USER;
|
|
868
842
|
};
|
|
869
843
|
|
|
870
|
-
|
|
844
|
+
OpentokMultiPartyService.prototype.getParticipantIdForStream = function (connection) {
|
|
871
845
|
var clientRole = this.getClientRole(connection);
|
|
872
846
|
return this.getParticipantId(clientRole, connection.connectionId);
|
|
873
847
|
};
|
|
874
848
|
|
|
875
|
-
return
|
|
876
|
-
}(
|
|
849
|
+
return OpentokMultiPartyService;
|
|
850
|
+
}(MultiPartyService_1.MultiPartyService);
|
|
877
851
|
|
|
878
|
-
exports.
|
|
879
|
-
//# sourceMappingURL=
|
|
852
|
+
exports.OpentokMultiPartyService = OpentokMultiPartyService;
|
|
853
|
+
//# sourceMappingURL=OpentokMultiPartyService.js.map
|