vani-meeting-client 0.4.8 → 0.5.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.
|
@@ -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";
|
|
@@ -138,10 +138,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
138
138
|
if (shouldInfrom) {
|
|
139
139
|
this.emitMessageToSource(VaniEvent.OnParticipantDataUpdated, oldParticipant);
|
|
140
140
|
}
|
|
141
|
+
this.updateParticipantAudioVideoDataAccordingToTrack(oldParticipant);
|
|
141
142
|
return oldParticipant;
|
|
142
143
|
}
|
|
143
144
|
else {
|
|
144
145
|
participant = Object.assign(new Participant(participant.userId, participant.roomId, participant.userData, participant.isAdmin), participant);
|
|
146
|
+
this.updateParticipantAudioVideoDataAccordingToTrack(participant);
|
|
145
147
|
this.allParticipants.push(participant);
|
|
146
148
|
if (shouldInfrom) {
|
|
147
149
|
this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
|
|
@@ -174,6 +176,10 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
};
|
|
179
|
+
CommunicationHandler.prototype.updateParticipantAudioVideoDataAccordingToTrack = function (participant) {
|
|
180
|
+
participant.isAudioEnable = this.getAllTracks().find(function (track) { return (track.trackKind === TrackKind.Audio && track.participant.userId === participant.userId); }) ? true : false;
|
|
181
|
+
participant.isVideoEnable = this.getAllTracks().find(function (track) { return (track.trackKind === TrackKind.Video && track.participant.userId === participant.userId); }) ? true : false;
|
|
182
|
+
};
|
|
177
183
|
CommunicationHandler.prototype.getSelfTrackByType = function (trackKind) {
|
|
178
184
|
return this.selfTracks.find(function (track) { return track.trackKind === trackKind; });
|
|
179
185
|
};
|
|
@@ -195,6 +201,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
195
201
|
CommunicationHandler.prototype.removeTrack = function (track, shouldInfromVideoController) {
|
|
196
202
|
var _a;
|
|
197
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
|
+
}
|
|
198
210
|
if (shouldInfromVideoController && this.isStartAndSetupWithServerCalled && track.isLocalTrack) {
|
|
199
211
|
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.stopTrack(track);
|
|
200
212
|
}
|
|
@@ -215,6 +227,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
215
227
|
this.allTracks.push(track);
|
|
216
228
|
}
|
|
217
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
|
+
}
|
|
218
236
|
if (shouldInfromIfNotExist) {
|
|
219
237
|
log.info("emitMessageToSource");
|
|
220
238
|
this.emitMessageToSource(VaniEvent.OnTrack, track);
|
|
@@ -236,6 +254,12 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
236
254
|
this.allTracks.push(track);
|
|
237
255
|
this.selfTracks.push(track);
|
|
238
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
|
+
}
|
|
239
263
|
if (this.isStartAndSetupWithServerCalled) {
|
|
240
264
|
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.sendTrack(track);
|
|
241
265
|
}
|