Files
livekit/config-sample.yaml
ee75008bea Generate downstream FlexFEC with per-track protection modes (#5195)
* Do not recover FlexFEC from RTX repaired packets

A packet repaired from RTX takes its header from the RTX packet: libwebrtc
adds a MID to retransmissions until the RTX SSRC is acknowledged, and sets
abs-send-time and transport-cc at send time. The stored packet therefore
differs from the media the publisher protected, so using it as a protected
packet recovered the wrong length, failing with "invalid recovered packet
size", or silently corrupted the recovered packet's header extensions when
the length happened to match.

Like libwebrtc's FlexfecReceiver, which skips packets recovered by RTX, mark
RTX repaired sequence numbers and treat them as missing for FEC recovery.
They are still forwarded and update NACK state as before.

With a libwebrtc publisher at 10% upstream loss, every recovery attempt in a
block containing a retransmitted packet failed; with retransmissions excluded
recoveries succeed.

* Move RTX repair tracking into BufferBase

Keep the RTX repaired history, its lookup and the publisher sequence number
extension in BufferBase, so every buffer built on it, such as the relay, can
exclude RTX repaired packets from FlexFEC recovery the same way. The history
is now cleared with the rest of the sequence number state when the stream
restarts.

Buffer only marks repaired packets from writeRTX. Packets recovered by FEC
also enter with isRTX set, but they are exact reconstructions and stay
usable, so marking is explicit rather than tied to that flag.

* Keep RTX-repaired history safe with large packet caches

The RTX repair history had 512 fixed slots. With a larger video packet
cache, e.g. packet_buffer_size_video: 1500, two cached repairs could share
a slot, the earlier mark was lost, and FlexFEC could recover from the
altered retransmission.

- Size the history from the video packet cache, at least 512 slots, and
  allocate it on the first repair.
- When a later repair reuses a slot, the earlier packet counts as repaired:
  losing a recovery is better than corrupting one.
- Do not mark a retransmission of a packet that is already cached. The
  bucket rejects it as a duplicate and keeps the exact packet, which stays
  usable for recovery.
- Mark a repair before ingesting it and do not feed RTX repaired packets to
  the FEC decoder, as BufferBase now feeds ingested media to the decoder.

* Generate downstream FlexFEC with per-track protection presets

Generate FlexFEC-03 repairs for subscribed video tracks. Subscribers select
none (default), low, medium or high through UpdateTrackSettings.fec; repairs
require rtc.flexfec.downstream_enabled and negotiated flexfec-03 support.

Generate repairs at each frame marker, splitting large frames into blocks of
at most 48 packets, with upstream Q8 repair-count rounding and at least one
repair per block. Reserve measured repair overhead during layer allocation
and charge repair traffic to pacing, bandwidth estimation and metrics.

Carry repair sequence state through the DownTrack GetState/SeedState handoff,
apply subscriber settings from immutable snapshots, and preserve upstream FEC
on shared sendrecv codec lists when downstream generation is disabled.

This squashes the three commits of dc/feature/fec_down (38a67502, d269ac59,
7b02897c) and rebases them onto master. Conflict resolution:
- pacer.Packet keeps master's held-extension scratch next to the FEC field,
  and the DownTrack sets FEC on the pacer packet master now creates before
  adding extensions
- DownTrackParams and subscriber config keep master's RTXBudget
- configureSenderParams uses master's enableFlexFEC name
- tests follow master: pion/transport v5 packetio, mid-less receivers skipped
  when restricting codecs, and settings compared by value since they are
  stored as merged snapshots

Requires the UpdateTrackSettings.fec field from livekit/protocol#1794, which
is not in the pinned protocol version yet.

* Add end-to-end tests for downstream FlexFEC

Publish a VP8 track through the SFU to a FlexFEC-capable subscriber,
simulate downstream loss before the subscriber's receive buffer, and recover
the dropped packets from the repairs actually sent, using the same FlexFEC-03
decoder as upstream recovery. RTX is dropped meanwhile so retransmissions
cannot fill the gaps.

The test checks that no repairs are sent before a preset is selected, that
every preset recovers isolated losses bit-exactly, that presets change
without renegotiation, and that a subscriber which declines flexfec-03
receives media but no repairs. Frames alternate between one and five
packets, so repair counts match the Q8 rounding for both block sizes.

The test client gains a subscriber RTP filter to simulate loss and accessors
for the subscriber descriptions. The tests use their own ports so they can
run next to a local server on the default ports.

* Support downstream FEC protection modes

Adopt the FECProtection message from livekit/protocol#1987: subscribers
select a mode (disabled, adaptive, fixed, minimum) and a level (low,
medium, high; unspecified is low) per track. As before, an update that
omits fec keeps the previous setting. Unknown modes disable FEC and
unknown levels are treated as unspecified.

The modes follow libwebrtc's RtpParameters::fec_protection
(webrtc-sdk/webrtc#329):
- adaptive ports VCMNackFecMethod: the kFecRateTable lookup with a 10
  second max-window loss filter, key frame boost, ConvertFECRate, NACK
  only delta frames below 20ms RTT, and BitRateTooLowForFec. Inputs are
  the subscriber's receiver reports, the sent bit and frame rates, and
  the forwarded layer's dimensions.
- fixed uses the level for delta and key frames.
- minimum uses the larger of the adaptive rate and the level.
- the adaptive state is updated in every mode, so switching to adaptive
  or minimum starts from the current loss history, and a protection
  change keeps the group that is accumulating and protects it at the
  new rate.

Key frames get their own protection factor, so pacer packets carry a
key frame flag. Repairs are still generated per frame; multi-frame
blocks (max_fec_frames) are not supported.

The end-to-end tests report the simulated loss in receiver reports,
since the test client sends none, and check that adaptive protection
sends no repairs without loss and protects with loss, and that minimum
protection matches its level without loss and rises with loss.

Requires livekit/protocol#1987, which is not in the pinned protocol
version yet.

* Point protocol at livekit/protocol#1987

* Report loss before repair in receiver reports to publishers

Receiver reports counted packets restored by RTX or recovered by FlexFEC
as received, so as long as repairs kept up the reported fraction lost
stayed at zero, even with 20% upstream loss. libwebrtc receivers exclude
recovered packets from their receive statistics, and a publisher's
loss-based protection depends on that: with no reported loss, FlexFEC
backs off to almost no repairs.

Packets that fill a loss through a repair are now counted separately, and
receiver reports include them in the fraction and cumulative loss.
Reordered packets that arrive on their own still cancel the loss. The
fraction is also capped at 255, so a full loss no longer wraps to zero.

With 20% simulated upstream loss from an Android publisher, the reported
fraction lost goes from 0 to about 0.15, the FEC packets received over 30
seconds go from 64 to 204, and the packets recovered by FEC from 11 to 61.

* Protect zeroed abs-send-time and TWCC in downstream FlexFEC

The pacer encoded FEC after it had filled in abs-send-time and the
transport-wide sequence number. libwebrtc generates FEC before its sender
fills them in, and its FlexFEC receiver zeroes both in media packets before
recovery. Packets recovered from SFU repairs therefore got wrong bytes in
those extensions, and in the payload when the header lengths within a group
differed, for example when only the first packet carried abs-capture-time.

Zero both extensions after the media packet is written and before it is
fed to the encoder.

* Aggregate receiver report loss for adaptive FEC protection

Adaptive and minimum protection fed the fraction lost of every reception
report into the max-window loss filter. libwebrtc receivers can send a
report with each NACK, so a report often covers only a few packets and its
fraction lost is very noisy. With 10% random loss, single reports read up
to 70%, and the filter kept the maximum.

Derive loss from the cumulative counters instead and produce a sample only
once it covers at least 20 expected packets, like libwebrtc's
SendSideBandwidthEstimation::UpdatePacketsLost. The end-to-end tests now
report cumulative loss and the extended highest sequence number in their
receiver reports.

* Report loss before repair only to FlexFEC publishers

Counting repaired packets as lost in receiver reports applied to every
publisher, so any publisher whose loss RTX repaired started to see that loss
and its bandwidth estimate could back off sooner. Only FlexFEC protection
needs loss before repair to choose its rate.

Count repairs only for streams that negotiated flexfec-03, which requires
FlexFEC to be enabled on the server. Other publishers keep receiving loss
after repair, as before.

* Keep the newest RTX repair mark of a history slot

A late retransmission of an older packet that has aged out of the cache
overwrote the slot of a newer repair sharing it. The newer repair, which
carries the RTX packet's header, could then be used for FlexFEC recovery and
corrupt the recovered packet.

Keep the highest extended sequence number written to a slot until the stream
restarts. isRTXRepairedLocked already treats an older packet in a slot with a
newer mark as repaired.

* Measure FEC overhead against all media

The allocator scales the whole media bitrate by the measured repair
overhead, but the overhead was measured against protected media only. With
adaptive protection below 20 ms RTT only key frames are protected, so the
ratio of key frame repairs to key frame media was applied to every frame,
and the reservation could make the allocator lower the layer or pause the
track although the bandwidth was sufficient.

Count all non-padding media while any protection is active.

* Keep the loss sample that closes a filter window

The max-window loss filter, ported from libwebrtc, dropped the report that
closes a one-second window when the window already had a maximum, so a loss
spike arriving on the boundary never reached adaptive protection. Store the
larger of the window's maximum and that sample.

* Skip the encoder allocation check under the race detector

CI runs the tests with -race and swaps sync.Mutex for go-deadlock, whose
Lock allocates, so Encode allocated about once per call there. Check
allocations only without the race detector, like the other allocation tests.

* Bump protocol to v1.55.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* sfu: reserve measured FEC overhead only on the forwarded layer

The measured repair overhead comes from the spatial layer being
forwarded. On a low layer with one or two packets per frame it can be
60-100%, and applying it to every layer reserved the high layer at
nearly twice its cost, so the allocator could stay on the low layer.

Attribute measurements to the forwarded spatial layer, restarting them
when forwarding starts, resumes or switches layers, and reserve the
configured rate for the other layers.

Also reallocate only when a reserved overhead moves by 5 points or
more, or turns on or off, so that per-second measurements and adaptive
protection do not re-run allocation on every receiver report.

* buffer: gate upstream FlexFEC on an explicit flag

A publisher PC registers flexfec-03 when only downstream FEC is enabled,
because it can also carry subscriptions. Its buffers then got a FEC
payload type, which reported loss before repair to the publisher and
let the decoder start from the observed repair SSRC, although upstream
FEC was disabled.

Buffers now ignore the negotiated FlexFEC payload type unless the buffer
factory enables upstream FlexFEC.

* pacer: protect interceptor-written transport-cc as zeros in FEC

With UseSendSideBWEInterceptor, Pion's TWCC header extension
interceptor writes transport-cc during WriteRTP while the DownTrack
leaves TransportWideExtID at zero. The extension was then protected
with its non-zero value, which the receiver zeroes before recovery, so
recovered packets got wrong bytes there.

Pass the negotiated transport-cc ID to the pacer for FEC and zero it
before encoding as well.

* sfu: skip the FEC encoder while protection is disabled

The encoder was attached whenever flexfec-03 was negotiated, including
in the default disabled mode, so every forwarded packet took the
encoder lock and updated the adaptive state without generating repairs.

Pass the encoder to the pacer only while protection is enabled. Receiver
reports still keep the loss history; adaptive protection measures media
rates again once enabled.

* sfu: account sent FEC repairs in the down track RTP stats

Repairs were counted only in the aggregate Prometheus counter, so the
down track's stats under-counted what the subscriber receives. Record
them in the sender's FEC packet and byte counters, separate from media,
and export the FEC counters in RTPStats for both directions.

* rtc: merge subscriber FEC settings in one place

The subscription merged and normalized settings, and the subscribed
track merged and normalized them again, while the DownTrack mapped
unknown modes and levels a third time.

Merge only in the subscription, store the merged settings in the
subscribed track as is, and leave unknown values to the DownTrack.

* prometheus: resolve fixed-label FEC counters once

RecordFECDownstream runs on the pacer path for every repair batch and
looked up both counter vectors by label each time.

* rtpstats: seed a sender without holding both locks

Seed took the receiving sender's lock and then the source's, so two
senders seeding from each other at the same time could deadlock. Copy
the source's state under its own lock first, then apply the copy under
the receiving sender's lock.

* telemetry: count FlexFEC repairs in traffic totals

Retransmissions and padding count towards node and participant
traffic, but FEC repairs, which are also on the wire, did not. Add
repairs sent and received to the node packet and byte totals, and to
the packets and bytes of TrafficStats.

Analytics streams are unchanged: AnalyticsStream has no FEC field.

* sfu: read the FEC transport-cc ID atomically

setRTPHeaderExtensions runs again when the stream allocator listener is
set, which can happen while media is already forwarded, and WriteRTP
read the ID without synchronization. Store it atomically once the
extensions are processed.

* telemetry: count only FEC repairs sent in node traffic

Media recovered from FEC repairs is counted as received media, so
adding the repairs received to node ingress counted recovered packets
twice. Node traffic feeds room admission against limit.bytes_per_sec,
so ingress must not be inflated. Keep repairs sent in node egress,
where nothing is synthesized, and leave ingress as before.

TrafficStats is derived from RTPStats without a direction, so it cannot
tell repairs sent from repairs received; leave it without FEC.

* rtc: add WebRTCConfig.SetFlexFEC for per-session FlexFEC settings

* rtc: apply a session's upstream FlexFEC to its buffers

SetFlexFEC changed what a session negotiates with its publisher, but the
publisher's buffers still followed the node config: the room's buffer
factory read it once. A session with upstream on and a node with it off
negotiated flexfec-03, so the publisher sent repairs that its buffers
ignored; the reverse turned on upstream recovery and loss reported before
repair for a session that asked for neither.

The session's buffer factory now follows the session's upstream setting,
whichever of SetFlexFEC and SetBufferFactory comes first. Without a
SetFlexFEC call it follows the node config, as before. The setting applies
to buffers the factory creates afterwards, so SetFlexFEC is meant to be
called while the session is set up, before any track is published.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Jules Testard <jules.testard@livekit.io>
Co-authored-by: David Chen <chenosaurus@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 14:55:27 +01:00

489 lines
24 KiB
YAML

# Copyright 2024 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# main TCP port for RoomService and RTC endpoint
# for production setups, this port should be placed behind a load balancer with TLS
port: 7880
# when redis is set, LiveKit will automatically operate in a fully distributed fashion
# clients could connect to any node and be routed to the same room
redis:
address: redis.host:6379
# db: 0
# username: myuser
# password: mypassword
# To use sentinel remove the address key above and add the following
# sentinel_master_name: livekit
# sentinel_addresses:
# - livekit-redis-node-0.livekit-redis-headless:26379
# - livekit-redis-node-1.livekit-redis-headless:26379
# If you use a different set of credentials for sentinel add
# sentinel_username: user
# sentinel_password: pass
#
# To use TLS with redis
# tls:
# enabled: true
# # when set to true, LiveKit will not verify the server's certificate, defaults to true
# insecure: false
# server_name: myserver.com
# # file containing trusted root certificates for verification
# ca_cert_file: /path/to/ca.crt
# client_cert_file: /path/to/client.crt
# client_key_file: /path/to/client.key
#
# To use cluster remove the address key above and add the following
# cluster_addresses:
# - livekit-redis-node-0.livekit-redis-headless:6379
# - livekit-redis-node-1.livekit-redis-headless:6380
# And it will use the password key above as cluster password
# And the db key will not be used due to cluster mode not support it.
# token_revocation:
# # revoke the existing tokens of a participant when RemoveParticipant is called or its
# # permissions are updated, default false. Tokens whose nbf is before the cutoff are rejected:
# # revoke_token_ts when given (must be within 60s of now), otherwise now minus a 1 minute leeway.
# enabled: false
# # how long a revocation is kept, default 11m10s.
# # Set it above the validity of the tokens handed out to participants to keep removed participants out for good.
# ttl: 11m10s
# WebRTC configuration
rtc:
# UDP ports to use for client traffic.
# this port range should be open for inbound traffic on the firewall
port_range_start: 50000
port_range_end: 60000
# when set, LiveKit enable WebRTC ICE over TCP when UDP isn't available
# this port *cannot* be behind load balancer or TLS, and must be exposed on the node
# WebRTC transports are encrypted and do not require additional encryption
# only 80/443 on public IP are allowed if less than 1024
tcp_port: 7881
# when set to true, attempts to discover the host's public IP via STUN
# this is useful for cloud environments such as AWS & Google where hosts have an internal IP
# that maps to an external one
use_external_ip: true
# # when set to true, advertises both mapped external and internal IPs to clients as server candidates.
# # useful when clients connect from both private and public networks.
# # works when `use_external_ip` is set to true, and also when `node_ip` is set explicitly below.
# # in both cases the node's local candidate is kept alongside the mapped one instead of being replaced by it.
# # when both this and `external_ip_only` are set, SFU advertises all private IPs with their mapped external IPs and skips
# # private IPs that do not have a mapped external IP.
# advertise_internal_ip: true
# # when set to true, SFU skips external IP accessibility checks via self-ping.
# # enable this when SFU is behind NAT that does not allow self-ping. only works when `use_external_ip` is set to true.
# skip_external_ip_validation: true
# # there are cases where the public IP determined via STUN is not the correct one
# # in such cases, use this setting to set the public IP of the node
# # use_external_ip takes precedence, for this to take effect, set use_external_ip to false
# node_ip: <external-ip-of-node>
# # when set, LiveKit will attempt to use a UDP mux so all UDP traffic goes through
# # listed port(s). To maximize system performance, we recommend using a range of ports
# # greater or equal to the number of vCPUs on the machine.
# # port_range_start & end must not be set for this config to take effect
# udp_port: 7882-7892
# # when set to true, server will use a lite ice agent, that will speed up ice connection, but
# # might cause connect issue if server running behind NAT. Only work on subscriber peerconnection
# # of dual-pc mode.
# use_ice_lite: true
# # optional STUN servers for LiveKit clients to use. Clients will be configured to use these STUN servers automatically.
# # by default LiveKit clients use Google's public STUN servers
# stun_servers:
# - server1
# # optional TURN servers for clients. This isn't necessary if using embedded TURN server (see below).
# turn_servers:
# - host: myhost.com
# port: 443
# # tls, tcp, or udp
# protocol: tls
# # Shared secret for TURN server authentication
# secret: ""
# # Path for file containing shared secret for TURN server authentication
# # When both secret and secret_file are set, secret takes precedence
# # An empty/whitespace-only secret file fails startup rather than silently
# # falling back to static credentials
# secret_file: "/var/lib/coturn/secret"
# # TTL of generated credentials in seconds. Defaults to 14400 (4h) when 0.
# # Negative values fall back to the 300s (5m) default; values are capped at 86400 (24h).
# ttl: 14400 # seconds
# # Insecure username/password authentication
# username: ""
# credential: ""
# # Alternatively, load the static username/credential pair from one YAML file:
# # username: myuser
# # credential: mycredential
# # The file must have no permissions for others (for example, chmod 640).
# # Inline username/credential take precedence; the pair is never mixed with
# # file values. Quoted YAML preserves whitespace in passwords.
# credentials_file: "/run/credentials/livekit/turn.yaml"
# # allows LiveKit to monitor congestion when sending streams and automatically
# # manage bandwidth utilization to avoid congestion/loss. Enabled by default
# congestion_control:
# enabled: true
# # in the unlikely event of highly congested networks, SFU may choose to pause some tracks
# # in order to allow others to stream smoothly. You can disable this behavior here
# allow_pause: true
# # use send-side bandwidth estimation instead of relying on receiver reports, default false
# use_send_side_bwe: false
# # how egress is paced when use_send_side_bwe is enabled. one of:
# # no-queue - hand packets to a send worker that drains them without rate
# # limiting, so the sender never blocks on a write (default)
# # pass-through - send each packet inline on the calling goroutine
# # leaky-bucket - accepted, but not currently wired to the bandwidth estimate; it
# # logs a warning and falls back to no-queue. see livekit/livekit#4724
# # an unrecognized value is rejected at startup.
# send_side_bwe_pacer: no-queue
# # FlexFEC-03 forward error correction, disabled by default.
# # Accepts FEC from publishers and uses it to repair lost packets before
# # forwarding.
# flexfec:
# upstream_enabled: false
# # Allow repairs for subscribers that negotiate FlexFEC. Clients select fec
# # per track in UpdateTrackSettings with a mode and a level:
# # - FEC_MODE_DISABLED (default): no repairs
# # - FEC_MODE_ADAPTIVE: follows the subscriber's reported loss and RTT like
# # libwebrtc's hybrid NACK/FEC (no delta frame repairs below 20ms RTT)
# # - FEC_MODE_FIXED: the level's repair packet overhead
# # - FEC_MODE_MINIMUM: at least the level, rising adaptively with loss
# # Levels are FEC_LEVEL_LOW (15%, also the default), FEC_LEVEL_MEDIUM (25%)
# # or FEC_LEVEL_HIGH (35%), matching publish track presets. These are
# # approximate: each protected frame/block gets at least one repair, so
# # small frames can exceed the nominal percentage.
# # Media is sent immediately; repairs follow the end of each frame, with
# # large frames split into blocks of at most 48 packets. Stale partial frames
# # spanning more than 200ms and packets without room for repair headers are skipped.
# downstream_enabled: false
# # allows automatic connection fallback to TCP and TURN/TLS (if configured) when UDP has been unstable, default true
# allow_tcp_fallback: true
# # signaling RTT (in milliseconds) below which ICE/TCP is attempted on a UDP failure; at or above it,
# # supporting clients fall back directly to TURN/TLS. 0 (default) disables the check (ICE/TCP always tried).
# # a positive value also enables allow_udp_unstable_fallback.
# tcp_fallback_rtt_threshold: 0
# # migrate an established-but-lossy UDP connection to ICE/TCP or TURN/TLS. requires tcp_fallback_rtt_threshold > 0, default false
# allow_udp_unstable_fallback: false
# # number of packets to buffer in the SFU for video, defaults to 500
# packet_buffer_size_video: 500
# # number of packets to buffer in the SFU for audio, defaults to 200
# packet_buffer_size_audio: 200
# # minimum amount of time between pli/fir rtcp packets being sent to an individual
# # producer. Increasing these times can lead to longer black screens when new participants join,
# # while reducing them can lead to higher stream bitrate.
# pli_throttle:
# low_quality: 500ms
# mid_quality: 1s
# high_quality: 1s
# # cap the bytes a subscriber's track retransmits in response to NACKs. Off by default.
# # max_ratio: retransmitted bytes allowed, as a fraction of the media bytes sent; 0 turns the cap off.
# # burst_bytes: retransmitted bytes allowed at once above that ratio; at least 1500.
# # When the budget is short, the newest packets are retransmitted first.
# rtx_budget:
# audio:
# max_ratio: 0.4
# burst_bytes: 4000
# video:
# max_ratio: 0.2
# burst_bytes: 64000
# # when set, Livekit will collect loopback candidates, it is useful for some VM have public address mapped to its loopback interface.
# enable_loopback_candidate: true
# # network interface filter. If the machine has more than one network interface and you'd like it to use or skip specific interfaces
# # both inclusion and exclusion filters can be used together. If neither is defined (default), all interfaces on the machine will be used.
# # If both of them are set, then only include takes effect.
# interfaces:
# includes:
# - en0
# excludes:
# - docker0
# # ip address filter. If the machine has more than one ip address and you'd like it to use or skip specific ips,
# # both inclusion and exclusion CIDR filters can be used together. If neither is defined (default), all ip on the machine will be used.
# # If both of them are set, then only include takes effect.
# ips:
# includes:
# - 10.0.0.0/16
# excludes:
# - 192.168.1.0/24
# # Set to true to enable mDNS name candidate. This should be left disabled for most users.
# # when enabled, it will impact performance since each PeerConnection will process the same mDNS message independently
# use_mdns: true
# # Set to false to disable strict ACKs for peer connections where LiveKit is the dialing side,
# # ie. subscriber peer connections. Disabling strict ACKs will prevent clients that do not ACK
# # peer connections from getting kicked out of rooms by the monitor. Note that if strict ACKs
# # are disabled and clients don't ACK opened peer connections, only reliable, ordered delivery
# # will be available.
# strict_acks: true
# # enable batch write to merge network write system calls to reduce cpu usage. Outgoing packets
# # will be queued until length of queue equal to `batch_size` or time elapsed since last write exceeds `max_flush_interval`.
# batch_io:
# batch_size: 128
# max_flush_interval: 2ms
# # max number of bytes to buffer for data channel. 0 means unlimited.
# # when this limit is breached, data messages will be dropped till the buffered amount drops below this limit.
# data_channel_max_buffered_amount: 0
# # target latency for data track channels. under downlink congestion, frames are dropped
# # to keep the per-subscriber buffer bounded (a fresh frame is preferable to a stale queued one).
# # 0 disables buffering control (unbounded buffering). defaults to 100ms.
# datachannel_data_track_target_latency: 100ms
# when enabled, LiveKit will expose prometheus metrics on :6789/metrics
# prometheus:
# port: 6789
# # optional: also export livekit_room_included_total, counting only rooms whose name
# # does not match this regex (RE2, unanchored).
# room_exclude_regex: "^(loadtest|healthcheck)-"
# expose /debug/pprof (and /debug/goroutine, /debug/rooms) on a dedicated port,
# separate from the public signalling port. only enabled when port is set.
# debug_handler_port:
# port: 7070
# API key / secret pairs.
# Keys are used for JWT authentication, server APIs would require a keypair in order to generate access tokens
# and make calls to the server
keys:
key1: secret1
key2: secret2
# Logging config
# logging:
# # log level, valid values: debug, info, warn, error
# level: info
# # log level for pion, default error
# pion_level: error
# # when set to true, emit json fields
# json: false
# # for production setups, enables sampling algorithm
# # https://github.com/uber-go/zap/blob/master/FAQ.md#why-sample-application-logs
# sample: false
# Default room config
# Each room created will inherit these settings. If rooms are created explicitly with CreateRoom, they will take
# precedence over defaults
# room:
# # allow rooms to be automatically created when participants join, defaults to true
# # auto_create: false
# # number of seconds to keep the room open if no one joins
# empty_timeout: 300
# # number of seconds to keep the room open after everyone leaves
# departure_timeout: 20
# # limit number of participants that can be in a room, 0 for no limit
# max_participants: 0
# # only accept specific codecs for clients publishing to this room
# # this is useful to standardize codecs across clients
# # other supported codecs are video/h264, video/vp9, video/av1, audio/red
# enabled_codecs:
# - mime: audio/opus
# - mime: video/vp8
# # allow tracks to be unmuted remotely, defaults to false
# # tracks can always be muted from the Room Service APIs
# enable_remote_unmute: true
# # control playout delay in ms of video track (and associated audio track)
# playout_delay:
# enabled: true
# min: 100
# max: 2000
# # improves A/V sync when playout_delay set to a value larger than 200ms. It will disables transceiver re-use
# # so not recommended for rooms with frequent subscription changes
# sync_streams: true
# Webhooks
# when configured, LiveKit notifies your URL handler with room events
# webhook:
# # the API key to use in order to sign the message
# # this must match one of the keys LiveKit is configured with
# api_key: <api_key>
# # list of URLs to be notified of room events
# urls:
# - https://your-host.com/handler
# Signal Relay
# since v1.4.0, a more reliable, psrpc based signal relay is available
# this gives us the ability to reliably proxy messages between a signal server and RTC node
# signal_relay:
# # amount of time a message delivery is tried before giving up
# retry_timeout: 30s
# # minimum amount of time to wait for RTC node to ack,
# # retries use exponentially increasing wait on every subsequent try
# # with an upper bound of max_retry_interval
# min_retry_interval: 500ms
# # maximum amount of time to wait for RTC node to ack
# max_retry_interval: 5s
# # number of messages to buffer before dropping
# stream_buffer_size: 1000
# PSRPC
# since v1.5.1, a more reliable, psrpc based internal rpc
# psrpc:
# # maximum number of rpc attempts
# max_attempts: 3
# # initial time to wait for calls to complete
# timeout: 500ms
# # amount of time added to the timeout after each failure
# backoff: 500ms
# # number of messages to buffer before dropping
# buffer_size: 1000
# # optional gzip compression of bus payloads
# compression:
# # gzip level 1-9; 0 disables. every node on the bus must support
# # compression before enabling it
# quality: 0
# # payload bytes below which compression is skipped
# threshold: 1024
# # cap on an inbound payload after decompression, 0 for unlimited
# max_decompressed_size: 0
# customize audio level sensitivity
# audio:
# # minimum level to be considered active, 0-127, where 0 is loudest
# # defaults to 30
# active_level: 30
# # percentile to measure, a participant is considered active if it has exceeded the
# # ActiveLevel more than MinPercentile% of the time
# # defaults to 40
# min_percentile: 40
# # frequency in ms to notify changes to clients, defaults to 500
# update_interval: 500
# # to prevent speaker updates from too jumpy, smooth out values over N samples
# smooth_intervals: 4
# # enable red encoding downtrack for opus only audio up track
# active_red_encoding: true
# turn server
# turn:
# # Uses TLS. Requires cert and key pem files by either:
# # - using turn.secretName if deploying with our helm chart, or
# # - setting LIVEKIT_TURN_CERT and LIVEKIT_TURN_KEY env vars with file locations, or
# # - using cert_file and key_file below
# # defaults to false
# enabled: false
# # defaults to 3478 - recommended to 443 if not running HTTP3/QUIC server
# # only 53/80/443 are allowed if less than 1024
# udp_port: 3478
# # defaults to 5349 - if not using a load balancer, this must be set to 443
# tls_port: 5349
# # set UDP port range for TURN relay to connect to LiveKit SFU, by default it uses a any available port
# relay_range_start: 1024
# relay_range_end: 30000
# # caps the number of concurrent relay allocations a single participant credential may hold.
# # prevents one authenticated participant from exhausting the shared relay-port range for everyone else.
# # defaults to 12; a value <= 0 disables the quota.
# per_user_relay_allocation_limit: 12
# # set external_tls to true if using a L4 load balancer to terminate TLS. when enabled,
# # LiveKit expects unencrypted traffic on tls_port, and still advertise tls_port as a TURN/TLS candidate.
# external_tls: true
# # set proxy_protocol to true if the proxy or load balancer in front of tls_port does not preserve
# # the client address (it terminates TLS, or dials LiveKit from its own IP) and can send a
# # PROXY protocol v1/v2 header instead. Without it TURN reports the proxy's address to the
# # client as XOR-MAPPED-ADDRESS, which Firefox rejects when it is loopback or wildcard.
# # every connection on tls_port must then carry the header; connections without it are rejected.
# # prefer PROXY protocol v2 on the proxy side: the v1 text header must arrive in a single read.
# proxy_protocol: false
# # proxies whose PROXY header is trusted. connections from any other address are closed, so a
# # client that reaches tls_port directly cannot claim an arbitrary source address.
# # defaults to loopback, for a proxy running on the same host.
# proxy_protocol_trusted_cidrs:
# - 127.0.0.0/8
# - ::1/128
# # needs to match tls cert domain
# domain: turn.myhost.com
# # optional (set only if not using external TLS termination)
# # cert_file: /path/to/cert.pem
# # key_file: /path/to/key.pem
# # TTL of the TURN credentials in seconds - defaults to 300.
# # Values <= 0 fall back to the 300s (5m) default; values are capped at 86400 (24h).
# ttl_seconds: 300
# # list of restricted peer CIDRs (loopback, link-local (unicast, multicast), multicast, private, unspecified) to allow access to.
# # By default (i. e. empty list), all restricted peer CIDRs are denied access.
# # When not empty, only the specified CIDRs are allowed access.
# # Note that this check is applied to restricted peer CIDRs only.
# allow_restricted_peer_cidrs:
# - 10.0.0.0/8
# - 192.168.0.0/16
# # list of peer CIDRs to deny access to.
# # This applies to all peer CIDRs, including restricted ones.
# # Deny list takes precedence over allow list.
# # A malformed CIDR in either list fails startup rather than being silently ignored.
# deny_peer_cidrs:
# - 10.0.0.0/8
# - 192.168.0.0/16
# ingress server
# ingress:
# # Prefix used to generate RTMP URLs for RTMP ingress.
# rtmp_base_url: "rtmp://my.domain.com/live"
# # Prefix used to generate WHIP URLs for WHIP ingress.
# whip_base_url: "http://my.domain.com/whip"
# # Allow URL pull ingress from udp:// source URLs. Disabled by default.
# # Only enable this if you trust both the callers allowed to create ingresses and the network the
# # ingress handlers run on. Unlike an http or srt source url, a udp source url doesn't make the
# # handler connect out to the url host: the handler binds a local socket on the address and port
# # taken from the url, and joins the multicast group if one is given. This lets the caller choose
# # which local port the handler binds, feed the session unauthenticated and easily spoofed traffic,
# # and make the handler join arbitrary multicast groups and republish whatever it receives into a
# # room, using the ingress as a relay for streams on the handler's local network.
# enable_udp_url_pull: false
# Region of the current node. Required if using regionaware node selector
# region: us-west-2
# # node selector
# node_selector:
# # default: any. valid values: any, sysload, cpuload, regionaware
# kind: sysload
# # priority used for selection of node when multiple are available
# # default: random. valid values: random, sysload, cpuload, rooms, clients, tracks, bytespersec
# sort_by: sysload
# # algorithm used to govern selecting from sorted nodes
# # default: lowest. valid values: lowest, twochoice
# algorithm: lowest
# # used in sysload and regionaware
# # do not assign room to node if load per CPU exceeds sysload_limit
# sysload_limit: 0.7
# # used in regionaware
# # list of regions and their lat/lon coordinates
# regions:
# - name: us-west-2
# lat: 44.19434095976287
# lon: -123.0674908379146
# # node limits
# # set to -1 to disable a limit
# limit:
# # defaults to 400 tracks in & out per CPU, up to 8000
# num_tracks: -1
# # defaults to 1 GB/s, or just under 10 Gbps
# bytes_per_sec: 1_000_000_000
# # how many tracks (audio / video) that a single participant can subscribe at same time.
# # if the limit is exceeded, subscriptions will be pending until any subscribed track has been unsubscribed.
# # value less or equal than 0 means no limit.
# subscription_limit_video: 0
# subscription_limit_audio: 0
# # limit size of room and participant's metadata, 0 for no limit
# max_metadata_size: 0
# # limit size of participant attributes without the lk. prefix, 0 for no limit
# max_attributes_size: 0
# # limit size of participant attributes with the lk. prefix, which LiveKit services set.
# # defaults to 2 KiB, 0 for no limit
# max_lk_attributes_size: 2048
# # limit length of room names
# max_room_name_length: 0
# # limit length of participant identity
# max_participant_identity_length: 0
# # max size (bytes) of a single client-facing signalling WebSocket message; oversized
# # frames are rejected by the transport before being buffered. defaults to 2 MiB, 0 for no limit
# signal_message_size_limit: 2097152
# # same as above, but for agent worker WebSocket connections. defaults to 2 MiB, 0 for no limit
# agent_signal_message_size_limit: 2097152
# # max size (bytes) of an HTTP request body on the main API listener (Twirp room/egress/ingress/SIP
# # routes). requests larger than this are rejected before their body is decoded, so large messages
# # cannot exhaust memory. defaults to 10 MiB, 0 for no limit
# max_api_request_body_size: 10485760