video-saas-client 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # video-saas-client
2
2
 
3
- Video calling SDK for Video SaaS. Connect to video rooms with API key authentication.
3
+ Video calling SDK for Video SaaS. Connect to video rooms with token-based authentication.
4
4
 
5
5
  ## Install
6
6
 
@@ -34,19 +34,46 @@ function MyVideoCall({ roomId, token }) {
34
34
  }
35
35
  ```
36
36
 
37
+ ### With a custom video track (e.g. virtual background)
38
+
39
+ Pass a pre-processed `MediaStreamTrack` via `videoTrack`. The SDK will use it instead of calling `getUserMedia` for video.
40
+
41
+ ```jsx
42
+ import { useVideoCall } from "video-saas-client";
43
+
44
+ function MyVideoCall({ roomId, token }) {
45
+ const [videoTrack, setVideoTrack] = useState(null);
46
+
47
+ useEffect(() => {
48
+ // Apply your virtual background and get a processed track
49
+ applyVirtualBackground().then(track => setVideoTrack(track));
50
+ }, []);
51
+
52
+ const { localStream, remoteStreams, leaveRoom } = useVideoCall(roomId, { token, videoTrack });
53
+
54
+ // ...
55
+ }
56
+ ```
57
+
37
58
  ## API
38
59
 
39
60
  ### `useVideoCall(roomId, options)`
40
61
 
41
- - **roomId** (string): Room ID to join
42
- - **options** (object):
43
- - **token** (string, required): Short-lived room token from `video-saas-admin`
62
+ | Option | Type | Required | Description |
63
+ |--------|------|----------|-------------|
64
+ | `token` | string | Yes | Short-lived room token from `video-saas-admin` |
65
+ | `videoTrack` | MediaStreamTrack | No | Custom video track — use this to pass a pre-processed track (e.g. with virtual background applied). Falls back to `getUserMedia` if not provided. |
44
66
 
45
67
  ### Returns
46
68
 
47
- - **localStream**: MediaStream | null
48
- - **remoteStreams**: Map<peerId, MediaStream>
49
- - **isConnected**: boolean
50
- - **error**: string | null
51
- - **leaveRoom**: () => void
52
- - **startRecording**, **stopRecording**, **isRecording**, **recordingIds**: Recording APIs (if supported by server)
69
+ | Value | Type | Description |
70
+ |-------|------|-------------|
71
+ | `localStream` | MediaStream \| null | The local camera/mic stream |
72
+ | `remoteStreams` | Map\<peerId, MediaStream\> | Streams from other participants |
73
+ | `isConnected` | boolean | Whether the socket is connected |
74
+ | `error` | string \| null | Error message if something went wrong |
75
+ | `leaveRoom` | () => void | Disconnect and stop all tracks |
76
+ | `startRecording` | (patientPeerId) => Promise | Start recording (if supported by server) |
77
+ | `stopRecording` | () => Promise | Stop recording |
78
+ | `isRecording` | boolean | Whether recording is active |
79
+ | `recordingIds` | \{ doctor, patient \} | Active recording IDs |
package/dist/index.js CHANGED
@@ -14956,7 +14956,7 @@ Object.assign(lookup2, {
14956
14956
  var import_mediasoup_client = __toESM(require_lib5());
14957
14957
  var SERVER_URL = "https://video-saas.breakbyte.com/";
14958
14958
  function useVideoCall(roomId, options = {}) {
14959
- const { token } = options;
14959
+ const { token, videoTrack } = options;
14960
14960
  const [localStream, setLocalStream] = (0, import_react.useState)(null);
14961
14961
  const [remoteStreams, setRemoteStreams] = (0, import_react.useState)(/* @__PURE__ */ new Map());
14962
14962
  const [isConnected, setIsConnected] = (0, import_react.useState)(false);
@@ -15034,7 +15034,9 @@ function useVideoCall(roomId, options = {}) {
15034
15034
  return { sendTransport, recvTransport };
15035
15035
  }
15036
15036
  async function getLocalMedia(sendTransport) {
15037
- const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
15037
+ const audioStream = await navigator.mediaDevices.getUserMedia({ audio: true });
15038
+ const resolvedVideoTrack = videoTrack ?? (await navigator.mediaDevices.getUserMedia({ video: true })).getVideoTracks()[0];
15039
+ const stream = new MediaStream([resolvedVideoTrack, ...audioStream.getAudioTracks()]);
15038
15040
  localStreamRef.current = stream;
15039
15041
  if (cancelled) {
15040
15042
  stream.getTracks().forEach((t) => t.stop());
@@ -15116,7 +15118,7 @@ function useVideoCall(roomId, options = {}) {
15116
15118
  cancelled = true;
15117
15119
  cleanup();
15118
15120
  };
15119
- }, [roomId, token]);
15121
+ }, [roomId, token, videoTrack]);
15120
15122
  function cleanup() {
15121
15123
  localStreamRef.current?.getTracks().forEach((t) => t.stop());
15122
15124
  sendTransportRef.current?.close();
package/dist/index.mjs CHANGED
@@ -14948,7 +14948,7 @@ Object.assign(lookup2, {
14948
14948
  var import_mediasoup_client = __toESM(require_lib5());
14949
14949
  var SERVER_URL = "https://video-saas.breakbyte.com/";
14950
14950
  function useVideoCall(roomId, options = {}) {
14951
- const { token } = options;
14951
+ const { token, videoTrack } = options;
14952
14952
  const [localStream, setLocalStream] = useState(null);
14953
14953
  const [remoteStreams, setRemoteStreams] = useState(/* @__PURE__ */ new Map());
14954
14954
  const [isConnected, setIsConnected] = useState(false);
@@ -15026,7 +15026,9 @@ function useVideoCall(roomId, options = {}) {
15026
15026
  return { sendTransport, recvTransport };
15027
15027
  }
15028
15028
  async function getLocalMedia(sendTransport) {
15029
- const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
15029
+ const audioStream = await navigator.mediaDevices.getUserMedia({ audio: true });
15030
+ const resolvedVideoTrack = videoTrack ?? (await navigator.mediaDevices.getUserMedia({ video: true })).getVideoTracks()[0];
15031
+ const stream = new MediaStream([resolvedVideoTrack, ...audioStream.getAudioTracks()]);
15030
15032
  localStreamRef.current = stream;
15031
15033
  if (cancelled) {
15032
15034
  stream.getTracks().forEach((t) => t.stop());
@@ -15108,7 +15110,7 @@ function useVideoCall(roomId, options = {}) {
15108
15110
  cancelled = true;
15109
15111
  cleanup();
15110
15112
  };
15111
- }, [roomId, token]);
15113
+ }, [roomId, token, videoTrack]);
15112
15114
  function cleanup() {
15113
15115
  localStreamRef.current?.getTracks().forEach((t) => t.stop());
15114
15116
  sendTransportRef.current?.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "video-saas-client",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Video calling SDK for Video SaaS",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",