UNPKG

@4players/odin

Version:

A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects

92 lines (91 loc) 5.08 kB
import { Backend } from '@4players/odin-common'; import { AudioInput } from '../api/media/audio-input'; import { InputSettings } from '../types'; import Device = Backend.Device; import DeviceParameters = Backend.DeviceParameters; import { VideoInput } from '../api/media/video-input'; import VideoInputOptions = Backend.VideoInputOptions; /** * Represents the types of device functionalities available for media operations. * * This type is used to define specific categories of media devices that are supported * in the application or environment. The available kinds include: * - 'AudioCapture': Refers to devices that capture audio input, such as microphones. * - 'VideoCapture': Refers to devices that capture video input, such as cameras. * - 'AudioPlayback': Refers to devices that output audio, such as speakers or headphones. * * Use this type to define or validate the kind of device being utilized or targeted. */ export type DeviceKinds = 'AudioCapture' | 'VideoCapture' | 'AudioPlayback'; /** * The DeviceManager class provides a collection of static methods to interact with audio and video devices. * It includes capabilities for listing available input/output devices and creating audio or video input instances. */ export declare class DeviceManager { static listAudioInputs(): Promise<Device[]>; /** * Retrieves a list of audio output devices available on the system. * * @return {Promise<Device[]>} A promise that resolves to an array of Device objects representing the audio output devices. */ static listAudioOutputs(): Promise<Device[]>; /** * Lists available devices, optionally filtered by the specified kind. * * @param {DeviceKinds} [kind] - The type of devices to filter. If undefined, all devices will be listed. * @return {Promise<Device[]>} A promise that resolves to an array of devices matching the specified kind. */ static listDevices(kind?: DeviceKinds): Promise<Device[]>; /** * Retrieves an input device by its name from the list of available audio input devices. * * @param {string} name - The name of the input device to search for. * @return {Promise<Device | undefined>} A promise that resolves to the input device object if found, or undefined if no matching device is found. */ static getInputDeviceByName(name: string): Promise<Device | undefined>; /** * Retrieves an audio output device by its name. * * @param {string} name - The name of the desired audio output device. * @return {Promise<Device | undefined>} A promise that resolves to the device object if a match is found, or undefined if no matching device is found. */ static getOutputDeviceByName(name: string): Promise<Device | undefined>; /** * Retrieves an input device by its id from the list of available audio input devices. * * @param {string} id - The id of the input device to search for. * @return {Promise<Device | undefined>} A promise that resolves to the input device object if found, or undefined if no matching device is found. */ static getInputDevice(id: string): Promise<Device | undefined>; /** * Retrieves an audio output device by its id. * * @param {string} id - The id of the desired audio output device. * @return {Promise<Device | undefined>} A promise that resolves to the device object if a match is found, or undefined if no matching device is found. */ static getOutputDevice(id: string): Promise<Device | undefined>; /** * Retrieves an audio device by its id. * * @param {string} id - The id of the desired audio device. * @return {Promise<Device | undefined>} A promise that resolves to the device object if a match is found, or undefined if no matching device is found. */ static getDevice(id: string): Promise<Device | undefined>; /** * Creates an audio input instance using the specified device parameters and input settings. * * @param {DeviceParameters} [device] - Optional parameters for selecting the audio capture device. * @param {InputSettings} [settings] - Optional configuration settings for the audio input. * @param {string} [customType] - Optional custom type for the audio input that's helping identify different AudioInputs. * @return {Promise<AudioInput>} A promise that resolves to an instance of AudioInput. */ static createAudioInput(device?: DeviceParameters, settings?: InputSettings, customType?: string): Promise<AudioInput>; /** * Creates a new VideoInput instance from the given MediaStream and optional configuration. * * @param {MediaStream} ms - The MediaStream instance used to initialize the VideoInput. * @param {VideoInputOptions} [options] - Optional configuration parameters for the VideoInput. * @return {Promise<VideoInput>} A promise that resolves to the created VideoInput instance. */ static createVideoInput(ms: MediaStream, options?: VideoInputOptions): Promise<VideoInput>; }