vani-meeting-client-native 0.0.5 → 0.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.
@@ -1,8 +1,10 @@
1
1
  import { MeetingStartRequest, VaniEventListener, Device, MessagePayload } from ".";
2
+ import { BaseVideoCallHandler } from "./video-call-handler/BaseVideoCallHandler";
2
3
  import { GetDevicesType } from "./user-media-handler/UserMediaHandler";
3
4
  import { Track, TrackKind } from "./model/Track";
4
5
  import { TaskResponse } from "./model/TaskResponse";
5
6
  import { Participant } from "./model/Participant";
7
+ import { TrackStats } from "./model/TrackStats";
6
8
  export declare class MeetingHandler {
7
9
  private meetingStartRequest?;
8
10
  private videoCallHandler?;
@@ -10,10 +12,11 @@ export declare class MeetingHandler {
10
12
  private websocketCallHandler?;
11
13
  private communicationHandler?;
12
14
  private userMediaHandler?;
13
- meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string): MeetingStartRequest;
15
+ meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string, shouldIgnoreCaseForRoomId?: boolean): MeetingStartRequest;
14
16
  endAndDestory(): void;
15
17
  requestToCloseTheRoom: () => void;
16
18
  init(): Promise<void>;
19
+ recreateVideoCallHandler: () => Promise<BaseVideoCallHandler | undefined>;
17
20
  switchCamera(): void;
18
21
  startLocalStream(isVideoRequired: boolean, isAudioRequired: boolean, shouldAddTrackImmediately?: boolean, userMediaPayload?: any): Promise<void>;
19
22
  startScreenShare(isAudioRequired?: boolean, shouldAddTrackImmediately?: boolean, screensharePayload?: any): Promise<void>;
