TeaSpeak-Client/imports/shared-app/voice/RecorderBase.d.ts

98 lines
3.0 KiB
TypeScript

import { InputDevice } from "../audio/Recorder";
import { Registry } from "../events";
import { Filter, FilterType, FilterTypeClass } from "../voice/Filter";
export declare enum InputConsumerType {
CALLBACK = 0,
NODE = 1,
NATIVE = 2
}
export interface CallbackInputConsumer {
type: InputConsumerType.CALLBACK;
callbackAudio?: (buffer: AudioBuffer) => any;
callbackBuffer?: (buffer: Float32Array, samples: number, channels: number) => any;
}
export interface NodeInputConsumer {
type: InputConsumerType.NODE;
callbackNode: (source_node: AudioNode) => any;
callbackDisconnect: (source_node: AudioNode) => any;
}
export interface NativeInputConsumer {
type: InputConsumerType.NATIVE;
}
export declare type InputConsumer = CallbackInputConsumer | NodeInputConsumer | NativeInputConsumer;
export declare enum InputState {
PAUSED = 0,
INITIALIZING = 1,
RECORDING = 2
}
export declare enum InputStartError {
EUNKNOWN = "eunknown",
EDEVICEUNKNOWN = "edeviceunknown",
EBUSY = "ebusy",
ENOTALLOWED = "enotallowed",
ESYSTEMDENIED = "esystemdenied",
ENOTSUPPORTED = "enotsupported",
ESYSTEMUNINITIALIZED = "esystemuninitialized"
}
export interface InputEvents {
notify_state_changed: {
oldState: InputState;
newState: InputState;
};
notify_voice_start: {};
notify_voice_end: {};
notify_filter_mode_changed: {
oldMode: FilterMode;
newMode: FilterMode;
};
notify_device_changed: {
oldDeviceId: string;
newDeviceId: string;
};
}
export declare enum FilterMode {
/**
* Apply all filters and act according to the output
*/
Filter = 0,
/**
* Bypass all filters and replay the audio
*/
Bypass = 1,
/**
* Block all communication
*/
Block = 2
}
export interface AbstractInput {
readonly events: Registry<InputEvents>;
currentState(): InputState;
destroy(): any;
start(): Promise<InputStartError | true>;
stop(): Promise<void>;
isFiltered(): boolean;
getFilterMode(): FilterMode;
setFilterMode(mode: FilterMode): any;
currentDeviceId(): string | undefined;
/**
* This method should not throw!
* If the target device is unknown, it should return `InputStartError.EDEVICEUNKNOWN` on start.
* If the device is different than the current device the recorder stops.
*
* When the device has been changed the event `notify_device_changed` will be fired.
*/
setDeviceId(device: string): Promise<void>;
currentConsumer(): InputConsumer | undefined;
setConsumer(consumer: InputConsumer): Promise<void>;
supportsFilter(type: FilterType): boolean;
createFilter<T extends FilterType>(type: T, priority: number): FilterTypeClass<T>;
removeFilter(filter: Filter): any;
getVolume(): number;
setVolume(volume: number): any;
}
export interface LevelMeter {
getDevice(): InputDevice;
setObserver(callback: (value: number) => any): any;
destroy(): any;
}