import { Backend, Logger, OnLogMessage } from '@4players/odin-common';

export type AudioContextFactory = (sampleRate: number | undefined) => Promise<AudioContext>;
export type DeviceInfo = {
	name: string;
	deviceId: string;
	kind: "audioinput" | "audiooutput" | "track";
	audioTrack?: MediaStreamTrack;
};
export interface WebDevice extends Backend.Device {
	readonly device: DeviceInfo;
}
export interface WebDeviceParameters extends Backend.DeviceParameters {
	readonly device?: WebDevice;
	onStatusChanged?: Backend.OnStatusChanged;
}
export declare function createPlugin(audioContextFactory: AudioContextFactory, options?: WebPluginOptions): WebPlugin;
export interface WebPluginOptions {
	logger?: Logger;
	onLogMessage?: OnLogMessage;
	/**
	 * Skip automatic reconnection attempts after connection loss; useful if the application implements custom reconnect logic
	 */
	disableAutoReconnect?: boolean;
	/**
	 * Skip registering the beforeunload handler that auto-closes the plugin on page unload
	 */
	disableBeforeUnload?: boolean;
	/**
	 * Enable an HTMLAudioElement-based output-device fallback on browsers that
	 * lack AudioContext.setSinkId (Firefox, Safari). The fallback works but
	 * routes audio through an extra <audio> element which can degrade playback
	 * performance. Disabled by default: on those browsers, output device
	 * selection is a no-op.
	 */
	enableHTMLAudioElementFallback?: boolean;
}
export declare const SESSION_ID: string;
export interface WebPlugin extends Backend.Plugin {
	joinRoom(parameters: Backend.JoinRoomParameters): WebRoom;
	enumerateDevices(): Promise<WebDevice[]>;
	setOutputDevice(device: WebDeviceParameters): Promise<void>;
}
export interface WebRoom extends Backend.Room {
}

export {};
