vani-meeting-client-native 0.0.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.
Files changed (42) hide show
  1. package/README.md +153 -0
  2. package/lib/MeetingHandler.d.ts +55 -0
  3. package/lib/MeetingHandler.js +496 -0
  4. package/lib/base/Base.d.ts +9 -0
  5. package/lib/base/Base.js +17 -0
  6. package/lib/index.d.ts +7 -0
  7. package/lib/index.js +7 -0
  8. package/lib/inter-communication-handler/CommunicationHandler.d.ts +65 -0
  9. package/lib/inter-communication-handler/CommunicationHandler.js +521 -0
  10. package/lib/model/Event.d.ts +84 -0
  11. package/lib/model/Event.js +35 -0
  12. package/lib/model/MeetingStartRequest.d.ts +54 -0
  13. package/lib/model/MeetingStartRequest.js +60 -0
  14. package/lib/model/MessagePayload.d.ts +32 -0
  15. package/lib/model/MessagePayload.js +31 -0
  16. package/lib/model/Participant.d.ts +16 -0
  17. package/lib/model/Participant.js +22 -0
  18. package/lib/model/TaskResponse.d.ts +5 -0
  19. package/lib/model/TaskResponse.js +1 -0
  20. package/lib/model/Track.d.ts +19 -0
  21. package/lib/model/Track.js +27 -0
  22. package/lib/user-media-handler/UserMediaHandler.d.ts +38 -0
  23. package/lib/user-media-handler/UserMediaHandler.js +786 -0
  24. package/lib/utility/DynamicLibHelper.d.ts +8 -0
  25. package/lib/utility/DynamicLibHelper.js +109 -0
  26. package/lib/utility/DynamicLibHelper.native.d.ts +8 -0
  27. package/lib/utility/DynamicLibHelper.native.js +109 -0
  28. package/lib/utility/DynamicLibHelper.node.d.ts +8 -0
  29. package/lib/utility/DynamicLibHelper.node.js +108 -0
  30. package/lib/utility/Utility.d.ts +3 -0
  31. package/lib/utility/Utility.js +12 -0
  32. package/lib/utility/VaniEventListener.d.ts +4 -0
  33. package/lib/utility/VaniEventListener.js +24 -0
  34. package/lib/video-call-handler/BaseVideoCallHandler.d.ts +25 -0
  35. package/lib/video-call-handler/BaseVideoCallHandler.js +98 -0
  36. package/lib/video-call-handler/SFUHandler.d.ts +57 -0
  37. package/lib/video-call-handler/SFUHandler.js +811 -0
  38. package/lib/video-call-handler/WebrtcHandler.d.ts +17 -0
  39. package/lib/video-call-handler/WebrtcHandler.js +107 -0
  40. package/lib/websocket-handler/WebsocketHandler.d.ts +102 -0
  41. package/lib/websocket-handler/WebsocketHandler.js +541 -0
  42. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+
