UNPKG

@4players/odin

Version:

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

131 lines (130 loc) 4.86 kB
import { OdinEventTarget } from '../../utils/odin-event-target'; import { MediaEvents } from '../room/types'; import { Backend } from '@4players/odin-common'; import { Media as MediaData } from '@4players/odin-common/api'; import { Room } from '../room'; import { RemotePeer } from '../peer/remote-peer'; import AudioPlayback = Backend.AudioPlayback; import PlaybackVolume = Backend.PlaybackVolume; import JitterStats = Backend.JitterStats; export declare class AudioOutput extends OdinEventTarget<MediaEvents> { #private; /** * The AudioPlayback that is provided by the underling plugin. * * @return {AudioPlayback} The AudioPlayback of the underling plugin. */ readonly playback: AudioPlayback; private readonly _mediaData; readonly peer: RemotePeer; readonly room: Room; readonly kind = "audio-output"; /** * A callback function that is invoked when audio activity occurs and voice activity detection (VAD) was set to true. * * @param {AudioActivityPayload} payload - An object containing the AudioMedia. */ onAudioActivity?: (payload: boolean) => void; /** * A callback function invoked when there is an update to the audio power level in rmsDBFS. * This function can be used to handle or process audio activity, such as * monitoring sound levels or visualizing audio input. * * @param {AudioActivityPayload} payload - An object containing the AudioMedia. */ onPowerLevel?: (payload: number) => void; /** * Optional callback function that is invoked to handle jitter statistics. * * @param {AudioActivityPayload} payload - The object containing metrics or data related to jitter statistics. */ onJitterStats?: (payload: JitterStats) => void; constructor( /** * The AudioPlayback that is provided by the underling plugin. * * @return {AudioPlayback} The AudioPlayback of the underling plugin. */ playback: AudioPlayback, _mediaData: MediaData, peer: RemotePeer, room: Room); /** * Retrieves the unique identifier (UID) associated with the playback. * * @return {string} The UID of the playback. */ get uid(): string; /** * Retrieves the media ID associated with this instance. * * @return {number} The unique identifier of the media. */ get mediaId(): number; /** * Whether the AudioOutput is currently active or not. * Only works when voice activity detection was enabled. * * @return {boolean} True if the instance is active, false otherwise. */ get isActive(): boolean; /** * The custom type helps to identify the purpose of the VideoOutput that was * defined by the remote AudioInput. * * @return {string | undefined} The custom type value if available; otherwise, undefined. */ get customType(): string | undefined; /** * Retrieves the current volume. * * @return {PlaybackVolume} The volume number or 'muted'. */ get volume(): PlaybackVolume; /** * Gets the aggregated volume (room * peer * audioOutput) that is currently in use. * * @return {number} The current aggregated volume level, or 0 if volume is not defined. */ get volumeAggregated(): number; /** * Sets the volume of the AudioOutput. * * The volume value should be between 0 and 2 (inclusive). Values outside this range are clamped. * * @param {PlaybackVolume | number} [value] - The desired volume setting. It can be a specific volume level or 'muted'. * @return {Promise<void>} A promise that resolves when the volume adjustment is complete. */ setVolume(value?: PlaybackVolume | number): Promise<void>; /** * Retrieves the paused state of the object. * * @return {boolean} Returns true if the object is in a paused state, otherwise false. */ get isPaused(): boolean; /** * Retrieves the Root Mean Square (RMS) in decibels relative to full scale (dBFS) * for the captured audio activity. This is a measure of the average power level * of the audio signal. * * @return {number} The RMS value expressed in dBFS. */ get powerLevel(): number; /** * Retrieves the jitter statistics for the playback. * * @return {JitterStats} The jitter statistics data associated with the playback. */ get jitterStats(): JitterStats; /** * Pauses the AudioOutput at the SFU and prevents receiving audio packets * * @return {Promise<void>} A promise that resolves when the media is successfully paused. */ pause(): Promise<void>; /** * Resumes the AudioOutput at the SFU. */ resume(): Promise<void>; /** * Closes the AudioOutput. */ close(): void; }