243 lines
7.7 KiB
TypeScript
243 lines
7.7 KiB
TypeScript
|
declare module "teaclient_connection" {
|
||
|
export enum ServerType {
|
||
|
UNKNOWN,
|
||
|
TEASPEAK,
|
||
|
TEAMSPEAK
|
||
|
}
|
||
|
|
||
|
export enum PlayerState {
|
||
|
BUFFERING,
|
||
|
PLAYING,
|
||
|
STOPPING,
|
||
|
STOPPED
|
||
|
}
|
||
|
|
||
|
export interface NativeVoiceClient {
|
||
|
client_id: number;
|
||
|
|
||
|
callback_playback: () => any;
|
||
|
callback_stopped: () => any;
|
||
|
|
||
|
callback_state_changed: (new_state: PlayerState) => any;
|
||
|
|
||
|
get_state() : PlayerState;
|
||
|
|
||
|
get_volume() : number;
|
||
|
set_volume(volume: number) : void;
|
||
|
|
||
|
abort_replay();
|
||
|
get_stream() : audio.playback.AudioOutputStream;
|
||
|
}
|
||
|
|
||
|
export interface NativeVoiceConnection {
|
||
|
register_client(client_id: number) : NativeVoiceClient;
|
||
|
available_clients() : NativeVoiceClient[];
|
||
|
unregister_client(client_id: number);
|
||
|
|
||
|
audio_source() : audio.record.AudioConsumer;
|
||
|
set_audio_source(consumer: audio.record.AudioConsumer | undefined);
|
||
|
|
||
|
decoding_supported(codec: number) : boolean;
|
||
|
encoding_supported(codec: number) : boolean;
|
||
|
}
|
||
|
|
||
|
export interface NativeServerConnection {
|
||
|
callback_voice_data: (buffer: Uint8Array, client_id: number, codec_id: number, flag_head: boolean, packet_id: number) => any;
|
||
|
callback_command: (command: string, arguments: any, switches: string[]) => any;
|
||
|
callback_disconnect: (reason?: string) => any;
|
||
|
_voice_connection: NativeVoiceConnection;
|
||
|
server_type: ServerType;
|
||
|
|
||
|
connected(): boolean;
|
||
|
|
||
|
connect(properties: {
|
||
|
remote_host: string,
|
||
|
remote_port: number,
|
||
|
|
||
|
timeout: number,
|
||
|
|
||
|
callback: (error: number) => any,
|
||
|
|
||
|
identity_key: string | undefined, /* if identity_key empty, then an ephemeral license will be created */
|
||
|
teamspeak: boolean
|
||
|
});
|
||
|
|
||
|
disconnect(reason: string | undefined, callback: (error: number) => any) : boolean;
|
||
|
|
||
|
error_message(id: number) : string;
|
||
|
|
||
|
send_command(command: string, arguments: any[], switches: string[]);
|
||
|
send_voice_data(buffer: Uint8Array, codec_id: number, header: boolean);
|
||
|
send_voice_data_raw(buffer: Float32Array, channels: number, sample_rate: number, header: boolean);
|
||
|
}
|
||
|
|
||
|
export function spawn_server_connection() : NativeServerConnection;
|
||
|
export function destroy_server_connection(connection: NativeServerConnection);
|
||
|
|
||
|
|
||
|
export namespace ft {
|
||
|
export interface TransferObject {
|
||
|
upload: boolean;
|
||
|
download: boolean;
|
||
|
}
|
||
|
|
||
|
export interface FileTransferSource extends TransferObject {
|
||
|
total_size: number;
|
||
|
uploaded_size: number;
|
||
|
}
|
||
|
|
||
|
export interface FileTransferTarget extends TransferObject {
|
||
|
expected_size: number;
|
||
|
current_size: number;
|
||
|
}
|
||
|
|
||
|
export interface HandledTransferObject extends TransferObject {}
|
||
|
|
||
|
export interface NativeFileTransfer {
|
||
|
handle: TransferObject;
|
||
|
|
||
|
callback_finished: (aborted?: boolean) => any;
|
||
|
callback_start: () => any;
|
||
|
callback_progress: (current: number, max: number) => any;
|
||
|
callback_failed: (message: string) => any;
|
||
|
|
||
|
start();
|
||
|
}
|
||
|
|
||
|
export interface TransferOptions {
|
||
|
remote_address: string;
|
||
|
remote_port: number;
|
||
|
|
||
|
transfer_key: string;
|
||
|
client_transfer_id: number;
|
||
|
server_transfer_id: number;
|
||
|
|
||
|
object: HandledTransferObject;
|
||
|
}
|
||
|
|
||
|
export function upload_transfer_object_from_buffer(buffer: ArrayBuffer);
|
||
|
export function download_transfer_object_from_buffer(target_buffer: ArrayBuffer);
|
||
|
|
||
|
export function spawn_connection(transfer: TransferOptions) : NativeFileTransfer;
|
||
|
export function destroy_connection(connection: NativeFileTransfer);
|
||
|
}
|
||
|
|
||
|
export namespace audio {
|
||
|
export interface AudioDevice {
|
||
|
name: string;
|
||
|
driver: string;
|
||
|
|
||
|
device_id: string;
|
||
|
|
||
|
input_supported: boolean;
|
||
|
output_supported: boolean;
|
||
|
|
||
|
input_default: boolean;
|
||
|
output_default: boolean;
|
||
|
|
||
|
device_index: number;
|
||
|
}
|
||
|
|
||
|
export namespace playback {
|
||
|
export interface AudioOutputStream {
|
||
|
sample_rate: number;
|
||
|
channels: number;
|
||
|
|
||
|
get_buffer_latency() : number;
|
||
|
set_buffer_latency(value: number);
|
||
|
|
||
|
get_buffer_max_latency() : number;
|
||
|
set_buffer_max_latency(value: number);
|
||
|
}
|
||
|
|
||
|
export interface OwnedAudioOutputStream extends AudioOutputStream {
|
||
|
callback_underflow: () => any;
|
||
|
callback_overflow: () => any;
|
||
|
|
||
|
clear();
|
||
|
write_data(buffer: ArrayBuffer, interleaved: boolean);
|
||
|
write_data_rated(buffer: ArrayBuffer, interleaved: boolean, sample_rate: number);
|
||
|
|
||
|
deleted() : boolean;
|
||
|
delete();
|
||
|
}
|
||
|
|
||
|
export function set_device(device: number);
|
||
|
export function current_device() : number;
|
||
|
|
||
|
export function create_stream() : OwnedAudioOutputStream;
|
||
|
|
||
|
export function get_master_volume() : number;
|
||
|
export function set_master_volume(volume: number);
|
||
|
}
|
||
|
|
||
|
export namespace record {
|
||
|
export interface ConsumeFilter {
|
||
|
get_name() : string;
|
||
|
}
|
||
|
|
||
|
export interface MarginedFilter {
|
||
|
get_margin_frames() : number;
|
||
|
set_margin_frames(value: number);
|
||
|
}
|
||
|
|
||
|
export interface VADConsumeFilter extends ConsumeFilter, MarginedFilter {
|
||
|
get_level() : number;
|
||
|
}
|
||
|
|
||
|
export interface ThresholdConsumeFilter extends ConsumeFilter, MarginedFilter {
|
||
|
get_threshold() : number;
|
||
|
set_threshold(value: number);
|
||
|
|
||
|
get_attack_smooth() : number;
|
||
|
set_attack_smooth(value: number);
|
||
|
|
||
|
get_release_smooth() : number;
|
||
|
set_release_smooth(value: number);
|
||
|
|
||
|
set_analyze_filter(callback: (value: number) => any);
|
||
|
}
|
||
|
|
||
|
export interface StateConsumeFilter extends ConsumeFilter {
|
||
|
is_consuming() : boolean;
|
||
|
set_consuming(flag: boolean);
|
||
|
}
|
||
|
|
||
|
export interface AudioConsumer {
|
||
|
sample_rate: number;
|
||
|
channels: number;
|
||
|
frame_size: number;
|
||
|
|
||
|
/* TODO add some kind of order to may improve CPU performance (Some filters are more intense then others) */
|
||
|
get_filters() : ConsumeFilter[];
|
||
|
unregister_filter(filter: ConsumeFilter);
|
||
|
|
||
|
create_filter_vad(level: number) : VADConsumeFilter;
|
||
|
create_filter_threshold(threshold: number) : ThresholdConsumeFilter;
|
||
|
create_filter_state() : StateConsumeFilter;
|
||
|
|
||
|
callback_data: (buffer: Float32Array) => any;
|
||
|
callback_ended: () => any;
|
||
|
callback_started: () => any;
|
||
|
}
|
||
|
|
||
|
export interface AudioRecorder {
|
||
|
get_device() : number;
|
||
|
set_device(device: number); /* Recorder needs to be started afterwards */
|
||
|
|
||
|
start();
|
||
|
started() : boolean;
|
||
|
stop();
|
||
|
|
||
|
create_consumer() : AudioConsumer;
|
||
|
get_consumers() : AudioConsumer[];
|
||
|
delete_consumer(consumer: AudioConsumer);
|
||
|
}
|
||
|
|
||
|
export function create_recorder() : AudioRecorder;
|
||
|
}
|
||
|
|
||
|
export function initialize();
|
||
|
export function available_devices() : AudioDevice[];
|
||
|
}
|
||
|
}
|