vani-meeting-client 1.3.9 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ export declare class UserMediaHandler extends Base {
25
25
  private onScreenShareStreamGot;
26
26
  private onTrack;
27
27
  getDevice(type: GetDevicesType): Promise<Device[]>;
28
- registerForDeviceChange(): void;
28
+ registerForDeviceChange: () => Promise<void>;
29
29
  stopScreenSharing(): Promise<void>;
30
30
  pauseCamera(userId?: string): Promise<TaskResponse>;
31
31
  muteUser(userId?: string): Promise<TaskResponse>;
@@ -67,6 +67,81 @@ var UserMediaHandler = /** @class */ (function (_super) {
67
67
  var _this = _super !== null && _super.apply(this, arguments) || this;
68
68
  _this.isVideoAudioFetchInProgress = false;
69
69
  _this.isScreenShareFetchInProgress = false;
70
+ _this.registerForDeviceChange = function () { return __awaiter(_this, void 0, void 0, function () {
71
+ var mediaDevice;
72
+ var _this = this;
73
+ return __generator(this, function (_a) {
74
+ mediaDevice = new DynamicLibHelper().getMediaDevicesVariable(this.meetingStartRequest);
75
+ if (mediaDevice) {
76
+ mediaDevice.ondevicechange = (function (event) { return __awaiter(_this, void 0, void 0, function () {
77
+ var oldTrack, isAudioInDeviceFound, canFetchAudioIn, audioInDevices, audioDevice, oldVideoTrack, isCameraDeviceFound, canFetchVideoIn, cameraDevices, cameraDevice;
78
+ var _this = this;
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
80
+ return __generator(this, function (_k) {
81
+ switch (_k.label) {
82
+ case 0:
83
+ oldTrack = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfTrackByType(TrackKind.Audio);
84
+ isAudioInDeviceFound = false;
85
+ canFetchAudioIn = false;
86
+ if (!(!oldTrack && ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.audioInDevice) && ((_d = (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getSelfParticipant()) === null || _d === void 0 ? void 0 : _d.isAudioEnable))) return [3 /*break*/, 1];
87
+ isAudioInDeviceFound = false;
88
+ canFetchAudioIn = true;
89
+ this.meetingStartRequest.audioInDevice = undefined;
90
+ return [3 /*break*/, 3];
91
+ case 1:
92
+ if (!oldTrack) return [3 /*break*/, 3];
93
+ return [4 /*yield*/, this.getDevice(GetDevicesType.AudioIn)];
94
+ case 2:
95
+ audioInDevices = _k.sent();
96
+ if (this.meetingStartRequest && this.meetingStartRequest.audioInDevice) {
97
+ audioDevice = audioInDevices.find(function (device) { return device.id === _this.meetingStartRequest.audioInDevice; });
98
+ if (audioDevice) {
99
+ isAudioInDeviceFound = true;
100
+ }
101
+ else {
102
+ this.meetingStartRequest.audioInDevice = undefined;
103
+ }
104
+ }
105
+ canFetchAudioIn = true;
106
+ _k.label = 3;
107
+ case 3:
108
+ oldVideoTrack = (_e = this.communicationHandler) === null || _e === void 0 ? void 0 : _e.getSelfTrackByType(TrackKind.Video);
109
+ isCameraDeviceFound = false;
110
+ canFetchVideoIn = false;
111
+ if (!(!oldTrack && ((_f = this.meetingStartRequest) === null || _f === void 0 ? void 0 : _f.cameraDevice) && ((_h = (_g = this.communicationHandler) === null || _g === void 0 ? void 0 : _g.getSelfParticipant()) === null || _h === void 0 ? void 0 : _h.isVideoEnable))) return [3 /*break*/, 4];
112
+ isCameraDeviceFound = false;
113
+ canFetchVideoIn = true;
114
+ this.meetingStartRequest.cameraDevice = undefined;
115
+ return [3 /*break*/, 6];
116
+ case 4:
117
+ if (!oldVideoTrack) return [3 /*break*/, 6];
118
+ canFetchVideoIn = true;
119
+ return [4 /*yield*/, this.getDevice(GetDevicesType.VideoIn)];
120
+ case 5:
121
+ cameraDevices = _k.sent();
122
+ if (this.meetingStartRequest && this.meetingStartRequest.cameraDevice) {
123
+ cameraDevice = cameraDevices.find(function (device) { return device.id === _this.meetingStartRequest.cameraDevice; });
124
+ if (cameraDevice) {
125
+ isCameraDeviceFound = true;
126
+ }
127
+ else {
128
+ this.meetingStartRequest.cameraDevice = undefined;
129
+ }
130
+ }
131
+ _k.label = 6;
132
+ case 6:
133
+ if ((!isAudioInDeviceFound && canFetchAudioIn) || (!isCameraDeviceFound && canFetchVideoIn)) {
134
+ this.startLocalStream(!isCameraDeviceFound && canFetchVideoIn, !isAudioInDeviceFound && canFetchAudioIn, true);
135
+ }
136
+ (_j = this.communicationHandler) === null || _j === void 0 ? void 0 : _j.emitMessageToSource(VaniEvent.OnDevicesChanged, {});
137
+ return [2 /*return*/];
138
+ }
139
+ });
140
+ }); });
141
+ }
142
+ return [2 /*return*/];
143
+ });
144
+ }); };
70
145
  return _this;
71
146
  }
72
147
  UserMediaHandler.prototype.switchCamera = function () {
@@ -369,65 +444,6 @@ var UserMediaHandler = /** @class */ (function (_super) {
369
444
  });
370
445
  });
371
446
  };
