vani-meeting-client-native 0.3.4 → 0.3.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.
- package/lib/inter-communication-handler/CommunicationHandler.d.ts +1 -0
- package/lib/inter-communication-handler/CommunicationHandler.js +13 -0
- package/lib/model/Participant.d.ts +2 -1
- package/lib/model/Participant.js +7 -2
- package/lib/utility/DynamicLibHelper.js +4 -1
- package/lib/utility/DynamicLibHelper.native.js +4 -1
- package/lib/utility/DynamicLibHelper.node.js +6 -1
- package/lib/video-call-handler/BaseVideoCallHandler.d.ts +1 -0
- package/lib/video-call-handler/BaseVideoCallHandler.js +7 -0
- package/lib/video-call-handler/WebrtcHandler.d.ts +11 -0
- package/lib/video-call-handler/WebrtcHandler.js +176 -33
- package/lib/websocket-handler/WebsocketHandler.d.ts +2 -0
- package/lib/websocket-handler/WebsocketHandler.js +19 -14
- package/package.json +1 -1
|
@@ -32,6 +32,7 @@ export declare class CommunicationHandler {
|
|
|
32
32
|
onServerParticipants(data: any): void;
|
|
33
33
|
getAllParticipants(): Participant[];
|
|
34
34
|
participantByUserId(userId: string): Participant | undefined;
|
|
35
|
+
onStartParticipantMeetingCalled: (participantData: any) => Promise<void>;
|
|
35
36
|
addParticipantIfNotExist(participant: Participant, shouldInfrom?: boolean): Participant | undefined;
|
|
36
37
|
removeParticipant(participant: Participant, shouldInfrom?: boolean): void;
|
|
37
38
|
onUserLeft(data: any): void;
|
|
@@ -58,6 +58,19 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
58
58
|
return [2 /*return*/];
|
|
59
59
|
});
|
|
60
60
|
}); };
|
|
61
|
+
this.onStartParticipantMeetingCalled = function (participantData) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
var participant;
|
|
63
|
+
var _a;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
if (participantData && participantData.userId && participantData.userId !== this.getSelfParticipant().userId) {
|
|
66
|
+
participant = this.addParticipantIfNotExist(participantData, true);
|
|
67
|
+
participant.isStartMeetingCalled = true;
|
|
68
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("onStartParticipantMeetingCalled", participant);
|
|
69
|
+
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantStartMeetingCalled(participant);
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
});
|
|
73
|
+
}); };
|
|
61
74
|
this.requestToCloseTheRoom = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
62
75
|
var _a;
|
|
63
76
|
return __generator(this, function (_b) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MeetingStartRequest } from "./MeetingStartRequest";
|
|
1
2
|
import { PeerConnection } from "./PeerConnection";
|
|
2
3
|
export declare class Participant {
|
|
3
4
|
userId: string;
|
|
@@ -15,6 +16,6 @@ export declare class Participant {
|
|
|
15
16
|
isRecordingUser: boolean;
|
|
16
17
|
private peerConnections;
|
|
17
18
|
getPeerConnections: () => Map<string, PeerConnection>;
|
|
18
|
-
getPeerConnectionsViaUserId: (userId: string) => PeerConnection;
|
|
19
|
+
getPeerConnectionsViaUserId: (userId: string, meetingStartRequest: MeetingStartRequest) => PeerConnection;
|
|
19
20
|
constructor(_userId: string, _roomId: string, _userData?: any, _isAdmin?: boolean);
|
|
20
21
|
}
|
package/lib/model/Participant.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DynamicLibHelper } from "../utility/DynamicLibHelper";
|
|
1
2
|
import { PeerConnection } from "./PeerConnection";
|
|
2
3
|
var Participant = /** @class */ (function () {
|
|
3
4
|
function Participant(_userId, _roomId, _userData, _isAdmin) {
|
|
@@ -21,9 +22,13 @@ var Participant = /** @class */ (function () {
|
|
|
21
22
|
}
|
|
22
23
|
return _this.peerConnections;
|
|
23
24
|
};
|
|
24
|
-
this.getPeerConnectionsViaUserId = function (userId) {
|
|
25
|
+
this.getPeerConnectionsViaUserId = function (userId, meetingStartRequest) {
|
|
25
26
|
if (!_this.getPeerConnections().has(userId)) {
|
|
26
|
-
|
|
27
|
+
var peerConnection = new PeerConnection();
|
|
28
|
+
if (!peerConnection.rtcPeerConnection) {
|
|
29
|
+
peerConnection.rtcPeerConnection = new DynamicLibHelper().getRTCPeerConnection(meetingStartRequest);
|
|
30
|
+
}
|
|
31
|
+
_this.getPeerConnections().set(userId, peerConnection);
|
|
27
32
|
}
|
|
28
33
|
return _this.getPeerConnections().get(userId);
|
|
29
34
|
};
|
|
@@ -104,7 +104,10 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
104
104
|
};
|
|
105
105
|
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
106
106
|
try {
|
|
107
|
-
if (meetingStartRequest
|
|
107
|
+
if (meetingStartRequest && meetingStartRequest.iceServers) {
|
|
108
|
+
return new (require("react-native-webrtc").RTCPeerConnection)({ iceServers: meetingStartRequest.iceServers });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
108
111
|
return new (require("react-native-webrtc").RTCPeerConnection)();
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -104,7 +104,10 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
104
104
|
};
|
|
105
105
|
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
106
106
|
try {
|
|
107
|
-
if (meetingStartRequest
|
|
107
|
+
if (meetingStartRequest && meetingStartRequest.iceServers) {
|
|
108
|
+
return new (require("react-native-webrtc").RTCPeerConnection)({ iceServers: meetingStartRequest.iceServers });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
108
111
|
return new (require("react-native-webrtc").RTCPeerConnection)();
|
|
109
112
|
}
|
|
110
113
|
}
|
|
@@ -104,7 +104,12 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
104
104
|
return MediaStream;
|
|
105
105
|
};
|
|
106
106
|
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
107
|
-
|
|
107
|
+
if (meetingStartRequest && meetingStartRequest.iceServers) {
|
|
108
|
+
return new RTCPeerConnection({ iceServers: meetingStartRequest.iceServers });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return new RTCPeerConnection();
|
|
112
|
+
}
|
|
108
113
|
};
|
|
109
114
|
return DynamicLibHelper;
|
|
110
115
|
}());
|
|
@@ -18,6 +18,7 @@ export declare abstract class BaseVideoCallHandler extends Base {
|
|
|
18
18
|
abstract createDataChannel(): any;
|
|
19
19
|
abstract sendMessageViaDataChannel(messagePayload: any): any;
|
|
20
20
|
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
21
|
+
onParticipantStartMeetingCalled(participants: Participant): Promise<void>;
|
|
21
22
|
onUserJoined(participants: Participant): Promise<void>;
|
|
22
23
|
onUserLeft(participants: Participant): Promise<void>;
|
|
23
24
|
getConsumerForTrack(track: Track): void;
|
|
@@ -75,6 +75,13 @@ var BaseVideoCallHandler = /** @class */ (function (_super) {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
|
+
BaseVideoCallHandler.prototype.onParticipantStartMeetingCalled = function (participants) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
78
85
|
BaseVideoCallHandler.prototype.onUserJoined = function (participants) {
|
|
79
86
|
return __awaiter(this, void 0, void 0, function () {
|
|
80
87
|
return __generator(this, function (_a) {
|
|
@@ -5,9 +5,11 @@ import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
|
5
5
|
export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
6
6
|
private dynamicLibHelper;
|
|
7
7
|
onParticipantUpdated(): void;
|
|
8
|
+
onParticipantStartMeetingCalled(participant: Participant): Promise<void>;
|
|
8
9
|
resumeIncomingTrack(track: Track): void;
|
|
9
10
|
pauseIncomingTrack(track: Track): void;
|
|
10
11
|
onSocketMessage(websocketCallHandler: WebSocketMessageBody): void;
|
|
12
|
+
private checkIfCanSendOffer;
|
|
11
13
|
onNewOffer: (data: {
|
|
12
14
|
sdp: string;
|
|
13
15
|
type: string;
|
|
@@ -18,8 +20,16 @@ export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
|
18
20
|
type: string;
|
|
19
21
|
sender: Participant;
|
|
20
22
|
}) => Promise<void>;
|
|
23
|
+
onIceCandidate: (data: {
|
|
24
|
+
candidate: any;
|
|
25
|
+
type: string;
|
|
26
|
+
sender: Participant;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
subToConnectionState: (remoteParticipant: Participant) => Promise<void>;
|
|
21
29
|
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
22
30
|
onUserJoined(participant: Participant): Promise<void>;
|
|
31
|
+
startSendTrackToPartiipant: (participant: Participant) => Promise<void>;
|
|
32
|
+
sendTrackToParticipant: (track: Track, participant: Participant) => Promise<void>;
|
|
23
33
|
private sendWebrtcMessage;
|
|
24
34
|
init(): Promise<void>;
|
|
25
35
|
onReconnect(): Promise<void>;
|
|
@@ -30,4 +40,5 @@ export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
|
30
40
|
createDataChannel(): Promise<void>;
|
|
31
41
|
sendMessageViaDataChannel(messagePayload: any): void;
|
|
32
42
|
private isOfferInitParticipant;
|
|
43
|
+
private printLogIfRequired;
|
|
33
44
|
}
|
|
@@ -49,6 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
import { Track } from "../model/Track";
|
|
52
53
|
import { WebrtcMessageType } from "../websocket-handler/WebsocketHandler";
|
|
53
54
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
54
55
|
import log from 'loglevel';
|
|
@@ -59,6 +60,37 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
59
60
|
function WebrtcHandler() {
|
|
60
61
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
61
62
|
_this.dynamicLibHelper = (new DynamicLibHelper());
|
|
63
|
+
_this.checkIfCanSendOffer = function (participant) { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
+
var selfParticpant, isOfferInitParticipant, peerConnectionObject, peerConnection, offer, messageJson;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
69
|
+
console.log(selfParticpant);
|
|
70
|
+
if (!(selfParticpant.userId !== participant.userId && !selfParticpant.getPeerConnections().has(participant.userId))) return [3 /*break*/, 2];
|
|
71
|
+
isOfferInitParticipant = this.isOfferInitParticipant(participant);
|
|
72
|
+
if (!!isOfferInitParticipant) return [3 /*break*/, 2];
|
|
73
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
74
|
+
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
75
|
+
if (!peerConnection) return [3 /*break*/, 2];
|
|
76
|
+
this.subToConnectionState(participant);
|
|
77
|
+
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
78
|
+
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
79
|
+
return [4 /*yield*/, peerConnection.createOffer()];
|
|
80
|
+
case 1:
|
|
81
|
+
offer = _a.sent();
|
|
82
|
+
peerConnection.setLocalDescription(offer);
|
|
83
|
+
peerConnectionObject.offer = offer;
|
|
84
|
+
peerConnectionObject.rtcPeerConnection = peerConnection;
|
|
85
|
+
// send offer to peer
|
|
86
|
+
console.log("offer", offer);
|
|
87
|
+
messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: offer };
|
|
88
|
+
this.sendWebrtcMessage(messageJson);
|
|
89
|
+
_a.label = 2;
|
|
90
|
+
case 2: return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); };
|
|
62
94
|
_this.onNewOffer = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
63
95
|
var selfParticpant, participant, peerConnectionObject, peerConnection, answer, messageJson;
|
|
64
96
|
return __generator(this, function (_a) {
|
|
@@ -66,12 +98,13 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
66
98
|
case 0:
|
|
67
99
|
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
68
100
|
participant = data.sender;
|
|
69
|
-
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
101
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
70
102
|
if (peerConnectionObject) {
|
|
71
103
|
peerConnectionObject.remoteOffer = data.sdp;
|
|
72
104
|
}
|
|
73
105
|
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
74
106
|
if (!peerConnection) return [3 /*break*/, 2];
|
|
107
|
+
this.subToConnectionState(participant);
|
|
75
108
|
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
76
109
|
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
77
110
|
peerConnection.setRemoteDescription({ type: 'offer', sdp: peerConnectionObject.remoteOffer });
|
|
@@ -94,7 +127,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
94
127
|
return __generator(this, function (_a) {
|
|
95
128
|
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
96
129
|
participant = data.sender;
|
|
97
|
-
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
130
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
98
131
|
if (peerConnectionObject) {
|
|
99
132
|
peerConnectionObject.remoteAnswer = data.sdp;
|
|
100
133
|
}
|
|
@@ -105,6 +138,95 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
105
138
|
return [2 /*return*/];
|
|
106
139
|
});
|
|
107
140
|
}); };
|
|
141
|
+
_this.onIceCandidate = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
142
|
+
var selfParticpant, participant, peerConnectionObject, rtcConnection, rtcCandidate;
|
|
143
|
+
return __generator(this, function (_a) {
|
|
144
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
145
|
+
participant = data.sender;
|
|
146
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
147
|
+
rtcConnection = peerConnectionObject.rtcPeerConnection;
|
|
148
|
+
if (rtcConnection) {
|
|
149
|
+
this.printLogIfRequired("on ice candidate", data.candidate);
|
|
150
|
+
rtcCandidate = new RTCIceCandidate({
|
|
151
|
+
candidate: data.candidate.candidate,
|
|
152
|
+
sdpMid: data.candidate.sdpMid,
|
|
153
|
+
sdpMLineIndex: data.candidate.sdpMLineIndex, // don't make it up, you get this in onicecandidate
|
|
154
|
+
});
|
|
155
|
+
rtcConnection.addIceCandidate(rtcCandidate);
|
|
156
|
+
}
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
});
|
|
159
|
+
}); };
|
|
160
|
+
_this.subToConnectionState = function (remoteParticipant) { return __awaiter(_this, void 0, void 0, function () {
|
|
161
|
+
var selfParticpant, peerConnectionObject, rtcConnection;
|
|
162
|
+
var _this = this;
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
165
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId, this.meetingStartRequest);
|
|
166
|
+
rtcConnection = peerConnectionObject.rtcPeerConnection;
|
|
167
|
+
rtcConnection.addEventListener('icecandidate', function (event) {
|
|
168
|
+
if (event.candidate && event.candidate !== null) {
|
|
169
|
+
_this.printLogIfRequired("icecandidate", event.candidate, remoteParticipant);
|
|
170
|
+
var sdpMid = event.candidate.sdpMid;
|
|
171
|
+
var sdpMLineIndex = event.candidate.sdpMLineIndex;
|
|
172
|
+
var messageJson = { to: remoteParticipant.userId, type: WebrtcMessageType.IceCandidate,
|
|
173
|
+
data: { sdpMid: sdpMid, sdpMLineIndex: sdpMLineIndex, candidate: event.candidate } };
|
|
174
|
+
_this.sendWebrtcMessage(messageJson);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
rtcConnection.addEventListener('iceconnectionstatechange', function (event) {
|
|
178
|
+
_this.printLogIfRequired("iceconnectionstatechange", event, remoteParticipant);
|
|
179
|
+
});
|
|
180
|
+
rtcConnection.addEventListener('connectionstatechange', function (event) {
|
|
181
|
+
if (rtcConnection.connectionState === 'connected') {
|
|
182
|
+
_this.printLogIfRequired("On Connection Change", event, remoteParticipant);
|
|
183
|
+
_this.startSendTrackToPartiipant(remoteParticipant);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
rtcConnection.addEventListener("track", function (onRemoteTrack) {
|
|
187
|
+
var _a, _b;
|
|
188
|
+
if (onRemoteTrack.streams && onRemoteTrack.streams.length > 0) {
|
|
189
|
+
var mediaStream = onRemoteTrack.streams.at(0);
|
|
190
|
+
if (mediaStream.getTracks() && mediaStream.getTracks().length > 0) {
|
|
191
|
+
var streamTrack = mediaStream.getTracks().at(0);
|
|
192
|
+
var track = new Track(remoteParticipant, false, streamTrack.kind, streamTrack);
|
|
193
|
+
(_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.addUpdateRemoteTrack(track, remoteParticipant, true);
|
|
194
|
+
_this.printLogIfRequired("New Remote Track", track);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (onRemoteTrack.track) {
|
|
198
|
+
var streamTrack = onRemoteTrack.track;
|
|
199
|
+
var track = new Track(remoteParticipant, false, streamTrack.kind, streamTrack);
|
|
200
|
+
(_b = _this.communicationHandler) === null || _b === void 0 ? void 0 : _b.addUpdateRemoteTrack(track, remoteParticipant, true);
|
|
201
|
+
_this.printLogIfRequired("New Remote Track", track);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
});
|
|
206
|
+
}); };
|
|
207
|
+
_this.startSendTrackToPartiipant = function (participant) { return __awaiter(_this, void 0, void 0, function () {
|
|
208
|
+
var _this = this;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
this.communicationHandler.getAllSelfTracks().forEach(function (eachTrack) {
|
|
211
|
+
_this.sendTrackToParticipant(eachTrack, participant);
|
|
212
|
+
});
|
|
213
|
+
return [2 /*return*/];
|
|
214
|
+
});
|
|
215
|
+
}); };
|
|
216
|
+
_this.sendTrackToParticipant = function (track, participant) { return __awaiter(_this, void 0, void 0, function () {
|
|
217
|
+
var selfParticpant, peerConnection;
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
220
|
+
if (selfParticpant) {
|
|
221
|
+
peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
|
|
222
|
+
if (peerConnection && peerConnection.rtcPeerConnection) {
|
|
223
|
+
this.printLogIfRequired("Send Track");
|
|
224
|
+
peerConnection.rtcPeerConnection.addTrack(track.track);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return [2 /*return*/];
|
|
228
|
+
});
|
|
229
|
+
}); };
|
|
108
230
|
_this.sendWebrtcMessage = function (data) {
|
|
109
231
|
_this.communicationHandler.sendWebSocketMessage(WebrtcMessageType.WebrtcMessage, data);
|
|
110
232
|
};
|
|
@@ -115,16 +237,41 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
115
237
|
}
|
|
116
238
|
return false;
|
|
117
239
|
};
|
|
240
|
+
_this.printLogIfRequired = function (message) {
|
|
241
|
+
var optionalParams = [];
|
|
242
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
243
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
244
|
+
}
|
|
245
|
+
if (optionalParams && optionalParams.length > 0) {
|
|
246
|
+
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(message, optionalParams);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(message);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
118
252
|
return _this;
|
|
119
253
|
}
|
|
120
254
|
WebrtcHandler.prototype.onParticipantUpdated = function () {
|
|
121
255
|
console.log("onParticipantUpdated");
|
|
122
256
|
// throw new Error("Method not implemented.");
|
|
123
257
|
};
|
|
258
|
+
WebrtcHandler.prototype.onParticipantStartMeetingCalled = function (participant) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
this.onUserJoined(participant);
|
|
262
|
+
return [2 /*return*/];
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
};
|
|
124
266
|
WebrtcHandler.prototype.resumeIncomingTrack = function (track) {
|
|
125
|
-
|
|
267
|
+
if (track.track) {
|
|
268
|
+
track.track.enabled = true;
|
|
269
|
+
}
|
|
126
270
|
};
|
|
127
271
|
WebrtcHandler.prototype.pauseIncomingTrack = function (track) {
|
|
272
|
+
if (track.track) {
|
|
273
|
+
track.track.enabled = false;
|
|
274
|
+
}
|
|
128
275
|
// throw new Error("Method not implemented.");
|
|
129
276
|
};
|
|
130
277
|
WebrtcHandler.prototype.onSocketMessage = function (websocketCallHandler) {
|
|
@@ -149,56 +296,44 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
149
296
|
else if (websocketCallHandler.type === WebrtcMessageType.SendAnswer) {
|
|
150
297
|
this.onNewAnswer(data);
|
|
151
298
|
}
|
|
299
|
+
else if (websocketCallHandler.type === WebrtcMessageType.IceCandidate) {
|
|
300
|
+
this.onIceCandidate(data);
|
|
301
|
+
}
|
|
152
302
|
// throw new Error("Method not implemented.");
|
|
153
303
|
};
|
|
154
304
|
WebrtcHandler.prototype.onAllParticipants = function (participants) {
|
|
155
305
|
return __awaiter(this, void 0, void 0, function () {
|
|
306
|
+
var selfParticpant;
|
|
156
307
|
var _this = this;
|
|
157
308
|
return __generator(this, function (_a) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
309
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
310
|
+
if (selfParticpant.isStartMeetingCalled) {
|
|
311
|
+
participants.forEach(function (eachParticiapant) {
|
|
312
|
+
_this.onUserJoined(eachParticiapant);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
161
315
|
return [2 /*return*/];
|
|
162
316
|
});
|
|
163
317
|
});
|
|
164
318
|
};
|
|
165
319
|
WebrtcHandler.prototype.onUserJoined = function (participant) {
|
|
166
320
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var selfParticpant, isOfferInitParticipant, peerConnectionObject, peerConnection, offer, messageJson;
|
|
168
321
|
return __generator(this, function (_a) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
172
|
-
console.log(selfParticpant);
|
|
173
|
-
if (!(selfParticpant.userId !== participant.userId && !selfParticpant.getPeerConnections().has(participant.userId))) return [3 /*break*/, 2];
|
|
174
|
-
console.log("onUserJoined ", participant);
|
|
175
|
-
isOfferInitParticipant = this.isOfferInitParticipant(participant);
|
|
176
|
-
if (!!isOfferInitParticipant) return [3 /*break*/, 2];
|
|
177
|
-
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
178
|
-
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
179
|
-
if (!peerConnection) return [3 /*break*/, 2];
|
|
180
|
-
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
181
|
-
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
182
|
-
return [4 /*yield*/, peerConnection.createOffer()];
|
|
183
|
-
case 1:
|
|
184
|
-
offer = _a.sent();
|
|
185
|
-
peerConnection.setLocalDescription(offer);
|
|
186
|
-
peerConnectionObject.offer = offer;
|
|
187
|
-
peerConnectionObject.rtcPeerConnection = peerConnection;
|
|
188
|
-
// send offer to peer
|
|
189
|
-
console.log("offer", offer);
|
|
190
|
-
messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: offer };
|
|
191
|
-
this.sendWebrtcMessage(messageJson);
|
|
192
|
-
_a.label = 2;
|
|
193
|
-
case 2: return [2 /*return*/];
|
|
322
|
+
if (participant.isStartMeetingCalled) {
|
|
323
|
+
this.checkIfCanSendOffer(participant);
|
|
194
324
|
}
|
|
325
|
+
return [2 /*return*/];
|
|
195
326
|
});
|
|
196
327
|
});
|
|
197
328
|
};
|
|
198
329
|
WebrtcHandler.prototype.init = function () {
|
|
199
330
|
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var _this = this;
|
|
200
332
|
return __generator(this, function (_a) {
|
|
201
333
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("Webrtc Init");
|
|
334
|
+
this.communicationHandler.getAllParticipants().forEach(function (eachParticiapant) {
|
|
335
|
+
_this.onUserJoined(eachParticiapant);
|
|
336
|
+
});
|
|
202
337
|
return [2 /*return*/];
|
|
203
338
|
});
|
|
204
339
|
});
|
|
@@ -207,16 +342,24 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
207
342
|
throw new Error("Method not implemented.");
|
|
208
343
|
};
|
|
209
344
|
WebrtcHandler.prototype.stopTrack = function (track) {
|
|
345
|
+
if (track.track) {
|
|
346
|
+
track.track.enabled = false;
|
|
347
|
+
}
|
|
210
348
|
// throw new Error("Method not implemented.");
|
|
211
349
|
};
|
|
212
350
|
WebrtcHandler.prototype.pauseTrack = function (track) {
|
|
351
|
+
if (track.track) {
|
|
352
|
+
track.track.enabled = false;
|
|
353
|
+
}
|
|
213
354
|
// throw new Error("Method not implemented.");
|
|
214
355
|
};
|
|
215
356
|
WebrtcHandler.prototype.resumeTrack = function (track) {
|
|
357
|
+
if (track.track) {
|
|
358
|
+
track.track.enabled = true;
|
|
359
|
+
}
|
|
216
360
|
// throw new Error("Method not implemented.");
|
|
217
361
|
};
|
|
218
362
|
WebrtcHandler.prototype.sendTrack = function (track) {
|
|
219
|
-
// throw new Error("Method not implemented.");
|
|
220
363
|
};
|
|
221
364
|
WebrtcHandler.prototype.createDataChannel = function () {
|
|
222
365
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -8,6 +8,7 @@ export declare enum WebSocketBasicEvents {
|
|
|
8
8
|
CloseRoomForceFully = "CloseRoomForceFully",
|
|
9
9
|
AudioVideoPauseResume = "audioVideoPauseResume",
|
|
10
10
|
OnStartMeetingCalled = "startMeetingCalled",
|
|
11
|
+
OnStartParticipantMeetingCalled = "OnStartParticipantMeetingCalled",
|
|
11
12
|
OnAudioVideoPauseResume = "audioVideoPauseResume",
|
|
12
13
|
OnAudioVideoStatusUpdated = "audioVideoStatusUpdated",
|
|
13
14
|
OnAudioUnblockRequest = "audioUnblock",
|
|
@@ -32,6 +33,7 @@ export declare enum WebSocketBasicEvents {
|
|
|
32
33
|
}
|
|
33
34
|
export declare enum WebrtcMessageType {
|
|
34
35
|
SendOffer = "SendOffer",
|
|
36
|
+
IceCandidate = "IceCandidate",
|
|
35
37
|
WebrtcMessage = "WebrtcMessage",
|
|
36
38
|
SendAnswer = "SendAnswer"
|
|
37
39
|
}
|
|
@@ -63,6 +63,7 @@ export var WebSocketBasicEvents;
|
|
|
63
63
|
WebSocketBasicEvents["CloseRoomForceFully"] = "CloseRoomForceFully";
|
|
64
64
|
WebSocketBasicEvents["AudioVideoPauseResume"] = "audioVideoPauseResume";
|
|
65
65
|
WebSocketBasicEvents["OnStartMeetingCalled"] = "startMeetingCalled";
|
|
66
|
+
WebSocketBasicEvents["OnStartParticipantMeetingCalled"] = "OnStartParticipantMeetingCalled";
|
|
66
67
|
WebSocketBasicEvents["OnAudioVideoPauseResume"] = "audioVideoPauseResume";
|
|
67
68
|
WebSocketBasicEvents["OnAudioVideoStatusUpdated"] = "audioVideoStatusUpdated";
|
|
68
69
|
WebSocketBasicEvents["OnAudioUnblockRequest"] = "audioUnblock";
|
|
@@ -88,6 +89,7 @@ export var WebSocketBasicEvents;
|
|
|
88
89
|
export var WebrtcMessageType;
|
|
89
90
|
(function (WebrtcMessageType) {
|
|
90
91
|
WebrtcMessageType["SendOffer"] = "SendOffer";
|
|
92
|
+
WebrtcMessageType["IceCandidate"] = "IceCandidate";
|
|
91
93
|
WebrtcMessageType["WebrtcMessage"] = "WebrtcMessage";
|
|
92
94
|
WebrtcMessageType["SendAnswer"] = "SendAnswer";
|
|
93
95
|
})(WebrtcMessageType || (WebrtcMessageType = {}));
|
|
@@ -485,7 +487,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
485
487
|
}, 300);
|
|
486
488
|
};
|
|
487
489
|
WebsocketHandler.prototype.onMessage = function (message) {
|
|
488
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
490
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
489
491
|
this.lastPingTimeStamp = new Date().getTime();
|
|
490
492
|
// this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("lastPingTimeStamp time ", this.lastPingTimeStamp)
|
|
491
493
|
var messagejson = JSON.parse(message);
|
|
@@ -505,36 +507,39 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
505
507
|
else if (type === WebSocketBasicEvents.IsSetupDone) {
|
|
506
508
|
this.onSetupDone(data);
|
|
507
509
|
}
|
|
510
|
+
else if (type === WebSocketBasicEvents.OnStartParticipantMeetingCalled) {
|
|
511
|
+
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.onStartParticipantMeetingCalled((_d = data === null || data === void 0 ? void 0 : data.message) === null || _d === void 0 ? void 0 : _d.participant);
|
|
512
|
+
}
|
|
508
513
|
else if (type === WebSocketBasicEvents.CloseRoomForceFully) {
|
|
509
514
|
this.onCloseTheRoomForcefully(data);
|
|
510
515
|
}
|
|
511
516
|
else if (type === WebSocketBasicEvents.OnUserOnFoundWhileReconnect) {
|
|
512
|
-
(
|
|
517
|
+
(_e = this.communicationHandler) === null || _e === void 0 ? void 0 : _e.emitMessageToSource(VaniEvent.OnUserOnFoundWhileReconnect, {});
|
|
513
518
|
}
|
|
514
519
|
else if (type === WebSocketBasicEvents.OnNewJoinee || type === WebSocketBasicEvents.OnRejoined) {
|
|
515
520
|
if (data && data.message && data.message.participant) {
|
|
516
521
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("OnParticipantUpdated from server", data.message.participant);
|
|
517
|
-
(
|
|
522
|
+
(_f = this.communicationHandler) === null || _f === void 0 ? void 0 : _f.addParticipantIfNotExist(data.message.participant, true);
|
|
518
523
|
}
|
|
519
524
|
}
|
|
520
525
|
else if (type === WebSocketBasicEvents.OnParticipantUpdated) {
|
|
521
526
|
if (data) {
|
|
522
527
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("WebSocketBasicEvents.OnParticipantUpdated", data.message);
|
|
523
|
-
(
|
|
528
|
+
(_g = this.communicationHandler) === null || _g === void 0 ? void 0 : _g.addParticipantIfNotExist(data.message, true);
|
|
524
529
|
}
|
|
525
530
|
}
|
|
526
531
|
else if (type === WebSocketBasicEvents.OnUserLeft) {
|
|
527
|
-
(
|
|
532
|
+
(_h = this.communicationHandler) === null || _h === void 0 ? void 0 : _h.onUserLeft(data);
|
|
528
533
|
}
|
|
529
534
|
else if (type === WebSocketBasicEvents.OnServerParticipants) {
|
|
530
|
-
(
|
|
535
|
+
(_j = this.communicationHandler) === null || _j === void 0 ? void 0 : _j.onServerParticipants(data);
|
|
531
536
|
}
|
|
532
537
|
else if (type === WebSocketBasicEvents.OnOldMessages) {
|
|
533
|
-
(
|
|
538
|
+
(_k = this.communicationHandler) === null || _k === void 0 ? void 0 : _k.onOldMessages(data);
|
|
534
539
|
}
|
|
535
540
|
else if (type === WebSocketBasicEvents.OnChat) {
|
|
536
541
|
if (data.message) {
|
|
537
|
-
(
|
|
542
|
+
(_l = this.communicationHandler) === null || _l === void 0 ? void 0 : _l.onMessage(data.message);
|
|
538
543
|
}
|
|
539
544
|
}
|
|
540
545
|
else if (type === WebSocketBasicEvents.OnMeetingStartTime) {
|
|
@@ -543,23 +548,23 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
543
548
|
if (time > new Date().getTime()) {
|
|
544
549
|
time = new Date().getTime();
|
|
545
550
|
}
|
|
546
|
-
(
|
|
551
|
+
(_m = this.communicationHandler) === null || _m === void 0 ? void 0 : _m.emitMessageToSource(VaniEvent.OnMeetingStartTime, (time + ""));
|
|
547
552
|
}
|
|
548
553
|
}
|
|
549
554
|
else if (type === WebSocketBasicEvents.OnAudioVideoStatusUpdated) {
|
|
550
|
-
(
|
|
555
|
+
(_o = this.communicationHandler) === null || _o === void 0 ? void 0 : _o.onAudioVideoStatusUpdated(data);
|
|
551
556
|
}
|
|
552
557
|
else if (type === WebSocketBasicEvents.OnAudioBlockRequest) {
|
|
553
|
-
(
|
|
558
|
+
(_p = this.communicationHandler) === null || _p === void 0 ? void 0 : _p.onAudioBlocked(data);
|
|
554
559
|
}
|
|
555
560
|
else if (type === WebSocketBasicEvents.OnAudioUnblockRequest) {
|
|
556
|
-
(
|
|
561
|
+
(_q = this.communicationHandler) === null || _q === void 0 ? void 0 : _q.onAudioUnblocked(data);
|
|
557
562
|
}
|
|
558
563
|
else if (type === WebSocketBasicEvents.OnVideoBlockRequest) {
|
|
559
|
-
(
|
|
564
|
+
(_r = this.communicationHandler) === null || _r === void 0 ? void 0 : _r.onVideoBlocked(data);
|
|
560
565
|
}
|
|
561
566
|
else if (type === WebSocketBasicEvents.OnVideoUnblockRequest) {
|
|
562
|
-
(
|
|
567
|
+
(_s = this.communicationHandler) === null || _s === void 0 ? void 0 : _s.onVideoUnblocked(data);
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
};
|