@@ -21,6 +24,7 @@ export declare class MeetingHandler {
21
24
  getDevices(deviceType: GetDevicesType): Promise<Device[] | undefined>;
22
25
  pauseCamera(userId?: string): Promise<TaskResponse>;
23
26
  muteUser(userId?: string): Promise<TaskResponse>;
27
+ getClientStats: () => Promise<TrackStats[] | undefined>;
24
28
  resumeCamera(userId?: string): Promise<TaskResponse>;
25
29
  unmute(userId?: string): Promise<TaskResponse>;
26
30
  resumeStreamWithoutAdding(streamKind: TrackKind): TaskResponse | undefined;
@@ -50,6 +54,7 @@ export declare class MeetingHandler {
50
54
  getEventEmitter(): VaniEventListener | undefined;
51
55
  restartTransport: () => Promise<void>;
52
56
  private emitMessageToSource;
57
+ restartSFU: () => Promise<void>;
53
58
  private cleanup;
54
59
  private handleGA;
55
60
  }
@@ -50,6 +50,34 @@ var MeetingHandler = /** @class */ (function () {
50
50
  var _a;
51
51
  (_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.requestToCloseTheRoom();
52
52
  };
53
+ this.recreateVideoCallHandler = function () { return __awaiter(_this, void 0, void 0, function () {
54
+ var _a;
55
+ var _b;
56
+ return __generator(this, function (_c) {
57
+ switch (_c.label) {
58
+ case 0:
59
+ if (!this.meetingStartRequest) {
60
+ log.error("meetingStartRequestObject not found");
61
+ return [2 /*return*/];
62
+ }
63
+ this.videoCallHandler = undefined;
64
+ _a = this;
65
+ return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.meetingType, this.meetingStartRequest, this.communicationHandler)];
66
+ case 1:
67
+ _a.videoCallHandler = _c.sent();
68
+ return [2 /*return*/, this.videoCallHandler];
69
+ }
70
+ });
71
+ }); };
72
+ this.getClientStats = function () { return __awaiter(_this, void 0, void 0, function () {
73
+ var _a;
74
+ return __generator(this, function (_b) {
75
+ switch (_b.label) {
76
+ case 0: return [4 /*yield*/, ((_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.getClientStats())];
77
+ case 1: return [2 /*return*/, _b.sent()];
78
+ }
79
+ });
80
+ }); };
53
81
  this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
54
82
  var _a;
55
83
  return __generator(this, function (_b) {
@@ -57,13 +85,25 @@ var MeetingHandler = /** @class */ (function () {
57
85
  return [2 /*return*/];
58
86
  });
59
87
  }); };
88
+ this.restartSFU = function () { return __awaiter(_this, void 0, void 0, function () {
89
+ var _a;
90
+ return __generator(this, function (_b) {
91
+ switch (_b.label) {
92
+ case 0: return [4 /*yield*/, ((_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.restartSFU())];
93
+ case 1:
94
+ _b.sent();
95
+ return [2 /*return*/];
96
+ }
97
+ });
98
+ }); };
60
99
  }
61
- MeetingHandler.prototype.meetingStartRequestObject = function (roomId, userId, appId, wssUrl) {
100
+ MeetingHandler.prototype.meetingStartRequestObject = function (roomId, userId, appId, wssUrl, shouldIgnoreCaseForRoomId) {
101
+ if (shouldIgnoreCaseForRoomId === void 0) { shouldIgnoreCaseForRoomId = false; }
62
102
  if (!this.meetingStartRequest) {
63
103
  if (roomId === userId) {
64
104
  roomId = roomId + "-r";
65
105
  }
66
- this.meetingStartRequest = new MeetingStartRequest(roomId, userId, appId, wssUrl);
106
+ this.meetingStartRequest = new MeetingStartRequest(roomId, userId, appId, wssUrl, shouldIgnoreCaseForRoomId);
67
107
  }
68
108
  return this.meetingStartRequest;
69
109
  };
@@ -61,5 +61,7 @@ export declare class CommunicationHandler {
61
61
  onIceCandidateDisconnected(): void;
62
62
  checkIfInternetReachable: (count: number) => void;
63
63
  private onApiResponded;
64
+ restartSFU: () => Promise<void>;
65
+ private reloadSFUCleanUpDone;
64
66
  cleanup(): void;
65
67
  }
@@ -38,7 +38,7 @@ import { VaniEvent, MessagePayload, LogLevel } from "..";
38
38
  import { Participant } from "../model/Participant";
39
39
  import * as log from 'loglevel';
40
40
  import { Track, TrackKind } from "../model/Track";
41
- import { WebSocketBasicEvents } from "../websocket-handler/WebsocketHandler";
41
+ import { SFUMessageType, WebSocketBasicEvents } from "../websocket-handler/WebsocketHandler";
42
42
  import { VaniEventListener } from "../utility/VaniEventListener";
43
43
  import { Utility } from "../utility/Utility";
44
44
  var CommunicationHandler = /** @class */ (function () {
@@ -104,6 +104,35 @@ var CommunicationHandler = /** @class */ (function () {
104
104
  });
105
105
  ;
106
106
  };
107
+ this.restartSFU = function () { return __awaiter(_this, void 0, void 0, function () {
108
+ var messageJson;
109
+ var _a;
110
+ return __generator(this, function (_b) {
111
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.cleanup(false);
112
+ messageJson = { to: "self", type: SFUMessageType.ReloadSFU, message: SFUMessageType.ReloadSFU };
113
+ this.sendWebSocketMessage(SFUMessageType.SFUMessage, messageJson);
114
+ return [2 /*return*/];
115
+ });
116
+ }); };
117
+ this.reloadSFUCleanUpDone = function () { return __awaiter(_this, void 0, void 0, function () {
118
+ var videoCallHandler;
119
+ var _a;
120
+ return __generator(this, function (_b) {
121
+ switch (_b.label) {
122
+ case 0:
123
+ this.videoCallHandler = undefined;
124
+ this.allTracks = this.allTracks.filter(function (eachTrack) { return eachTrack.isLocalTrack === true; });
125
+ return [4 /*yield*/, ((_a = this.meetingHandler) === null || _a === void 0 ? void 0 : _a.recreateVideoCallHandler())];
126
+ case 1:
127
+ videoCallHandler = _b.sent();
128
+ if (videoCallHandler) {
129
+ this.setVideoCallHandler(videoCallHandler);
130
+ videoCallHandler.init();
131
+ }
132
+ return [2 /*return*/];
133
+ }
134
+ });
135
+ }); };
107
136
  this.meetingHandler = meetingHandler;
108
137
  this.eventEmitter.setMaxListeners(100000);
109
138
  }
@@ -409,7 +438,12 @@ var CommunicationHandler = /** @class */ (function () {
409
438
  var _a;
410
439
  return __awaiter(this, void 0, void 0, function () {
411
440
  return __generator(this, function (_b) {
412
- (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onSocketMessage(websocketMessage);
441
+ if (websocketMessage.type === SFUMessageType.ReloadSFUCleanUpDone) {
442
+ this.reloadSFUCleanUpDone();
443
+ }
444
+ else {
445
+ (_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onSocketMessage(websocketMessage);
446
+ }
413
447
  return [2 /*return*/];
414
448
  });
415
449
  });
@@ -33,7 +33,10 @@ export declare enum VaniEvent {
33
33
  OnReconectionTimeout = "reconectionTimeout",
34
34
  OnReconecting = "reconecting",
35
35
  OnUserOnFoundWhileReconnect = "onUserOnFoundWhileReconnect",
36
- OnNewPingFromServer = "OnNewPingFromServer"
36
+ OnNewPingFromServer = "OnNewPingFromServer",
37
+ OnConsumerScoreChange = "OnConsumerScoreChange",
38
+ OnProducerScoreChange = "OnProducerScoreChange",
39
+ OnConsumerLayerChange = "OnConsumerLayerChange"
37
40
  }
38
41
  interface VaniConnectionEvents {
39
42
  [VaniEvent.OnInitDone]: () => any;
@@ -61,6 +64,21 @@ interface VaniConnectionEvents {
61
64
  participant: Participant;
62
65
  volume: any;
63
66
  }) => any;
67
+ [VaniEvent.OnConsumerScoreChange]: (data: {
68
+ participant: Participant;
69
+ track: Track;
70
+ score: any;
71
+ }) => any;
72
+ [VaniEvent.OnProducerScoreChange]: (data: {
73
+ participant: Participant;
74
+ track: Track;
75
+ score: any;
76
+ }) => any;
77
+ [VaniEvent.OnConsumerLayerChange]: (data: {
78
+ participant: Participant;
79
+ track: Track;
80
+ layer: any;
81
+ }) => any;
64
82
  [VaniEvent.OnNotReachable]: () => any;
65
83
  [VaniEvent.OnReconectionTimeout]: () => any;
66
84
  [VaniEvent.OnReconecting]: () => any;
@@ -32,4 +32,7 @@ export var VaniEvent;
32
32
  VaniEvent["OnReconecting"] = "reconecting";
33
33
  VaniEvent["OnUserOnFoundWhileReconnect"] = "onUserOnFoundWhileReconnect";
34
34
  VaniEvent["OnNewPingFromServer"] = "OnNewPingFromServer";
35
+ VaniEvent["OnConsumerScoreChange"] = "OnConsumerScoreChange";
36
+ VaniEvent["OnProducerScoreChange"] = "OnProducerScoreChange";
37
+ VaniEvent["OnConsumerLayerChange"] = "OnConsumerLayerChange";
35
38
  })(VaniEvent || (VaniEvent = {}));
@@ -49,6 +49,7 @@ export declare class MeetingStartRequest {
49
49
  shouldPauseUploadingStreamOnSingleParticipant: boolean;
50
50
  connectionProtocol: ConnectionProtocol;
51
51
  shouldKeepTryToReconnect: boolean;
52
+ shouldIgnoreCaseForRoomId: boolean;
52
53
  urlToCheckInternetPresent: string;
53
- constructor(_roomId: string, _userId: string, _appId: string, _wssUrl: string);
54
+ constructor(_roomId: string, _userId: string, _appId: string, _wssUrl: string, _shouldIgnoreCaseForRoomId?: boolean);
54
55
  }
@@ -20,7 +20,8 @@ export var LogLevel;
20
20
  LogLevel["Debug"] = "Debug";
21
21
  })(LogLevel || (LogLevel = {}));
22
22
  var MeetingStartRequest = /** @class */ (function () {
23
- function MeetingStartRequest(_roomId, _userId, _appId, _wssUrl) {
23
+ function MeetingStartRequest(_roomId, _userId, _appId, _wssUrl, _shouldIgnoreCaseForRoomId) {
24
+ if (_shouldIgnoreCaseForRoomId === void 0) { _shouldIgnoreCaseForRoomId = false; }
24
25
  this.videoCaptureWidth = 0;
25
26
  this.videoCaptureHeight = 0;
26
27
  this.defaultWhiteboardEditEnable = true;
@@ -46,8 +47,15 @@ var MeetingStartRequest = /** @class */ (function () {
46
47
  this.shouldPauseUploadingStreamOnSingleParticipant = true;
47
48
  this.connectionProtocol = ConnectionProtocol.UDP;
48
49
  this.shouldKeepTryToReconnect = false;
50
+ this.shouldIgnoreCaseForRoomId = false;
49
51
  this.urlToCheckInternetPresent = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Stack%20Overflow";
50
- this.roomId = _roomId.toLowerCase();
52
+ this.shouldIgnoreCaseForRoomId = _shouldIgnoreCaseForRoomId;
53
+ if (this.shouldIgnoreCaseForRoomId) {
54
+ this.roomId = _roomId;
55
+ }
56
+ else {
57
+ this.roomId = _roomId.toLowerCase();
58
+ }
51
59
  this.userId = _userId;
52
60
  this.appId = _appId;
53
61
  if (_wssUrl.indexOf("connection=") < 0) {
@@ -0,0 +1,11 @@
1
+ import { Track } from "./Track";
2
+ export declare enum StreamType {
3
+ Consumer = "Consumer",
4
+ Producer = "Producer"
5
+ }
6
+ export declare class TrackStats {
7
+ track: Track;
8
+ type: StreamType;
9
+ stats: any;
10
+ constructor(_track: Track, _type: StreamType, _stats?: any);
11
+ }
@@ -0,0 +1,14 @@
1
+ export var StreamType;
2
+ (function (StreamType) {
3
+ StreamType["Consumer"] = "Consumer";
4
+ StreamType["Producer"] = "Producer";
5
+ })(StreamType || (StreamType = {}));
6
+ var TrackStats = /** @class */ (function () {
7
+ function TrackStats(_track, _type, _stats) {
8
+ this.track = _track;
9
+ this.type = _type;
10
+ this.stats = _stats;
11
+ }
12
+ return TrackStats;
13
+ }());
14
+ export { TrackStats };
@@ -1,6 +1,7 @@
1
1
  import { Track } from "../model/Track";
2
2
  import { WebSocketMessageBody } from "../websocket-handler/WebsocketHandler";
3
3
  import { Base } from "../base/Base";
4
+ import { TrackStats } from "../model/TrackStats";
4
5
  export declare abstract class BaseVideoCallHandler extends Base {
5
6
  protected onObjectCreated(): void;
6
7
  abstract init(): Promise<void>;
@@ -20,6 +21,7 @@ export declare abstract class BaseVideoCallHandler extends Base {
20
21
  pauseProducerOrConsumerForTrack(track: Track): Promise<void>;
21
22
  reconnectedWithoutPing(): void;
22
23
  updateSpatialForTrack(track: Track, spatialLayerIndex: number): Promise<void>;
23
- cleanup(): void;
24
+ cleanup(shouldStopTracks?: boolean): void;
24
25
  restartTransport(): void;
26
+ getClientStats: () => Promise<TrackStats[]>;
25
27
  }
@@ -55,7 +55,13 @@ import { Base } from "../base/Base";
55
55
  var BaseVideoCallHandler = /** @class */ (function (_super) {
56
56
  __extends(BaseVideoCallHandler, _super);
57
57
  function BaseVideoCallHandler() {
58
- return _super !== null && _super.apply(this, arguments) || this;
58
+ var _this = _super !== null && _super.apply(this, arguments) || this;
59
+ _this.getClientStats = function () { return __awaiter(_this, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ return [2 /*return*/, []];
62
+ });
63
+ }); };
64
+ return _this;
59
65
  }
60
66
  BaseVideoCallHandler.prototype.onObjectCreated = function () {
61
67
  var _a;
@@ -87,7 +93,8 @@ var BaseVideoCallHandler = /** @class */ (function (_super) {
87
93
  });
88
94
  });
89
95
  };
90
- BaseVideoCallHandler.prototype.cleanup = function () {
96
+ BaseVideoCallHandler.prototype.cleanup = function (shouldStopTracks) {
97
+ if (shouldStopTracks === void 0) { shouldStopTracks = true; }
91
98
  this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("cleanup ");
92
99
  _super.prototype.cleanup.call(this);
93
100
  };
@@ -4,6 +4,7 @@ import { Track } from "../model/Track";
4
4
  import { Consumer } from "mediasoup-client/lib/Consumer";
5
5
  import { MeetingStartRequest } from '..';
6
6
  import { CommunicationHandler } from '../inter-communication-handler/CommunicationHandler';
7
+ import { TrackStats } from '../model/TrackStats';
7
8
  export declare class SFUHandler extends BaseVideoCallHandler {
8
9
  private device?;
9
10
  private transportCallBacks;
@@ -50,8 +51,13 @@ export declare class SFUHandler extends BaseVideoCallHandler {
50
51
  private onProducerNotFound;
51
52
  private onTrackEnded;
52
53
  private onNewProducer;
54
+ onConsumerScoreChange: (_data: any) => Promise<void>;
55
+ onProducerScoreChange: (_data: any) => Promise<void>;
56
+ onConsumerLayerChange: (_data: any) => Promise<void>;
53
57
  private onServerConsumer;
54
58
  private onAudioVolumeChanged;
55
59
  private onSpeakerChanged;
56
- cleanup(): void;
60
+ getClientStats: () => Promise<TrackStats[]>;
61
+ private eachTrackStats;
62
+ cleanup(shouldStopTracks?: boolean): void;
57
63
  }
@@ -66,6 +66,7 @@ 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 { LogLevel, VaniEvent } from '..';
69
+ import { StreamType, TrackStats } from '../model/TrackStats';
69
70
  var SFUHandler = /** @class */ (function (_super) {
70
71
  __extends(SFUHandler, _super);
71
72
  function SFUHandler(_meetingStartRequest, _communicationHandler) {
@@ -97,6 +98,115 @@ var SFUHandler = /** @class */ (function (_super) {
97
98
  }
98
99
  }
99
100
  };
101
+ _this.onConsumerScoreChange = function (_data) { return __awaiter(_this, void 0, void 0, function () {
102
+ var data, score, consumerId, consumedProducer, track;
103
+ var _a, _b;
104
+ return __generator(this, function (_c) {
105
+ data = _data.message;
106
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onConsumerScoreChange", data);
107
+ score = data.score;
108
+ consumerId = data.consumerId;
109
+ consumedProducer = this.consumers.find(function (eachConsumer) { return eachConsumer.id === consumerId; });
110
+ if (consumedProducer) {
111
+ track = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (eachTrack) { return consumedProducer.appData.producerData.trackId === eachTrack.trackId; });
112
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnConsumerScoreChange, { track: track, score: score, participant: track === null || track === void 0 ? void 0 : track.participant });
113
+ }
114
+ return [2 /*return*/];
115
+ });
116
+ }); };
117
+ _this.onProducerScoreChange = function (_data) { return __awaiter(_this, void 0, void 0, function () {
118
+ var data, score, producerId, producer, consumedProducer, track, track;
119
+ var _a, _b, _c, _d;
120
+ return __generator(this, function (_e) {
121
+ data = _data.message;
122
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onProducerScoreChange", data);
123
+ score = data.score;
124
+ producerId = data.producerId;
125
+ producer = this.producers.find(function (producer) { return producer.id === producerId; });
126
+ consumedProducer = this.consumers.find(function (eachConsumer) { return eachConsumer.producerId === producerId; });
127
+ if (consumedProducer) {
128
+ track = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (eachTrack) { return consumedProducer.appData.producerData.trackId === eachTrack.trackId; });
129
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnProducerScoreChange, { track: track, score: score, participant: track === null || track === void 0 ? void 0 : track.participant });
130
+ }
131
+ if (producer) {
132
+ track = (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.getAllTracks().find(function (eachTrack) { return (producer.appData).trackId === eachTrack.trackId; });
133
+ if (track) {
134
+ (_d = this.communicationHandler) === null || _d === void 0 ? void 0 : _d.emitMessageToSource(VaniEvent.OnProducerScoreChange, { track: track, score: score, participant: track === null || track === void 0 ? void 0 : track.participant });
135
+ }
136
+ }
137
+ return [2 /*return*/];
138
+ });
139
+ }); };
140
+ _this.onConsumerLayerChange = function (_data) { return __awaiter(_this, void 0, void 0, function () {
141
+ var data, layer, consumerId, consumer, track;
142
+ var _a, _b;
143
+ return __generator(this, function (_c) {
144
+ data = _data.message;
145
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onConsumerLayerChange", data);
146
+ layer = data.layer;
147
+ consumerId = data.consumerId;
148
+ consumer = this.consumers.find(function (consumer) { return consumer.id === consumerId; });
149
+ if (consumer) {
150
+ track = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks().find(function (eachTrack) { return consumer.appData.producerData.trackId === eachTrack.trackId; });
151
+ if (track) {
152
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnConsumerLayerChange, { track: track, layer: layer, participant: track.participant });
153
+ }
154
+ }
155
+ return [2 /*return*/];
156
+ });
157
+ }); };
158
+ _this.getClientStats = function () { return __awaiter(_this, void 0, void 0, function () {
159
+ var allTracks, promisesArray, _i, allTracks_1, track;
160
+ var _a;
161
+ return __generator(this, function (_b) {
162
+ switch (_b.label) {
163
+ case 0:
164
+ if (!this.communicationHandler) return [3 /*break*/, 2];
165
+ allTracks = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks();
166
+ promisesArray = [];
167
+ for (_i = 0, allTracks_1 = allTracks; _i < allTracks_1.length; _i++) {
168
+ track = allTracks_1[_i];
169
+ promisesArray.push(this.eachTrackStats(track));
170
+ }
171
+ return [4 /*yield*/, Promise.all(promisesArray)];
172
+ case 1: return [2 /*return*/, _b.sent()];
173
+ case 2: return [2 /*return*/, []];
174
+ }
175
+ });
176
+ }); };
177
+ _this.eachTrackStats = function (track) { return __awaiter(_this, void 0, void 0, function () {
178
+ var _this = this;
179
+ return __generator(this, function (_a) {
180
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
181
+ var consumer, _a, _b, _c, producer, _d, _e, _f;
182
+ return __generator(this, function (_g) {
183
+ switch (_g.label) {
184
+ case 0:
185
+ consumer = this.consumers.find(function (consumer) { return consumer.appData.producerData.trackId === track.trackId; });
186
+ if (!consumer) return [3 /*break*/, 2];
187
+ _a = resolve;
188
+ _b = TrackStats.bind;
189
+ _c = [void 0, track, StreamType.Consumer];
190
+ return [4 /*yield*/, consumer.getStats()];
191
+ case 1:
192
+ _a.apply(void 0, [new (_b.apply(TrackStats, _c.concat([_g.sent()])))()]);
193
+ return [3 /*break*/, 4];
194
+ case 2:
195
+ producer = this.producers.find(function (producer) { return (producer.appData).trackId === track.trackId; });
196
+ if (!producer) return [3 /*break*/, 4];
197
+ _d = resolve;
198
+ _e = TrackStats.bind;
199
+ _f = [void 0, track, StreamType.Producer];
200
+ return [4 /*yield*/, producer.getStats()];
201
+ case 3:
202
+ _d.apply(void 0, [new (_e.apply(TrackStats, _f.concat([_g.sent()])))()]);
203
+ _g.label = 4;
204
+ case 4: return [2 /*return*/];
205
+ }
206
+ });
207
+ }); })];
208
+ });
209
+ }); };
100
210
  var handlerName = detectDevice();
101
211
  if (handlerName) {
102
212
  _this.device = new Device();
@@ -614,6 +724,15 @@ var SFUHandler = /** @class */ (function (_super) {
614
724
  else if (websocketCallHandler.type === SFUMessageType.OnServerConsumer) {
615
725
  this.onServerConsumer(websocketCallHandler.data);
616
726
  }
727
+ else if (websocketCallHandler.type === SFUMessageType.OnConsumerLayerChange) {
728
+ this.onConsumerLayerChange(websocketCallHandler.data);
729
+ }
730
+ else if (websocketCallHandler.type === SFUMessageType.OnConsumerScoreChange) {
731
+ this.onConsumerScoreChange(websocketCallHandler.data);
732
+ }
733
+ else if (websocketCallHandler.type === SFUMessageType.OnProducerScoreChange) {
734
+ this.onProducerScoreChange(websocketCallHandler.data);
735
+ }
617
736
  else if (websocketCallHandler.type === SFUMessageType.OnProduceSyncDone) {
618
737
  this.onProduceSyncDone(websocketCallHandler.data);
619
738
  }
@@ -762,7 +881,8 @@ var SFUHandler = /** @class */ (function (_super) {
762
881
  }
763
882
  }
764
883
  };
765
- SFUHandler.prototype.cleanup = function () {
884
+ SFUHandler.prototype.cleanup = function (shouldStopTracks) {
885
+ if (shouldStopTracks === void 0) { shouldStopTracks = true; }
766
886
  if (this.sendTransport) {
767
887
  this.sendTransport.close();
768
888
  this.sendTransport = undefined;
@@ -775,7 +895,9 @@ var SFUHandler = /** @class */ (function (_super) {
775
895
  this.producers.forEach(function (producer) {
776
896
  var _a;
777
897
  try {
778
- (_a = producer.track) === null || _a === void 0 ? void 0 : _a.stop();
898
+ if (shouldStopTracks) {
899
+ (_a = producer.track) === null || _a === void 0 ? void 0 : _a.stop();
900
+ }
779
901
  }
780
902
  catch (err) {
781
903
  }
@@ -786,7 +908,9 @@ var SFUHandler = /** @class */ (function (_super) {
786
908
  }
787
909
  this.dataProducers.forEach(function (producer) {
788
910
  if (producer.closed === false) {
789
- producer.close();
911
+ if (shouldStopTracks) {
912
+ producer.close();
913
+ }
790
914
  }
791
915
  });
792
916
  this.dataConsumer.forEach(function (consumer) {
@@ -33,6 +33,8 @@ export declare enum WebSocketBasicEvents {
33
33
  export declare enum SFUMessageType {
34
34
  SFUMessage = "sfuMessage",
35
35
  GetRouterRtpCapabilities = "routerRtpCapabilities",
36
+ ReloadSFUCleanUpDone = "ReloadSFUCleanUpDone",
37
+ ReloadSFU = "reloadSFU",
36
38
  OnRouterRtpCapabilities = "onRouterRtpCapabilities",
37
39
  OnTransportConnect = "transportConnect",
38
40
  OnCreateTransports = "createTransports",
@@ -63,7 +65,10 @@ export declare enum SFUMessageType {
63
65
  OnAllProducers = "onAllProducers",
64
66
  OnAudioVolumeChanged = "OnAudioVolumeChanged",
65
67
  OnConsumerNotFound = "OnConsumerNotFound",
66
- OnProducerNotFound = "OnProducerNotFound"
68
+ OnProducerNotFound = "OnProducerNotFound",
69
+ OnConsumerScoreChange = "OnConsumerScoreChange",
70
+ OnProducerScoreChange = "OnProducerScoreChange",
71
+ OnConsumerLayerChange = "OnConsumerLayerChange"
67
72
  }
68
73
  export type WebSocketEvents = SFUMessageType | WebSocketBasicEvents;
69
74
  export interface WebSocketMessageBody {
@@ -89,6 +89,8 @@ export var SFUMessageType;
89
89
  (function (SFUMessageType) {
90
90
  SFUMessageType["SFUMessage"] = "sfuMessage";
91
91
  SFUMessageType["GetRouterRtpCapabilities"] = "routerRtpCapabilities";
92
+ SFUMessageType["ReloadSFUCleanUpDone"] = "ReloadSFUCleanUpDone";
93
+ SFUMessageType["ReloadSFU"] = "reloadSFU";
92
94
  SFUMessageType["OnRouterRtpCapabilities"] = "onRouterRtpCapabilities";
93
95
  SFUMessageType["OnTransportConnect"] = "transportConnect";
94
96
  SFUMessageType["OnCreateTransports"] = "createTransports";
@@ -120,6 +122,9 @@ export var SFUMessageType;
120
122
  SFUMessageType["OnAudioVolumeChanged"] = "OnAudioVolumeChanged";
121
123
  SFUMessageType["OnConsumerNotFound"] = "OnConsumerNotFound";
122
124
  SFUMessageType["OnProducerNotFound"] = "OnProducerNotFound";
125
+ SFUMessageType["OnConsumerScoreChange"] = "OnConsumerScoreChange";
126
+ SFUMessageType["OnProducerScoreChange"] = "OnProducerScoreChange";
127
+ SFUMessageType["OnConsumerLayerChange"] = "OnConsumerLayerChange";
123
128
  })(SFUMessageType || (SFUMessageType = {}));
124
129
  var ConnectionType;
125
130
  (function (ConnectionType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client-native",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "analytics": "^0.7.21",
47
47
  "axios": "^0.24.0",
48
48
  "loglevel": "^1.8.0",
49
- "mediasoup-client": "^3.7.16",
49
+ "mediasoup-client": "^3.81.1",
50
50
  "react-native-google-analytics-bridge": "^7.1.0"
51
51
  },
52
52
  "optionalDependencies": {}