vani-meeting-client 0.4.7 → 0.5.0
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.
|
@@ -32,6 +32,7 @@ export declare class CommunicationHandler {
|
|
|
32
32
|
addParticipantIfNotExist(participant: Participant, shouldInfrom?: boolean): Participant | undefined;
|
|
33
33
|
removeParticipant(participant: Participant, shouldInfrom?: boolean): void;
|
|
34
34
|
onUserLeft(data: any): void;
|
|
35
|
+
private updateParticipantAudioVideoDataAccordingToTrack;
|
|
35
36
|
getSelfTrackByType(trackKind: TrackKind): Track | undefined;
|
|
36
37
|
getAllSelfTracks(): Track[];
|
|
37
38
|
getAllTracks(): Track[];
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { VaniEvent, MessagePayload } from "..";
|
|
38
38
|
import { Participant } from "../model/Participant";
|
|
39
39
|
import * as log from 'loglevel';
|
|
40
|
-
import { Track } from "../model/Track";
|
|
40
|
+
import { Track, TrackKind } from "../model/Track";
|
|
41
41
|
import { WebSocketBasicEvents } from "../websocket-handler/WebsocketHandler";
|
|
42
42
|
import { VaniEventListener } from "../utility/VaniEventListener";
|
|
43
43
|
import { Utility } from "../utility/Utility";
|
|
@@ -108,6 +108,7 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
108
108
|
};
|
|
109
109
|
CommunicationHandler.prototype.onServerParticipants = function (data) {
|
|
110
110
|
var _this = this;
|
|
111
|
+
log.info(data);
|
|
111
112
|
if (data && data.message) {
|
|
112
113
|
var userIds = "";
|
|
113
114
|
Object.entries(data.message).forEach(function (_a) {
|
|
@@ -137,10 +138,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
137
138
|
if (shouldInfrom) {
|
|
138
139
|
this.emitMessageToSource(VaniEvent.OnParticipantDataUpdated, oldParticipant);
|
|
139
140
|
}
|
|
141
|
+
this.updateParticipantAudioVideoDataAccordingToTrack(oldParticipant);
|
|
140
142
|
return oldParticipant;
|
|
141
143
|
}
|
|
142
144
|
else {
|
|
143
145
|
participant = Object.assign(new Participant(participant.userId, participant.roomId, participant.userData, participant.isAdmin), participant);
|
|
146
|
+
this.updateParticipantAudioVideoDataAccordingToTrack(participant);
|
|
144
147
|
this.allParticipants.push(participant);
|
|
145
148
|
if (shouldInfrom) {
|
|
146
149
|
this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
|
|
@@ -173,6 +176,10 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
};
|
|
179
|
+
CommunicationHandler.prototype.updateParticipantAudioVideoDataAccordingToTrack = function (participant) {
|
|
180
|
+
participant.isAudioEnable = this.getAllTracks().find(function (track) { return track.trackKind === TrackKind.Audio; }) ? true : false;
|
|
181
|
+
participant.isVideoEnable = this.getAllTracks().find(function (track) { return track.trackKind === TrackKind.Video; }) ? true : false;
|
|
182
|
+
};
|
|
176
183
|
CommunicationHandler.prototype.getSelfTrackByType = function (trackKind) {
|
|
177
184
|
return this.selfTracks.find(function (track) { return track.trackKind === trackKind; });
|
|
178
185
|
};
|
|
@@ -194,6 +201,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
194
201
|
CommunicationHandler.prototype.removeTrack = function (track, shouldInfromVideoController) {
|
|
195
202
|
var _a;
|
|
196
203
|
if (shouldInfromVideoController === void 0) { shouldInfromVideoController = true; }
|
|
204
|
+
if (track.trackKind === TrackKind.Audio) {
|
|
205
|
+
track.participant.isAudioEnable = false;
|
|
206
|
+
}
|
|
207
|
+
else if (track.trackKind === TrackKind.Video) {
|
|
208
|
+
track.participant.isVideoEnable = false;
|
|
209
|
+
}
|
|
197
210
|
if (shouldInfromVideoController && this.isStartAndSetupWithServerCalled && track.isLocalTrack) {
|
|
198
211
|
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.stopTrack(track);
|
|
199
212
|
}
|
|
@@ -214,6 +227,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
214
227
|
this.allTracks.push(track);
|
|
215
228
|
}
|
|
216
229
|
track.participant = participant;
|
|
230
|
+
if (track.trackKind === TrackKind.Audio) {
|
|
231
|
+
track.participant.isAudioEnable = true;
|
|
232
|
+
}
|
|
233
|
+
else if (track.trackKind === TrackKind.Video) {
|
|
234
|
+
track.participant.isVideoEnable = true;
|
|
235
|
+
}
|
|
217
236
|
if (shouldInfromIfNotExist) {
|
|
218
237
|
log.info("emitMessageToSource");
|
|
219
238
|
this.emitMessageToSource(VaniEvent.OnTrack, track);
|
|
@@ -235,6 +254,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
235
254
|
this.allTracks.push(track);
|
|
236
255
|
this.selfTracks.push(track);
|
|
237
256
|
}
|
|
257
|
+
if (track.trackKind === TrackKind.Audio) {
|
|
258
|
+
track.participant.isAudioEnable = true;
|
|
259
|
+
}
|
|
260
|
+
else if (track.trackKind === TrackKind.Video) {
|
|
261
|
+
track.participant.isVideoEnable = true;
|
|
262
|
+
}
|
|
238
263
|
if (this.isStartAndSetupWithServerCalled) {
|
|
239
264
|
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.sendTrack(track);
|
|
240
265
|
}
|