Hiyve Components - v1.0.0
    Preparing search index...

    Function useAdditionalCameras

    • Manage additional camera feeds that join as ghost participants.

      Parameters

      Returns UseAdditionalCamerasReturn

      Each additional camera creates a separate WebRTC connection to the room as a ghost participant. Audio is automatically muted on ghost participants. Ghost participant userIds follow the format: {ownerUserId}__cam__{label}.

      Cameras are automatically cleaned up when the hook unmounts or when enabled becomes false.

      const { cameras, addCamera, removeCamera } = useAdditionalCameras({
      roomName: 'my-room',
      ownerUserId: 'user@example.com',
      generateRoomToken: async () => {
      const res = await fetch('/api/generate-room-token', { method: 'POST' });
      const data = await res.json();
      return data.roomToken;
      },
      enabled: isInRoom,
      });

      // Add a document camera
      await addCamera('device-id-123', 'Document Camera');

      // Remove it later
      await removeCamera(cameras[0].id);