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}.

      In a room that requires a waiting room, a camera is held until the host admits it — automatic when the host renders WaitingRoomAdmittance with autoAdmitSystemUsers, otherwise the host admits it from the waiting list like any participant. If it is not admitted within 30 seconds, or the host rejects it, onError is called and the camera is removed.

      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);