vani-meeting-client 2.2.5 → 2.2.7

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.
@@ -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
  }
@@ -22,11 +22,11 @@ var Participant = /** @class */ (function () {
22
22
  }
23
23
  return _this.peerConnections;
24
24
  };
25
- this.getPeerConnectionsViaUserId = function (userId) {
25
+ this.getPeerConnectionsViaUserId = function (userId, meetingStartRequest) {
26
26
  if (!_this.getPeerConnections().has(userId)) {
27
27
  var peerConnection = new PeerConnection();
28
28
  if (!peerConnection.rtcPeerConnection) {
29
- peerConnection.rtcPeerConnection = new DynamicLibHelper().getRTCPeerConnection();
29
+ peerConnection.rtcPeerConnection = new DynamicLibHelper().getRTCPeerConnection(meetingStartRequest);
30
30
  }
31
31
  _this.getPeerConnections().set(userId, peerConnection);
32
32
  }
@@ -1,7 +1,5 @@
1
- import { DynamicLibHelper } from "../utility/DynamicLibHelper";
2
1
  var PeerConnection = /** @class */ (function () {
3
2
  function PeerConnection() {
4
- this.rtcPeerConnection = new DynamicLibHelper().getRTCPeerConnection();
5
3
  }
6
4
  return PeerConnection;
7
5
  }());
@@ -5,5 +5,5 @@ export declare class DynamicLibHelper {
5
5
  getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
6
6
  getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
7
7
  getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
8
- getRTCPeerConnection(): any;
8
+ getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
9
9
  }
@@ -103,8 +103,13 @@ var DynamicLibHelper = /** @class */ (function () {
103
103
  }
104
104
  return MediaStream;
105
105
  };
106
- DynamicLibHelper.prototype.getRTCPeerConnection = function () {
107
- return new RTCPeerConnection();
106
+ DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
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
  }());
@@ -5,5 +5,5 @@ export declare class DynamicLibHelper {
5
5
  getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
6
6
  getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
7
7
  getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
8
- getRTCPeerConnection(): any;
8
+ getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
9
9
  }
@@ -102,9 +102,14 @@ var DynamicLibHelper = /** @class */ (function () {
102
102
  }
103
103
  return MediaStream;
104
104
  };
105
- DynamicLibHelper.prototype.getRTCPeerConnection = function () {
105
+ DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
106
106
  try {
107
- return new (require("react-native-webrtc").RTCPeerConnection)();
107
+ if (meetingStartRequest && meetingStartRequest.iceServers) {
108
+ return new (require("react-native-webrtc").RTCPeerConnection)({ iceServers: meetingStartRequest.iceServers });
109
+ }
110
+ else {
111
+ return new (require("react-native-webrtc").RTCPeerConnection)();
112
+ }
108
113
  }
109
114
  catch (err) {
110
115
  log.error("react-native-webrtc not found. Please do npm install ");
@@ -5,5 +5,5 @@ export declare class DynamicLibHelper {
5
5
  getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
6
6
  getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
7
7
  getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
8
- getRTCPeerConnection(): any;
8
+ getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
9
9
  }
@@ -103,8 +103,13 @@ var DynamicLibHelper = /** @class */ (function () {
103
103
  }
104
104
  return MediaStream;
105
105
  };
106
- DynamicLibHelper.prototype.getRTCPeerConnection = function () {
107
- return new RTCPeerConnection();
106
+ DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
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
  }());
@@ -68,10 +68,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
68
68
  selfParticpant = this.communicationHandler.getSelfParticipant();
69
69
  console.log(selfParticpant);
70
70
  if (!(selfParticpant.userId !== participant.userId && !selfParticpant.getPeerConnections().has(participant.userId))) return [3 /*break*/, 2];
71
+ this.printLogIfRequired("Check if Can Send Offer");
71
72
  isOfferInitParticipant = this.isOfferInitParticipant(participant);
72
73
  if (!!isOfferInitParticipant) return [3 /*break*/, 2];
73
- peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
74
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection();
74
+ peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
75
+ peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
75
76
  if (!peerConnection) return [3 /*break*/, 2];
76
77
  this.subToConnectionState(participant);
77
78
  peerConnection.addTransceiver("audio", { direction: "sendrecv" });
@@ -83,7 +84,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
83
84
  peerConnectionObject.offer = offer;
84
85
  peerConnectionObject.rtcPeerConnection = peerConnection;
85
86
  // send offer to peer
86
- console.log("offer", offer);
87
+ this.printLogIfRequired("Send Offer", offer);
87
88
  messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: offer };
88
89
  this.sendWebrtcMessage(messageJson);
89
90
  _a.label = 2;
@@ -96,13 +97,14 @@ var WebrtcHandler = /** @class */ (function (_super) {
96
97
  return __generator(this, function (_a) {
97
98
  switch (_a.label) {
98
99
  case 0:
100
+ this.printLogIfRequired("On New Offer", data);
99
101
  selfParticpant = this.communicationHandler.getSelfParticipant();
100
102
  participant = data.sender;
101
- peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
103
+ peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
102
104
  if (peerConnectionObject) {
103
105
  peerConnectionObject.remoteOffer = data.sdp;
104
106
  }
105
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection();
107
+ peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
106
108
  if (!peerConnection) return [3 /*break*/, 2];
107
109
  this.subToConnectionState(participant);
108
110
  peerConnection.addTransceiver("audio", { direction: "sendrecv" });
@@ -125,13 +127,14 @@ var WebrtcHandler = /** @class */ (function (_super) {
125
127
  _this.onNewAnswer = function (data) { return __awaiter(_this, void 0, void 0, function () {
126
128
  var selfParticpant, participant, peerConnectionObject, peerConnection;
127
129
  return __generator(this, function (_a) {
130
+ this.printLogIfRequired("On New Answer", data);
128
131
  selfParticpant = this.communicationHandler.getSelfParticipant();
129
132
  participant = data.sender;
130
- peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
133
+ peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
131
134
  if (peerConnectionObject) {
132
135
  peerConnectionObject.remoteAnswer = data.sdp;
133
136
  }
134
- peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection();
137
+ peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
135
138
  if (peerConnection) {
136
139
  peerConnection.setRemoteDescription({ type: 'answer', sdp: peerConnectionObject.remoteAnswer });
137
140
  }
@@ -143,7 +146,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
143
146
  return __generator(this, function (_a) {
144
147
  selfParticpant = this.communicationHandler.getSelfParticipant();
145
148
  participant = data.sender;
146
- peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
149
+ peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
147
150
  rtcConnection = peerConnectionObject.rtcPeerConnection;
148
151
  if (rtcConnection) {
149
152
  this.printLogIfRequired("on ice candidate", data.candidate);
@@ -162,7 +165,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
162
165
  var _this = this;
163
166
  return __generator(this, function (_a) {
164
167
  selfParticpant = this.communicationHandler.getSelfParticipant();
165
- peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId);
168
+ peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(remoteParticipant.userId, this.meetingStartRequest);
166
169
  rtcConnection = peerConnectionObject.rtcPeerConnection;
167
170
  rtcConnection.addEventListener('icecandidate', function (event) {
168
171
  if (event.candidate && event.candidate !== null) {
@@ -183,8 +186,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
183
186
  _this.startSendTrackToPartiipant(remoteParticipant);
184
187
  }
185
188
  });
189
+ rtcConnection.addEventListener("");
186
190
  rtcConnection.addEventListener("track", function (onRemoteTrack) {
187
191
  var _a, _b;
192
+ _this.printLogIfRequired("On New Track Remote", onRemoteTrack);
188
193
  if (onRemoteTrack.streams && onRemoteTrack.streams.length > 0) {
189
194
  var mediaStream = onRemoteTrack.streams.at(0);
190
195
  if (mediaStream.getTracks() && mediaStream.getTracks().length > 0) {
@@ -218,10 +223,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
218
223
  return __generator(this, function (_a) {
219
224
  selfParticpant = this.communicationHandler.getSelfParticipant();
220
225
  if (selfParticpant) {
221
- peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
226
+ peerConnection = selfParticpant.getPeerConnectionsViaUserId(participant.userId, this.meetingStartRequest);
222
227
  if (peerConnection && peerConnection.rtcPeerConnection) {
223
- this.printLogIfRequired("Send Track");
228
+ this.printLogIfRequired("Send Track", participant);
224
229
  peerConnection.rtcPeerConnection.addTrack(track.track);
230
+ // peerConnection.rtcPeerConnection.addStream(new MediaStream([track.track]))
225
231
  }
226
232
  }
227
233
  return [2 /*return*/];
@@ -243,10 +249,10 @@ var WebrtcHandler = /** @class */ (function (_super) {
243
249
  optionalParams[_i - 1] = arguments[_i];
244
250
  }
245
251
  if (optionalParams && optionalParams.length > 0) {
246
- _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(message, optionalParams);
252
+ _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Webrtc-" + message, optionalParams);
247
253
  }
248
254
  else {
249
- _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log(message);
255
+ _this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("Webrtc-" + message);
250
256
  }
251
257
  };
252
258
  return _this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",