vani-meeting-client 0.4.9 → 0.5.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.d.ts +3 -1
- package/lib/MeetingHandler.js +8 -0
- package/lib/inter-communication-handler/CommunicationHandler.d.ts +1 -0
- package/lib/inter-communication-handler/CommunicationHandler.js +6 -0
- package/lib/user-media-handler/UserMediaHandler.d.ts +3 -0
- package/lib/user-media-handler/UserMediaHandler.js +42 -0
- package/package.json +1 -1
package/lib/MeetingHandler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MeetingStartRequest, VaniEventListener, Device, MessagePayload } from ".";
|
|
2
2
|
import { GetDevicesType } from "./user-media-handler/UserMediaHandler";
|
|
3
|
-
import { Track } from "./model/Track";
|
|
3
|
+
import { Track, TrackKind } from "./model/Track";
|
|
4
4
|
import { TaskResponse } from "./model/TaskResponse";
|
|
5
5
|
import { Participant } from "./model/Participant";
|
|
6
6
|
export declare class MeetingHandler {
|
|
@@ -22,6 +22,8 @@ export declare class MeetingHandler {
|
|
|
22
22
|
muteUser(userId?: string): Promise<TaskResponse>;
|
|
23
23
|
resumeCamera(userId?: string): Promise<TaskResponse>;
|
|
24
24
|
unmute(userId?: string): Promise<TaskResponse>;
|
|
25
|
+
resumeStreamWithoutStopping(streamKind: TrackKind): TaskResponse | undefined;
|
|
26
|
+
pauseStreamWithoutStopping(streamKind: TrackKind): TaskResponse | undefined;
|
|
25
27
|
stopTrack(track: Track): void;
|
|
26
28
|
addCustomTrack(track: Track): void;
|
|
27
29
|
pauseIncomingTrack(track: Track): void;
|
package/lib/MeetingHandler.js
CHANGED
|
@@ -227,6 +227,14 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
+
MeetingHandler.prototype.resumeStreamWithoutStopping = function (streamKind) {
|
|
231
|
+
var _a;
|
|
232
|
+
return (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.resumeStreamWithoutStopping(streamKind);
|
|
233
|
+
};
|
|
234
|
+
MeetingHandler.prototype.pauseStreamWithoutStopping = function (streamKind) {
|
|
235
|
+
var _a;
|
|
236
|
+
return (_a = this.userMediaHandler) === null || _a === void 0 ? void 0 : _a.pauseStreamWithoutStopping(streamKind);
|
|
237
|
+
};
|
|
230
238
|
MeetingHandler.prototype.stopTrack = function (track) {
|
|
231
239
|
var _a;
|
|
232
240
|
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.removeTrack(track);
|
|
@@ -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[];
|
|
@@ -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
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Device } from "..";
|
|
2
2
|
import { Base } from "../base/Base";
|
|
3
3
|
import { TaskResponse } from "../model/TaskResponse";
|
|
4
|
+
import { TrackKind } from "../model/Track";
|
|
4
5
|
export declare enum GetDevicesType {
|
|
5
6
|
AudioIn = "audioinput",
|
|
6
7
|
VideoIn = "videoinput",
|
|
@@ -30,4 +31,6 @@ export declare class UserMediaHandler extends Base {
|
|
|
30
31
|
muteUser(userId?: string): Promise<TaskResponse>;
|
|
31
32
|
resumeCamera(userId?: string): Promise<TaskResponse>;
|
|
32
33
|
unmute(userId?: string): Promise<TaskResponse>;
|
|
34
|
+
pauseStreamWithoutStopping(streamKind: TrackKind): TaskResponse;
|
|
35
|
+
resumeStreamWithoutStopping(streamKind: TrackKind): TaskResponse;
|
|
33
36
|
}
|
|
@@ -669,6 +669,48 @@ var UserMediaHandler = /** @class */ (function (_super) {
|
|
|
669
669
|
});
|
|
670
670
|
});
|
|
671
671
|
};
|
|
672
|
+
UserMediaHandler.prototype.pauseStreamWithoutStopping = function (streamKind) {
|
|
673
|
+
var _a, _b, _c;
|
|
674
|
+
var track = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfTrackByType(streamKind);
|
|
675
|
+
if (track && track.track) {
|
|
676
|
+
track.track.enabled = false;
|
|
677
|
+
if (streamKind === TrackKind.Audio) {
|
|
678
|
+
var data = { userId: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId, type: "audio", status: "pause" };
|
|
679
|
+
var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
|
|
680
|
+
this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
var data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "pause" };
|
|
684
|
+
var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
|
|
685
|
+
this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
|
|
686
|
+
}
|
|
687
|
+
return { message: "Success", error: 'NoError', isSuccess: true };
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
return ({ message: "No Track Found", error: 'NoDevice', isSuccess: false });
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
UserMediaHandler.prototype.resumeStreamWithoutStopping = function (streamKind) {
|
|
694
|
+
var _a, _b, _c;
|
|
695
|
+
var track = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfTrackByType(streamKind);
|
|
696
|
+
if (track && track.track) {
|
|
697
|
+
track.track.enabled = true;
|
|
698
|
+
if (streamKind === TrackKind.Audio) {
|
|
699
|
+
var data = { userId: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.userId, type: "audio", status: "resume" };
|
|
700
|
+
var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
|
|
701
|
+
this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
var data = { userId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.userId, type: "video", status: "resume" };
|
|
705
|
+
var audioPause = { message: data, type: WebSocketBasicEvents.AudioVideoPauseResume };
|
|
706
|
+
this.communicationHandler.sendWebSocketMessage(WebSocketBasicEvents.AudioVideoPauseResume, audioPause);
|
|
707
|
+
}
|
|
708
|
+
return { message: "Success", error: 'NoError', isSuccess: true };
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
return ({ message: "No Track Found", error: 'NoDevice', isSuccess: false });
|
|
712
|
+
}
|
|
713
|
+
};
|
|
672
714
|
return UserMediaHandler;
|
|
673
715
|
}(Base));
|
|
674
716
|
export { UserMediaHandler };
|