vani-meeting-client 1.9.1 → 1.9.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.
@@ -4,6 +4,7 @@ import { GetDevicesType } from "./user-media-handler/UserMediaHandler";
4
4
  import { Track, TrackKind } from "./model/Track";
5
5
  import { TaskResponse } from "./model/TaskResponse";
6
6
  import { Participant } from "./model/Participant";
7
+ import { TrackStats } from "./model/TrackStats";
7
8
  export declare class MeetingHandler {
8
9
  private meetingStartRequest?;
9
10
  private videoCallHandler?;
@@ -23,6 +24,7 @@ export declare class MeetingHandler {
23
24
  getDevices(deviceType: GetDevicesType): Promise<Device[] | undefined>;
24
25
  pauseCamera(userId?: string): Promise<TaskResponse>;
25
26
  muteUser(userId?: string): Promise<TaskResponse>;
27
+ getClientStats: () => Promise<TrackStats[] | undefined>;
26
28
  resumeCamera(userId?: string): Promise<TaskResponse>;
27
29
  unmute(userId?: string): Promise<TaskResponse>;
28
30
  resumeStreamWithoutAdding(streamKind: TrackKind): TaskResponse | undefined;
@@ -69,6 +69,15 @@ var MeetingHandler = /** @class */ (function () {
69
69
  }
70
70
  });
71
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
+ }); };
72
81
  this.restartTransport = function () { return __awaiter(_this, void 0, void 0, function () {
73
82
  var _a;
74
83
  return __generator(this, function (_b) {
@@ -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>;
@@ -22,4 +23,5 @@ export declare abstract class BaseVideoCallHandler extends Base {
22
23
  updateSpatialForTrack(track: Track, spatialLayerIndex: number): Promise<void>;
23
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;
@@ -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;
@@ -56,5 +57,6 @@ export declare class SFUHandler extends BaseVideoCallHandler {
56
57
  private onServerConsumer;
57
58
  private onAudioVolumeChanged;
58
59
  private onSpeakerChanged;
60
+ getClientStats: () => Promise<TrackStats[]>;
59
61
  cleanup(shouldStopTracks?: boolean): void;
60
62
  }
@@ -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) {
@@ -101,7 +102,7 @@ var SFUHandler = /** @class */ (function (_super) {
101
102
  var score, consumerId, consumedProducer, track;
102
103
  var _a, _b;
103
104
  return __generator(this, function (_c) {
104
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onConsumerLayerChange", data);
105
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onConsumerScoreChange", data);
105
106
  score = data.score;
106
107
  consumerId = data.consumerId;
107
108
  consumedProducer = this.consumers.find(function (eachConsumer) { return eachConsumer.id === consumerId; });
@@ -116,7 +117,7 @@ var SFUHandler = /** @class */ (function (_super) {
116
117
  var score, producerId, producer, consumedProducer, track, track;
117
118
  var _a, _b, _c, _d;
118
119
  return __generator(this, function (_e) {
119
- this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onConsumerLayerChange", data);
120
+ this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("onProducerScoreChange", data);
120
121
  score = data.score;
121
122
  producerId = data.producerId;
122
123
  producer = this.producers.find(function (producer) { return producer.id === producerId; });
@@ -151,6 +152,61 @@ var SFUHandler = /** @class */ (function (_super) {
151
152
  return [2 /*return*/];
152
153
  });
153
154
  }); };
155
+ _this.getClientStats = function () { return __awaiter(_this, void 0, void 0, function () {
156
+ var allStats, allTracks, _loop_1, this_1, _i, allTracks_1, track;
157
+ var _a;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
160
+ case 0:
161
+ allStats = [];
162
+ if (!this.communicationHandler) return [3 /*break*/, 4];
163
+ allTracks = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getAllTracks();
164
+ _loop_1 = function (track) {
165
+ var trackId, consumer, _c, _d, _e, _f, producer, _g, _h, _j, _k;
166
+ return __generator(this, function (_l) {
167
+ switch (_l.label) {
168
+ case 0:
169
+ trackId = track.trackId;
170
+ consumer = this_1.consumers.find(function (consumer) { return consumer.appData.producerData.trackId === trackId; });
171
+ if (!consumer) return [3 /*break*/, 2];
172
+ _d = (_c = allStats).push;
173
+ _e = TrackStats.bind;
174
+ _f = [void 0, track, StreamType.Consumer];
175
+ return [4 /*yield*/, consumer.getStats()];
176
+ case 1:
177
+ _d.apply(_c, [new (_e.apply(TrackStats, _f.concat([_l.sent()])))()]);
178
+ return [3 /*break*/, 4];
179
+ case 2:
180
+ producer = this_1.producers.find(function (producer) { return (producer.appData).trackId === trackId; });
181
+ if (!producer) return [3 /*break*/, 4];
182
+ _h = (_g = allStats).push;
183
+ _j = TrackStats.bind;
184
+ _k = [void 0, track, StreamType.Producer];
185
+ return [4 /*yield*/, producer.getStats()];
186
+ case 3:
187
+ _h.apply(_g, [new (_j.apply(TrackStats, _k.concat([_l.sent()])))()]);
188
+ _l.label = 4;
189
+ case 4: return [2 /*return*/];
190
+ }
191
+ });
192
+ };
193
+ this_1 = this;
194
+ _i = 0, allTracks_1 = allTracks;
195
+ _b.label = 1;
196
+ case 1:
197
+ if (!(_i < allTracks_1.length)) return [3 /*break*/, 4];
198
+ track = allTracks_1[_i];
199
+ return [5 /*yield**/, _loop_1(track)];
200
+ case 2:
201
+ _b.sent();
202
+ _b.label = 3;
203
+ case 3:
204
+ _i++;
205
+ return [3 /*break*/, 1];
206
+ case 4: return [2 /*return*/, allStats];
207
+ }
208
+ });
209
+ }); };
154
210
  var handlerName = detectDevice();
155
211
  if (handlerName) {
156
212
  _this.device = new Device();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",