@sawport/peers-caller
Version:
WebRTC multi-peer video call library with mesh architecture supporting up to 4 participants
90 lines • 2.92 kB
TypeScript
/**
* React hooks for PeersCaller integration
* Provides easy-to-use React hooks for video call functionality
*/
import { PeersCaller } from "../core/PeersCaller";
import { useCallStore } from "../store";
import type { PeersCallerConfig, PeersCallerCallbacks, CallParticipant, MediaStreamConfig, RecordingData } from "../types";
export interface UseVideoCallOptions extends PeersCallerConfig {
callbacks?: PeersCallerCallbacks;
autoInitialize?: boolean;
}
export interface UseVideoCallReturn {
initialize: () => Promise<void>;
startCall: (mediaConfig?: MediaStreamConfig) => Promise<void>;
joinCall: (mediaConfig?: MediaStreamConfig) => Promise<void>;
endCall: () => void;
toggleAudio: (enabled: boolean) => void;
toggleVideo: (enabled: boolean) => void;
startScreenShare: () => Promise<void>;
stopScreenShare: () => Promise<void>;
startRecording: (recordingData: RecordingData) => Promise<void>;
stopRecording: () => Promise<void>;
callState: ReturnType<typeof useCallStore.getState>;
participants: CallParticipant[];
localParticipant: CallParticipant | null;
isConnected: boolean;
isRecording: boolean;
error: string | null;
cleanup: () => void;
peersCaller: PeersCaller | null;
}
/**
* Main hook for video call functionality
*/
export declare function useVideoCall(options: UseVideoCallOptions): UseVideoCallReturn;
/**
* Hook for accessing participant video streams
*/
export declare function useParticipantVideo(userId: string): {
videoElement: HTMLVideoElement | null;
stream: MediaStream | null;
participant: CallParticipant;
};
/**
* Hook for call state management
*/
export declare function useCallState(): {
conversationId: string;
participants: Record<string, CallParticipant>;
localParticipant: CallParticipant | null;
isCalling: boolean;
isRecording: boolean;
recordLoading: boolean;
callStatus: "idle" | "connecting" | "connected" | "disconnecting" | "failed";
error: string | null;
participantCount: number;
isConnected: boolean;
hasError: boolean;
};
/**
* Hook for media device management
*/
export declare function useMediaDevices(): {
devices: {
videoDevices: MediaDeviceInfo[];
audioDevices: MediaDeviceInfo[];
};
permissions: {
camera: PermissionState | null;
microphone: PermissionState | null;
};
getDevices: () => Promise<void>;
checkPermissions: () => Promise<void>;
requestPermissions: () => Promise<boolean>;
};
/**
* Hook for browser compatibility checking
*/
export declare function useBrowserSupport(): {
support: {
webRTC: boolean;
getUserMedia: boolean;
getDisplayMedia: boolean;
mediaRecorder: boolean;
speechRecognition: boolean;
};
isSupported: boolean;
unsupportedFeatures: string[];
};
//# sourceMappingURL=index.d.ts.map