vg-x07df 1.9.4 → 1.10.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.
- package/CHANGELOG.md +41 -41
- package/LICENSE +20 -20
- package/README.md +249 -249
- package/dist/channel/index.cjs +3 -1
- package/dist/channel/index.cjs.map +1 -1
- package/dist/channel/index.d.cts +1 -1
- package/dist/channel/index.d.ts +1 -1
- package/dist/channel/index.mjs +3 -1
- package/dist/channel/index.mjs.map +1 -1
- package/dist/index.cjs +973 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +420 -12
- package/dist/index.d.ts +420 -12
- package/dist/index.mjs +959 -37
- package/dist/index.mjs.map +1 -1
- package/dist/livekit/index.cjs +4 -1
- package/dist/livekit/index.cjs.map +1 -1
- package/dist/livekit/index.mjs +4 -1
- package/dist/livekit/index.mjs.map +1 -1
- package/dist/{types-DrUtRtHg.d.cts → types-BbdWZE4Y.d.cts} +15 -2
- package/dist/{types-DrUtRtHg.d.ts → types-BbdWZE4Y.d.ts} +15 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# vg-x07df
|
|
2
|
-
|
|
3
|
-
## 1.3.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- edaed71: Bug fixes
|
|
8
|
-
- 72bb02b: exit
|
|
9
|
-
- 77d4cf4: Peformance and bug fixes
|
|
10
|
-
|
|
11
|
-
## 1.0.2
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Update README documentation
|
|
16
|
-
|
|
17
|
-
- Enhanced README with improved examples and API reference
|
|
18
|
-
- Updated hook descriptions to match actual implementation
|
|
19
|
-
- Corrected usage examples for better clarity
|
|
20
|
-
|
|
21
|
-
## 1.0.1
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- Add comprehensive README and LICENSE files
|
|
26
|
-
|
|
27
|
-
- Added detailed README.md with installation, usage examples, and API reference
|
|
28
|
-
- Added MIT LICENSE file
|
|
29
|
-
- Fixed missing documentation on npm package page
|
|
30
|
-
|
|
31
|
-
## 1.0.0
|
|
32
|
-
|
|
33
|
-
### Major Changes
|
|
34
|
-
|
|
35
|
-
- Initial release of CallPad SDK
|
|
36
|
-
|
|
37
|
-
- Production-ready headless SDK for CallPad audio/video calls
|
|
38
|
-
- React hooks for managing call state, participants, media controls
|
|
39
|
-
- LiveKit integration for real-time communication
|
|
40
|
-
- Socket.io support for call signaling
|
|
41
|
-
- TypeScript support with full type definitions
|
|
1
|
+
# vg-x07df
|
|
2
|
+
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- edaed71: Bug fixes
|
|
8
|
+
- 72bb02b: exit
|
|
9
|
+
- 77d4cf4: Peformance and bug fixes
|
|
10
|
+
|
|
11
|
+
## 1.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Update README documentation
|
|
16
|
+
|
|
17
|
+
- Enhanced README with improved examples and API reference
|
|
18
|
+
- Updated hook descriptions to match actual implementation
|
|
19
|
+
- Corrected usage examples for better clarity
|
|
20
|
+
|
|
21
|
+
## 1.0.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Add comprehensive README and LICENSE files
|
|
26
|
+
|
|
27
|
+
- Added detailed README.md with installation, usage examples, and API reference
|
|
28
|
+
- Added MIT LICENSE file
|
|
29
|
+
- Fixed missing documentation on npm package page
|
|
30
|
+
|
|
31
|
+
## 1.0.0
|
|
32
|
+
|
|
33
|
+
### Major Changes
|
|
34
|
+
|
|
35
|
+
- Initial release of CallPad SDK
|
|
36
|
+
|
|
37
|
+
- Production-ready headless SDK for CallPad audio/video calls
|
|
38
|
+
- React hooks for managing call state, participants, media controls
|
|
39
|
+
- LiveKit integration for real-time communication
|
|
40
|
+
- Socket.io support for call signaling
|
|
41
|
+
- TypeScript support with full type definitions
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Voyatek Group
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Voyatek Group
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
# CallPad SDK
|
|
2
|
-
|
|
3
|
-
Production-ready headless SDK for CallPad audio/video calls with React integration.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install vg-x07df
|
|
9
|
-
# or
|
|
10
|
-
yarn add vg-x07df
|
|
11
|
-
# or
|
|
12
|
-
pnpm add vg-x07df
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Quick Start
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import { CallpadSdkProvider, useCallActions, useCallState } from 'vg-x07df';
|
|
19
|
-
|
|
20
|
-
function App() {
|
|
21
|
-
return (
|
|
22
|
-
<CallpadSdkProvider config={{ apiUrl: 'your-api-url' }}>
|
|
23
|
-
<CallInterface />
|
|
24
|
-
</CallpadSdkProvider>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function CallInterface() {
|
|
29
|
-
const { initiate, accept, end } = useCallActions();
|
|
30
|
-
const { status, participants } = useCallState();
|
|
31
|
-
|
|
32
|
-
const handleStartCall = () => {
|
|
33
|
-
initiate(['user@example.com'], 'VIDEO');
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div>
|
|
38
|
-
<h1>Call Status: {status}</h1>
|
|
39
|
-
<button onClick={handleStartCall}>Start Video Call</button>
|
|
40
|
-
<div>Participants: {participants.length}</div>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Features
|
|
47
|
-
|
|
48
|
-
- 🎥 **Audio & Video Calls** - High-quality real-time communication
|
|
49
|
-
- ⚡ **React Hooks** - Modern React integration with custom hooks
|
|
50
|
-
- 🔧 **Headless UI** - Bring your own UI components
|
|
51
|
-
- 📱 **Responsive** - Works across desktop and mobile
|
|
52
|
-
- 🔒 **Secure** - End-to-end encrypted communications
|
|
53
|
-
- 🎛️ **Media Controls** - Camera, microphone, and screen sharing
|
|
54
|
-
- 👥 **Multi-participant** - Support for group calls
|
|
55
|
-
- 📊 **Call Quality** - Real-time quality monitoring
|
|
56
|
-
- 🔔 **Event System** - Comprehensive call event handling
|
|
57
|
-
|
|
58
|
-
## API Reference
|
|
59
|
-
|
|
60
|
-
### Providers
|
|
61
|
-
|
|
62
|
-
- `CallpadSdkProvider` - Main provider component for SDK configuration
|
|
63
|
-
|
|
64
|
-
### Hooks
|
|
65
|
-
|
|
66
|
-
- `useCallActions()` - Actions for managing calls (initiate, accept, decline, end, cancel)
|
|
67
|
-
- `useCallState()` - Current call state and session information
|
|
68
|
-
- `useParticipants()` - Participant management and information
|
|
69
|
-
- `useMediaControls()` - Camera, microphone, and screen sharing controls
|
|
70
|
-
- `useDevices()` - Audio/video device selection
|
|
71
|
-
- `useEvent()` - SDK event subscriptions
|
|
72
|
-
- `useCallQuality()` - Real-time call quality metrics
|
|
73
|
-
- `useErrors()` - Error handling and management
|
|
74
|
-
|
|
75
|
-
### LiveKit Integration
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
import { LiveKitProvider, useTrack } from 'vg-x07df/livekit';
|
|
79
|
-
|
|
80
|
-
// Access LiveKit room and tracks directly
|
|
81
|
-
const track = useTrack();
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Video Call Features
|
|
85
|
-
|
|
86
|
-
### Video Initialization
|
|
87
|
-
|
|
88
|
-
The SDK automatically initializes camera capability but keeps it disabled by default for privacy:
|
|
89
|
-
|
|
90
|
-
- Camera permissions are requested when the room connects
|
|
91
|
-
- Video starts disabled (privacy-first approach)
|
|
92
|
-
- Users must explicitly enable video via UI controls
|
|
93
|
-
- Room is optimized with adaptive streaming and dynacast for performance
|
|
94
|
-
|
|
95
|
-
### Using Video Controls
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
import { useTrackToggle, Track } from "vg-x07df/livekit";
|
|
99
|
-
|
|
100
|
-
function VideoControls() {
|
|
101
|
-
// Toggle video on/off
|
|
102
|
-
const { toggle: toggleVideo, enabled: isVideoEnabled } = useTrackToggle({
|
|
103
|
-
source: Track.Source.Camera
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<button onClick={toggleVideo}>
|
|
108
|
-
{isVideoEnabled ? "Turn Off Video" : "Turn On Video"}
|
|
109
|
-
</button>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Displaying Video
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
import { VideoTrack, useParticipantTracks, Track } from "vg-x07df/livekit";
|
|
118
|
-
import { hasVideoTrack } from "vg-x07df/utils";
|
|
119
|
-
|
|
120
|
-
function ParticipantVideo({ participant }) {
|
|
121
|
-
const tracks = useParticipantTracks(participant, Track.Source.Camera);
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<div className="participant-container">
|
|
125
|
-
{hasVideoTrack(participant) ? (
|
|
126
|
-
<VideoTrack
|
|
127
|
-
participant={participant}
|
|
128
|
-
source={Track.Source.Camera}
|
|
129
|
-
className="video-element"
|
|
130
|
-
/>
|
|
131
|
-
) : (
|
|
132
|
-
<div className="avatar-fallback">
|
|
133
|
-
{participant.identity}
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Video Utilities
|
|
142
|
-
|
|
143
|
-
The SDK provides utility functions for common video operations:
|
|
144
|
-
|
|
145
|
-
```tsx
|
|
146
|
-
import { hasVideoTrack, getVideoTrack, hasVideoCapability } from "vg-x07df/utils";
|
|
147
|
-
|
|
148
|
-
// Check if participant has active video (enabled and published)
|
|
149
|
-
const hasActiveVideo = hasVideoTrack(participant);
|
|
150
|
-
|
|
151
|
-
// Get video track publication
|
|
152
|
-
const videoTrack = getVideoTrack(participant);
|
|
153
|
-
|
|
154
|
-
// Check if video capability exists (track exists, may be muted)
|
|
155
|
-
const canHaveVideo = hasVideoCapability(participant);
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Complete Video Implementation Example
|
|
159
|
-
|
|
160
|
-
```tsx
|
|
161
|
-
import {
|
|
162
|
-
VideoTrack,
|
|
163
|
-
useTrackToggle,
|
|
164
|
-
useParticipantTracks,
|
|
165
|
-
Track,
|
|
166
|
-
useParticipants
|
|
167
|
-
} from "vg-x07df/livekit";
|
|
168
|
-
import { hasVideoTrack } from "vg-x07df/utils";
|
|
169
|
-
|
|
170
|
-
function VideoCallInterface() {
|
|
171
|
-
const participants = useParticipants();
|
|
172
|
-
const { toggle: toggleVideo, enabled: isVideoEnabled } = useTrackToggle({
|
|
173
|
-
source: Track.Source.Camera
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<div className="video-call-container">
|
|
178
|
-
{/* Video Controls */}
|
|
179
|
-
<div className="controls">
|
|
180
|
-
<button onClick={toggleVideo}>
|
|
181
|
-
{isVideoEnabled ? "Turn Off Video" : "Turn On Video"}
|
|
182
|
-
</button>
|
|
183
|
-
</div>
|
|
184
|
-
|
|
185
|
-
{/* Participant Videos */}
|
|
186
|
-
<div className="participants-grid">
|
|
187
|
-
{participants.map((participant) => (
|
|
188
|
-
<div key={participant.identity} className="participant-tile">
|
|
189
|
-
{hasVideoTrack(participant) ? (
|
|
190
|
-
<VideoTrack
|
|
191
|
-
participant={participant}
|
|
192
|
-
source={Track.Source.Camera}
|
|
193
|
-
className="video-element"
|
|
194
|
-
/>
|
|
195
|
-
) : (
|
|
196
|
-
<div className="avatar-placeholder">
|
|
197
|
-
{participant.identity.charAt(0).toUpperCase()}
|
|
198
|
-
</div>
|
|
199
|
-
)}
|
|
200
|
-
<span className="participant-name">
|
|
201
|
-
{participant.identity}
|
|
202
|
-
</span>
|
|
203
|
-
</div>
|
|
204
|
-
))}
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Video Troubleshooting
|
|
212
|
-
|
|
213
|
-
**Camera permissions denied:**
|
|
214
|
-
- The SDK handles permissions gracefully
|
|
215
|
-
- Users will see a browser permission prompt on first video toggle
|
|
216
|
-
- If permissions are denied, the call continues as audio-only
|
|
217
|
-
- Check browser settings if video toggle doesn't work
|
|
218
|
-
|
|
219
|
-
**Video not appearing:**
|
|
220
|
-
- Verify `hasVideoTrack(participant)` returns `true`
|
|
221
|
-
- Check that `useTrackToggle` shows `enabled: true`
|
|
222
|
-
- Ensure the `VideoTrack` component has the correct `participant` prop
|
|
223
|
-
- Confirm the participant has published their video track
|
|
224
|
-
|
|
225
|
-
**Performance issues with multiple videos:**
|
|
226
|
-
- The SDK uses optimized settings (720p, adaptive streaming, dynacast)
|
|
227
|
-
- Video quality automatically adjusts based on available bandwidth
|
|
228
|
-
- Multiple video streams are handled efficiently with simulcast
|
|
229
|
-
- Consider reducing video quality for low-bandwidth scenarios
|
|
230
|
-
|
|
231
|
-
**Audio works but video doesn't:**
|
|
232
|
-
- Check if camera is being used by another application
|
|
233
|
-
- Verify camera permissions in browser settings
|
|
234
|
-
- Try refreshing the page to reinitialize camera access
|
|
235
|
-
- Check browser console for camera-related errors
|
|
236
|
-
|
|
237
|
-
## Requirements
|
|
238
|
-
|
|
239
|
-
- React ≥18.0.0
|
|
240
|
-
- React DOM ≥18.0.0
|
|
241
|
-
- LiveKit Client ≥2.8.0
|
|
242
|
-
- Socket.IO Client ≥4.7.0
|
|
243
|
-
|
|
244
|
-
## TypeScript Support
|
|
245
|
-
|
|
246
|
-
This package includes full TypeScript definitions. No additional @types packages needed.
|
|
247
|
-
|
|
248
|
-
```tsx
|
|
249
|
-
import type { CallState, Participant, CallQuality } from 'vg-x07df';
|
|
1
|
+
# CallPad SDK
|
|
2
|
+
|
|
3
|
+
Production-ready headless SDK for CallPad audio/video calls with React integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install vg-x07df
|
|
9
|
+
# or
|
|
10
|
+
yarn add vg-x07df
|
|
11
|
+
# or
|
|
12
|
+
pnpm add vg-x07df
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { CallpadSdkProvider, useCallActions, useCallState } from 'vg-x07df';
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
return (
|
|
22
|
+
<CallpadSdkProvider config={{ apiUrl: 'your-api-url' }}>
|
|
23
|
+
<CallInterface />
|
|
24
|
+
</CallpadSdkProvider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function CallInterface() {
|
|
29
|
+
const { initiate, accept, end } = useCallActions();
|
|
30
|
+
const { status, participants } = useCallState();
|
|
31
|
+
|
|
32
|
+
const handleStartCall = () => {
|
|
33
|
+
initiate(['user@example.com'], 'VIDEO');
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<h1>Call Status: {status}</h1>
|
|
39
|
+
<button onClick={handleStartCall}>Start Video Call</button>
|
|
40
|
+
<div>Participants: {participants.length}</div>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- 🎥 **Audio & Video Calls** - High-quality real-time communication
|
|
49
|
+
- ⚡ **React Hooks** - Modern React integration with custom hooks
|
|
50
|
+
- 🔧 **Headless UI** - Bring your own UI components
|
|
51
|
+
- 📱 **Responsive** - Works across desktop and mobile
|
|
52
|
+
- 🔒 **Secure** - End-to-end encrypted communications
|
|
53
|
+
- 🎛️ **Media Controls** - Camera, microphone, and screen sharing
|
|
54
|
+
- 👥 **Multi-participant** - Support for group calls
|
|
55
|
+
- 📊 **Call Quality** - Real-time quality monitoring
|
|
56
|
+
- 🔔 **Event System** - Comprehensive call event handling
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### Providers
|
|
61
|
+
|
|
62
|
+
- `CallpadSdkProvider` - Main provider component for SDK configuration
|
|
63
|
+
|
|
64
|
+
### Hooks
|
|
65
|
+
|
|
66
|
+
- `useCallActions()` - Actions for managing calls (initiate, accept, decline, end, cancel)
|
|
67
|
+
- `useCallState()` - Current call state and session information
|
|
68
|
+
- `useParticipants()` - Participant management and information
|
|
69
|
+
- `useMediaControls()` - Camera, microphone, and screen sharing controls
|
|
70
|
+
- `useDevices()` - Audio/video device selection
|
|
71
|
+
- `useEvent()` - SDK event subscriptions
|
|
72
|
+
- `useCallQuality()` - Real-time call quality metrics
|
|
73
|
+
- `useErrors()` - Error handling and management
|
|
74
|
+
|
|
75
|
+
### LiveKit Integration
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { LiveKitProvider, useTrack } from 'vg-x07df/livekit';
|
|
79
|
+
|
|
80
|
+
// Access LiveKit room and tracks directly
|
|
81
|
+
const track = useTrack();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Video Call Features
|
|
85
|
+
|
|
86
|
+
### Video Initialization
|
|
87
|
+
|
|
88
|
+
The SDK automatically initializes camera capability but keeps it disabled by default for privacy:
|
|
89
|
+
|
|
90
|
+
- Camera permissions are requested when the room connects
|
|
91
|
+
- Video starts disabled (privacy-first approach)
|
|
92
|
+
- Users must explicitly enable video via UI controls
|
|
93
|
+
- Room is optimized with adaptive streaming and dynacast for performance
|
|
94
|
+
|
|
95
|
+
### Using Video Controls
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { useTrackToggle, Track } from "vg-x07df/livekit";
|
|
99
|
+
|
|
100
|
+
function VideoControls() {
|
|
101
|
+
// Toggle video on/off
|
|
102
|
+
const { toggle: toggleVideo, enabled: isVideoEnabled } = useTrackToggle({
|
|
103
|
+
source: Track.Source.Camera
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<button onClick={toggleVideo}>
|
|
108
|
+
{isVideoEnabled ? "Turn Off Video" : "Turn On Video"}
|
|
109
|
+
</button>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Displaying Video
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { VideoTrack, useParticipantTracks, Track } from "vg-x07df/livekit";
|
|
118
|
+
import { hasVideoTrack } from "vg-x07df/utils";
|
|
119
|
+
|
|
120
|
+
function ParticipantVideo({ participant }) {
|
|
121
|
+
const tracks = useParticipantTracks(participant, Track.Source.Camera);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className="participant-container">
|
|
125
|
+
{hasVideoTrack(participant) ? (
|
|
126
|
+
<VideoTrack
|
|
127
|
+
participant={participant}
|
|
128
|
+
source={Track.Source.Camera}
|
|
129
|
+
className="video-element"
|
|
130
|
+
/>
|
|
131
|
+
) : (
|
|
132
|
+
<div className="avatar-fallback">
|
|
133
|
+
{participant.identity}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Video Utilities
|
|
142
|
+
|
|
143
|
+
The SDK provides utility functions for common video operations:
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { hasVideoTrack, getVideoTrack, hasVideoCapability } from "vg-x07df/utils";
|
|
147
|
+
|
|
148
|
+
// Check if participant has active video (enabled and published)
|
|
149
|
+
const hasActiveVideo = hasVideoTrack(participant);
|
|
150
|
+
|
|
151
|
+
// Get video track publication
|
|
152
|
+
const videoTrack = getVideoTrack(participant);
|
|
153
|
+
|
|
154
|
+
// Check if video capability exists (track exists, may be muted)
|
|
155
|
+
const canHaveVideo = hasVideoCapability(participant);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Complete Video Implementation Example
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import {
|
|
162
|
+
VideoTrack,
|
|
163
|
+
useTrackToggle,
|
|
164
|
+
useParticipantTracks,
|
|
165
|
+
Track,
|
|
166
|
+
useParticipants
|
|
167
|
+
} from "vg-x07df/livekit";
|
|
168
|
+
import { hasVideoTrack } from "vg-x07df/utils";
|
|
169
|
+
|
|
170
|
+
function VideoCallInterface() {
|
|
171
|
+
const participants = useParticipants();
|
|
172
|
+
const { toggle: toggleVideo, enabled: isVideoEnabled } = useTrackToggle({
|
|
173
|
+
source: Track.Source.Camera
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div className="video-call-container">
|
|
178
|
+
{/* Video Controls */}
|
|
179
|
+
<div className="controls">
|
|
180
|
+
<button onClick={toggleVideo}>
|
|
181
|
+
{isVideoEnabled ? "Turn Off Video" : "Turn On Video"}
|
|
182
|
+
</button>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{/* Participant Videos */}
|
|
186
|
+
<div className="participants-grid">
|
|
187
|
+
{participants.map((participant) => (
|
|
188
|
+
<div key={participant.identity} className="participant-tile">
|
|
189
|
+
{hasVideoTrack(participant) ? (
|
|
190
|
+
<VideoTrack
|
|
191
|
+
participant={participant}
|
|
192
|
+
source={Track.Source.Camera}
|
|
193
|
+
className="video-element"
|
|
194
|
+
/>
|
|
195
|
+
) : (
|
|
196
|
+
<div className="avatar-placeholder">
|
|
197
|
+
{participant.identity.charAt(0).toUpperCase()}
|
|
198
|
+
</div>
|
|
199
|
+
)}
|
|
200
|
+
<span className="participant-name">
|
|
201
|
+
{participant.identity}
|
|
202
|
+
</span>
|
|
203
|
+
</div>
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Video Troubleshooting
|
|
212
|
+
|
|
213
|
+
**Camera permissions denied:**
|
|
214
|
+
- The SDK handles permissions gracefully
|
|
215
|
+
- Users will see a browser permission prompt on first video toggle
|
|
216
|
+
- If permissions are denied, the call continues as audio-only
|
|
217
|
+
- Check browser settings if video toggle doesn't work
|
|
218
|
+
|
|
219
|
+
**Video not appearing:**
|
|
220
|
+
- Verify `hasVideoTrack(participant)` returns `true`
|
|
221
|
+
- Check that `useTrackToggle` shows `enabled: true`
|
|
222
|
+
- Ensure the `VideoTrack` component has the correct `participant` prop
|
|
223
|
+
- Confirm the participant has published their video track
|
|
224
|
+
|
|
225
|
+
**Performance issues with multiple videos:**
|
|
226
|
+
- The SDK uses optimized settings (720p, adaptive streaming, dynacast)
|
|
227
|
+
- Video quality automatically adjusts based on available bandwidth
|
|
228
|
+
- Multiple video streams are handled efficiently with simulcast
|
|
229
|
+
- Consider reducing video quality for low-bandwidth scenarios
|
|
230
|
+
|
|
231
|
+
**Audio works but video doesn't:**
|
|
232
|
+
- Check if camera is being used by another application
|
|
233
|
+
- Verify camera permissions in browser settings
|
|
234
|
+
- Try refreshing the page to reinitialize camera access
|
|
235
|
+
- Check browser console for camera-related errors
|
|
236
|
+
|
|
237
|
+
## Requirements
|
|
238
|
+
|
|
239
|
+
- React ≥18.0.0
|
|
240
|
+
- React DOM ≥18.0.0
|
|
241
|
+
- LiveKit Client ≥2.8.0
|
|
242
|
+
- Socket.IO Client ≥4.7.0
|
|
243
|
+
|
|
244
|
+
## TypeScript Support
|
|
245
|
+
|
|
246
|
+
This package includes full TypeScript definitions. No additional @types packages needed.
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import type { CallState, Participant, CallQuality } from 'vg-x07df';
|
|
250
250
|
```
|