@videosdk.live/react-sdk 0.7.0 → 0.8.0

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.
@@ -0,0 +1,138 @@
1
+ export class AgentParticipant {
2
+ /**
3
+ * @description This represents the participant's ID
4
+ */
5
+ id: string;
6
+ /**
7
+ * @description This represents the participant's name
8
+ */
9
+ displayName: string;
10
+ /**
11
+ * @description This represents the all the Streams that the participant is producing
12
+ *
13
+ */
14
+ streams: Map<string, Stream>;
15
+ /**
16
+ * @description This represents whether the participant is an agent.
17
+ */
18
+ isAgent: boolean;
19
+ /**
20
+ * @description This represents the agent ID of the agentParticipant.
21
+ */
22
+ agentId: string;
23
+ /**
24
+ * @description This represents participant's current pin state
25
+ *
26
+ */
27
+ pinState: {
28
+ cam: boolean;
29
+ share: boolean;
30
+ };
31
+ /**
32
+ * @description This represents participant's current webcam status
33
+ */
34
+ webcamOn: boolean;
35
+ /**
36
+ * @description This represents participant's current mic status
37
+ *
38
+ */
39
+ micOn: boolean;
40
+ /**
41
+ * @description This represents participant's current mode
42
+ *
43
+ */
44
+ mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
45
+ /**
46
+ * @description This represents metaData which is passed in MeetingProvider
47
+ *
48
+ */
49
+ metaData: object;
50
+
51
+ /**
52
+ * @description This method can be used to kickout a participant from the meeting
53
+ */
54
+ remove(): void;
55
+
56
+ /**
57
+ * @param type If `SHARE_AND_CAM` is provided, it will pin screenshare and camera of the participant.
58
+ * If `CAM` is provided, it will only pin the participant's camera, If `SHARE` is provided, it will only pin the participant's screen share
59
+ */
60
+ pin(type: 'SHARE_AND_CAM' | 'CAM' | 'SHARE'): void;
61
+ /**
62
+ * @param type If `SHARE_AND_CAM` is provided, it will unpin screenshare and camera of the participant.
63
+ * If `CAM` is provided, it will only unpin the participant's camera, If `SHARE` is provided, it will only unpin the participant's screen share
64
+ */
65
+ unpin(type: 'SHARE_AND_CAM' | 'CAM' | 'SHARE'): void;
66
+ /**
67
+ * @description This method returns the Video Statistics of the participant.
68
+ * To learn more about the video statistics check these [reference](https://docs.videosdk.live/react/guide/video-and-audio-calling-api-sdk/render-media/understanding-call-quality)
69
+ */
70
+ getVideoStats(): Promise<
71
+ Array<{
72
+ bitrate: number;
73
+ rtt: number;
74
+ network: string;
75
+ codec: string;
76
+ jitter: number;
77
+ limitation: any;
78
+ totalPackets: number;
79
+ packetsLost: number;
80
+ concealmentEvents: number;
81
+ insertedSamplesForDecelaration: number;
82
+ removedSamplesForAccelaration: number;
83
+ size: any;
84
+ currentSpatialLayer: number;
85
+ currentTemporalLayer: number;
86
+ preferredSpatialLayer: number;
87
+ preferredTemporalLayer: number;
88
+ }>
89
+ >;
90
+ /**
91
+ * @description This method returns the Audio Statistics of the participant.
92
+ * To learn more about the video statistics check these [reference](https://docs.videosdk.live/react/guide/video-and-audio-calling-api-sdk/render-media/understanding-call-quality)
93
+ */
94
+ getAudioStats(): Promise<
95
+ Array<{
96
+ bitrate: number;
97
+ rtt: number;
98
+ network: string;
99
+ codec: string;
100
+ jitter: number;
101
+ totalPackets: number;
102
+ packetsLost: number;
103
+ concealmentEvents: number;
104
+ insertedSamplesForDecelaration: number;
105
+ removedSamplesForAccelaration: number;
106
+ size: any;
107
+ }>
108
+ >;
109
+ /**
110
+ * Add event listener
111
+ * @param eventType Event name to which you want to subscribe.
112
+ * @param listener Callback function which will be triggered when the event happens
113
+ */
114
+ on(
115
+ eventType:
116
+ | "stream-enabled"
117
+ | "stream-disabled"
118
+ | "media-status-changed"
119
+ | "agent-state-changed"
120
+ | "transcription-received",
121
+ listener: (data: any) => void
122
+ ): void;
123
+ /**
124
+ * Remove event
125
+ * @param eventType Event name to which you want to unsubscribe.
126
+ * @param listener Callback function which was passed while subscribing to the event
127
+ */
128
+ off(
129
+ eventType:
130
+ | "stream-enabled"
131
+ | "stream-disabled"
132
+ | "media-status-changed"
133
+ | "agent-state-changed"
134
+ | "transcription-received",
135
+ listener: (data: any) => void
136
+ ): void;
137
+ }
138
+ import { Stream } from './stream';
@@ -16,6 +16,7 @@ import {
16
16
  import { Permission } from './permission';
17
17
  import { Meeting } from './meeting';
18
18
  import { Participant } from './participant';
19
+ import { AgentParticipant } from './agentParticipant';
19
20
  import { Stream } from './stream';
20
21
  import { Character, CharacterMode, CharacterState } from './character';
21
22
  /**
@@ -420,7 +421,7 @@ export function useMediaDevice({
420
421
  *
421
422
  * **Code Example :**
422
423
  * ```js
423
- * function onMediaStatusChanged(stream) {
424
+ * function onMediaStatusChanged(data) {
424
425
  * const { kind, newStatus} = data;
425
426
  * console.log("onMediaStatusChanged", kind, newStatus);
426
427
  * }
@@ -435,7 +436,7 @@ export function useMediaDevice({
435
436
  *
436
437
  * **Code Example :**
437
438
  * ```js
438
- * function onVideoQualityChanged(stream) {
439
+ * function onVideoQualityChanged(data) {
439
440
  * const { currentQuality, prevQuality } = data;
440
441
  * console.log("onVideoQualityChanged", currentQuality, prevQuality );
441
442
  * }
@@ -630,6 +631,167 @@ export function useParticipant(
630
631
  >;
631
632
  };
632
633
 
634
+ /**
635
+ *
636
+ * @param participantId - Id of the participant.
637
+ * ---
638
+ * @param onStreamEnabled - It's a callback which gets triggered whenever a participant's video, audio or screen share stream is enabled.
639
+ *
640
+ * **Code Example :**
641
+ * ```js
642
+ * function onStreamEnabled(stream) {
643
+ * console.log("onStreamEnabled", stream);
644
+ * }
645
+ * const { displayName } = useAgentParticipant(participantId,{
646
+ * onStreamEnabled
647
+ * });
648
+ * ```
649
+ * ---
650
+ * @param onStreamDisabled - It's a callback which gets triggered whenever a participant's video, audio or screen share stream is disabled.
651
+ *
652
+ * **Code Example :**
653
+ * ```js
654
+ * function onStreamEnabled(stream) {
655
+ * console.log("onStreamEnabled", stream);
656
+ * }
657
+ * const { displayName } = useAgentParticipant(participantId,{
658
+ * onStreamEnabled
659
+ * });
660
+ * ```
661
+ * ---
662
+ * @param onMediaStatusChanged - It's a callback which gets triggered whenever a participant's video, audio, screenshare or screenshare audio is disabled or enabled.
663
+ *
664
+ * **Code Example :**
665
+ * ```js
666
+ * function onMediaStatusChanged(data) {
667
+ * const { kind, newStatus} = data;
668
+ * console.log("onMediaStatusChanged", kind, newStatus);
669
+ * }
670
+ * const { displayName } = useAgentParticipant(participantId,{
671
+ * onMediaStatusChanged
672
+ * });
673
+ * ```
674
+ * ---
675
+ * @param onAgentTranscriptionReceived - It's a callback which gets triggered whenever a participant's transcription is received.
676
+ *
677
+ * **Code Example :**
678
+ * ```js
679
+ * function onAgentTranscriptionReceived(data) {
680
+ * const { segment, participant } = data;
681
+ * const {text, timestamp} = segment;
682
+ *
683
+ * console.log("onAgentTranscriptionReceived", text, timestamp, participant);
684
+ * }
685
+ * const { displayName } = useAgentParticipant(participantId,{
686
+ * onAgentTranscriptionReceived
687
+ * });
688
+ * ```
689
+ * ---
690
+ * @param onAgentStateChanged - It's a callback which gets triggered whenever a participant's agent state is changed.
691
+ *
692
+ * **Code Example :**
693
+ * ```js
694
+ * function onAgentStateChanged(data) {
695
+ * console.log("onAgentStateChanged", data.state);
696
+ * }
697
+ * const { displayName } = useAgentParticipant(participantId,{
698
+ * onAgentStateChanged
699
+ * });
700
+ * ```
701
+ * ---
702
+ * @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)
703
+ */
704
+ export function useAgentParticipant(
705
+ participantId: string,
706
+ {
707
+ onStreamEnabled,
708
+ onStreamDisabled,
709
+ onMediaStatusChanged,
710
+ onAgentTranscriptionReceived,
711
+ onAgentStateChanged
712
+ }?: {
713
+ onStreamDisabled?: (stream: Stream) => void;
714
+ onStreamEnabled?: (stream: Stream) => void;
715
+ onMediaStatusChanged?: ({
716
+ kind,
717
+ peerId,
718
+ newStatus
719
+ }: {
720
+ kind: 'audio' | 'video' | 'share' | 'shareAudio';
721
+ peerId: string;
722
+ newStatus: boolean;
723
+ }) => void;
724
+ onAgentTranscriptionReceived? :({
725
+ segment : {
726
+ text,
727
+ timestamp
728
+ },
729
+ participant
730
+ }:{
731
+ segment :{
732
+ text: string;
733
+ timestamp: number;
734
+ }
735
+ participant: Participant | AgentParticipant,
736
+ }) => void;
737
+ onAgentStateChanged?:({
738
+ state
739
+ }:{
740
+ state: string;
741
+ })=>void;
742
+ }
743
+ ): {
744
+ displayName: string;
745
+ agentParticipant: AgentParticipant;
746
+ webcamStream: Stream;
747
+ micStream: Stream;
748
+ webcamOn: boolean;
749
+ micOn: boolean;
750
+ isActiveSpeaker: boolean;
751
+ pinState: any;
752
+ agentState: string;
753
+ mode: 'SEND_AND_RECV' | 'SIGNALLING_ONLY' | 'RECV_ONLY'
754
+ remove: () => void;
755
+ pin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
756
+ unpin: (data: 'SHARE_AND_CAM' | 'CAM' | 'SHARE') => void;
757
+ getAudioStats: () => Promise<
758
+ Array<{
759
+ bitrate: number;
760
+ rtt: number;
761
+ network: string;
762
+ codec: string;
763
+ jitter: number;
764
+ limitation: any;
765
+ totalPackets: number;
766
+ packetsLost: number;
767
+ concealmentEvents: number;
768
+ insertedSamplesForDecelaration: number;
769
+ removedSamplesForAccelaration: number;
770
+ size: any;
771
+ }>
772
+ >;
773
+ getVideoStats: () => Promise<
774
+ Array<{
775
+ bitrate: number;
776
+ rtt: number;
777
+ network: string;
778
+ codec: string;
779
+ jitter: number;
780
+ limitation: any;
781
+ totalPackets: number;
782
+ packetsLost: number;
783
+ concealmentEvents: number;
784
+ insertedSamplesForDecelaration: number;
785
+ removedSamplesForAccelaration: number;
786
+ size: any;
787
+ currentSpatialLayer: number;
788
+ currentTemporalLayer: number;
789
+ preferredSpatialLayer: number;
790
+ preferredTemporalLayer: number;
791
+ }>
792
+ >;
793
+ };
794
+
633
795
  /**
634
796
  *
635
797
  * @param streamId - ID of the stream.
@@ -2090,5 +2252,11 @@ export const Constants: {
2090
2252
  DEBUG: string;
2091
2253
  ALL: string;
2092
2254
  };
2255
+ AgentState:{
2256
+ IDLE:string;
2257
+ LISTENING:string;
2258
+ THINKING:string;
2259
+ SPEAKING:string;
2260
+ }
2093
2261
  };
2094
2262
  export { CameraDeviceInfo, DeviceInfo, MicrophoneDeviceInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videosdk.live/react-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "dependencies": {
79
- "@videosdk.live/js-sdk": "0.6.0",
79
+ "@videosdk.live/js-sdk": "0.7.0",
80
80
  "events": "^3.3.0"
81
81
  }
82
82
  }