feat(voice): add opt-in peer-to-peer calls and country rollouts (#3367)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-10 15:45:17 +02:00
1 parent e5a568acca
commit bef5e33eec
215 files changed
+15840 -2693

No files matched your search

@@ -18,6 +18,10 @@ Every file went through the same mechanical steps, so a fresh upstream tree can
`connectionHelper`, `createLocalScreenTracks`, `getStereoAudioStreamTrack`, `isLocalPub`, the frame metadata worker, `room/token-source/test-tokens.ts`, `utils/subscribeToEvents.ts`, and the `DataTrackPacket`, data track packet extension and `LocalTrackRecorder` exports. `createV0RtcUrl`, `truncateBytes`, `videoQualityForRid` and `STOP_REFETCH_DELAY_MS` are no longer exported.
## Added seams
`InternalRoomOptions.createEngine` lets a caller build the engine, and `Room` uses it in place of `new RTCEngine`. The index exports `RTCEngine`, `SignalClient`, `SignalConnectionState`, `PCTransportState`, `selectPublisherCodecPreferences` and the protocol messages a substitute engine has to build. The P2P mesh engine in `fluxer_app/src/features/voice/engine/mesh` depends on all of them. `room/Room.test.ts` covers the option.
## Updating from upstream
1. Read the upstream changelog for the target version.
+25 -1
View File
@@ -2,7 +2,20 @@
//
// SPDX-License-Identifier: Apache-2.0
import {Mutex} from '@livekit/mutex';
import {DataPacket_Kind, DisconnectReason, Encryption_Type, SubscriptionError, TrackType} from '@livekit/protocol';
import {
Codec,
DataPacket_Kind,
DisconnectReason,
Encryption_Type,
JoinResponse,
ParticipantInfo,
ParticipantInfo_State,
ParticipantPermission,
SpeakerInfo,
SubscriptionError,
TrackInfo,
TrackType,
} from '@livekit/protocol';
import {getLogger, LoggerNames, LogLevel, setLogExtension, setLogLevel} from './logger.ts';
import * as attributes from './room/attribute-typings.ts';
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy.ts';
@@ -60,6 +73,8 @@ import {
} from './room/utils.ts';
import {getBrowser} from './utils/browserParser.ts';
export type {AddTrackRequest} from '@livekit/protocol';
export {SignalClient, SignalConnectionState, type SignalOptions} from './api/SignalClient.ts';
export type {BaseE2EEManager} from './e2ee/E2eeManager.ts';
export * from './e2ee/index.ts';
export {
@@ -80,7 +95,9 @@ export type * from './room/data-stream/outgoing/StreamWriter.ts';
export type {DataTrackFrame} from './room/data-track/frame.ts';
export * from './room/errors.ts';
export * from './room/events.ts';
export {type PCTransportManager, PCTransportState} from './room/PCTransportManager.ts';
export type {DataChannelKind} from './room/RTCEngine.ts';
export {default as RTCEngine, selectPublisherCodecPreferences} from './room/RTCEngine.ts';
export {type PerformRpcParams, RpcError, type RpcInvocationData} from './room/rpc/index.ts';
export * from './room/token-source/TokenSource.ts';
export * from './room/token-source/types.ts';
@@ -127,6 +144,7 @@ export type {
};
export {
attributes,
Codec,
ConnectionQuality,
ConnectionState,
CriticalTimers,
@@ -150,6 +168,7 @@ export {
isSVCCodec,
isVideoCodec,
isVideoTrack,
JoinResponse,
LocalAudioTrack,
LocalDataTrack,
LocalParticipant,
@@ -160,7 +179,10 @@ export {
LogLevel,
Mutex,
Participant,
ParticipantInfo,
ParticipantInfo_State,
ParticipantKind,
ParticipantPermission,
RemoteAudioTrack,
RemoteDataTrack,
RemoteParticipant,
@@ -168,6 +190,7 @@ export {
RemoteTrackPublication,
RemoteVideoTrack,
Room,
SpeakerInfo,
SubscriptionError,
selectPreferredVideoCodec,
setLogExtension,
@@ -180,6 +203,7 @@ export {
supportsScalabilityMode,
supportsVideoCodec,
supportsVP9,
TrackInfo,
TrackPublication,
TrackType,
};
@@ -4,6 +4,7 @@
import type {E2EEOptions} from './e2ee/types.ts';
import type {FrameMetadataOptions} from './frameMetadata/FrameMetadataManager.ts';
import type {ReconnectPolicy} from './room/ReconnectPolicy.ts';
import type RTCEngine from './room/RTCEngine.ts';
import type {
AudioCaptureOptions,
AudioOutputOptions,
@@ -54,6 +55,7 @@ export interface InternalRoomOptions {
subscriberVideoCodecExclusions?: Array<VideoCodec>;
h264HardwareProfiles?: ReadonlySet<string>;
dataStream?: RoomDataStreamOptions;
createEngine?: (options: InternalRoomOptions) => RTCEngine;
}
export interface RoomDataStreamOptions {
maxPayloadByteLength?: number;
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import {describe, expect, it, vi} from 'vitest';
import type {InternalRoomOptions} from '../options.ts';
import Room from './Room.ts';
import RTCEngine from './RTCEngine.ts';
describe('Room createEngine option', () => {
it('builds the engine through the factory and hands it the merged room options', () => {
const createEngine = vi.fn((options: InternalRoomOptions) => new RTCEngine(options));
const room = new Room({createEngine, dynacast: false});
expect(createEngine).toHaveBeenCalledTimes(1);
expect(room.engine).toBe(createEngine.mock.results[0]?.value);
expect(createEngine.mock.calls[0]?.[0]).toBe(room.options);
});
it('builds a plain RTCEngine when no factory is set', () => {
const room = new Room({dynacast: false});
expect(room.engine).toBeInstanceOf(RTCEngine);
});
});
@@ -499,7 +499,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
return;
}
this.engine = new RTCEngine(this.options);
this.engine = this.options.createEngine ? this.options.createEngine(this.options) : new RTCEngine(this.options);
this.engine.e2eeManager = this.e2eeManager;
this.engine