2
+ # Vani Meeting SDK
3
+ Next generation video and audio API and SDK solutions to enhance your online experience. Engage with your audience in real-time, on any platform, from anywhere, through the addition of video and voice with Vani Meetings’s API and SDK solutions.
4
+
5
+
6
+
7
+
8
+
9
+ ## Getting Started
10
+
11
+
12
+ ## Installation
13
+
14
+ Install vani-meeting.demo with npm
15
+
16
+ ```bash
17
+ npm install com.vanimeeting.demo
18
+
19
+ yarn add com.vanimeeting.demo
20
+ ```
21
+
22
+ ## Usage/Examples
23
+
24
+ ```bash
25
+ import * as MeetingHandler from "com.vanimeeting.demo";
26
+ import * as EventEmitter from "events";
27
+
28
+ class WebrtcCallHandler {
29
+ constructor() {
30
+ this.roomid = null;
31
+ this.meetingRequest = null;
32
+ this.evenetEmitter = new EventEmitter();
33
+ }
34
+
35
+ static instance = new WebrtcCallHandler();
36
+ static getInstance() {
37
+ if (WebrtcCallHandler.instance === null) {
38
+ WebrtcCallHandler.instance = new WebrtcCallHandler();
39
+ } else {
40
+ return WebrtcCallHandler.instance;
41
+ }
42
+ }
43
+ setup(roomid, userid, appName, userData) {
44
+ if (this.meetingRequest === null) {
45
+ const locaUserid =
46
+ new Date().getTime() + "_" + Math.floor(Math.random() * 20);
47
+ this.meetingRequest = MeetingHandler.meetingStartRequestObject(
48
+ roomid,
49
+ userid || locaUserid,
50
+ "demo" || appName
51
+ );
52
+ this.meetingRequest.numberOfUsers = 2;
53
+ this.meetingRequest.userData = userData;
54
+ }
55
+ return this.meetingRequest;
56
+ }
57
+ }
58
+
59
+ export default WebrtcCallHandler;
60
+
61
+ ```
62
+
63
+ First we have to import SDK.
64
+ ```
65
+ import * as MeetingHandler from "com.vanimeeting.demo";
66
+ import * as EventEmitter from "events";
67
+ ```
68
+
69
+ Then we have to call meetingStartRequestObject which returns meetingStartRequestObject modal and accepts `roomId`, `userId`, `appId`, and `userData` as its params where:
70
+
71
+ * `roomId` : is always unique string to join a meeting.
72
+ * `userId` : is always unique string respective to user.
73
+ * `appId` : can be any manual id given by user.
74
+ * `userData` : any extra data.
75
+ ```
76
+ setup(roomid, userid, appName, userData) {
77
+ if (this.meetingRequest === null) {
78
+ const locaUserid =
79
+ new Date().getTime() + "_" + Math.floor(Math.random() * 20);
80
+ this.meetingRequest = MeetingHandler.meetingStartRequestObject(
81
+ roomid,
82
+ userid || locaUserid,
83
+ "demo" || appName
84
+ );
85
+ this.meetingRequest.numberOfUsers = 2;
86
+ this.meetingRequest.userData = userData;
87
+ }
88
+ return this.meetingRequest;
89
+ }
90
+ }
91
+ ```
92
+
93
+ Then we will initialize the meeting and establish the connection by calling init method.
94
+
95
+ ```
96
+ MeetingHandler.init();
97
+ ```
98
+
99
+ Then we will call startLocalStream method of MeetingHandler which will ask for camera and mic permission, once given returns the localStream of the user itself.
100
+ It accepts `isVideoRequired` and `isAudioRequired` as its params.
101
+
102
+ * `isVideoRequired` : boolean
103
+ * `isAudioRequired` : boolean
104
+
105
+ ```
106
+ MeetingHandler.startLocalStream();
107
+ ```
108
+
109
+ Then we will call checkSocket method of MeetingHandler to establish a connection with web socket.
110
+
111
+ ```
112
+ MeetingHandler.checkSocket();
113
+ ```
114
+
115
+ After the connection is established with the websocket we will recieve an `onConnected` event and pass event name "onConnected" as first params and pass callback function `onConnected` as second parameter which will call `startMeeting` method of MeetingHandler to start the meeting.
116
+
117
+ ```
118
+ MeetingHandler.eventEmitter.on("onConnected", this.onConnected);
119
+ onConnected = () => {
120
+ MeetingHandler.startMeeting();
121
+ };
122
+ ```
123
+
124
+ After the initiation of meeting we will recieve an `onTrack` event and pass that event as event name "onTrack" as first params and pass callback function `onTrack` as second parameter which will recieve track as a parameter which will be passed as a `MediaStream` to `video` tag.
125
+
126
+ ```
127
+ MeetingHandler.eventEmitter.on("onTrack", this.onTrack);
128
+ MeetingHandler.eventEmitter.on("refreshTrack", this.onTrack);*
129
+ onTrack(track) {
130
+ if (
131
+ track.track !== null &&
132
+ track &&
133
+ track.kind === "video" &&
134
+ track.isLocalTrack
135
+ ) {
136
+ this.localVideoRef.current.srcObject = new MediaStream([track.track]);
137
+ this.localVideoRef.current.play();
138
+ } else if (track && track.track !== null && !track.isLocalTrack) {
139
+ if (track.kind === "video" && track) {
140
+ this.remoteVideoRef.current.srcObject = new MediaStream([track.track]);
141
+ this.remoteVideoRef.current.play();
142
+ } else {
143
+ if (track && track.track !== null) {
144
+ this.remoteAudioRef.current.srcObject = new MediaStream([
145
+ track.track,
146
+ ]);
147
+ this.remoteAudioRef.current.play();
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
@@ -0,0 +1,55 @@
1
+ import { MeetingStartRequest, VaniEventListener, Device, MessagePayload } from ".";
2
+ import { GetDevicesType } from "./user-media-handler/UserMediaHandler";
3
+ import { Track, TrackKind } from "./model/Track";
4
+ import { TaskResponse } from "./model/TaskResponse";
5
+ import { Participant } from "./model/Participant";
6
+ export declare class MeetingHandler {
7
+ private meetingStartRequest?;
8
+ private videoCallHandler?;
9
+ private reactNativeWebrtcPlugin?;
10
+ private websocketCallHandler?;
11
+ private communicationHandler?;
12
+ private userMediaHandler?;
13
+ meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string): MeetingStartRequest;
14
+ endAndDestory(): void;
15
+ requestToCloseTheRoom: () => void;
16
+ init(): Promise<void>;
17
+ switchCamera(): void;
18
+ startLocalStream(isVideoRequired: boolean, isAudioRequired: boolean, shouldAddTrackImmediately?: boolean, userMediaPayload?: any): Promise<void>;
19
+ startScreenShare(isAudioRequired?: boolean, shouldAddTrackImmediately?: boolean, screensharePayload?: any): Promise<void>;
20
+ stopScreenSharing(): Promise<void>;
21
+ getDevices(deviceType: GetDevicesType): Promise<Device[] | undefined>;
22
+ pauseCamera(userId?: string): Promise<TaskResponse>;
23
+ muteUser(userId?: string): Promise<TaskResponse>;
24
+ resumeCamera(userId?: string): Promise<TaskResponse>;
25
+ unmute(userId?: string): Promise<TaskResponse>;
26
+ resumeStreamWithoutAdding(streamKind: TrackKind): TaskResponse | undefined;
27
+ pauseStreamWithoutStopping(streamKind: TrackKind): TaskResponse | undefined;
28
+ stopTrack(track: Track): void;
29
+ addCustomTrack(track: Track): void;
30
+ pauseIncomingTrack(track: Track): void;
31
+ resumeIncomingTrack(track: Track): void;
32
+ updateSpatialForTrack(track: Track, spatialLayerIndex: number): Promise<void>;
33
+ resumeProducerOrConsumerForTrack(track: Track): Promise<void>;
34
+ pauseProducerOrConsumerForTrack(track: Track): Promise<void>;
35
+ getConsumerForTrack(track: Track): void | undefined;
36
+ participantByUserId(userId: string): Participant | undefined;
37
+ updateParticipantData(participant: Participant): Participant | undefined;
38
+ getUpdatedParticipantsListFromServer(): void;
39
+ getAllParticipants(): Participant[];
40
+ getAllTracks(): Track[];
41
+ getTracksByParticipantId(participantId: string): Track[];
42
+ isWebScoketConnected(): boolean;
43
+ sendMessage(message: MessagePayload): TaskResponse;
44
+ getOldMessages(): Promise<void>;
45
+ onOldMessages(data: any): Promise<void>;
46
+ checkSocket(): Promise<void>;
47
+ startMeeting(): Promise<void>;
48
+ getMeetingStartTime(): Promise<void>;
49
+ startRTMPStream(urls: string[]): Promise<void>;
50
+ getEventEmitter(): VaniEventListener | undefined;
51
+ restartTransport: () => Promise<void>;
52
+ private emitMessageToSource;
53
+ private cleanup;
54
+ private handleGA;
55
+ }