@videosdk.live/react-sdk 0.4.6 → 0.4.8

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.
@@ -102,6 +102,8 @@ export function MeetingProvider({
102
102
  metaData?: object;
103
103
  defaultCamera?: 'front' | 'back';
104
104
  debugMode: boolean;
105
+ translationLanguage?: string;
106
+ speakingLanguage?: string;
105
107
  };
106
108
  token: string;
107
109
  joinWithoutUserInteraction?: boolean;
@@ -174,6 +176,8 @@ export function MeetingProvider({
174
176
  * - **SEND_AND_RECV**: Both audio and video streams will be produced and consumed in this mode.
175
177
  * - **RECV_ONLY**: Both audio and video streams will be only consumed in this mode.
176
178
  * - **SIGNALLING_ONLY**: Audio and video streams will not be produced or consumed in this mode.
179
+ * ---
180
+ * @param onQualityLimitation - This event will be emitted when a quality limitation is detected or resolved during the meeting.
177
181
  */
178
182
 
179
183
  export function MeetingConsumer({
@@ -209,7 +213,8 @@ export function MeetingConsumer({
209
213
  onRecordingStateChanged,
210
214
  onLivestreamStateChanged,
211
215
  onMeetingStateChanged,
212
- onParticipantModeChanged
216
+ onParticipantModeChanged,
217
+ onQualityLimitation,
213
218
  }: {
214
219
  children: any;
215
220
  onParticipantJoined?: (participant: Participant) => void;
@@ -336,6 +341,15 @@ export function MeetingConsumer({
336
341
  participantId: string;
337
342
  mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
338
343
  }) => void;
344
+ onQualityLimitation?: ({
345
+ type,
346
+ state,
347
+ timestamp,
348
+ }: {
349
+ type: "congestion" | "bandwidth" | "cpu",
350
+ state: "detected" | "resolved",
351
+ timestamp: number,
352
+ }) => void,
339
353
  }): any;
340
354
 
341
355
  /**
@@ -611,6 +625,53 @@ export function useParticipant(
611
625
  >;
612
626
  };
613
627
 
628
+ /**
629
+ *
630
+ * @param streamId - ID of the stream.
631
+ * ---
632
+ * @param onStreamStateChanged - It’s a callback that triggers whenever the state of a remote participant’s video stream changes.
633
+ *
634
+ * **Code Example:**
635
+ * ```js
636
+ * function onStreamStateChanged({ state, timestamp }) {
637
+ * console.log("onStreamStateChanged", state, timestamp);
638
+ * }
639
+ * const { kind, paused, pause, resume } = useStream(streamId, {
640
+ * onStreamStateChanged,
641
+ * });
642
+ * ```
643
+ * ---
644
+ * @returns This will return the stream properties and methods.
645
+ */
646
+ export function useStream(
647
+ streamId: string,
648
+ {
649
+ onStreamStateChanged,
650
+ }?: {
651
+ onStreamStateChanged?: ({
652
+ state,
653
+ timestamp,
654
+ }: {
655
+ state:
656
+ | 'active'
657
+ | 'ended'
658
+ | 'stuck'
659
+ | 'freeze-detected'
660
+ | 'freeze-resolved';
661
+ timestamp: number;
662
+ }) => void;
663
+ }
664
+ ): {
665
+ kind: 'audio' | 'video' | 'share' | 'shareAudio';
666
+ stream: Stream;
667
+ codec: string;
668
+ track: MediaStreamTrack;
669
+ paused: boolean;
670
+ pause: () => void;
671
+ resume: () => void;
672
+ };
673
+
674
+
614
675
  /**
615
676
  * @param onParticipantJoined - This event callback is trigger when a new participant joins the meeting.
616
677
  * ---
@@ -677,6 +738,9 @@ export function useParticipant(
677
738
  * ---
678
739
  * @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
740
  *
741
+ * ---
742
+ * @param onQualityLimitation - This event will be emitted when a quality limitation is detected or resolved during the meeting.
743
+
680
744
  */
681
745
 
682
746
  export function useMeeting({
@@ -719,6 +783,7 @@ export function useMeeting({
719
783
  onMediaRelayError,
720
784
  onMediaRelayRequestResponse,
721
785
  onMediaRelayRequestReceived,
786
+ onQualityLimitation,
722
787
  }?: {
723
788
  onParticipantJoined?: (participant: Participant) => void;
724
789
  onParticipantLeft?: (participant: Participant) => void;
@@ -887,6 +952,15 @@ export function useMeeting({
887
952
  accept: () => void;
888
953
  reject: () => void;
889
954
  }) => void;
955
+ onQualityLimitation?: ({
956
+ type,
957
+ state,
958
+ timestamp,
959
+ }: {
960
+ type: "congestion" | "bandwidth" | "cpu",
961
+ state: "detected" | "resolved",
962
+ timestamp: number,
963
+ }) => void,
890
964
  }): {
891
965
  meetingId: string;
892
966
  meeting: Meeting;
@@ -914,6 +988,7 @@ export function useMeeting({
914
988
  livestreamUrl: string;
915
989
  };
916
990
  transcriptionState: string;
991
+ translationState: string;
917
992
  selectedCameraDevice?: {
918
993
  deviceId: string;
919
994
  groupId: string;
@@ -1235,6 +1310,76 @@ export function useTranscription({
1235
1310
  stopTranscription: () => void;
1236
1311
  };
1237
1312
 
1313
+ /**
1314
+ * @param onTranslationStateChanged - This will triggered when a realtime translation state is changed.
1315
+ * ---
1316
+ * @param onTranslationLanguageChanged - This will triggered when a realtime translation language is changed.
1317
+ * ---
1318
+ * @param onTranslationText - This will triggered when a realtime translation text is published.
1319
+ * ---
1320
+ * @returns This will return `startTranslation()`, `changeTranslationLanguage()` and `stopTranslation()` method. You can refer this [API Reference](https://docs.videosdk.live/react/api/sdk-reference/use-translation#returns)
1321
+ * ---
1322
+ * **useTranslation example**
1323
+ * ```js
1324
+ *
1325
+ * function onTranslationStateChanged(data) {
1326
+ * console.log('New State Payload:', data)
1327
+ * }
1328
+ *
1329
+ * function onTranslationLanguageChanged(data) {
1330
+ * console.log('New Language Payload:', data)
1331
+ * }
1332
+ *
1333
+ * function onTranslationText(data) {
1334
+ * console.log('Translation Text Payload:', data);
1335
+ * }
1336
+ *
1337
+ * const { startTranslation, changeTranslationLanguage, stopTranslation } = useTranslation({
1338
+ * onTranslationStateChanged,
1339
+ * onTranslationLanguageChanged
1340
+ * onTranslationText,
1341
+ * });
1342
+ *
1343
+ * async function startTranslation()=>{
1344
+ * await startTranslation()
1345
+ * }
1346
+ *
1347
+ * async function changeTranslationLanguage()=>{
1348
+ * await changeTranslationLanguage(languageCode)
1349
+ * }
1350
+ *
1351
+ * async function stopTranslation()=>{
1352
+ * await stopTranslation()
1353
+ * }
1354
+ * ```
1355
+ */
1356
+ export function useTranslation({
1357
+ onTranslationStateChanged,
1358
+ onTranslationLanguageChanged,
1359
+ onTranslationText
1360
+ }?: {
1361
+ onTranslationStateChanged?: (data: { id: string; status: string }) => void;
1362
+ onTranslationLanguageChanged?: (data: {
1363
+ participantId: string,
1364
+ language: string,
1365
+ }) => void;
1366
+ onTranslationText?: (data: {
1367
+ participantId: string;
1368
+ participantName: string;
1369
+ text: string;
1370
+ timestamp: number;
1371
+ language: string;
1372
+ type: string;
1373
+ }) => void;
1374
+ }): {
1375
+ /**
1376
+ * @description This method is used to start the meeting translation
1377
+ */
1378
+ startTranslation: () => Promise<void>;
1379
+ changeTranslationLanguage: (languageCode: string) => Promise<void>;
1380
+ stopTranslation: () => Promise<void>;
1381
+ };
1382
+
1238
1383
  /**
1239
1384
  * @param onCharacterStateChanged - This will triggered when a character state is changed.
1240
1385
  * ---
@@ -1746,10 +1891,14 @@ export const Constants: {
1746
1891
  STOP_HLS_FAILED: number;
1747
1892
  START_TRANSCRIPTION_FAILED: number;
1748
1893
  STOP_TRANSCRIPTION_FAILED: number;
1894
+ START_TRANSLATION_FAILED: number;
1895
+ STOP_TRANSLATION_FAILED: number;
1896
+ CHANGE_TRANSLATION_LANGUAGE_FAILED: number;
1749
1897
  RECORDING_FAILED: number;
1750
1898
  LIVESTREAM_FAILED: number;
1751
1899
  HLS_FAILED: number;
1752
1900
  TRANSCRIPTION_FAILED: number;
1901
+ TRANSLATION_FAILED: number;
1753
1902
  ERROR_GET_VIDEO_MEDIA: number;
1754
1903
  ERROR_GET_AUDIO_MEDIA: number;
1755
1904
  ERROR_GET_DISPLAY_MEDIA: number;
@@ -1801,6 +1950,12 @@ export const Constants: {
1801
1950
  TRANSCRIPTION_STOPPING: string;
1802
1951
  TRANSCRIPTION_STOPPED: string;
1803
1952
  };
1953
+ translationEvents: {
1954
+ TRANSLATION_STARTING: string;
1955
+ TRANSLATION_STARTED: string;
1956
+ TRANSLATION_STOPPING: string;
1957
+ TRANSLATION_STOPPED: string;
1958
+ };
1804
1959
  characterState: CharacterState;
1805
1960
  characterMode: CharacterMode;
1806
1961
  modes: {
@@ -70,6 +70,15 @@ export class Meeting {
70
70
  | 'TRANSCRIPTION_STARTING'
71
71
  | 'TRANSCRIPTION_STARTED'
72
72
  | 'TRANSCRIPTION_STOPPING';
73
+
74
+ /**
75
+ * @description These represents the current state of the meeting translation
76
+ */
77
+ translationState:
78
+ | 'TRANSLATION_STOPPED'
79
+ | 'TRANSLATION_STARTING'
80
+ | 'TRANSLATION_STARTED'
81
+ | 'TRANSLATION_STOPPING';
73
82
 
74
83
  /**
75
84
  * @description These object will contain all the messages send using the `send` method
@@ -532,6 +541,9 @@ export class Meeting {
532
541
  | 'data'
533
542
  | 'transcription-text'
534
543
  | 'transcription-state-changed'
544
+ | 'translation-text'
545
+ | 'translation-state-changed'
546
+ | 'translation-language-changed'
535
547
  | 'character-joined'
536
548
  | 'character-left'
537
549
  | "paused-all-streams"
@@ -540,7 +552,8 @@ export class Meeting {
540
552
  | "media-relay-stopped"
541
553
  | "media-relay-error"
542
554
  | "media-relay-request-response"
543
- | "media-relay-request-received",
555
+ | "media-relay-request-received"
556
+ | "quality-limitation",
544
557
  listener: (data: any) => void
545
558
  ): void;
546
559
  /**
@@ -586,6 +599,9 @@ export class Meeting {
586
599
  | 'data'
587
600
  | 'transcription-text'
588
601
  | 'transcription-state-changed'
602
+ | 'translation-text'
603
+ | 'translation-state-changed'
604
+ | 'translation-language-changed'
589
605
  | 'character-joined'
590
606
  | 'character-left'
591
607
  | "paused-all-streams"
@@ -594,7 +610,8 @@ export class Meeting {
594
610
  | "media-relay-stopped"
595
611
  | "media-relay-error"
596
612
  | "media-relay-request-response"
597
- | "media-relay-request-received",
613
+ | "media-relay-request-received"
614
+ | "quality-limitation",
598
615
 
599
616
  listener: (data: any) => void
600
617
  ): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videosdk.live/react-sdk",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -74,7 +74,7 @@
74
74
  }
75
75
  },
76
76
  "dependencies": {
77
- "@videosdk.live/js-sdk": "0.3.8",
77
+ "@videosdk.live/js-sdk": "0.3.9",
78
78
  "events": "^3.3.0"
79
79
  }
80
80
  }