372
- UserMediaHandler.prototype.registerForDeviceChange = function () {
373
- var _this = this;
374
- var mediaDevice = new DynamicLibHelper().getMediaDevicesVariable(this.meetingStartRequest);
375
- if (mediaDevice) {
376
- mediaDevice.ondevicechange = (function (event) { return __awaiter(_this, void 0, void 0, function () {
377
- var oldTrack, isAudioInDeviceFound, canFetchAudioIn, audioInDevices, audioDevice, oldVideoTrack, isCameraDeviceFound, canFetchVideoIn, cameraDevices, cameraDevice;
378
- var _this = this;
379
- var _a, _b, _c;
380
- return __generator(this, function (_d) {
381
- switch (_d.label) {
382
- case 0:
383
- oldTrack = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfTrackByType(TrackKind.Audio);
384
- isAudioInDeviceFound = false;
385
- canFetchAudioIn = false;
386
- if (!oldTrack) return [3 /*break*/, 2];
387
- return [4 /*yield*/, this.getDevice(GetDevicesType.AudioIn)];
388
- case 1:
389
- audioInDevices = _d.sent();
390
- if (this.meetingStartRequest && this.meetingStartRequest.audioInDevice) {
391
- audioDevice = audioInDevices.find(function (device) { return device.id === _this.meetingStartRequest.audioInDevice; });
392
- if (audioDevice) {
393
- isAudioInDeviceFound = true;
394
- }
395
- else {
396
- this.meetingStartRequest.audioInDevice = undefined;
397
- }
398
- }
399
- canFetchAudioIn = true;
400
- _d.label = 2;
401
- case 2:
402
- oldVideoTrack = (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.getSelfTrackByType(TrackKind.Video);
403
- isCameraDeviceFound = false;
404
- canFetchVideoIn = false;
405
- if (!oldVideoTrack) return [3 /*break*/, 4];
406
- canFetchVideoIn = true;
407
- return [4 /*yield*/, this.getDevice(GetDevicesType.VideoIn)];
408
- case 3:
409
- cameraDevices = _d.sent();
410
- if (this.meetingStartRequest && this.meetingStartRequest.cameraDevice) {
411
- cameraDevice = cameraDevices.find(function (device) { return device.id === _this.meetingStartRequest.cameraDevice; });
412
- if (cameraDevice) {
413
- isCameraDeviceFound = true;
414
- }
415
- else {
416
- this.meetingStartRequest.cameraDevice = undefined;
417
- }
418
- }
419
- _d.label = 4;
420
- case 4:
421
- if ((!isAudioInDeviceFound && canFetchAudioIn) || (!isCameraDeviceFound && canFetchVideoIn)) {
422
- this.startLocalStream(!isCameraDeviceFound && canFetchVideoIn, !isAudioInDeviceFound && canFetchAudioIn, true);
423
- }
424
- (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnDevicesChanged, {});
425
- return [2 /*return*/];
426
- }
427
- });
428
- }); });
429
- }
430
- };
431
447
  UserMediaHandler.prototype.stopScreenSharing = function () {
432
448
  var _a, _b, _c, _d;
433
449
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "1.3.9",
3
+ "version": "1.4.1",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",