From bed4759b98ba3769d8a722d0abdb59e71d88d79d Mon Sep 17 00:00:00 2001 From: Ryan Gaus Date: Thu, 23 Jul 2026 13:25:04 -0400 Subject: [PATCH] fix: add useLegacyClientImplementation to ffi to ensure that only data streams v1 support is advertised The node and python sdks today have their own data streams implementations. If the livekit-ffi upgrade in node-sdks were done today, then it would mean that the new client_protocol=2 would be advertised, and these pre-existing implementations would receive data stream v2 messages, not v1 (ie, single packet data streams, compression, etc). So for now, add a flag which can be set in livekit-ffi to disable advertising the new client protocol so this can be merged. Once merged, node and python can be updated to pass this flag and the livekit-ffi package can be updated. Then, once data streams v2 is done on both node + python and both are updated, this flag can be removed by reverting this commit. --- packages/livekit-rtc/src/index.ts | 9 ++++++++- packages/livekit-rtc/src/room.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/livekit-rtc/src/index.ts b/packages/livekit-rtc/src/index.ts index 7d131a3a..50728c46 100644 --- a/packages/livekit-rtc/src/index.ts +++ b/packages/livekit-rtc/src/index.ts @@ -36,7 +36,14 @@ export { TrackSource, } from '@livekit/rtc-ffi-bindings'; export { VideoBufferType, VideoCodec, VideoRotation } from '@livekit/rtc-ffi-bindings'; -export { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js'; +export { + ConnectError, + Room, + RoomEvent, + type RoomDataStreamOptions, + type RoomOptions, + type RtcConfiguration, +} from './room.js'; export { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js'; export { LocalAudioTrack, diff --git a/packages/livekit-rtc/src/room.ts b/packages/livekit-rtc/src/room.ts index 6ee23de0..b9e4798e 100644 --- a/packages/livekit-rtc/src/room.ts +++ b/packages/livekit-rtc/src/room.ts @@ -29,6 +29,7 @@ import { type IceServer, IceTransportType, type ReadyForRoomEventResponse, + RoomDataStreamOptions, type RoomInfo, type SimulateScenarioCallback, type SimulateScenarioKind, @@ -58,6 +59,8 @@ import { RemoteTrackPublication } from './track_publication.js'; import type { ChatMessage } from './types.js'; import { bigIntToNumber } from './utils.js'; +export { RoomDataStreamOptions }; + export interface RtcConfiguration { iceTransportType: IceTransportType; continualGatheringPolicy: ContinualGatheringPolicy; @@ -273,6 +276,13 @@ export class Room extends (EventEmitter as new () => TypedEmitter */ async connect(url: string, token: string, opts?: RoomOptions) { const options = { ...defaultRoomOptions, ...opts }; + // The Node SDK still implements data streams in TypeScript on top of raw FFI + // packets, so always advertise only legacy (v1) data stream support to other + // clients, preserving any other data stream options provided by the user. + options.dataStream = new RoomDataStreamOptions({ + ...options.dataStream, + useLegacyClientImplementation: true, + }); const e2eeEnabled = options.encryption || options.e2ee; const e2eeOptions = options.encryption ? { ...defaultE2EEOptions, ...options.encryption }