UNPKG

@sawport/peers-caller

Version:

WebRTC multi-peer video call library with mesh architecture supporting up to 4 participants

155 lines 4.04 kB
/** * PeersCaller - Main orchestrator class for multi-peer video calls * Coordinates all components to provide a simple API for WebRTC calls */ import { CallParticipant } from "./CallParticipant"; import { type CallStore } from "../store"; import { BaseStore } from "./BaseStore"; import type { PeersCallerConfig, PeersCallerCallbacks, RecordingConfig, RecordingData, CallStatusResponse } from "../types"; export declare class PeersCaller extends BaseStore<CallStore> { private config; private callbacks; private socket; private localParticipant; private participants; private recorder; private iceServers; private isInitialized; private listenersSetup; private eventListeners; constructor(config: PeersCallerConfig, callbacks?: PeersCallerCallbacks); /** * Initialize the PeersCaller and establish WebSocket connection */ initialize(): Promise<void>; /** * Start a new call */ startCall(mediaConfig?: import("..").MediaStreamConfig | undefined): Promise<void>; /** * Join an existing call */ joinCall(mediaConfig?: import("..").MediaStreamConfig | undefined): Promise<void>; /** * End the call and cleanup all resources * This sends a request to the server to end the call for all participants */ endCall(): Promise<void>; /** * Leave the call gracefully (with server acknowledgement) */ leaveCall(): Promise<void>; /** * Toggle audio for local participant */ toggleAudio(enabled: boolean): void; /** * Toggle video for local participant */ toggleVideo(enabled: boolean): void; /** * Start screen sharing */ startScreenShare(): Promise<void>; /** * Stop screen sharing */ stopScreenShare(): Promise<void>; /** * Start recording the call */ startRecording(recordingData: RecordingData, config?: RecordingConfig): Promise<void>; /** * Stop recording */ stopRecording(): Promise<void>; /** * Get current call state */ getCallState(): any; /** * Get local participant */ getLocalParticipant(): CallParticipant | null; /** * Get all participants */ getParticipants(): Map<string, CallParticipant>; /** * Get participant by user ID */ getParticipant(userId: string): CallParticipant | undefined; /** * Get debug information about the current call state */ getDebugInfo(): any; /** * Cleanup and disconnect */ cleanup(): void; /** * Initialize local participant */ private initializeLocalParticipant; /** * Setup WebSocket event listeners */ private setupSocketListeners; /** * Clean up socket event listeners */ private cleanupSocketListeners; /** * Handle participant joined */ private handleParticipantJoined; /** * Check call status for the conversation */ checkCallStatus(): Promise<CallStatusResponse>; /** * Handle WebRTC offer */ private handleOffer; /** * Handle WebRTC answer */ private handleAnswer; /** * Handle ICE candidate */ private handleCandidate; /** * Handle participant state update */ private handleParticipantStateUpdate; /** * Handle participant left */ private handleParticipantLeft; /** * Handle call ended notification from server */ private handleCallEnded; /** * Broadcast state update to all participants */ private broadcastStateUpdate; /** * Handle call status change */ private handleCallStatusChanged; /** * Cleanup all participants */ private cleanupAllParticipants; /** * Handle errors with proper categorization */ private handleError; /** * Forward WebRTC signaling data to the server */ private forwardSignalToServer; } //# sourceMappingURL=PeersCaller.d.ts.map