import { type CustomAudioTrack } from '@fishjam-cloud/react-native-webrtc'; /** * Settings for {@link useCustomAudioSource}, fixed for the lifetime of a * streaming session (a `startStreaming`/`stopStreaming` pair). */ export interface UseCustomAudioSourceOptions { /** * Stable id identifying this custom source. Defaults to * `"customAudioSource"`. Every hook instance that streams at the same time * needs its own id — two instances sharing one silently replace each * other's published track. */ sourceId?: string; /** * Sample rate of the PCM you will push, in hertz. Must be a positive * multiple of `100`. Push whatever your source produces natively — it is * resampled downstream. Defaults to `48000`. */ sampleRateHz?: number; /** * `1` for mono or `2` for interleaved stereo. Defaults to `1`. */ channelCount?: 1 | 2; /** * How much pushed-but-not-yet-sent audio to hold, in milliseconds, before * the oldest is dropped. The buffer drains in real time, so this is the * furthest you can push ahead — for example a long text-to-speech utterance * handed over in one call. Must be at least `10`. Defaults to `60000` (one * minute). */ maxBufferedDurationMs?: number; } export interface UseCustomAudioSourceResult { /** Whether the custom audio track is currently published. */ isStreaming: boolean; /** * Push handle for the published track; `null` until streaming starts. Hand * it to `pushAudioSamples` whenever your source produces audio. The handle * is plain and worklet-serializable, so it can be shared into a worklet and * pushed from there directly — no thread hop. */ track: CustomAudioTrack | null; /** * Create the custom audio track and publish it. Once this resolves the * track is registered — pushed samples are streamed to the room right away * when the peer is connected, or automatically once it connects. No-op when * already streaming. */ startStreaming: () => Promise; /** * Unpublish and release the custom audio track. No-op when not streaming. */ stopStreaming: () => Promise; /** The error that failed the last `startStreaming` or `stopStreaming` call, if any. */ error: Error | null; } /** * Publish your own audio to Fishjam. * * Creates a custom audio track, publishes it, and cleans it up — you supply * the PCM from any source (a synthesizer, a decoder, an audio pipeline) via * `pushAudioSamples`. The published track behaves like a live microphone: * pauses in pushing are fine and play as silence. It is independent of * {@link useMicrophone} and does not involve the device microphone in any way — * publishing it does not trigger the recording permission. * * Remote peers receive the track with metadata type `"customAudio"` * (`usePeers` exposes it under `customAudioTracks`). * * Push PCM with `pushAudioSamples` (from `@fishjam-cloud/react-native-client`) * and the returned {@link UseCustomAudioSourceResult.track | track} handle — * from the JS thread or from inside a worklet, with any chunk size. The track * re-paces pushes into a continuous stream, filling gaps with silence like a * live microphone. `Float32Array` samples are expected in `[-1, 1]`; * `Int16Array` is taken as-is. * * ```tsx * const { startStreaming, stopStreaming, track } = useCustomAudioSource(); * * // e.g. from react-native-audio-api's AudioRecorder: * recorder.onAudioReady({ sampleRate: 48000, bufferLength: 4800, channelCount: 1 }, * ({ buffer }) => track && pushAudioSamples(track, buffer.getChannelData(0))); * ``` * * Requires the New Architecture; `startStreaming` reports an error on the old * architecture. * * @group Hooks */ export declare function useCustomAudioSource(options?: UseCustomAudioSourceOptions): UseCustomAudioSourceResult; //# sourceMappingURL=useCustomAudioSource.d.ts.map