import { a as BaseStreamInfo, e as ByteStreamOptions } from './stream_reader-CuG4b8Y-.js'; import { Mutex } from '@livekit/mutex'; import { ParticipantInfo, FfiHandle, OwnedParticipant, ParticipantKind, DisconnectReason, TrackPublishOptions } from '@livekit/rtc-ffi-bindings'; import { PathLike } from 'node:fs'; import { TextStreamWriter, ByteStreamWriter } from './data_streams/stream_writer.js'; import './ffi_client.js'; import { PerformRpcParams, RpcInvocationData } from './rpc.js'; import { LocalTrack } from './track.js'; import { TrackPublication, LocalTrackPublication, RemoteTrackPublication } from './track_publication.js'; import { Transcription } from './transcription.js'; import { ChatMessage } from './types.js'; import '@livekit/typed-emitter'; import './audio_source.js'; import './audio_frame.js'; import './video_source.js'; import './video_frame.js'; declare abstract class Participant { /** @internal */ info: ParticipantInfo; /** @internal */ ffi_handle: FfiHandle; trackPublications: Map; constructor(owned_info: OwnedParticipant); get sid(): string | undefined; get name(): string | undefined; get identity(): string; get metadata(): string; get attributes(): Record; get kind(): ParticipantKind; get disconnectReason(): DisconnectReason | undefined; } type DataPublishOptions = { /** * whether to send this as reliable or lossy. * For data that you need delivery guarantee (such as chat messages), use Reliable. * For data that should arrive as quickly as possible, but you are ok with dropped * packets, use Lossy. */ reliable?: boolean; /** * the identities of participants who will receive the message, will be sent to every one if empty */ destination_identities?: string[]; /** the topic under which the message gets published */ topic?: string; }; declare class LocalParticipant extends Participant { private rpcHandlers; private ffiEventLock; trackPublications: Map; constructor(info: OwnedParticipant, ffiEventLock: Mutex); publishData(data: Uint8Array, options: DataPublishOptions): Promise; publishDtmf(code: number, digit: string): Promise; publishTranscription(transcription: Transcription): Promise; updateMetadata(metadata: string): Promise; /** * Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream. * Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead */ streamText(options?: { topic?: string; attributes?: Record; destinationIdentities?: Array; streamId?: string; senderIdentity?: string; }): Promise; sendText(text: string, options?: { topic?: string; attributes?: Record; destinationIdentities?: Array; streamId?: string; }): Promise; streamBytes(options?: { name?: string; topic?: string; attributes?: Record; destinationIdentities?: Array; streamId?: string; mimeType?: string; totalSize?: number; }): Promise; /** Sends a file provided as PathLike to specified recipients */ sendFile(path: PathLike, options?: ByteStreamOptions): Promise; private sendStreamHeader; private sendStreamChunk; private sendStreamTrailer; /** * Sends a chat message to participants in the room * * @param text - The text content of the chat message. * @param destinationIdentities - An optional array of recipient identities to whom the message will be sent. If omitted, the message is broadcast to all participants. * @param senderIdentity - An optional identity of the sender. If omitted, the default sender identity is used. * */ sendChatMessage(text: string, destinationIdentities?: Array, senderIdentity?: string): Promise; /** * @experimental */ editChatMessage(editText: string, originalMessage: ChatMessage, destinationIdentities?: Array, senderIdentity?: string): Promise; updateName(name: string): Promise; setAttributes(attributes: Record): Promise; publishTrack(track: LocalTrack, options: TrackPublishOptions): Promise; unpublishTrack(trackSid: string, stopOnUnpublish?: boolean): Promise; /** * Initiate an RPC call to a remote participant. * @param params - Parameters for initiating the RPC call, see {@link PerformRpcParams} * @returns A promise that resolves with the response payload or rejects with an error. * @throws Error on failure. Details in `message`. */ performRpc({ destinationIdentity, method, payload, responseTimeout, }: PerformRpcParams): Promise; /** * Establishes the participant as a receiver for calls of the specified RPC method. * Will overwrite any existing callback for the same method. * * @param method - The name of the indicated RPC method * @param handler - Will be invoked when an RPC request for this method is received * @returns A promise that resolves when the method is successfully registered * * @example * ```typescript * room.localParticipant?.registerRpcMethod( * 'greet', * async (data: RpcInvocationData) => { * console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`); * return `Hello, ${data.callerIdentity}!`; * } * ); * ``` * * See {@link RpcInvocationData} for more details on invocation params. * * The handler should return a Promise that resolves to a string. * If unable to respond within `responseTimeout`, the request will result in an error on the caller's side. * * You may throw errors of type `RpcError` with a string `message` in the handler, * and they will be received on the caller's side with the message intact. * Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as `1500` ("Application Error"). */ registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise): void; /** * Unregisters a previously registered RPC method. * * @param method - The name of the RPC method to unregister */ unregisterRpcMethod(method: string): void; /** @internal */ handleRpcMethodInvocation(invocationId: bigint, method: string, requestId: string, callerIdentity: string, payload: string, responseTimeout: number): Promise; } declare class RemoteParticipant extends Participant { trackPublications: Map; constructor(owned_info: OwnedParticipant); } export { type DataPublishOptions, LocalParticipant, Participant, RemoteParticipant };