Explicitly configure options for the LiveKit room
This commit is contained in:
parent
28fe813b76
commit
048dce05c3
2 changed files with 47 additions and 1 deletions
45
src/livekit/options.ts
Normal file
45
src/livekit/options.ts
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import {
|
||||||
|
AudioPresets,
|
||||||
|
DefaultReconnectPolicy,
|
||||||
|
RoomOptions,
|
||||||
|
ScreenSharePresets,
|
||||||
|
TrackPublishDefaults,
|
||||||
|
VideoPreset,
|
||||||
|
VideoPresets,
|
||||||
|
} from "livekit-client";
|
||||||
|
|
||||||
|
const publishOptions: TrackPublishDefaults = {
|
||||||
|
audioPreset: AudioPresets.music,
|
||||||
|
dtx: true,
|
||||||
|
red: true,
|
||||||
|
forceStereo: false,
|
||||||
|
simulcast: true,
|
||||||
|
videoSimulcastLayers: [VideoPresets.h180, VideoPresets.h216] as VideoPreset[],
|
||||||
|
screenShareEncoding: ScreenSharePresets.h1080fps15.encoding,
|
||||||
|
stopMicTrackOnMute: false,
|
||||||
|
videoCodec: "vp8",
|
||||||
|
videoEncoding: VideoPresets.h360.encoding,
|
||||||
|
backupCodec: { codec: "vp8", encoding: VideoPresets.h360.encoding },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const roomOptions: RoomOptions = {
|
||||||
|
// automatically manage subscribed video quality
|
||||||
|
adaptiveStream: true,
|
||||||
|
|
||||||
|
// optimize publishing bandwidth and CPU for published tracks
|
||||||
|
dynacast: true,
|
||||||
|
|
||||||
|
// capture settings
|
||||||
|
videoCaptureDefaults: {
|
||||||
|
resolution: VideoPresets.h360.resolution,
|
||||||
|
},
|
||||||
|
|
||||||
|
// publish settings
|
||||||
|
publishDefaults: publishOptions,
|
||||||
|
|
||||||
|
// default LiveKit options that seem to be sane
|
||||||
|
stopLocalTrackOnUnpublish: true,
|
||||||
|
reconnectPolicy: new DefaultReconnectPolicy(),
|
||||||
|
disconnectOnPageLeave: true,
|
||||||
|
expWebAudioMix: false,
|
||||||
|
};
|
|
@ -7,6 +7,7 @@ import {
|
||||||
|
|
||||||
import { MediaDevicesState, MediaDevices } from "../settings/mediaDevices";
|
import { MediaDevicesState, MediaDevices } from "../settings/mediaDevices";
|
||||||
import { LocalMediaInfo, MediaInfo } from "../room/VideoPreview";
|
import { LocalMediaInfo, MediaInfo } from "../room/VideoPreview";
|
||||||
|
import { roomOptions } from "./options";
|
||||||
|
|
||||||
type LiveKitState = {
|
type LiveKitState = {
|
||||||
// The state of the media devices (changing the devices will also change them in the room).
|
// The state of the media devices (changing the devices will also change them in the room).
|
||||||
|
@ -25,7 +26,7 @@ type LiveKitState = {
|
||||||
export function useLiveKit(): LiveKitState | undefined {
|
export function useLiveKit(): LiveKitState | undefined {
|
||||||
// TODO: Pass the proper paramters to configure the room (supported codecs, simulcast, adaptive streaming, etc).
|
// TODO: Pass the proper paramters to configure the room (supported codecs, simulcast, adaptive streaming, etc).
|
||||||
const [room] = React.useState<Room>(() => {
|
const [room] = React.useState<Room>(() => {
|
||||||
return new Room();
|
return new Room(roomOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a React state to store the available devices and the selected device for each kind.
|
// Create a React state to store the available devices and the selected device for each kind.
|
||||||
|
|
Loading…
Add table
Reference in a new issue