UNPKG

react-native-whip-whep

Version:

An implementation of WHIP and WHEP protocols functionalities for React Native.

84 lines 4.67 kB
import type { NativeModule } from "expo-modules-core/types"; import { WhipConfigurationOptions, CameraId, ConnectOptions, WhepConfigurationOptions, SenderAudioCodecName, SenderVideoCodecName, ReceiverAudioCodecName, ReceiverVideoCodecName } from "./ReactNativeMobileWhepClient.types"; /** Describes whether the camera is front-facing or back-facing. */ export type CameraFacingDirection = "front" | "back" | "unspecified"; /** Contains information about the camera available on the device. */ export type Camera = { /** A unique ID of the camera. */ id: CameraId; /** A string describing camera name. */ name: string; /** Information about the camera being a front one or back one. */ facingDirection: CameraFacingDirection; }; type RNMobileWhepClientModule = { cameras: readonly Camera[]; whepPeerConnectionState: PeerConnectionState | null; whipPeerConnectionState: PeerConnectionState | null; createWhepClient: (configurationOptions: WhepConfigurationOptions, preferredVideoCodecs: ReceiverVideoCodecName[], preferredAudioCodecs: ReceiverAudioCodecName[]) => void; connectWhep: (serverUrl: string, authToken?: string) => Promise<void>; disconnectWhep: () => Promise<void>; pauseWhep: () => void; unpauseWhep: () => void; createWhipClient: (configurationOptions: WhipConfigurationOptions, preferredVideoCodecs: SenderVideoCodecName[], preferredAudioCodecs: SenderAudioCodecName[]) => void; connectWhip: (serverUrl: string, authToken?: string) => Promise<void>; disconnectWhip: () => Promise<void>; cleanupWhip: () => void; getSupportedSenderVideoCodecsNames: () => SenderVideoCodecName[]; getSupportedReceiverVideoCodecsNames: () => ReceiverVideoCodecName[]; getSupportedReceiverAudioCodecsNames: () => ReceiverAudioCodecName[]; getSupportedSenderAudioCodecsNames: () => SenderAudioCodecName[]; }; export declare const ReceivableEvents: { readonly WhepPeerConnectionStateChanged: "WhepPeerConnectionStateChanged"; readonly WhipPeerConnectionStateChanged: "WhipPeerConnectionStateChanged"; readonly ReconnectionStatusChanged: "ReconnectionStatusChanged"; readonly Warning: "Warning"; }; export type PeerConnectionState = "new" | "connecting" | "connected" | "disconnected" | "failed" | "closed" | "unknown"; export type ReceivableEventPayloads = { [ReceivableEvents.ReconnectionStatusChanged]: "reconnectionStarted" | "reconnected" | "reconnectionRetriesLimitReached"; [ReceivableEvents.WhepPeerConnectionStateChanged]: PeerConnectionState; [ReceivableEvents.WhipPeerConnectionStateChanged]: PeerConnectionState; [ReceivableEvents.Warning]: string; }; declare const nativeModule: RNMobileWhepClientModule & NativeModule<Record<keyof typeof ReceivableEvents, (payload: any) => void>>; export declare class WhipClient { private readonly configurationOptions; private readonly preferredVideoCodecs; private readonly preferredAudioCodecs; private isInitialized; constructor(configurationOptions: WhipConfigurationOptions, preferredVideoCodecs?: SenderVideoCodecName[], preferredAudioCodecs?: SenderAudioCodecName[]); private initializeIfNeeded; connect(connectOptions: ConnectOptions): Promise<void>; disconnect(): Promise<void>; cleanup(): Promise<void>; static getSupportedAudioCodecs(): SenderAudioCodecName[]; static getSupportedVideoCodecs(): SenderVideoCodecName[]; } export declare class WhepClient { private readonly configurationOptions; private readonly preferredVideoCodecs; private readonly preferredAudioCodecs; private isInitialized; constructor(configurationOptions: WhepConfigurationOptions, preferredVideoCodecs?: ReceiverVideoCodecName[], preferredAudioCodecs?: ReceiverAudioCodecName[]); private initializeIfNeeded; /** * Connects to the WHEP server defined while creating WHEP client. * Allows user to receive video and audio stream. */ connect(connectOptions: ConnectOptions): Promise<void>; /** * Disconnects from the WHEP server defined while creating WHEP client. * Frees the resources. */ disconnect(): Promise<void>; } /** Gives access to the cameras available on the device.*/ export declare const cameras: readonly Camera[]; /** Gives access to the current state of the WHEP peer connection. */ export declare const whepPeerConnectionState: PeerConnectionState | null; /** Gives access to the current state of the WHIP peer connection. */ export declare const whipPeerConnectionState: PeerConnectionState | null; export default nativeModule; //# sourceMappingURL=ReactNativeMobileWhepClientModule.d.ts.map