vani-meeting-client 2.0.4 → 2.0.6

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.
@@ -50,6 +50,7 @@ export declare class MeetingStartRequest {
50
50
  connectionProtocol: ConnectionProtocol;
51
51
  shouldKeepTryToReconnect: boolean;
52
52
  shouldIgnoreCaseForRoomId: boolean;
53
+ shouldUseExactDeviceForUserMedia: boolean;
53
54
  urlToCheckInternetPresent: string;
54
55
  constructor(_roomId: string, _userId: string, _appId: string, _wssUrl: string, _shouldIgnoreCaseForRoomId?: boolean);
55
56
  }
@@ -48,6 +48,7 @@ var MeetingStartRequest = /** @class */ (function () {
48
48
  this.connectionProtocol = ConnectionProtocol.UDP;
49
49
  this.shouldKeepTryToReconnect = false;
50
50
  this.shouldIgnoreCaseForRoomId = false;
51
+ this.shouldUseExactDeviceForUserMedia = false;
51
52
  this.urlToCheckInternetPresent = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Stack%20Overflow";
52
53
  this.shouldIgnoreCaseForRoomId = _shouldIgnoreCaseForRoomId;
53
54
  if (this.shouldIgnoreCaseForRoomId) {
@@ -280,7 +280,12 @@ var UserMediaHandler = /** @class */ (function (_super) {
280
280
  userMediaPayload.video = this.getVideoDictionay();
281
281
  }
282
282
  if ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.cameraDevice) {
283
- userMediaPayload.video.deviceId = this.meetingStartRequest.cameraDevice;
283
+ if (this.meetingStartRequest.shouldUseExactDeviceForUserMedia) {
284
+ userMediaPayload.video.deviceId = { exact: this.meetingStartRequest.cameraDevice };
285
+ }
286
+ else {
287
+ userMediaPayload.video.deviceId = this.meetingStartRequest.cameraDevice;
288
+ }
284
289
  }
285
290
  else {
286
291
  if (!this.cameraFacingMode) {
@@ -298,7 +303,12 @@ var UserMediaHandler = /** @class */ (function (_super) {
298
303
  userMediaPayload.audio = this.getAudioDictionay();
299
304
  }
300
305
  if ((_e = this.meetingStartRequest) === null || _e === void 0 ? void 0 : _e.audioInDevice) {
301
- userMediaPayload.audio.deviceId = this.meetingStartRequest.audioInDevice;
306
+ if (this.meetingStartRequest.shouldUseExactDeviceForUserMedia) {
307
+ userMediaPayload.audio.deviceId = { exact: this.meetingStartRequest.audioInDevice };
308
+ }
309
+ else {
310
+ userMediaPayload.audio.deviceId = this.meetingStartRequest.audioInDevice;
311
+ }
302
312
  }
303
313
  }
304
314
  this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(userMediaPayload);
@@ -345,61 +355,65 @@ var UserMediaHandler = /** @class */ (function (_super) {
345
355
  }
346
356
  catch (err) {
347
357
  }
348
- if (!stream || (isForAudio === false && isForVideo === false)) {
349
- this.isVideoAudioFetchInProgress = false;
350
- return [2 /*return*/];
351
- }
352
- if (!this.communicationHandler.getSelfParticipant()) {
353
- return [2 /*return*/];
354
- }
355
- permissionApprovedFor = [];
356
- if (isForAudio && stream.getAudioTracks().length > 0) {
357
- this.onTrack(stream.getAudioTracks()[0], TrackKind.Audio, shouldAddTrackImmediately);
358
- // removeAndStreamInLocalStream(stream.getAudioTracks()[0])
359
- // updateLocalTrackInAllTracks(stream.getAudioTracks()[0]);
360
- this.communicationHandler.getSelfParticipant().isAudioEnable = true;
361
- data = { userId: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId, type: "audio", status: "resume" };
362
- audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
363
- this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
364
- if (this.muteUmutePromiseResolver) {
365
- this.muteUmutePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
366
- this.muteUmutePromiseResolver = undefined;
367
- }
368
- if (this.meetingStartRequest
369
- && stream.getAudioTracks()[0].getSettings() && stream.getAudioTracks()[0].getSettings().deviceId) {
370
- this.meetingStartRequest.audioInDevice = stream.getAudioTracks()[0].getSettings().deviceId;
371
- }
372
- else if (this.meetingStartRequest
373
- && stream.getAudioTracks()[0].getConstraints() && stream.getAudioTracks()[0].getConstraints().deviceId) {
374
- this.meetingStartRequest.audioInDevice = (_b = stream.getAudioTracks()[0].getConstraints().deviceId) === null || _b === void 0 ? void 0 : _b.toString();
358
+ try {
359
+ if (!stream || (isForAudio === false && isForVideo === false)) {
360
+ this.isVideoAudioFetchInProgress = false;
361
+ return [2 /*return*/];
375
362
  }
376
- permissionApprovedFor.push(TrackKind.Audio);
377
- }
378
- if (isForVideo && stream.getVideoTracks().length > 0) {
379
- this.onTrack(stream.getVideoTracks()[0], TrackKind.Video, shouldAddTrackImmediately);
380
- // removeAndStreamInLocalStream(stream.getVideoTracks()[0])
381
- // updateLocalTrackInAllTracks(stream.getVideoTracks()[0])
382
- this.communicationHandler.getSelfParticipant().isVideoEnable = true;
383
- data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "resume" };
384
- audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
385
- this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
386
- if (this.videoPauseResumePromiseResolver) {
387
- this.videoPauseResumePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
388
- this.videoPauseResumePromiseResolver = undefined;
363
+ if (!this.communicationHandler.getSelfParticipant()) {
364
+ return [2 /*return*/];
389
365
  }
390
- if (this.meetingStartRequest
391
- && stream.getVideoTracks()[0].getSettings() && stream.getVideoTracks()[0].getSettings().deviceId) {
392
- this.meetingStartRequest.cameraDevice = stream.getVideoTracks()[0].getSettings().deviceId;
366
+ permissionApprovedFor = [];
367
+ if (isForAudio && stream.getAudioTracks().length > 0) {
368
+ this.onTrack(stream.getAudioTracks()[0], TrackKind.Audio, shouldAddTrackImmediately);
369
+ // removeAndStreamInLocalStream(stream.getAudioTracks()[0])
370
+ // updateLocalTrackInAllTracks(stream.getAudioTracks()[0]);
371
+ this.communicationHandler.getSelfParticipant().isAudioEnable = true;
372
+ data = { userId: (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.userId, type: "audio", status: "resume" };
373
+ audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
374
+ this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
375
+ if (this.muteUmutePromiseResolver) {
376
+ this.muteUmutePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
377
+ this.muteUmutePromiseResolver = undefined;
378
+ }
379
+ if (this.meetingStartRequest
380
+ && stream.getAudioTracks()[0].getSettings() && stream.getAudioTracks()[0].getSettings().deviceId) {
381
+ this.meetingStartRequest.audioInDevice = stream.getAudioTracks()[0].getSettings().deviceId;
382
+ }
383
+ else if (this.meetingStartRequest
384
+ && stream.getAudioTracks()[0].getConstraints() && stream.getAudioTracks()[0].getConstraints().deviceId) {
385
+ this.meetingStartRequest.audioInDevice = (_b = stream.getAudioTracks()[0].getConstraints().deviceId) === null || _b === void 0 ? void 0 : _b.toString();
386
+ }
387
+ permissionApprovedFor.push(TrackKind.Audio);
393
388
  }
394
- else if (this.meetingStartRequest
395
- && stream.getVideoTracks()[0].getConstraints() && stream.getVideoTracks()[0].getConstraints().deviceId) {
396
- this.meetingStartRequest.cameraDevice = (_d = stream.getVideoTracks()[0].getConstraints().deviceId) === null || _d === void 0 ? void 0 : _d.toString();
389
+ if (isForVideo && stream.getVideoTracks().length > 0) {
390
+ this.onTrack(stream.getVideoTracks()[0], TrackKind.Video, shouldAddTrackImmediately);
391
+ // removeAndStreamInLocalStream(stream.getVideoTracks()[0])
392
+ // updateLocalTrackInAllTracks(stream.getVideoTracks()[0])
393
+ this.communicationHandler.getSelfParticipant().isVideoEnable = true;
394
+ data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "resume" };
395
+ audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
396
+ this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
397
+ if (this.videoPauseResumePromiseResolver) {
398
+ this.videoPauseResumePromiseResolver({ message: "Success", error: 'NoError', isSuccess: true });
399
+ this.videoPauseResumePromiseResolver = undefined;
400
+ }
401
+ if (this.meetingStartRequest
402
+ && stream.getVideoTracks()[0].getSettings() && stream.getVideoTracks()[0].getSettings().deviceId) {
403
+ this.meetingStartRequest.cameraDevice = stream.getVideoTracks()[0].getSettings().deviceId;
404
+ }
405
+ else if (this.meetingStartRequest
406
+ && stream.getVideoTracks()[0].getConstraints() && stream.getVideoTracks()[0].getConstraints().deviceId) {
407
+ this.meetingStartRequest.cameraDevice = (_d = stream.getVideoTracks()[0].getConstraints().deviceId) === null || _d === void 0 ? void 0 : _d.toString();
408
+ }
409
+ permissionApprovedFor.push(TrackKind.Video);
397
410
  }
398
- permissionApprovedFor.push(TrackKind.Video);
411
+ this.isVideoAudioFetchInProgress = false;
412
+ (_e = this.communicationHandler) === null || _e === void 0 ? void 0 : _e.emitMessageToSource(VaniEvent.OnPermissionApproved, permissionApprovedFor);
413
+ this.registerForDeviceChange();
414
+ }
415
+ catch (er) {
399
416
  }
400
- this.isVideoAudioFetchInProgress = false;
401
- (_e = this.communicationHandler) === null || _e === void 0 ? void 0 : _e.emitMessageToSource(VaniEvent.OnPermissionApproved, permissionApprovedFor);
402
- this.registerForDeviceChange();
403
417
  return [2 /*return*/];
404
418
  });
405
419
  });
@@ -441,16 +455,19 @@ var UserMediaHandler = /** @class */ (function (_super) {
441
455
  };
442
456
  UserMediaHandler.prototype.onTrack = function (trackStream, trackKind, shouldAddTrackImmediately) {
443
457
  var _a, _b, _c;
444
- var selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
445
- if (selfParticpant) {
446
- var track = new Track(selfParticpant, true, trackKind, trackStream);
447
- if (!shouldAddTrackImmediately) {
448
- (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnTrack, track);
449
- }
450
- else {
451
- (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.addUpdateLocalTrack(track);
458
+ try {
459
+ var selfParticpant = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant();
460
+ if (selfParticpant) {
461
+ var track = new Track(selfParticpant, true, trackKind, trackStream);
462
+ if (!shouldAddTrackImmediately) {
463
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnTrack, track);
464
+ }
465
+ else {
466
+ (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.addUpdateLocalTrack(track);
467
+ }
452
468
  }
453
469
  }
470
+ catch (err) { }
454
471
  };
455
472
  UserMediaHandler.prototype.getDevice = function (type) {
456
473
  return __awaiter(this, void 0, void 0, function () {
@@ -620,11 +637,12 @@ var UserMediaHandler = /** @class */ (function (_super) {
620
637
  var _this = this;
621
638
  return __generator(this, function (_a) {
622
639
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
623
- var participant, videoInputDevices, data, videoUnblock, participant;
640
+ var participant, videoInputDevices, data, videoUnblock, participant, err_1;
624
641
  var _a, _b, _c;
625
642
  return __generator(this, function (_d) {
626
643
  switch (_d.label) {
627
644
  case 0:
645
+ _d.trys.push([0, 4, , 5]);
628
646
  if (!this.meetingStartRequest) {
629
647
  resolve({ message: "Start Meeting Object not found", error: 'InvalidMeetingRequest', isSuccess: false });
630
648
  return [2 /*return*/];
@@ -665,7 +683,11 @@ var UserMediaHandler = /** @class */ (function (_super) {
665
683
  resolve({ message: "Permission Not Allowed", error: 'PermissionDenied', isSuccess: false });
666
684
  }
667
685
  _d.label = 3;
668
- case 3: return [2 /*return*/];
686
+ case 3: return [3 /*break*/, 5];
687
+ case 4:
688
+ err_1 = _d.sent();
689
+ return [3 /*break*/, 5];
690
+ case 5: return [2 /*return*/];
669
691
  }
670
692
  });
671
693
  }); })];
@@ -677,11 +699,12 @@ var UserMediaHandler = /** @class */ (function (_super) {
677
699
  var _this = this;
678
700
  return __generator(this, function (_a) {
679
701
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
680
- var participant, audioInputDevices, data, audioUnblock, participant;
702
+ var participant, audioInputDevices, data, audioUnblock, participant, err_2;
681
703
  var _a, _b, _c;
682
704
  return __generator(this, function (_d) {
683
705
  switch (_d.label) {
684
706
  case 0:
707
+ _d.trys.push([0, 4, , 5]);
685
708
  if (!this.meetingStartRequest) {
686
709
  resolve({ message: "Start Meeting Object not found", error: 'InvalidMeetingRequest', isSuccess: false });
687
710
  return [2 /*return*/];
@@ -722,7 +745,11 @@ var UserMediaHandler = /** @class */ (function (_super) {
722
745
  resolve({ message: "Permission Not Allowed", error: 'PermissionDenied', isSuccess: false });
723
746
  }
724
747
  _d.label = 3;
725
- case 3: return [2 /*return*/];
748
+ case 3: return [3 /*break*/, 5];
749
+ case 4:
750
+ err_2 = _d.sent();
751
+ return [3 /*break*/, 5];
752
+ case 5: return [2 /*return*/];
726
753
  }
727
754
  });
728
755
  }); })];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",