vani-meeting-client 0.6.9 → 0.7.2
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/MeetingHandler.js
CHANGED
|
@@ -61,7 +61,7 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
61
61
|
MeetingHandler.prototype.init = function () {
|
|
62
62
|
var _a, _b, _c;
|
|
63
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var _d, _e;
|
|
64
|
+
var _d, _e, err_1;
|
|
65
65
|
return __generator(this, function (_f) {
|
|
66
66
|
switch (_f.label) {
|
|
67
67
|
case 0:
|
|
@@ -79,15 +79,26 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
79
79
|
this.reactNativeWebrtcPlugin.registerGlobals();
|
|
80
80
|
_f.label = 2;
|
|
81
81
|
case 2:
|
|
82
|
+
_f.trys.push([2, 5, , 6]);
|
|
82
83
|
if (!!this.videoCallHandler) return [3 /*break*/, 4];
|
|
83
84
|
_e = this;
|
|
84
85
|
return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.meetingType, this.meetingStartRequest, this.communicationHandler)];
|
|
85
86
|
case 3:
|
|
86
87
|
_e.videoCallHandler = _f.sent();
|
|
87
88
|
_f.label = 4;
|
|
88
|
-
case 4:
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
case 4: return [3 /*break*/, 6];
|
|
90
|
+
case 5:
|
|
91
|
+
err_1 = _f.sent();
|
|
92
|
+
console.log("his.videoCallHandler error", err_1);
|
|
93
|
+
return [3 /*break*/, 6];
|
|
94
|
+
case 6:
|
|
95
|
+
try {
|
|
96
|
+
if (!this.websocketCallHandler) {
|
|
97
|
+
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
console.log("his.websocketCallHandler error", err);
|
|
91
102
|
}
|
|
92
103
|
// this.handleGA();
|
|
93
104
|
this.emitMessageToSource(VaniEvent.OnInitDone, {});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MeetingStartRequest, MeetingType } from '..';
|
|
2
2
|
import { CommunicationHandler } from '../inter-communication-handler/CommunicationHandler';
|
|
3
|
+
import { SFUHandler } from '../video-call-handler/SFUHandler';
|
|
3
4
|
export declare class DynamicLibHelper {
|
|
4
5
|
getReactNativeWebrtcPlugin(meetingStartRequest: MeetingStartRequest): Promise<any>;
|
|
5
|
-
getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<
|
|
6
|
+
getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler | undefined>;
|
|
6
7
|
getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
7
8
|
getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
8
9
|
}
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { MeetingType } from '..';
|
|
38
38
|
import * as log from 'loglevel';
|
|
39
|
+
import { SFUHandler } from '../video-call-handler/SFUHandler';
|
|
39
40
|
var DynamicLibHelper = /** @class */ (function () {
|
|
40
41
|
function DynamicLibHelper() {
|
|
41
42
|
}
|
|
@@ -61,21 +62,18 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
61
62
|
return __generator(this, function (_a) {
|
|
62
63
|
switch (_a.label) {
|
|
63
64
|
case 0:
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return [2 /*return*/, new baseVideoCallHandler.SFUHandler(meetingStartRequest, _communicationHandler)];
|
|
65
|
+
if (meetingType === MeetingType.SFU) {
|
|
66
|
+
baseVideoCallHandler = SFUHandler;
|
|
67
|
+
if (baseVideoCallHandler) {
|
|
68
|
+
return [2 /*return*/, new baseVideoCallHandler(meetingStartRequest, _communicationHandler)];
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
case 2:
|
|
73
|
-
if (!(meetingType === MeetingType.WEBRTC)) return [3 /*break*/, 4];
|
|
71
|
+
if (!(meetingType === MeetingType.WEBRTC)) return [3 /*break*/, 2];
|
|
74
72
|
baseVideoCallHandler = import("../video-call-handler/WebrtcHandler");
|
|
75
|
-
if (!baseVideoCallHandler) return [3 /*break*/,
|
|
73
|
+
if (!baseVideoCallHandler) return [3 /*break*/, 2];
|
|
76
74
|
return [4 /*yield*/, baseVideoCallHandler];
|
|
77
|
-
case
|
|
78
|
-
case
|
|
75
|
+
case 1: return [2 /*return*/, new (_a.sent()).WebrtcHandler(meetingStartRequest, _communicationHandler)];
|
|
76
|
+
case 2: return [2 /*return*/, undefined];
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
2
2
|
import { WebSocketMessageBody } from "../websocket-handler/WebsocketHandler";
|
|
3
3
|
import { Track } from "../model/Track";
|
|
4
|
+
import { MeetingStartRequest } from '..';
|
|
5
|
+
import { CommunicationHandler } from '../inter-communication-handler/CommunicationHandler';
|
|
4
6
|
export declare class SFUHandler extends BaseVideoCallHandler {
|
|
5
7
|
private device;
|
|
6
8
|
private transportCallBacks;
|
|
@@ -12,6 +14,7 @@ export declare class SFUHandler extends BaseVideoCallHandler {
|
|
|
12
14
|
private consumers;
|
|
13
15
|
private dataProducers;
|
|
14
16
|
private dataConsumer;
|
|
17
|
+
constructor(_meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler);
|
|
15
18
|
onReconnect(): Promise<void>;
|
|
16
19
|
stopTrack(track: Track): void;
|
|
17
20
|
pauseTrack(track: Track): void;
|
|
@@ -62,14 +62,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
62
62
|
};
|
|
63
63
|
import log from 'loglevel';
|
|
64
64
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
65
|
-
import { Device } from 'mediasoup-client';
|
|
65
|
+
import { detectDevice, Device } from 'mediasoup-client';
|
|
66
66
|
import { SFUMessageType } from "../websocket-handler/WebsocketHandler";
|
|
67
67
|
import { Track, TrackKind } from "../model/Track";
|
|
68
68
|
import { VaniEvent } from '..';
|
|
69
69
|
var SFUHandler = /** @class */ (function (_super) {
|
|
70
70
|
__extends(SFUHandler, _super);
|
|
71
|
-
function SFUHandler() {
|
|
72
|
-
var _this = _super
|
|
71
|
+
function SFUHandler(_meetingStartRequest, _communicationHandler) {
|
|
72
|
+
var _this = _super.call(this, _meetingStartRequest, _communicationHandler) || this;
|
|
73
73
|
_this.device = new Device();
|
|
74
74
|
_this.transportCallBacks = {};
|
|
75
75
|
_this.isProduceTrackIntialWorkDone = false;
|
|
@@ -77,6 +77,13 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
77
77
|
_this.consumers = [];
|
|
78
78
|
_this.dataProducers = [];
|
|
79
79
|
_this.dataConsumer = [];
|
|
80
|
+
var handlerName = detectDevice();
|
|
81
|
+
if (handlerName) {
|
|
82
|
+
console.log("detected handler: %s", handlerName);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.warn("no suitable handler found for current browser/device");
|
|
86
|
+
}
|
|
80
87
|
return _this;
|
|
81
88
|
}
|
|
82
89
|
SFUHandler.prototype.onReconnect = function () {
|
|
@@ -228,15 +235,17 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
228
235
|
});
|
|
229
236
|
};
|
|
230
237
|
SFUHandler.prototype.onParticipantUpdated = function () {
|
|
231
|
-
if (
|
|
232
|
-
this.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
if (this.producers) {
|
|
239
|
+
if (!this.communicationHandler || this.communicationHandler.getAllParticipants().length < 2) {
|
|
240
|
+
this.producers.forEach(function (producer) {
|
|
241
|
+
producer.pause();
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.producers.forEach(function (producer) {
|
|
246
|
+
producer.resume();
|
|
247
|
+
});
|
|
248
|
+
}
|
|
240
249
|
}
|
|
241
250
|
};
|
|
242
251
|
SFUHandler.prototype.sendMessageViaDataChannel = function (messagePayload) {
|
|
@@ -530,11 +539,13 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
530
539
|
this.consumerTransport.close();
|
|
531
540
|
this.consumerTransport = undefined;
|
|
532
541
|
}
|
|
533
|
-
this.producers
|
|
534
|
-
|
|
535
|
-
producer.
|
|
536
|
-
|
|
537
|
-
|
|
542
|
+
if (this.producers) {
|
|
543
|
+
this.producers.forEach(function (producer) {
|
|
544
|
+
if (producer.closed === false) {
|
|
545
|
+
producer.close();
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
538
549
|
this.dataProducers.forEach(function (producer) {
|
|
539
550
|
if (producer.closed === false) {
|
|
540
551
|
producer.close();
|