@videosdk.live/react-sdk 0.4.3 → 0.4.5

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,1821 +0,0 @@
1
- // Type definitions for @videosdk.live/react-sdk 0.1
2
- // Project: https://docs.videosdk.live/docs/realtime-communication/sdk-reference/react-sdk/setup
3
- // Definitions by: Rajan Surani <https://github.com/rajansurani>
4
- // Ahmed Bhesaniya <https://github.com/ahmedbhesaniya97>
5
- // Zujo Now <https://github.com/zujonow>
6
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
-
8
- import React, { JSX } from 'react';
9
- import { Connection } from './connection';
10
- import {
11
- CameraDeviceInfo,
12
- DeviceInfo,
13
- MicrophoneDeviceInfo,
14
- PlaybackDeviceInfo
15
- } from './deviceInfo';
16
- import { Permission } from './permission';
17
- import { Meeting } from './meeting';
18
- import { Participant } from './participant';
19
- import { Stream } from './stream';
20
- import { Character, CharacterMode, CharacterState } from './character';
21
- /**
22
- * @param children - Render child component.
23
- * ---
24
- * @param config - This is meeting configuration object, whiich contains `meetingId`, `name` of the participant, `webcamEnabled`, `micEnabled` and many more.
25
- * ---
26
- * @param config.meetingId -
27
- * - Unique Id of the meeting where that participant will be joining.
28
- *
29
- * - It will be in the format of xxx-yyy-zzz and will be generated using the [VideoSDK's Room API](https://docs.videosdk.live/api-reference/realtime-communication/create-room).
30
- * ---
31
- * @param config.name - Name of the participant who will be joining the meeting, this name will be displayed to other participants in the same meeting.
32
- * ---
33
- * @param config.micEnabled - Whether mic of the participant will be on while joining the meeting. If it is set to false, then mic of that participant will be disabled by default,
34
- * but can be enabled or disabled later.
35
- * ---
36
- * @param config.webcamEnabled - Whether webcam of the participant will be on while joining the meeting. If it is set to false, then webcam of that participant will
37
- * be disabled by default, but can be enabled or disabled later.
38
- * ---
39
- * @param config.participantId - You can specify your custom participantId here.
40
- * ---
41
- * @param config.multiStream - Sets wheather to send multi resoultion streams while publishing video. Please refere thi link for more understanding
42
- * [What is multiStream ?](https://docs.videosdk.live/react/guide/video-and-audio-calling-api-sdk/render-media/optimize-video-track#what-is-multistream)
43
- * ---
44
- * @param config.maxResolution - You can specify your custom participantId here.
45
- * ---
46
- * @param config.mode -
47
- *
48
- * - There are 3 types of modes:
49
- *
50
- * - **SEND_AND_RECV**: Both audio and video streams will be produced and consumed in this mode.
51
- *
52
- * - **RECV_ONLY**: Both audio and video streams will be only consumed in this mode.
53
- *
54
- * - **SIGNALLING_ONLY**: Audio and video streams will not be produced or consumed in this mode.
55
- *
56
- * - defaultValue : **SEND_AND_RECV**
57
- *
58
- * ---
59
- *
60
- * @param config.customCameraVideoTrack - Set the initial custom video track using different encoding parameters, camera facing mode, and optimization mode.
61
- * ---
62
- * @param config.customMicrophoneAudioTrack - Set the initial custom audio track using different encoding parameters and optimization mode.
63
- * ---
64
- * @param config.defaultCamera - [For Mobile Browser] It sets the initial camera orientation. Use 'front' to initialize the camera with the front-facing (selfie) mode, or 'back' to initialize it with the rear-facing (main) mode.
65
- * ---
66
- * @param config.debugMode - Enables users to view detailed error logs generated by our SDK directly on the VideoSDK's dashboard.
67
- * ---
68
- * @param token -
69
- * - You can generate a token in two ways:
70
- *
71
- * 1. **Temporary Token** : You can visit [Dashboard's API Key section](https://app.videosdk.live/api-keys) and generate the temporary token from there.
72
- * 2. **Server** : You can setup JWT in backend and make an API call to get the token from your server.
73
- * ---
74
- * @param joinWithoutUserInteraction -
75
- * - This is a boolean flag, when set to true, allows a participant to join a meeting directly without explicitly calling the join() function.
76
- *
77
- * - This is an OPTIONAL parameter. By default, it is set to false meaning, user has to manually call the join().
78
- *
79
- */
80
- export function MeetingProvider({
81
- children,
82
- config,
83
- token,
84
- joinWithoutUserInteraction,
85
- reinitialiseMeetingOnConfigChange: _reinitialiseMeetingOnConfigChange,
86
- deviceInfo
87
- }: {
88
- children: any;
89
- config: {
90
- meetingId: string;
91
- autoConsume?: boolean;
92
- preferredProtocol?: 'UDP_ONLY' | 'UDP_OVER_TCP' | 'TCP_ONLY';
93
- participantId?: string | undefined;
94
- name: string;
95
- micEnabled: boolean;
96
- webcamEnabled: boolean;
97
- maxResolution?: 'hd' | 'sd';
98
- customCameraVideoTrack?: MediaStream | undefined;
99
- customMicrophoneAudioTrack?: MediaStream | undefined;
100
- multiStream?: boolean;
101
- mode?: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY';
102
- metaData?: object;
103
- defaultCamera?: 'front' | 'back';
104
- debugMode: boolean;
105
- };
106
- token: string;
107
- joinWithoutUserInteraction?: boolean;
108
- reinitialiseMeetingOnConfigChange?: boolean;
109
- deviceInfo?: object;
110
- }): any;
111
-
112
- /**
113
- * @param children - Render child component.
114
- * ---
115
- * @param onParticipantJoined - This event callback is trigger when a new participant joins the meeting.
116
- * ---
117
- * @param onParticipantLeft - This event callback is trigger when a participant leaves the meeting.
118
- * ---
119
- * @param onSpeakerChanged -
120
- * - This event will be emitted when a active speaker changed.
121
- * - If you want to know which participant is actively speaking, then this event will be used.
122
- * - If no participant is actively speaking, then this event will pass null as en event callback parameter.
123
- * ---
124
- * @param onPresenterChanged -
125
- * - This event will be emitted when any participant starts or stops screen sharing.
126
- * - It will pass participantId as an event callback parameter.
127
- * - If a participant stops screensharing, then this event will pass null as en event callback parameter.
128
- * ---
129
- * @param onEntryRequested -
130
- * - This event will be triggered when a new participant who is trying to join the meeting, is having permission ask_join in token.
131
- * - This event will only be triggered to the participants in the meeting, who is having the permission allow_join in token.
132
- * - This event will pass following parameters as an event parameters, participantId and name of the new participant who is trying to join the meeting, allow() and deny() to take required actions.
133
- * ---
134
- * @param onEntryResponded -
135
- * - This event will be triggered when the join() request is responded.
136
- * - This event will be triggered to the participants in the meeting, who is having the permission allow_join in token.
137
- * - This event will be also triggered to the participant who requested to join the meeting.
138
- * ---
139
- * @param onMeetingJoined - This event callback is trigger when a local participant joins the meeting.
140
- * ---
141
- * @param onMeetingLeft - This event callback is trigger when local participant leaves the meeting.
142
- * ---
143
- * @param onPausedAllStreams - This event will be emitted when all the consumer streams are paused succesfully.
144
- * ---
145
- * @param onResumedAllStreams - This event will be emitted when all the consumer streams are resumed succesfully.
146
- * ---
147
- * @param onRecordingStateChanged - This event will be emitted when the meeting's recording status changed.
148
- * ---
149
- * @param onLivestreamStateChanged - This event will be emitted when the meeting's livestream status changed.
150
- * ---
151
- * @param onHlsStateChanged - This event will be emitted when the meeting's HLS(Http Livestreaming) status changed.
152
- * ---
153
- * @param onWebcamRequested -
154
- * - This event will be triggered to the participant B when any other participant A requests to enable webcam of participant B.
155
- * - On accepting the request, webcam of participant B will be enabled.
156
- * ---
157
- * @param onMicRequested -
158
- * - This event will be triggered to the participant B when any other participant A requests to enable mic of participant B.
159
- * - On accepting the request, mic of participant B will be enabled.
160
- * ---
161
- * @param onError -
162
- * - This event will be triggered when any error occured.
163
- * - It will pass code and message, as an event callback parameter.
164
- * - To see all available error codes from SDK. [Meeting Error Codes](https://docs.videosdk.live/react/api/sdk-reference/error-codes)
165
- * ---
166
- * @param onMeetingStateChanged -
167
- * - This event will be triggered when state of meeting changes.
168
- * - It will pass state as an event callback parameter which will indicate current state of the meeting.
169
- * - All available states are `CONNECTING`, `CONNECTED`, `FAILED`, `DISCONNECTED`, `CLOSING`, `CLOSED`.
170
- * ---
171
- * @param onParticipantModeChanged -
172
- * - This event will be triggered when mode gets chanded.
173
- * - It will pass mode, as an event callback parameter.
174
- * - **SEND_AND_RECV**: Both audio and video streams will be produced and consumed in this mode.
175
- * - **RECV_ONLY**: Both audio and video streams will be only consumed in this mode.
176
- * - **SIGNALLING_ONLY**: Audio and video streams will not be produced or consumed in this mode.
177
- */
178
-
179
- export function MeetingConsumer({
180
- children,
181
- onParticipantJoined,
182
- onParticipantLeft,
183
- onSpeakerChanged,
184
- onPresenterChanged,
185
- onMainParticipantChanged,
186
- onEntryRequested,
187
- onEntryResponded,
188
- onPausedAllStreams,
189
- onResumedAllStreams,
190
- onRecordingStarted,
191
- onRecordingStopped,
192
- onData,
193
- onMeetingJoined,
194
- onMeetingLeft,
195
- onLiveStreamStarted,
196
- onLiveStreamStopped,
197
- onVideoStateChanged,
198
- onVideoSeeked,
199
- onWebcamRequested,
200
- onMicRequested,
201
- onPinStateChanged,
202
- onConnectionOpen,
203
- onConnetionClose,
204
- onSwitchMeeting,
205
- onError,
206
- onHlsStarted,
207
- onHlsStopped,
208
- onHlsStateChanged,
209
- onRecordingStateChanged,
210
- onLivestreamStateChanged,
211
- onMeetingStateChanged,
212
- onParticipantModeChanged
213
- }: {
214
- children: any;
215
- onParticipantJoined?: (participant: Participant) => void;
216
- onParticipantLeft?: (participant: Participant) => void;
217
- onSpeakerChanged?: (activeSpeakerId: string | null) => void;
218
- onPresenterChanged?: (presenterId: string | null) => void;
219
- onMainParticipantChanged?: (participant: Participant) => void;
220
- onEntryRequested?: ({
221
- participantId,
222
- name,
223
- allow,
224
- deny
225
- }: {
226
- participantId: string;
227
- name: string;
228
- allow: () => void;
229
- deny: () => void;
230
- }) => void;
231
- onEntryResponded?: ({
232
- participantId,
233
- decision
234
- }: {
235
- participantId: string;
236
- decision: string;
237
- }) => void;
238
- onPausedAllStreams?: ({ kind }: { kind: "audio" | "video" | "share" | "shareAudio" | "all" | undefined }) => void;
239
- onResumedAllStreams?: ({ kind }: { kind: "audio" | "video" | "share" | "shareAudio" | "all" | undefined }) => void;
240
- onRecordingStarted?: () => void;
241
- onRecordingStopped?: () => void;
242
- onData?: (data: {
243
- from: string;
244
- timestamp: string;
245
- payload: string | Uint8Array;
246
- reliability: string;
247
- }) => void;
248
- onMeetingJoined?: () => void;
249
- onMeetingLeft?: () => void;
250
- onLiveStreamStarted?: () => void;
251
- onLiveStreamStopped?: () => void;
252
- onVideoStateChanged?: () => void;
253
- onVideoSeeked?: () => void;
254
- onWebcamRequested?: ({
255
- participantId,
256
- accept,
257
- reject
258
- }: {
259
- participantId: string;
260
- accept: () => void;
261
- reject: () => void;
262
- }) => void;
263
- onMicRequested?: ({
264
- participantId,
265
- accept,
266
- reject
267
- }: {
268
- participantId: string;
269
- accept: () => void;
270
- reject: () => void;
271
- }) => void;
272
- onPinStateChanged?: ({
273
- participantId,
274
- state,
275
- pinnedBy
276
- }: {
277
- participantId: string;
278
- state: { share: boolean; cam: boolean };
279
- pinnedBy: string;
280
- }) => void;
281
- onConnectionOpen?: () => void;
282
- onConnetionClose?: () => void;
283
- onSwitchMeeting?: () => void;
284
- onError?: ({ code, message }: { code: string; message: string }) => void;
285
- onHlsStarted?: ({ downstreamUrl }: { downstreamUrl: string }) => void;
286
- onHlsStopped?: () => void;
287
- onHlsStateChanged?: ({
288
- status,
289
- downstreamUrl,
290
- playbackHlsUrl,
291
- livestreamUrl
292
- }: {
293
- status:
294
- | 'HLS_STARTING'
295
- | 'HLS_STARTED'
296
- | 'HLS_PLAYABLE'
297
- | 'HLS_STOPPING'
298
- | 'HLS_STOPPED';
299
- downstreamUrl?: string;
300
- playbackHlsUrl?: string;
301
- livestreamUrl?: string;
302
- }) => void;
303
- onRecordingStateChanged?: ({
304
- status
305
- }: {
306
- status:
307
- | 'RECORDING_STARTING'
308
- | 'RECORDING_STARTED'
309
- | 'RECORDING_STOPPING'
310
- | 'RECORDING_STOPPED';
311
- }) => void;
312
- onLivestreamStateChanged?: ({
313
- status
314
- }: {
315
- status:
316
- | 'LIVESTREAM_STARTING'
317
- | 'LIVESTREAM_STARTED'
318
- | 'LIVESTREAM_STOPPING'
319
- | 'LIVESTREAM_STOPPED';
320
- }) => void;
321
- onMeetingStateChanged?: ({
322
- state
323
- }: {
324
- state:
325
- | 'CONNECTING'
326
- | 'CONNECTED'
327
- | 'FAILED'
328
- | 'DISCONNECTED'
329
- | 'CLOSING'
330
- | 'CLOSED';
331
- }) => void;
332
- onParticipantModeChanged?: ({
333
- participantId,
334
- mode
335
- }: {
336
- participantId: string;
337
- mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
338
- }) => void;
339
- }): any;
340
-
341
- /**
342
- *
343
- * ---
344
- * @param onDeviceChanged - It's a callback which gets triggered whenever a media device such as a camera, microphone, or speaker is connected to or removed from the system.
345
- *
346
- * **Code Example :**
347
- * ```js
348
- * function onDeviceChanged(devices) {
349
- * console.log("onDeviceChanged", devices);
350
- * }
351
- * const {} = useMediaDevice({
352
- * onDeviceChanged
353
- * });
354
- * ```
355
- * ---
356
- * @returns This will returns methods and events associated with media devices and permissions. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-mediaDevice/introduction)
357
- */
358
- export function useMediaDevice({
359
- onDeviceChanged
360
- }?: {
361
- onDeviceChanged?: (devices: Promise<Array<DeviceInfo>>) => void;
362
- }): {
363
- getDevices: () => Promise<Array<DeviceInfo>>;
364
- getCameras: () => Promise<Array<CameraDeviceInfo>>;
365
- getMicrophones: () => Promise<Array<MicrophoneDeviceInfo>>;
366
- getPlaybackDevices: () => Promise<Array<PlaybackDeviceInfo>>;
367
- checkPermissions: (permissions?: Permission) => Promise<Map<string, boolean>>;
368
- requestPermission: (
369
- permissions?: Permission
370
- ) => Promise<Map<string, boolean>>;
371
- };
372
-
373
- /**
374
- *
375
- * @param participantId - Id of the participant.
376
- * ---
377
- * @param onStreamEnabled - It's a callback which gets triggered whenever a participant's video, audio or screen share stream is enabled.
378
- *
379
- * **Code Example :**
380
- * ```js
381
- * function onStreamEnabled(stream) {
382
- * console.log("onStreamEnabled", stream);
383
- * }
384
- * const { displayName } = useParticipant(participantId,{
385
- * onStreamEnabled
386
- * });
387
- * ```
388
- * ---
389
- * @param onStreamEnabled - It's a callback which gets triggered whenever a participant's video, audio or screen share stream is disabled.
390
- *
391
- * **Code Example :**
392
- * ```js
393
- * function onStreamEnabled(stream) {
394
- * console.log("onStreamEnabled", stream);
395
- * }
396
- * const { displayName } = useParticipant(participantId,{
397
- * onStreamEnabled
398
- * });
399
- * ```
400
- * ---
401
- * @param onMediaStatusChanged - It's a callback which gets triggered whenever a participant's video or audio is disabled or enabled.
402
- *
403
- * **Code Example :**
404
- * ```js
405
- * function onMediaStatusChanged(stream) {
406
- * const { kind, newStatus} = data;
407
- * console.log("onMediaStatusChanged", kind, newStatus);
408
- * }
409
- * const { displayName } = useParticipant(participantId,{
410
- * onMediaStatusChanged
411
- * });
412
- * ```
413
- * ---
414
- * @param onVideoQualityChanged -
415
- * - It's a callback which gets triggered whenever a participant's video quality changes.
416
- * - currentQuality and prevQuality can have values `HIGH` | `MEDIUM` | `LOW`.
417
- *
418
- * **Code Example :**
419
- * ```js
420
- * function onVideoQualityChanged(stream) {
421
- * const { currentQuality, prevQuality } = data;
422
- * console.log("onVideoQualityChanged", currentQuality, prevQuality );
423
- * }
424
- * const { displayName } = useParticipant(participantId,{
425
- * onVideoQualityChanged
426
- * });
427
- * ```
428
- * ---
429
- * @param onStreamPaused -
430
- * - It's a callback that gets triggered whenever a participant's stream is paused by adaptive subscription manager.
431
- * - The `data` parameter contains the reason for pausing.
432
- *
433
- * **Code Example :**
434
- * ```js
435
- * function onStreamPaused(data) {
436
- * console.log("Stream paused:", data);
437
- * }
438
- * const { displayName } = useParticipant(participantId, {
439
- * onStreamPaused,
440
- * });
441
- * ```
442
- * ---
443
- * @param onStreamResumed -
444
- * - It's a callback that gets triggered whenever a participant's stream is resumed by adaptive subscription manager.
445
- * - The `stream` parameter contains the reason for resuming.
446
- *
447
- * **Code Example :**
448
- * ```js
449
- * function onStreamResumed(data) {
450
- * console.log("Stream resumed:", data);
451
- * }
452
- * const { displayName } = useParticipant(participantId, {
453
- * onStreamResumed,
454
- * });
455
- * ```
456
- * ---
457
- * @returns This will return particular participant properties and method. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-participant/introduction)
458
- */
459
- export function useParticipant(
460
- participantId: string,
461
- {
462
- onStreamEnabled,
463
- onStreamDisabled,
464
- onMediaStatusChanged,
465
- onVideoQualityChanged,
466
- onStreamPaused,
467
- onStreamResumed
468
- }?: {
469
- onStreamDisabled?: (stream: Stream) => void;
470
- onStreamEnabled?: (stream: Stream) => void;
471
- onMediaStatusChanged?: ({
472
- kind,
473
- peerId,
474
- newStatus
475
- }: {
476
- kind: 'audio' | 'video';
477
- peerId: string;
478
- newStatus: boolean;
479
- }) => void;
480
- onVideoQualityChanged?: ({
481
- peerId,
482
- prevQuality,
483
- currentQuality
484
- }: {
485
- peerId: string;
486
- prevQuality: 'low' | 'med' | 'high';
487
- currentQuality: 'low' | 'med' | 'high';
488
- }) => void;
489
- onStreamPaused?: ({
490
- kind,
491
- reason
492
- }: {
493
- kind: 'video';
494
- reason: string;
495
- }) => void;
496
- onStreamResumed?: ({
497
- kind,
498
- reason
499
- }: {
500
- kind: 'video';
501
- reason: string;
502
- }) => void;
503
- }
504
- ): {
505
- displayName: string;
506
- participant: Participant;
507
- webcamStream: Stream;
508
- micStream: Stream;
509
- screenShareStream: Stream;
510
- screenShareAudioStream: Stream;
511
- webcamOn: boolean;
512
- micOn: boolean;
513
- screenShareOn: boolean;
514
- isLocal: boolean;
515
- isActiveSpeaker: boolean;
516
- isMainParticipant: boolean;
517
- pinState: any;
518
- mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
519
- consumeMicStreams: () => void;
520
- consumeWebcamStreams: () => void;
521
- stopConsumingMicStreams: () => void;
522
- stopConsumingWebcamStreams: () => void;
523
- setQuality: (quality: 'low' | 'med' | 'high') => void;
524
- setScreenShareQuality: (quality: 'low' | 'med' | 'high') => void;
525
- setViewPort: (width: number, height: number) => void;
526
- enableMic: () => void;
527
- disableMic: () => void;
528
- enableWebcam: () => void;
529
- disableWebcam: () => void;
530
- remove: () => void;
531
- captureImage: ({
532
- height,
533
- width
534
- }: {
535
- height?: number;
536
- width?: number;
537
- }) => Promise<string | null>;
538
- pin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
539
- unpin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
540
- getShareAudioStats: () => Promise<
541
- Array<{
542
- bitrate: number;
543
- rtt: number;
544
- network: string;
545
- codec: string;
546
- jitter: number;
547
- limitation: any;
548
- totalPackets: number;
549
- packetsLost: number;
550
- concealmentEvents: number;
551
- insertedSamplesForDecelaration: number;
552
- removedSamplesForAccelaration: number;
553
- size: any;
554
- }>
555
- >;
556
- getAudioStats: () => Promise<
557
- Array<{
558
- bitrate: number;
559
- rtt: number;
560
- network: string;
561
- codec: string;
562
- jitter: number;
563
- limitation: any;
564
- totalPackets: number;
565
- packetsLost: number;
566
- concealmentEvents: number;
567
- insertedSamplesForDecelaration: number;
568
- removedSamplesForAccelaration: number;
569
- size: any;
570
- }>
571
- >;
572
- getVideoStats: () => Promise<
573
- Array<{
574
- bitrate: number;
575
- rtt: number;
576
- network: string;
577
- codec: string;
578
- jitter: number;
579
- limitation: any;
580
- totalPackets: number;
581
- packetsLost: number;
582
- concealmentEvents: number;
583
- insertedSamplesForDecelaration: number;
584
- removedSamplesForAccelaration: number;
585
- size: any;
586
- currentSpatialLayer: number;
587
- currentTemporalLayer: number;
588
- preferredSpatialLayer: number;
589
- preferredTemporalLayer: number;
590
- }>
591
- >;
592
- getShareStats: () => Promise<
593
- Array<{
594
- bitrate: number;
595
- rtt: number;
596
- network: string;
597
- codec: string;
598
- jitter: number;
599
- limitation: any;
600
- totalPackets: number;
601
- packetsLost: number;
602
- concealmentEvents: number;
603
- insertedSamplesForDecelaration: number;
604
- removedSamplesForAccelaration: number;
605
- size: any;
606
- currentSpatialLayer: number;
607
- currentTemporalLayer: number;
608
- preferredSpatialLayer: number;
609
- preferredTemporalLayer: number;
610
- }>
611
- >;
612
- };
613
-
614
- /**
615
- * @param onParticipantJoined - This event callback is trigger when a new participant joins the meeting.
616
- * ---
617
- * @param onParticipantLeft - This event callback is trigger when a participant leaves the meeting.
618
- * ---
619
- * @param onSpeakerChanged -
620
- * - This event will be emitted when a active speaker changed.
621
- * - If you want to know which participant is actively speaking, then this event will be used.
622
- * - If no participant is actively speaking, then this event will pass null as en event callback parameter.
623
- * ---
624
- * @param onPresenterChanged -
625
- * - This event will be emitted when any participant starts or stops screen sharing.
626
- * - It will pass participantId as an event callback parameter.
627
- * - If a participant stops screensharing, then this event will pass null as en event callback parameter.
628
- * ---
629
- * @param onEntryRequested -
630
- * - This event will be triggered when a new participant who is trying to join the meeting, is having permission ask_join in token.
631
- * - This event will only be triggered to the participants in the meeting, who is having the permission allow_join in token.
632
- * - This event will pass following parameters as an event parameters, participantId and name of the new participant who is trying to join the meeting, allow() and deny() to take required actions.
633
- * ---
634
- * @param onEntryResponded -
635
- * - This event will be triggered when the join() request is responded.
636
- * - This event will be triggered to the participants in the meeting, who is having the permission allow_join in token.
637
- * - This event will be also triggered to the participant who requested to join the meeting.
638
- * ---
639
- * @param onMeetingJoined - This event callback is trigger when a local participant joins the meeting.
640
- * ---
641
- * @param onMeetingLeft - This event callback is trigger when local participant leaves the meeting.
642
- * ---
643
- * @param onPausedAllStreams - This event will be emitted when all the consumer streams are paused succesfully.
644
- * ---
645
- * @param onResumedAllStreams - This event will be emitted when all the consumer streams are resumed succesfully.
646
- * ---
647
- * @param onRecordingStateChanged - This event will be emitted when the meeting's recording status changed.
648
- * ---
649
- * @param onLivestreamStateChanged - This event will be emitted when the meeting's livestream status changed.
650
- * ---
651
- * @param onHlsStateChanged - This event will be emitted when the meeting's HLS(Http Livestreaming) status changed.
652
- * ---
653
- * @param onWebcamRequested -
654
- * - This event will be triggered to the participant B when any other participant A requests to enable webcam of participant B.
655
- * - On accepting the request, webcam of participant B will be enabled.
656
- * ---
657
- * @param onMicRequested -
658
- * - This event will be triggered to the participant B when any other participant A requests to enable mic of participant B.
659
- * - On accepting the request, mic of participant B will be enabled.
660
- * ---
661
- * @param onError -
662
- * - This event will be triggered when any error occured.
663
- * - It will pass code and message, as an event callback parameter.
664
- * - To see all available error codes from SDK. [Meeting Error Codes](https://docs.videosdk.live/react/api/sdk-reference/error-codes)
665
- * ---
666
- * @param onMeetingStateChanged -
667
- * - This event will be triggered when state of meeting changes.
668
- * - It will pass state as an event callback parameter which will indicate current state of the meeting.
669
- * - All available states are `CONNECTING`, `CONNECTED`, `FAILED`, `DISCONNECTED`, `CLOSING`, `CLOSED`.
670
- * ---
671
- * @param onParticipantModeChanged -
672
- * - This event will be triggered when mode gets chanded.
673
- * - It will pass mode, as an event callback parameter.
674
- * - **SEND_AND_RECV**: Both audio and video streams will be produced and consumed in this mode.
675
- * - **RECV_ONLY**: Both audio and video streams will be only consumed in this mode.
676
- * - **SIGNALLING_ONLY**: Audio and video streams will not be produced or consumed in this mode.
677
- * ---
678
- * @returns This will return Meeting properties and method. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-meeting/introduction)
679
- *
680
- */
681
-
682
- export function useMeeting({
683
- onParticipantJoined,
684
- onParticipantLeft,
685
- onSpeakerChanged,
686
- onPresenterChanged,
687
- onMainParticipantChanged,
688
- onEntryRequested,
689
- onEntryResponded,
690
- onPausedAllStreams,
691
- onResumedAllStreams,
692
- onRecordingStarted,
693
- onRecordingStopped,
694
- onData,
695
- onMeetingJoined,
696
- onMeetingLeft,
697
- onLiveStreamStarted,
698
- onLiveStreamStopped,
699
- onVideoStateChanged,
700
- onVideoSeeked,
701
- onWebcamRequested,
702
- onMicRequested,
703
- onPinStateChanged,
704
- onConnectionOpen,
705
- onConnetionClose,
706
- onSwitchMeeting,
707
- onError,
708
- onHlsStarted,
709
- onHlsStopped,
710
- onHlsStateChanged,
711
- onRecordingStateChanged,
712
- onLivestreamStateChanged,
713
- onMeetingStateChanged,
714
- onParticipantModeChanged,
715
- onCharacterJoined,
716
- onCharacterLeft,
717
- onMediaRelayStarted,
718
- onMediaRelayStopped,
719
- onMediaRelayError,
720
- onMediaRelayRequestResponse,
721
- onMediaRelayRequestReceived,
722
- }?: {
723
- onParticipantJoined?: (participant: Participant) => void;
724
- onParticipantLeft?: (participant: Participant) => void;
725
- onSpeakerChanged?: (activeSpeakerId: string | null) => void;
726
- onPresenterChanged?: (presenterId: string | null) => void;
727
- onMainParticipantChanged?: (participant: Participant) => void;
728
- onEntryRequested?: ({
729
- participantId,
730
- name,
731
- allow,
732
- deny
733
- }: {
734
- participantId: string;
735
- name: string;
736
- allow: () => void;
737
- deny: () => void;
738
- }) => void;
739
- onEntryResponded?: ({
740
- participantId,
741
- decision
742
- }: {
743
- participantId: string;
744
- decision: string;
745
- }) => void;
746
- onPausedAllStreams?: ({ kind }: { kind: "audio" | "video" | "share" | "shareAudio" | "all" | undefined }) => void;
747
- onResumedAllStreams?: ({ kind }: { kind: "audio" | "video" | "share" | "shareAudio" | "all" | undefined }) => void;
748
- onRecordingStarted?: () => void;
749
- onRecordingStopped?: () => void;
750
- onData?: (data: {
751
- from: string;
752
- timestamp: string;
753
- payload: string | Uint8Array;
754
- reliability: string;
755
- }) => void;
756
- onMeetingJoined?: () => void;
757
- onMeetingLeft?: () => void;
758
- onLiveStreamStarted?: () => void;
759
- onLiveStreamStopped?: () => void;
760
- onVideoStateChanged?: () => void;
761
- onVideoSeeked?: () => void;
762
- onWebcamRequested?: ({
763
- participantId,
764
- accept,
765
- reject
766
- }: {
767
- participantId: string;
768
- accept: () => void;
769
- reject: () => void;
770
- }) => void;
771
- onMicRequested?: ({
772
- participantId,
773
- accept,
774
- reject
775
- }: {
776
- participantId: string;
777
- accept: () => void;
778
- reject: () => void;
779
- }) => void;
780
- onPinStateChanged?: ({
781
- participantId,
782
- state,
783
- pinnedBy
784
- }: {
785
- participantId: string;
786
- state: { share: boolean; cam: boolean };
787
- pinnedBy: string;
788
- }) => void;
789
- onConnectionOpen?: () => void;
790
- onConnetionClose?: () => void;
791
- onSwitchMeeting?: () => void;
792
- onError?: ({ code, message }: { code: string; message: string }) => void;
793
- onHlsStarted?: ({ downstreamUrl }: { downstreamUrl: string }) => void;
794
- onHlsStopped?: () => void;
795
- onHlsStateChanged?: ({
796
- status,
797
- downstreamUrl,
798
- playbackHlsUrl,
799
- livestreamUrl
800
- }: {
801
- status:
802
- | 'HLS_STARTING'
803
- | 'HLS_STARTED'
804
- | 'HLS_PLAYABLE'
805
- | 'HLS_STOPPING'
806
- | 'HLS_STOPPED';
807
- downstreamUrl?: string;
808
- playbackHlsUrl?: string;
809
- livestreamUrl?: string;
810
- }) => void;
811
- onRecordingStateChanged?: ({
812
- status
813
- }: {
814
- status:
815
- | 'RECORDING_STARTING'
816
- | 'RECORDING_STARTED'
817
- | 'RECORDING_STOPPING'
818
- | 'RECORDING_STOPPED';
819
- }) => void;
820
- onLivestreamStateChanged?: ({
821
- status
822
- }: {
823
- status:
824
- | 'LIVESTREAM_STARTING'
825
- | 'LIVESTREAM_STARTED'
826
- | 'LIVESTREAM_STOPPING'
827
- | 'LIVESTREAM_STOPPED';
828
- }) => void;
829
- onMeetingStateChanged?: ({
830
- state
831
- }: {
832
- state:
833
- | 'CONNECTING'
834
- | 'CONNECTED'
835
- | 'FAILED'
836
- | 'DISCONNECTED'
837
- | 'CLOSING'
838
- | 'CLOSED';
839
- }) => void;
840
- onParticipantModeChanged?: ({
841
- participantId,
842
- mode
843
- }: {
844
- participantId: string;
845
- mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
846
- }) => void;
847
- onCharacterJoined?: (character: Character) => void;
848
- onCharacterLeft?: (character: Character) => void;
849
- onMediaRelayStarted?: ({
850
- meetingId
851
- }: {
852
- meetingId: string
853
- }) => void;
854
- onMediaRelayStopped?: ({
855
- meetingId,
856
- reason
857
- }: {
858
- meetingId: string;
859
- reason: string;
860
- }) => void;
861
- onMediaRelayError?: ({
862
- meetingId,
863
- error
864
- }: {
865
- meetingId: string;
866
- error: string;
867
- }) => void;
868
- onMediaRelayRequestResponse?: ({
869
- decision,
870
- decidedBy,
871
- meetingId
872
- }: {
873
- decision: "accepted" | "declined";
874
- decidedBy: string;
875
- meetingId: string;
876
- }) => void;
877
- onMediaRelayRequestReceived?: ({
878
- participantId,
879
- meetingId,
880
- displayName,
881
- accept,
882
- reject
883
- }: {
884
- participantId: string;
885
- meetingId: string;
886
- displayName: string;
887
- accept: () => void;
888
- reject: () => void;
889
- }) => void;
890
- }): {
891
- meetingId: string;
892
- meeting: Meeting;
893
- localParticipant: Participant;
894
- activeSpeakerId: string;
895
- participants: Map<string, Participant>;
896
- characters: Map<string, Character>;
897
- pinnedParticipants: Map<
898
- string,
899
- {
900
- cam: boolean;
901
- share: boolean;
902
- }
903
- >;
904
- presenterId?: string;
905
- localMicOn: boolean;
906
- localWebcamOn: boolean;
907
- isRecording: boolean;
908
- recordingState: string;
909
- livestreamState: string;
910
- hlsState: string;
911
- hlsUrls: {
912
- downstreamUrl: string;
913
- playbackHlsUrl: string;
914
- livestreamUrl: string;
915
- };
916
- transcriptionState: string;
917
- selectedCameraDevice?: {
918
- deviceId: string;
919
- groupId: string;
920
- kind: 'videoinput';
921
- label: string;
922
- };
923
- selectedMicrophoneDevice?: {
924
- deviceId: string;
925
- groupId: string;
926
- kind: 'audioinput';
927
- label: string;
928
- };
929
- localScreenShareOn: boolean;
930
- connections: Map<string, Connection>;
931
- join: () => void;
932
- leave: () => void;
933
- end: () => void;
934
- unmuteMic: (customAudioTrack?: MediaStream | undefined) => void;
935
- muteMic: () => void;
936
- toggleMic: (customAudioTrack?: MediaStream | undefined) => void;
937
- enableWebcam: (customVideoTrack?: MediaStream | undefined) => void;
938
- send: (payload: string | Blob | ArrayBuffer | ArrayBufferView,
939
- options?: {
940
- reliability?: "RELIABLE" | "UNRELIABLE";
941
- }) => Promise<boolean>;
942
- disableWebcam: () => void;
943
- toggleWebcam: (customVideoTrack?: MediaStream | undefined) => void;
944
- enableScreenShare: (customScreenShareTrack?: MediaStream | undefined) => void;
945
- disableScreenShare: () => void;
946
- toggleScreenShare: (customScreenShareTrack?: MediaStream | undefined) => void;
947
- pauseAllStreams: (kind?: "audio" | "video" | "share" | "shareAudio" | "all" | undefined) => void;
948
- resumeAllStreams: (kind?: "audio" | "video" | "share" | "shareAudio" | "all" | undefined) => void;
949
- startRecording: (
950
- webhookUrl?: string,
951
- awsDirPath?: string,
952
- config?: {
953
- layout: {
954
- type: 'GRID' | 'SPOTLIGHT' | 'SIDEBAR';
955
- priority: 'SPEAKER' | 'PIN';
956
- gridSize: number;
957
- };
958
- orientation: 'landscape' | 'portrait';
959
- theme: 'DEFAULT' | 'DARK' | 'LIGHT';
960
- quality: 'low' | 'med' | 'high';
961
- mode: 'video-and-audio' | 'audio';
962
- },
963
- transcription?: {
964
- enabled: boolean;
965
- summary?: {
966
- enabled: boolean;
967
- prompt?: string;
968
- };
969
- language?: string;
970
- }
971
- ) => void;
972
- stopRecording: () => void;
973
- switchTo: ({
974
- meetingId,
975
- token
976
- }: {
977
- meetingId: string;
978
- token?: string;
979
- }) => void;
980
- startLiveStream: (
981
- outputs: Array<{
982
- url: string;
983
- streamKey: string;
984
- }>,
985
- config?: {
986
- layout: {
987
- type: 'GRID' | 'SPOTLIGHT' | 'SIDEBAR';
988
- priority: 'SPEAKER' | 'PIN';
989
- gridSize: number;
990
- };
991
- theme: 'DEFAULT' | 'DARK' | 'LIGHT';
992
- }
993
- ) => void;
994
- stopLiveStream: () => void;
995
- startHls: (config?: {
996
- layout: {
997
- type: 'GRID' | 'SPOTLIGHT' | 'SIDEBAR';
998
- priority: 'SPEAKER' | 'PIN';
999
- gridSize: number;
1000
- };
1001
- orientation: 'landscape' | 'portrait';
1002
- theme: 'DEFAULT' | 'DARK' | 'LIGHT';
1003
- quality: 'low' | 'med' | 'high';
1004
- mode: 'video-and-audio' | 'audio';
1005
- }) => void;
1006
- stopHls: () => void;
1007
- getMics: () => Promise<
1008
- Array<{
1009
- deviceId: string;
1010
- label: string;
1011
- }>
1012
- >;
1013
- getWebcams: () => Promise<
1014
- Array<{
1015
- deviceId: string;
1016
- label: string;
1017
- facingMode: 'environment' | 'front';
1018
- }>
1019
- >;
1020
- changeMic: (object: string | MediaStream) => void;
1021
- changeWebcam: (object: string | MediaStream) => void;
1022
- changeMode(mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'): void;
1023
- startVideo: ({ link }: { link: string }) => void;
1024
- stopVideo: () => void;
1025
- pauseVideo: ({ currentTime }: { currentTime: number }) => void;
1026
- resumeVideo: () => void;
1027
- seekVideo: ({ currentTime }: { currentTime: number }) => void;
1028
- connectTo: ({
1029
- meetingId,
1030
- payload
1031
- }: {
1032
- meetingId: string;
1033
- payload: string;
1034
- }) => void;
1035
- };
1036
-
1037
- /**
1038
- *
1039
- * @param topic - Represents the topic for which you are publishing and getting a message.
1040
- * ---
1041
- * @param onMessageReceived - This will triggered when a new message is published for the subscribed topic with the message object.
1042
- * ---
1043
- * @param onOldMessagesReceived - This will triggered once when you subscribe to the topic and will receive all the old messages present for that topic as an array of message object.
1044
- * ---
1045
- * @returns This will return `message` properties and `publish()` method. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-pubsub#returns)
1046
- * ---
1047
- * **usePubSub example**
1048
- * ```js
1049
- * var topic = 'CHAT';
1050
- *
1051
- * function onMessageReceived(message) {
1052
- * console.log('New Message:', message);
1053
- * }
1054
- *
1055
- * function onOldMessagesReceived(messages) {
1056
- * console.log('Old Messages:', messages);
1057
- * }
1058
- *
1059
- * const {publish, messages} = usePubSub(topic, {
1060
- * onMessageReceived,
1061
- * onOldMessagesReceived,
1062
- * });
1063
- * ```
1064
- */
1065
- export function usePubSub(
1066
- topic: string,
1067
- {
1068
- onMessageReceived,
1069
- onOldMessagesReceived
1070
- }?: {
1071
- onMessageReceived?: (message: {
1072
- id: string;
1073
- message: string;
1074
- senderId: string;
1075
- senderName: string;
1076
- timestamp: string;
1077
- topic: string;
1078
- payload: object;
1079
- }) => void;
1080
- onOldMessagesReceived?: (
1081
- messages: Array<{
1082
- id: string;
1083
- message: string;
1084
- senderId: string;
1085
- senderName: string;
1086
- timestamp: string;
1087
- topic: string;
1088
- payload: object;
1089
- }>
1090
- ) => void;
1091
- }
1092
- ): {
1093
- publish: (
1094
- message: string,
1095
- {
1096
- persist,
1097
- sendOnly
1098
- }: {
1099
- persist: boolean;
1100
- sendOnly?: Array<String>;
1101
- },
1102
- payload?: object
1103
- ) => void;
1104
- messages: Array<{
1105
- id: string;
1106
- message: string;
1107
- senderId: string;
1108
- senderName: string;
1109
- timestamp: string;
1110
- topic: string;
1111
- payload: object;
1112
- }>;
1113
- };
1114
-
1115
- export function useFile(): {
1116
- uploadBase64File: ({
1117
- base64Data,
1118
- token,
1119
- fileName
1120
- }: {
1121
- base64Data: string;
1122
- token: string;
1123
- fileName: string;
1124
- }) => Promise<string | null>;
1125
-
1126
- fetchBase64File: ({
1127
- url,
1128
- token
1129
- }: {
1130
- url: string;
1131
- token: string;
1132
- }) => Promise<string | null>;
1133
- };
1134
-
1135
- /**
1136
- * @returns - This will return `startWhiteboard()`, `stopWhiteboard()` and `whiteboardUrl`.
1137
- * ---
1138
- * **useWhiteboard example**
1139
- * ```javascript
1140
- * const { startWhiteboard, stopWhiteboard, whiteboardUrl } = useWhiteboard();
1141
- *
1142
- * async function handleStartWhiteboard() {
1143
- * await startWhiteboard();
1144
- * }
1145
- *
1146
- * async function handleStopWhiteboard() {
1147
- * await stopWhiteboard();
1148
- * }
1149
- * ```
1150
- */
1151
- export function useWhiteboard(): {
1152
- /**
1153
- * @description Starts the whiteboard for the meeting.
1154
- */
1155
- startWhiteboard: () => Promise<void>;
1156
-
1157
- /**
1158
- * @description Stops the whiteboard session for the meeting.
1159
- */
1160
- stopWhiteboard: () => Promise<void>;
1161
-
1162
- /**
1163
- * @description The URL of the active whiteboard, or `null` if the whiteboard is not currently active.
1164
- */
1165
- whiteboardUrl: string | null;
1166
- };
1167
-
1168
- /**
1169
- * @param onTranscriptionStateChanged - This will triggered when a realtime transcription state is changed.
1170
- * ---
1171
- * @param onTranscriptionText - This will triggered when a realtime transcription text is published.
1172
- * ---
1173
- * @returns This will return `startTranscription()` and `stopTranscription()` method. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-transcription#returns)
1174
- * ---
1175
- * **useTranscription example**
1176
- * ```js
1177
- *
1178
- * function onTranscriptionStateChanged(data) {
1179
- * console.log('New State Payload:', data)
1180
- * }
1181
- *
1182
- * function onTranscriptionText(data) {
1183
- * console.log('Transcription Text Payload:', data);
1184
- * }
1185
- *
1186
- * const { startTranscription, stopTranscription } = useTranscription({
1187
- * onTranscriptionStateChanged,
1188
- * onTranscriptionText,
1189
- * });
1190
- *
1191
- * async function startTranscription()=>{
1192
- * await startTranscription()
1193
- * }
1194
- *
1195
- * async function stopTranscription()=>{
1196
- * await stopTranscription()
1197
- * }
1198
- * ```
1199
- */
1200
- export function useTranscription({
1201
- onTranscriptionStateChanged,
1202
- onTranscriptionText
1203
- }?: {
1204
- onTranscriptionStateChanged?: (data: { id: string; status: string }) => void;
1205
- onTranscriptionText?: (data: {
1206
- participantId: string;
1207
- participantName: string;
1208
- text: string;
1209
- timestamp: number;
1210
- type: 'realtime';
1211
- }) => void;
1212
- }): {
1213
- /**
1214
- * @description This method is used to start the meeting transcription
1215
- * @param config.webhookUrl? Webhook URL which will be called by VideoSDK when the transcription state gets changed
1216
- * @param config.modelConfig? modelConfig if any, which will be used while doing transcription
1217
- * @param config.summary.enabled Enables or disables summary generation from realtime transcriptions.
1218
- * @param config.summary.prompt Guides summary generation (optional).
1219
- * @param config.language Language code for transcription, default is 'en' (optional).
1220
- */
1221
- startTranscription: ({
1222
- webhookUrl,
1223
- modelConfig,
1224
- summary,
1225
- language
1226
- }: {
1227
- webhookUrl?: string;
1228
- modelConfig?: object;
1229
- summary?: {
1230
- enabled: boolean;
1231
- prompt?: string;
1232
- };
1233
- language?: string;
1234
- }) => void;
1235
- stopTranscription: () => void;
1236
- };
1237
-
1238
- /**
1239
- * @param onCharacterStateChanged - This will triggered when a character state is changed.
1240
- * ---
1241
- * @param onCharacterMessage - This will triggered when a character response/message is published.
1242
- * ---
1243
- * @param onUserMessage - This will triggered when a user/participant message is published.
1244
- * ---
1245
- * @param onData - This will triggered when a character worker notify payload.
1246
- * ---
1247
- * @param onError - This will triggered when a there is an error related to character.
1248
- * ---
1249
- * @param onStreamEnabled - It's a callback which gets triggered whenever a character's video, audio or screen share stream is enabled.
1250
- * ---
1251
- * @param onStreamEnabled - It's a callback which gets triggered whenever a character's video, audio or screen share stream is disabled.
1252
- * ---
1253
- * @param onMediaStatusChanged - It's a callback which gets triggered whenever a character's video or audio is disabled or enabled.
1254
- * ---
1255
- * @param onVideoQualityChanged -
1256
- * - It's a callback which gets triggered whenever a character's video quality changes.
1257
- * - currentQuality and prevQuality can have values `HIGH` | `MEDIUM` | `LOW`.
1258
- * ---
1259
- * @returns This will return `character` Object.
1260
- * ---
1261
- * **useCharacter example**
1262
- * ```js
1263
- *
1264
- * function onCharacterStateChanged(data) {
1265
- * console.log('New State Payload:', data)
1266
- * }
1267
- *
1268
- * function onCharacterMessage(data) {
1269
- * console.log('character message Payload:', data);
1270
- * }
1271
- *
1272
- * function onUserMessage(data) {
1273
- * console.log('user message Payload:', data);
1274
- * }
1275
- *
1276
- * function onData(topic, data) {
1277
- * console.log('character data available:', topic, data);
1278
- * }
1279
- *
1280
- * function onError(topic, data) {
1281
- * console.log('character error:', data.code,data.message);
1282
- * }
1283
- *
1284
- * const { join, leave, sendMessage, interrupt } = useCharacter({
1285
- * interactionId,
1286
- * // OR
1287
- * id,
1288
- * displayName,
1289
- * characterRole,
1290
- * characterMode,
1291
- * knowledgeBases,
1292
- * language,
1293
- * },
1294
- * {
1295
- * onCharacterStateChanged,
1296
- * onCharacterMessage,
1297
- * onUserMessage,
1298
- * onData,
1299
- * onError,
1300
- * onCharacterJoined,
1301
- * onCharacterLeft,
1302
- *
1303
- * onStreamEnabled,
1304
- * onStreamDisabled,
1305
- * onMediaStatusChanged,
1306
- * onVideoQualityChanged
1307
- * });
1308
- *
1309
- * async function joinCharacter()=>{
1310
- * await join()
1311
- * }
1312
- *
1313
- * async function removeCharacter()=>{
1314
- * await leave()
1315
- * }
1316
- * ```
1317
- */
1318
- export function useCharacter(
1319
- {
1320
- interactionId,
1321
- // OR
1322
- id,
1323
- displayName,
1324
- characterRole,
1325
- characterMode,
1326
- knowledgeBases,
1327
- language,
1328
- metaData
1329
- }: {
1330
- interactionId: string;
1331
- // OR
1332
- id: string;
1333
- displayName: string;
1334
- characterRole: string;
1335
- characterMode: 'text' | 'co_pilot' | 'auto_pilot' | 'vision_pilot';
1336
- knowledgeBases: string[];
1337
- language: string;
1338
- metaData: any;
1339
- },
1340
- {
1341
- onCharacterStateChanged,
1342
- onCharacterMessage,
1343
- onUserMessage,
1344
- onData,
1345
- onError,
1346
- onStreamEnabled,
1347
- onStreamDisabled,
1348
- onMediaStatusChanged,
1349
- onVideoQualityChanged
1350
- }: {
1351
- onCharacterStateChanged?: (data: {
1352
- id: string;
1353
- status: CharacterState;
1354
- }) => void;
1355
- onUserMessage?: (data: {
1356
- participantId: string;
1357
- participantName: string;
1358
- text: string;
1359
- timestamp: number;
1360
- }) => void;
1361
- onCharacterMessage?: (data: {
1362
- characterId: string;
1363
- characterName: string;
1364
- text: string;
1365
- timestamp: number;
1366
- }) => void;
1367
-
1368
- onData?: (topic: string, data: any) => void;
1369
- onError?: (data: any) => void;
1370
- onCharacterJoined?: () => void;
1371
- onCharacterLeft?: () => void;
1372
-
1373
- onStreamDisabled?: (stream: Stream) => void;
1374
- onStreamEnabled?: (stream: Stream) => void;
1375
- onMediaStatusChanged?: ({
1376
- kind,
1377
- peerId,
1378
- newStatus
1379
- }: {
1380
- kind: 'audio' | 'video';
1381
- peerId: string;
1382
- newStatus: boolean;
1383
- }) => void;
1384
- onVideoQualityChanged?: ({
1385
- peerId,
1386
- prevQuality,
1387
- currentQuality
1388
- }: {
1389
- peerId: string;
1390
- prevQuality: 'low' | 'med' | 'high';
1391
- currentQuality: 'low' | 'med' | 'high';
1392
- }) => void;
1393
- }
1394
- ): {
1395
- displayName: string;
1396
- webcamStream: Stream;
1397
- micStream: Stream;
1398
- webcamOn: boolean;
1399
- micOn: boolean;
1400
- isActiveSpeaker: boolean;
1401
-
1402
- interactionId?: string;
1403
- id?: string;
1404
- characterMode?: CharacterMode;
1405
- characterState?: CharacterState;
1406
- knowledgeBases?: string[];
1407
- metaData?: any;
1408
-
1409
- enableMic: () => void;
1410
- disableMic: () => void;
1411
- enableWebcam: () => void;
1412
- disableWebcam: () => void;
1413
- join: () => Promise<void>;
1414
- leave: () => Promise<void>;
1415
- sendMessage: (text: string) => Promise<void>;
1416
- interrupt: () => Promise<void>;
1417
- };
1418
-
1419
- /**
1420
- * @param microphoneId - It will be the id of the mic from which the audio should be captured.
1421
- * ---
1422
- * @param encoderConfig - This will accept the voice profile you want to capture. You can checkout all value [here](https://docs.videosdk.live/react/api/sdk-reference/custom-tracks#parameters-1)
1423
- *
1424
- * #### Example : `speech_standard`, `high_quality`, `music_standard`,
1425
- * ---
1426
- * @param noiseConfig - You can provide different noise configuration
1427
- * ---
1428
- * @param noiseConfig.noiseSuppression - It is used to improve the quality of audio by removing background noise that can interfere with the clarity of speech.
1429
- * ---
1430
- * @param noiseConfig.echoCancellation - It is used to remove unwanted echoes from voice.
1431
- * ---
1432
- * @param noiseConfig.autoGainControl - It is used to maintain a consistent level of loudness or amplitude in a voice.
1433
- * ---
1434
- *
1435
- * **Code Example**
1436
- * ```js
1437
- * import { createMicrophoneAudioTrack } from "@videosdk.live/react-sdk";
1438
- *
1439
- * let customTrack = await createMicrophoneAudioTrack({
1440
- * microphoneId : 'mic-id', // OPTIONAL
1441
- * encoderConfig: "speech_standard", // `high_quality` | `music_standard`, Default : `speech_standard`
1442
- * noiseConfig: {
1443
- * noiseSuppression: true,
1444
- * echoCancellation: true,
1445
- * autoGainControl: true,
1446
- * },
1447
- * });
1448
- * ```
1449
- */
1450
-
1451
- export function createMicrophoneAudioTrack({
1452
- noiseConfig,
1453
- encoderConfig,
1454
- microphoneId
1455
- }: {
1456
- noiseConfig?:
1457
- | {
1458
- echoCancellation: boolean;
1459
- autoGainControl: boolean;
1460
- noiseSuppression: boolean;
1461
- }
1462
- | undefined;
1463
- encoderConfig?:
1464
- | 'speech_low_quality'
1465
- | 'speech_standard'
1466
- | 'music_standard'
1467
- | 'standard_stereo'
1468
- | 'high_quality'
1469
- | 'high_quality_stereo'
1470
- | undefined;
1471
- microphoneId?: string | undefined;
1472
- }): Promise<MediaStream>;
1473
-
1474
- /**
1475
- * @param cameraId - It will be the id of the camera from which the video should be captured.
1476
- * ---
1477
- * @param encoderConfig - This will accept the resolution (height x width) of video you want to capture.
1478
- * You can checkout all value [here](https://docs.videosdk.live/react/api/sdk-reference/custom-tracks#parameters)
1479
- *
1480
- * #### Example : `h360p_w640p`, `h720p_w1280p`, `h1080p_w1440p`
1481
- * ---
1482
- * @param facingMode - For Mobile browser It will specifiy whether to use front or back camera for the video track.
1483
- *
1484
- * #### Values : `front`, `environment`
1485
- * ---
1486
- * @param optimizationMode - It will specifiy the optimization mode for the video track being generated.
1487
- *
1488
- * #### Values : `motion`, `text`, `detail`
1489
- *
1490
- * ---
1491
- * @param multiStream - It will specifiy if the stream should send multiple resolution layers or single resolution layer.
1492
- * Please refere thi link for more understanding [What is multiStream ?](https://docs.videosdk.live/react/guide/video-and-audio-calling-api-sdk/render-media/optimize-video-track#what-is-multistream)
1493
- * ---
1494
- *
1495
- * **Code Example**
1496
- * ```js
1497
- * import { createCameraVideoTrack } from "@videosdk.live/react-sdk";
1498
- *
1499
- * let customTrack = await createCameraVideoTrack({
1500
- * cameraId:"camera-id", // OPTIONAL
1501
- * optimizationMode: "motion", // "text" | "detail", Default : "motion"
1502
- * encoderConfig: "h480p_w640p", // "h540p_w960p" | "h720p_w1280p" ... // Default : "h360p_w640p"
1503
- * facingMode: "environment", // "front", Default : "environment"
1504
- * multiStream:true // false, Default : true
1505
- * });
1506
- * ```
1507
- */
1508
- export function createCameraVideoTrack({
1509
- cameraId,
1510
- encoderConfig,
1511
- facingMode,
1512
- optimizationMode,
1513
- multiStream
1514
- }: {
1515
- cameraId?: string | undefined;
1516
- encoderConfig?:
1517
- | 'h90p_w160p'
1518
- | 'h180p_w320p'
1519
- | 'h216p_w384p'
1520
- | 'h360p_w640p'
1521
- | 'h360p_w640p_150kbps'
1522
- | 'h540p_w960p'
1523
- | 'h720p_w1280p'
1524
- | 'h1080p_w1920p'
1525
- | 'h1440p_w2560p'
1526
- | 'h2160p_w3840p'
1527
- | 'h120p_w160p'
1528
- | 'h180p_w240p'
1529
- | 'h240p_w320p'
1530
- | 'h360p_w480p'
1531
- | 'h480p_w640p'
1532
- | 'h540p_w720p'
1533
- | 'h720p_w960p'
1534
- | 'h1080p_w1440p'
1535
- | 'h1440p_w1920p'
1536
- | undefined;
1537
- facingMode?: 'user' | 'environment' | undefined;
1538
- optimizationMode?: 'text' | 'motion' | 'detail' | undefined;
1539
- multiStream?: boolean;
1540
- }): Promise<MediaStream>;
1541
-
1542
- /**
1543
- * @param encoderConfig - This will accept the height & FPS of video you want to capture.
1544
- * You can checkout all value [here](https://docs.videosdk.live/react/api/sdk-reference/custom-tracks#parameters)
1545
- *
1546
- * #### Example : `h360p_30fps`, `h720p_5fps`, `h720p_15fps`, `h1080p_15fps`, `h1080p_30fps`
1547
- * ---
1548
- * @param optimizationMode - It will specifiy the optimization mode for the video track being generated.
1549
- *
1550
- * #### Values : `motion`, `text`, `detail`
1551
- * ---
1552
- * @param withAudio - It will specifiy to use screen share with audio or not
1553
- *
1554
- * #### Values : `enable`, `disable`
1555
- * ---
1556
- * @param multiStream - It will specifiy if the stream should send multiple resolution layers or single resolution layer.
1557
- * Please refere thi link for more understanding [What is multiStream ?](https://docs.videosdk.live/react/guide/video-and-audio-calling-api-sdk/render-media/optimize-video-track#what-is-multistream)
1558
- *
1559
- * **Code Example**
1560
- * ```js
1561
- * import { createScreenShareVideoTrack } from "@videosdk.live/react-sdk";
1562
- *
1563
- * let customTrack = await createCameraVideoTrack({
1564
- * optimizationMode: "motion", // "text" | "detail", Default : "motion"
1565
- * encoderConfig: "h720p_15fps", // `h360p_30fps` | `h1080p_30fps` // Default : `h720p_15fps`
1566
- * withAudio:'enable' // `disable`, Default : `disable`
1567
- * multiStream: true // false, Default : false
1568
- *
1569
- * });
1570
- * ```
1571
- */
1572
- export function createScreenShareVideoTrack({
1573
- encoderConfig,
1574
- optimizationMode,
1575
- withAudio,
1576
- multiStream,
1577
- }: {
1578
- encoderConfig?:
1579
- | "h360p_30fps"
1580
- | "h480p_15fps"
1581
- | "h480p_30fps"
1582
- | "h720p_5fps"
1583
- | "h720p_15fps"
1584
- | "h720p_30fps"
1585
- | "h1080p_15fps"
1586
- | "h1080p_30fps"
1587
- | undefined;
1588
- optimizationMode?: 'text' | 'motion' | 'detail' | undefined;
1589
- withAudio?: 'enable' | 'disable';
1590
- multiStream?: boolean;
1591
- }): Promise<MediaStream>;
1592
-
1593
- /**
1594
- * @deprecated
1595
- * @param timeoutDuration - This will accept the timeoutDuration.
1596
- *
1597
- * **Code Example**
1598
- * ```js
1599
- * import { getNetworkStats } from "@videosdk.live/react-sdk";
1600
- *
1601
- * try{
1602
- * const options = { timeoutDuration: 45000 };
1603
- * const networkStats = await VideoSDK.getNetworkStats(options);
1604
- * console.log("networkStats", networkStats);
1605
- * }catch(Ex)
1606
- * {
1607
- * console.log("exception",Ex);
1608
- * }
1609
- * ```
1610
- */
1611
- export function getNetworkStats({
1612
- timeoutDuration
1613
- }?: {
1614
- timeoutDuration?: number | undefined;
1615
- }): Promise<{ downloadSpeed: number; uploadSpeed: number }>;
1616
-
1617
- /**
1618
- * @param participantId - Unique ID of the participant whose video stream will be rendered.
1619
- *
1620
- * ---
1621
- * @param type - Type of stream to render.
1622
- * - **"video"**: Renders the participant's webcam video stream.
1623
- * - **"share"**: Renders the participant's screen share video stream. Observers are not attached for this type.
1624
- *
1625
- * ---
1626
- * @param containerStyle - Custom styles for the video container.
1627
- *
1628
- * ---
1629
- * @param className - Custom class name for the video container.
1630
- *
1631
- * ---
1632
- * @param classNameVideo - Custom class name for the video element inside the container.
1633
- *
1634
- * ---
1635
- * @param videoStyle - Custom styles for the video element inside the container.
1636
- *
1637
- * ---
1638
- * @returns A React component that renders the participant's video stream with optional adaptive observers.
1639
- *
1640
- * **Code Example:**
1641
- * ```tsx
1642
- * <VideoPlayer
1643
- * participantId="participant123"
1644
- * type="video"
1645
- * containerStyle={{ border: "1px solid red" }}
1646
- * className="custom-container"
1647
- * classNameVideo="custom-video"
1648
- * videoStyle={{ objectFit: "cover" }}
1649
- * />
1650
- * ```
1651
- */
1652
- export function VideoPlayer({
1653
- participantId,
1654
- type,
1655
- containerStyle,
1656
- className,
1657
- classNameVideo,
1658
- videoStyle
1659
- }: {
1660
- participantId: string;
1661
- type?: "video" | "share";
1662
- containerStyle?: React.CSSProperties;
1663
- className?: string;
1664
- classNameVideo?: string;
1665
- videoStyle?: React.CSSProperties;
1666
- }): JSX.Element;
1667
-
1668
- /**
1669
- * @param participantId - Unique ID of the participant whose audio stream will be rendered.
1670
- *
1671
- * ---
1672
- * @param type - Type of audio stream to render.
1673
- * - **"audio"**: Renders the participant's microphone audio stream.
1674
- * - **"shareAudio"**: Renders the participant's screen share audio stream.
1675
- *
1676
- * ---
1677
- * @returns A React component that renders the participant's audio stream.
1678
- *
1679
- * **Code Example:**
1680
- * ```tsx
1681
- * <AudioPlayer
1682
- * participantId="participant123"
1683
- * type="audio"
1684
- * />
1685
- * ```
1686
- */
1687
- export function AudioPlayer({
1688
- participantId,
1689
- type
1690
- }: {
1691
- participantId: string;
1692
- type?: "audio" | "shareAudio";
1693
- }): JSX.Element;
1694
-
1695
- /**
1696
- * @param VideoPlayerComponent - The base video player component to be enhanced with adaptive observers.
1697
- *
1698
- * ---
1699
- * @param intersectionObserverOptions - Options for the IntersectionObserver.
1700
- *
1701
- * ---
1702
- * @param debounceDelay - Delay in milliseconds for debouncing observer callbacks.
1703
- *
1704
- * ---
1705
- * @returns A Higher-Order Component (HOC) that wraps the provided video player component and adds adaptive observers.
1706
- *
1707
- * **Code Example:**
1708
- * ```tsx
1709
- * const EnhancedVideoPlayer = withAdaptiveObservers(VideoPlayer, {
1710
- * root: null,
1711
- * rootMargin: "0px",
1712
- * threshold: 0
1713
- * }, 400);
1714
- *
1715
- * <EnhancedVideoPlayer participantId="participant123" type="video" />;
1716
- * ```
1717
- */
1718
- export function withAdaptiveObservers(
1719
- VideoPlayerComponent: React.ComponentType<any>,
1720
- intersectionObserverOptions?: {
1721
- root?: Element | null;
1722
- rootMargin?: string;
1723
- threshold?: number | number[];
1724
- },
1725
- debounceDelay?: number
1726
- ): React.ComponentType<any>;
1727
-
1728
- export const Constants: {
1729
- errors: {
1730
- INVALID_API_KEY: number;
1731
- INVALID_TOKEN: number;
1732
- INVALID_MEETING_ID: number;
1733
- INVALID_PARTICIPANT_ID: number;
1734
- DUPLICATE_PARTICIPANT: number;
1735
- ACCOUNT_DEACTIVATED: number;
1736
- ACCOUNT_DISCONTINUED: number;
1737
- INVALID_PERMISSIONS: number;
1738
- MAX_PARTCIPANT_REACHED: number;
1739
- MAX_SPEAKER_REACHED: number;
1740
- START_RECORDING_FAILED: number;
1741
- STOP_RECORDING_FAILED: number;
1742
- START_LIVESTREAM_FAILED: number;
1743
- STOP_LIVESTREAM_FAILED: number;
1744
- INVALID_LIVESTREAM_CONFIG: number;
1745
- START_HLS_FAILED: number;
1746
- STOP_HLS_FAILED: number;
1747
- START_TRANSCRIPTION_FAILED: number;
1748
- STOP_TRANSCRIPTION_FAILED: number;
1749
- RECORDING_FAILED: number;
1750
- LIVESTREAM_FAILED: number;
1751
- HLS_FAILED: number;
1752
- TRANSCRIPTION_FAILED: number;
1753
- ERROR_GET_VIDEO_MEDIA: number;
1754
- ERROR_GET_AUDIO_MEDIA: number;
1755
- ERROR_GET_DISPLAY_MEDIA: number;
1756
- ERROR_GET_VIDEO_MEDIA_PERMISSION_DENIED: number;
1757
- ERROR_GET_AUDIO_MEDIA_PERMISSION_DENIED: number;
1758
- ERROR_GET_DISPLAY_MEDIA_PERMISSION_DENIED: number;
1759
- ERROR_CAMERA_ACCESS_DENIED_OR_DISMISSED: number;
1760
- ERROR_MICROPHONE_ACCESS_DENIED_OR_DISMISSED: number;
1761
- ERROR_CAMERA_PERMISSION_DENIED_BY_OS: number;
1762
- ERROR_MICROPHONE_PERMISSION_DENIED_BY_OS: number;
1763
- ERROR_CAMERA_NOT_FOUND: number;
1764
- ERROR_MICROPHONE_NOT_FOUND: number;
1765
- ERROR_CAMERA_IN_USE: number;
1766
- ERROR_MICROPHONE_IN_USE: number;
1767
- ERROR_CAMERA_PERMISSION_OR_AUTOPLAY_ISSUE: number;
1768
- ERROR_VIDEO_SOURCE_INITIATION_FAILED: number;
1769
- ERROR_WEBCAM_TRACK_ENDED: number;
1770
- ERROR_MICROPHONE_TRACK_ENDED: number;
1771
- ERROR_INVALID_CUSTOM_VIDEO_TRACK: number;
1772
- ERROR_INVALID_CUSTOM_AUDIO_TRACK: number;
1773
- ERROR_CUSTOM_VIDEO_TRACK_ENDED: number;
1774
- ERROR_CUSTOM_AUDIO_TRACK_ENDED: number;
1775
- ERROR_CAMERA_ACCESS_UNAVAILABLE: number;
1776
- ERROR_MICROPHONE_ACCESS_UNAVAILABLE: number;
1777
- ERROR_ACTION_PERFORMED_BEFORE_MEETING_JOINED: number;
1778
- };
1779
- recordingEvents: {
1780
- RECORDING_STARTING: string;
1781
- RECORDING_STARTED: string;
1782
- RECORDING_STOPPING: string;
1783
- RECORDING_STOPPED: string;
1784
- };
1785
- livestreamEvents: {
1786
- LIVESTREAM_STARTING: string;
1787
- LIVESTREAM_STARTED: string;
1788
- LIVESTREAM_STOPPING: string;
1789
- LIVESTREAM_STOPPED: string;
1790
- };
1791
- hlsEvents: {
1792
- HLS_STARTING: string;
1793
- HLS_STARTED: string;
1794
- HLS_PLAYABLE: string;
1795
- HLS_STOPPING: string;
1796
- HLS_STOPPED: string;
1797
- };
1798
- transcriptionEvents: {
1799
- TRANSCRIPTION_STARTING: string;
1800
- TRANSCRIPTION_STARTED: string;
1801
- TRANSCRIPTION_STOPPING: string;
1802
- TRANSCRIPTION_STOPPED: string;
1803
- };
1804
- characterState: CharacterState;
1805
- characterMode: CharacterMode;
1806
- modes: {
1807
- // Deprecated modes
1808
- CONFERENCE: string; // Deprecated
1809
- VIEWER: string; // Deprecated
1810
- // New modes
1811
- SEND_AND_RECV: string; // New mode
1812
- SIGNALLING_ONLY: string; // New mode
1813
- RECV_ONLY: string
1814
- };
1815
- permission: {
1816
- AUDIO: Permission;
1817
- VIDEO: Permission;
1818
- AUDIO_AND_VIDEO: Permission;
1819
- };
1820
- };
1821
- export { CameraDeviceInfo, DeviceInfo, MicrophoneDeviceInfo };