Files
piik/docs/standards/media-quality.md
T
AAA 499789671c feat(app): bring Android sharing and touch control into the shared runtime (#504)
## Problem and outcome / 问题与结果

Bring Android into Piik's shared App workflow and make phone control usable without a separate Web UI. One signed APK covers ARM64 and x64; screen capture, room authority, routing, voice and site approval reuse the existing Go and Browser owners. Android opens the user's system browser rather than shipping an embedded browser.

This phase also fixes capture replacement and encoding-clock failures, improves source-audio startup, contains recoverable input and transport failures, adds a bounded relay-volunteer setting and supports hostnames in `SFU_PUBLIC_IP`. The website separates desktop and mobile downloads, gives iOS users an online entry and aligns the bilingual installation guides.

Related reports: #495, #499, #500, #501, #502 and #503. For #502, input execution failures now preserve authorization, and temporary target observations suspend rather than revoke it; the original Windows report remains open for candidate feedback.

## Release notes

**Piik, now in your pocket.**

Piik App now supports Android screen sharing, with touch controls for a friend's computer.

**手机,也能开播。**

Piik App 现已支持 Android 屏幕分享,也能用手机控制朋友的电脑。

### English

Piik v2.5.0 brings the App to Android and improves capture reliability, touch control and everyday startup. The existing 2.x compatibility baseline is unchanged.

- **Android App:** share your screen, join room voice or control a supported computer. One APK supports ARM64 and x64, using your own browser and the same Piik interface.
- **Phone controls:** use direct touch or a compact floating mouse with dragging, left/right buttons and a scroll wheel. Pinch to zoom and pan the picture while controlling.
- **More reliable sharing:** keep video progressing through source and encoder-output changes, and improve low-bitrate recovery and stationary-screen keyframes. Correct Windows window-size handling and Linux NVENC settings; start optional source sound after video is ready.
- **Smoother App entry:** retry failed startup in place, reopen the running room and retain the correct App connection when returning from the browser. Compress shared page assets to reduce loading traffic and keep microphone choices stable during ordinary page updates.
- **Recovery stays local:** a rejected input or canceled source replacement no longer revokes remote-control permission. Full ICE candidate queues and failed audio-parameter updates retain healthy connections. A failed local room leaves the App and unrelated approved sites running.
- **Connection settings:** relay volunteers can cap their downstream viewers. Self-hosted SFU setups can use a DNS hostname in `SFU_PUBLIC_IP`.
- **Clearer help:** refine sharing-error guidance, preserve input-failure diagnostics without recording input content, and update the bilingual platform and network guides.

Update both the App and your self-hosted site to use the new features. Android can control a supported computer; the Android device itself is not a controlled endpoint.

If you previously installed a test APK, uninstall it once before installing this release: the official signing key is different. Uninstalling clears App-local site approvals and starred-site choices; browser settings remain in the browser. Later official releases can be installed over this one.

### 中文

Piik v2.5.0 带来 Android App,并改善采集稳定性、手机远控与日常启动体验。沿用现有 2.x 兼容基线。

- **Android App:** 分享手机画面、加入房间语音,或控制支持远控的电脑。一个安装包同时支持 ARM64 与 x64,使用自己的浏览器和熟悉的 Piik 界面。
- **手机远控:** 直接触摸操作,或展开小巧的悬浮鼠标,使用拖拽、左右键与滚轮;控制时也能双指缩放、移动画面。
- **分享更稳定:** 修复切换采集来源、编码输出时画面停止推进的问题,改善低码率恢复与静止画面的关键帧响应。修正 Windows 窗口尺寸处理和 Linux NVENC 设置,来源声音会在画面就绪后启动。
- **App 进出更顺畅:** 启动失败可原地重试,再次打开会回到正在运行的房间;从浏览器返回时保持连接到正确的 App。共用页面资源启用压缩,减少加载流量,麦克风选项不再随普通页面更新反复加载。
- **局部问题就地恢复:** 单次操作失败或取消换源不再撤销远控授权;ICE 候选队列满或音频参数调整失败时保留健康连接。本地房间故障不会连带停止 App 和其他已授权站点的分享。
- **连接设置:** 帮助转发的观众可设置承接人数上限;自部署 SFU 的 `SFU_PUBLIC_IP` 现在支持 DNS 主机名。
- **排查更直接:** 打磨分享失败提示,补充不记录输入内容的远控故障诊断,并更新中英文平台说明与网络指南。

使用新功能时,请一起更新 App 与自部署站点。Android 可作为控制端操作电脑,手机本身不作为被控端。

曾安装测试 APK 的用户需先卸载一次,再安装正式版,两者签名不同。卸载会清除 App 内的站点授权和收藏,浏览器设置仍保留在浏览器中;后续正式版可直接覆盖安装。

## Verification / 验证

- Local full Web/type/build checks passed: 104 test files, 1,848 tests; the website and documentation builds passed.
- Android full-App emulator acceptance covered real decoded screen sharing, concurrent 1080p/540p encoder allocation, live bitrate changes, stationary keyframes, Viewer departure, consent reuse/reentry and final capture-resource retirement.
- A local universal release APK passed signing, package identity, version-code, ABI and non-debuggable checks using the permanent release key. GitHub Actions receives the same key through encrypted Secrets; manual candidate runs use a disposable candidate signer.
- Windows real capture checks covered H264/VP8 window resizing and restoration. Source-audio startup and failure/close ordering passed focused runtime checks; Linux race checks passed.
- Desktop/mobile website layouts were reviewed in English and Chinese, both themes, including grouped downloads, the iOS online entry and self-hosting links.
- All three Server and six App candidate targets, including the signed Android universal APK, passed in https://github.com/TNTcraftHIM/Piik/actions/runs/40350004792. This uses the same release packaging path with publication disabled.
- The complete network laboratory passed in https://github.com/TNTcraftHIM/Piik/actions/runs/40354253735: 43 expected scenario outcomes (37 media connections, six expected-unavailable controls), six negative controls, and complete process/network cleanup.
- Recoverable-error checks cover real encrypted input replies and legacy opt-in, retained grants and held-key cleanup, real Windows target geometry recovery, candidate queue overflow, and audio-parameter retry on the existing edge. Android room failure and full shutdown use real launcher, control WebSocket and supervised-process checks; unrelated site resources remain intact.
- The lifecycle fixes at `7eb04de373567cfe7aff2db6c93adf2a38e0b1aa` passed all nine package targets and Go/vulnerability/race/Web checks in https://github.com/TNTcraftHIM/Piik/actions/runs/40362794088, including macOS x64/ARM64 cgo and Android. Publication was skipped.
- Final cross-review found and fixed the same candidate-overflow false failure in the SFU voice owner. Its real-Pion regression verifies the first 64 candidates remain queued, a valid answer drains them, and renegotiation succeeds. Independent reviews confirmed real SDP and authorization failures still propagate.
- A real-browser before/after check reduced microphone enumeration from nine calls to one across eight ordinary Host rerenders. Changing the native client or switching to Browser capture still enumerates the new devices. The separate focused contribution #507 preserves input focus during queued floating-panel opening and is not attributed to this phase.
- The verified Windows candidate and reproduction steps have been updated in #502. macOS/Linux physical-device coverage and iOS device acceptance keep their documented boundaries.

## Impact / 影响

- Planned release: **v2.5.0**; no public wire or storage version bump.
- Android is a sharing and controlling endpoint, not a remotely controlled Android device. iOS is held outside this release.
- New Android release target joins the existing complete-target, checksum, GitHub and Gitee artifact pipeline. Signing material stays outside Git; optional input SDKs/drivers are not bundled.
- The owner authorized closure and publication after the final design review and acceptance checks. Restore the publication gate after the held focused contribution and merge this complete phase once; CI publishes only after its full checks and registered packages pass.
- Current TODO, platform guidance, media/routing evidence and release operations retain their existing document owners; no additional audit ledger or changelog archive is introduced.
2026-10-26 13:37:33 -04:00

549 lines
36 KiB
Markdown

# Capture, Audio, And Media Quality
This file owns the current Browser and App media contract. Detailed measurements and
platform limits live in [realtime quality research](../research/realtime-quality-adaptation.md)
and [screen-audio research](../research/browser-screen-audio-quality.md).
[ADR-0007](../adr/0007-path-isolated-representation-quality.md) owns Browser
source intent and codec selection, [ADR-0008](../adr/0008-window-scoped-audio-capture.md)
owns screen-audio scope, and [ADR-0013](../adr/0013-embedded-node-local-media.md)
owns the shared Native/SFU output model. This file describes that product
contract. [Status](../status.md) indexes delivery and remaining acceptance.
## Capture And Controls
Room voice handles Host and Viewer conversation microphones, separate
from source sound and optional Host source commentary. Its Browser capture owner supplies device selection, input
gain and optional speech processing, including on App-backed pages. Settings
remain local to the Browser origin; joining and microphone activation are never
remembered. Stopping picture capture does not stop room voice. Source audio stays
with the picture; room voice prioritizes interactive latency and is not promised
to remain synchronized with a delayed picture.
Microphone gain, master voice listening volume and each person's local volume
range from 0% to 200%, defaulting to 100%. Master and per-person listening gains
multiply. Per-person levels belong to the current participant identity and retire
with it. Listening gain, deafen and per-person mute affect only local playback,
never forwarding or the picture's source audio.
Room voice defaults to 64 kbps mono, with Saver/Standard/Clear shortcuts at
32/64/96 kbps and a custom 6..320 kbps sender ceiling in the Host's voice settings.
Microphone and Peer-relay voice senders use the same room ceiling; WebRTC may send
less as speech or network conditions change. Receive SDP accepts Opus's full 6..510 kbps
range independently of that sender setting. Published older pages can join
without the optional bitrate extension; their senders and negotiated receive
limits may retain the earlier 32 kbps bound.
The Host may enable **Sharing settings → Sound → Include my microphone** to mix
commentary into the picture's audio. It starts off for each new share and retires
with that share. Browser capture reuses the stable HostAudio source/microphone
output; Native capture reuses its mixer and microphone API. Room voice has its
own room lifetime. Both microphones may be enabled intentionally; the UI warns
that listeners may hear the same speech twice through the separate deliveries.
Piik does not automatically mute either microphone or switch between them.
- The Web Host may share a display, application window, Browser tab or camera and may
stop, synchronously pause/resume audio and video, or switch source.
- An App-launched Host explicitly chooses either that Browser capture path or
one native screen/window enumerated by the packaged platform capture boundary. The
latter uses one supported native codec path and never infers a target from
a title. An ordinary Web Host does not probe localhost.
- Camera is a peer source choice in the same picker, including on phones. Only
the chosen source requests permission. Camera input and thumbnails request
an uncropped device format; sender constraints own later scaling.
Camera capture does not implicitly open a microphone. Source commentary and
room voice require their own explicit activation. A microphone device/processing change keeps the previous input
on failure and does not replace picture media. Browser processing preferences
do not bypass device/system effects.
- Source-audio availability belongs to the Host capture owner. A live source
input makes source audio available; a retained Native output track alone does
not. This describes input presence, not measured
loudness; quiet content, share pause and Viewer-local mute remain separate facts.
Source replacement and source-audio changes update this fact without rebuilding
the output or media route. An opted-in room session carries it for the current
publication, including late joins and signaling reconnects.
- An audio-only update with the same capture video preserves the Browser video
sender, encoding state and startup evidence on both direct and SFU paths.
A new video source owns a new startup baseline; audio changes do not.
On Browser direct edges, source/audio renegotiation waits for the current
answer and coalesces newer intent into the next offer. A local operation queue
alone does not serialize the remote offer/answer exchange.
- Windows native capture follows an explicitly stretched active display path
for an entire display or a window covering that display, when the captured
frame matches its desktop source dimensions. Other frames retain their own
aspect ratio. This changes only the encoded presentation, never the game or
display settings; vendor-private scaling is not inferred.
- Windows and Linux outputs preserve source presentation aspect within the
selected ceiling, rounded to even dimensions. Small sources are not enlarged
to a fixed landscape canvas. Windows uses its existing converter; Linux uses
GStreamer's size negotiation. Source resizing does not create a new room or
route, and frame envelopes carry actual output dimensions. Network adaptation
remains owned by the existing media framework.
- Windows SDR conversion owns one output color contract: limited-range BT.601
NV12 with matching H.264 metadata. RGB capture and decoded video retain their
input range/matrix through conversion and relay scaling; dimensions do not
determine color space. Unspecified SDR follows the WebRTC convention.
- Windows native HDR sources retain scRGB FP16 until platform tone mapping,
source-display white-level adjustment and sRGB conversion produce SDR. Live
capture and source thumbnails share this owner; conversion precedes output
fanout and does not add a media route or per-encoder tone curve. Ordinary SDR
keeps its copy path. Source-display color changes refresh capture input,
not room authority or transport. [Fidelity evidence](../research/media-fidelity.md)
owns platform checks; this is HDR-to-SDR, not end-to-end HDR delivery.
- Where Windows supports border control, the native source picker offers
**Show capture border**, off by default. The choice stays in the Host page and
follows native source and quality changes. Source previews request borderless
capture independently. Windows owns consent and final border visibility;
unsupported, pending, denied or failed access must leave ordinary capture and
stop controls usable. Other capture sessions can keep the border visible.
Browser indicators remain browser-owned.
- Display/window/tab capture requests ask the Browser for available audio by
default. Missing audio is reported clearly but does not block video-only
sharing. Native screen capture can include system playback audio and native
window capture can include selected-process audio when the platform exposes it.
- Authoritative Browser pause disables the current source and sender-owned tracks
while retaining the room and established routes. The connection owns its
encoded-output pause even when shared encoding is unavailable; the pool pauses
a shared producer only when all its members pause. Native pause keeps capture
alive but stops session output through the same owner. Black frames, track
mute, or network failure are not interpreted as a user pause.
- The Host preview displays the capture stream directly and creates no Viewer or
media route. Hiding the page may pause only that local video element; it must
not intentionally stop capture, encoding, or upload.
- Live quality changes update the current capture and Host sender-track
constraints plus sender ceilings without reopening source selection or
replacing a healthy route. Shared Browser capture constraints express size
ceilings, not ideal dimensions or a fixed aspect ratio: lowering a ceiling
must not request a crop, and source orientation remains Browser-owned.
- Native quality changes use the same room settings. The App prepares a new
platform capture/encoder generation, then replaces the old generation behind
the same encoded source and PeerConnections; audio-only changes update the
current Opus encoder directly. A live profile update may remain pending while
the selected source produces no frames. Setup and encoding failures remain
bounded; quiet-source waiting must not block pause, stop or connection control.
Applied settings change only after the replacement is ready and installed;
required-output failure preserves the previous capture and profile. Failed lower
outputs stay unavailable across preparation and installation without rejecting
a healthy original output. Platform quality preference uses the hardware
encoder's standard quality-versus-speed hint. Pion owns Native WebRTC
transport; the shared media adapter uses LiveKit media components for bandwidth
estimation, forwarding allocation, pacing and recovery.
Windows VP8 uses libvpx's realtime mode; it does not claim the same hardware
quality-versus-speed control or per-edge Browser adaptation.
- With App available, Browser H.264 capture can use one local sender and the
existing Native encoded fanout while topology optimization is enabled. The
Browser still owns preview, pause, capture settings, and source selection.
Loss of that optional ingress retains capture and rebuilds the assigned
Browser edges. [ADR-0011](../adr/0011-browser-assisted-native-fanout.md) owns
this composition; pure Browser and VP8 sharing use the Browser-owned sender
paths described below.
## Video Profiles
The Host remembers explicitly applied picture and source-audio quality settings.
Browser-only use stores them per origin. An App-opened page uses the running,
authorized App's optional preference store when available, including across
temporary public-link origins; older or unavailable Apps retain Browser storage.
These preferences seed a new page, never an active share. Explicit edits and
authoritative room recovery win over a late preference read. Failed or superseded
changes and server snapshots do not replace the preference; pending saves retain
only the latest applied choice. Storage failure never fails capture or startup.
This does not retain capture permission, device/session identity, routing policy
or microphone activation, and reading settings claims no Native media session.
The three recommended profiles are ceilings, not delivery guarantees:
| Profile | Target | Video bitrate ceiling |
| --- | --- | ---: |
| `720p30` | 1280x720 at 30 fps | 3 Mbps |
| `1080p30` | 1920x1080 at 30 fps | 5 Mbps |
| `1080p60` | 1920x1080 at 60 fps | 8 Mbps |
`1080p30` is the default. The 2.0 contract carries numeric width/height ceilings;
480p, 720p, 1080p, 1440p and 4K are UI shortcuts. Advanced picture settings also
accept custom even dimensions within the combined implementation bounds below.
Width and height form one applied edit. A size change caps the requested frame
rate in the same quality operation when the larger size requires a lower limit.
Larger wire-valid requests do not
authorize an adapter to exceed its local capture, codec or allocation limits.
Numeric requests use representational bounds rather than the current control
ranges. Current capture admits integer 1..240 fps and 0.1..240 Mbps, further
limited by picture size. Advanced controls accept typed values alongside sliders;
the three recommended profiles and default remain unchanged. These are useful
product controls, not universal codec
limits or a minimum for framework-driven output. Codec and resource budgets
apply separately. App descriptions may advertise stronger capabilities;
controls use their intersection with local support. An unsupported request is
an operation failure, not malformed signaling. An unsupported saved preference
does not seed capture or overwrite its stored value with a fallback.
Derived outputs must stay within their source bitrate ceiling, including when
that ceiling is below a usual lower-output floor. Codec preflight must observe
real encoded progress; cadence tolerance alone cannot make zero output pass.
Frame rate, bitrate, and `maintain-resolution | balanced |
maintain-framerate` retain their controls. Display video uses the standard
`contentHint = "motion"` for game motion.
Native H264 retains Constrained Baseline. Capture validates the coding-tool subset under
RFC 6184, including equivalent Constrained Baseline constraint bytes, and reports
the actual SPS profile/level; one vendor's byte spelling is not the contract.
The platform encoder selects its level from the requested format. Validate the
actual supported level instead of forcing a calculated minimum into the encoder.
Native ingress and relay accept only a negotiated profile/packetization compatible
with their unchanged encoded downstream source. A codec name alone is not enough;
same-source renegotiation must preserve that boundary before altering the live peer.
Received picture summaries are not decoder allocation limits. Before Native
derivation, validate every H.264 sequence parameter set's supported format,
coded storage and visible crop; a later small descriptor cannot authorize earlier
large input.
Candidate capture admits even dimensions up to 8192 per axis and 36,864
16x16 macroblocks per picture, including alignment. Its shared codec budget
follows H.264 Level 5.2: 2,073,600 macroblocks per second and a 240 Mbps video
bitrate ceiling; capture scheduling is separately bounded at 240 fps.
This admits 1080p240, 1440p144, 5120x1440 at 60 fps and landscape/portrait
4K60. It does not admit a full 8K picture. Decoder alignment has a
separate coded-storage bound; reference-picture storage is bounded before
Native derivation. These are admission limits, not a device performance promise.
App discovery reports size, pixel-count, frame-rate and bitrate limits through the
existing native health description. Controls use the intersection with local
implementation limits; a remote claim cannot raise those limits. Whole-route
and physical-device acceptance remain separate from available controls.
Use platform decoder defaults for internal provisioning, rather than turning
independent axis ceilings into a maximum-square preallocation. Encoded input
and actual output storage remain bounded before use.
Quality observations have independent numeric bounds. A valid capacity estimate
above the requested send rate remains evidence; invalid optional measurements
become unavailable. Invalid Native quality samples are discarded without closing
media control. Required identity, generation and state evidence must still pass
before a sample can influence route decisions. SFU encoding descriptions likewise
do not grant resources: the SFU admits supported formats before allocating them.
Framework-driven downscaling under bandwidth or device pressure is valid within
the selected degradation preference. A low decoded resolution alone is not a
defect and does not justify a new quality floor. Review avoidable disruption,
recovery and healthy-child isolation instead of requiring a minimum observed size.
Current acceptance targets are:
- on a controlled P2P path with RTT at most 40 ms and loss at most 1%, glass-
to-glass latency p50 at most 150 ms and p95 at most 250 ms;
- through a regional SFU/UDP root, glass-to-glass p95 at most 350 ms; and
- when the 60 fps profile is selected, no silent run of five seconds below 50
decoded fps without an explicit adaptation or user-visible limitation.
These are targets pending the physical matrices in verification status, not
claims that every Browser, game, or network already meets them.
## Codec Decision
The pre-share Browser selector is `VP8 | Auto | H264`, defaults to Auto, and is
locked while sharing. It is local UI state and is not persisted or carried as a
room quality setting.
Auto uses one bounded actual-sender probe rather than a capability or device
allowlist. A proved sender prefers H.264 with VP8 fallback; unsupported, failed,
or inconclusive probes use VP8. Manual VP8 or H264 strictly selects that codec.
The probe deadline covers setup, negotiation and statistics; cancellation retires
its resources even when a Browser operation remains pending. The result stays
fixed for the current share and is reconsidered for a new share.
ADR-0007 owns probe and negotiation mechanics.
Codec selection preserves the negotiated repair stream associated with the
selected primary codec. Native and SFU receivers use standard Pion RTX/NACK;
their shared outgoing transport also offers RTX, with LiveKit owning repair.
Codec restrictions must not strip recovery or disable SRTP replay protection.
The Browser chooses the concrete encoder implementation. A reported H.264 codec
does not by itself prove hardware acceleration, and Web content cannot select a
specific MFT, NVENC, AMF, or QSV implementation.
Windows native capture uses the same VP8/Auto/H264 controls. H264 selects the
hardware path and VP8 the bundled libvpx encoder. Hardware enumeration is only
a candidate list: startup tries the preferred encoder first, then remaining
adapter/encoder candidates within the shared selection budget. Manual H264
requires actual H264 output and never changes codec on failure. The selected
device owns capture and output workers; its identity is retained as the first
choice for quality/source replacement. Native relay encoding uses the same
selection owner. Auto paces synthetic NV12 frames at the selected dimensions and
frame rate through the live encoder pipeline, including its rate control and frame
dropper, with the Browser probe's warmup, one-second sample and 100 ms lag
allowance. Cold-start lag is excluded from the measured window; the selection
deadline still bounds warmup and hardware input/output waits. A candidate whose
measured delivery falls outside that allowance is rejected and the next candidate
is tried within the four-second budget. A measured frame deficit beyond that
allowance ends the probe immediately: remaining frames cannot change its result.
Do not start another candidate unless the remaining budget can cover its
measurement. A successful probe hands the same hardware encoder to live output;
only its synthetic adaptation history is retired, so selection needs one hardware
session and does not repeat unproven activation.
Without a sustaining candidate, Auto starts the ordinary VP8 path directly, as manual VP8 does. A
faster software encode never replaces a sustaining H264 encoder. Encoder readiness
uses Media Foundation events rather than timer-based polling.
Actual encoding and failure reporting remain owned by the capture worker. This
is a cadence check, not a perceptual-quality score or a promise under future
GPU load.
The returned actual codec owns the shared source, preview, and relay; live
quality/source changes retain it. Other native platform encoders remain H264.
## Framework-Owned Adaptation
Requested ceilings, committed network allocation and actual encoded output are
separate facts. Congestion must not turn a temporary reduced output into a new
requested ceiling. Recovery demand must survive lower-layer selection and reach
the existing encoder or dormant-output owner without recreating the connection.
Native outputs share one source presentation timeline across encoder groups,
dormancy and capture replacement. Capture and refresh timestamps express elapsed
source time; encoder completion and pipe arrival do not establish another clock.
Internal RTP copies reuse the original ingress's accepted remote-to-local clock
mapping. Only that ingress estimates network delay; outgoing sender reports
project the source timeline onto the media core's local clock at emission.
Each Browser direct, relay, or SFU video sender owns a separate track. The original
track remains a source and local presentation track; it is never attached directly
to an outbound sender. Display capture with raw-frame stream support forwards a
bounded input clone into a generated sender track, without resizing or encoding.
This prevents encoder feedback from shrinking its own capture recovery input;
[the Chromium capture lock](../research/browser-local-encoding-pool.md#sustained-h264-recovery)
owns the evidence. Camera/received tracks and unsupported Browsers retain ordinary
clones. Capture constraints and capture metadata belong to the input. Its native
idle refresh is retained through a 1 fps capture constraint; sender adaptation has
no new FPS or resolution floor. Pause gates the outgoing track. Replacement and
retirement cancel the frame pipe and stop both owned ends; an unexpected input
end belongs to the current sending operation, never the shared source or siblings.
Connection retirement also settles its pending sender and negotiation waits;
closing a Browser PeerConnection alone does not guarantee that its promises
settle. Cancellation starts before joining work that depends on it, while a
replacement still waits for the retired owner's cleanup.
Browser and Native encoder-group admission uses current native demand, not the
previously applied rate. A new or pending join must not displace an existing
rate owner by raising or retaining its budget against that owner's demand.
Revalidate pending admission before planning other memberships.
Eligible Browser P2P parents use the source-owned pool in
[ADR-0014](../adr/0014-browser-node-local-encoding-pool.md). Compatible direct
children share one independent local WebRTC producer; incompatible demands
remain separate. Joining another producer must fit the child's native allocation;
a quiet scene's low byte rate does not prove that producer's rate budget fits.
Pending separation remains necessary while another compatible member needs a
higher native budget; quiet output alone cannot cancel it. When that demand
leaves or the child's budget recovers, the current producer can adapt in place.
Optional reuse also preserves the healthy current output's rate budget and
observed quality within Host ceilings through recovery-frame commitment, using
the actual candidate frame and current output rather than preparation alone.
Rejected membership retains current delivery and its recovery requests.
A recovery frame already being written retains its owner until completion,
including across pause/resume; cancellation belongs to the output that knows
whether writing has started.
Each outgoing connection keeps native transport, allocation and recovery, with
a tiny carrier supplying its RTP clock. Producers use the existing native video
target under Host ceilings. A new producer seeds its
local WebRTC start rate from that allocation, without a minimum or a change to
the outgoing connection's estimate. Subsequent budgets use the existing sender
parameters; initialization does not add a recovery controller. Actual forwarded-frame
and producer observations remain distinct from the tiny carrier's statistics.
Producer startup protection begins at actual outgoing publication, excluding
local warmup and paused frames. The synthetic carrier uses screen-content
transport probing; the real producer keeps the Host's picture adaptation.
Capture constraints and the picture's sender FPS ceiling belong to the real
source and producer, not the producer-driven carrier clock. The carrier
preserves its frame rate instead of adapting picture cadence a second time.
The producer retains the Host's degradation preference. Outgoing transport
bitrate still follows the Host ceiling; ordinary fallback restores its picture
sender limits. Preparation and applied-budget completion re-evaluate pending
membership immediately; accepting a recovery frame still commits the handoff.
The first eligible consumer follows the same path; unsupported APIs or failed
pooling use ordinary senders. Negotiated codec incompatibility retires only
that connection's pool membership; healthy siblings keep their producers.
Prepared ordinary quality candidates, Native
ingress and Browser SFU remain independent compositions.
Each ordinary Browser PeerConnection owns stock WebRTC congestion control and
sender adaptation. Ordinary clones share one underlying media source and therefore
do not provide complete simultaneous isolation: framework source-wants aggregation
may still partially reduce frames available to sibling clones. Sibling outputs may differ;
Piik does not impose a room-wide minimum. The Host's one Browser SFU
publication uses the share-generation codec and selected ceilings. Its ordinary
simulcast outputs follow pinned LiveKit screen-share construction: original and
half size at the same frame rate, with a quarter-bitrate lower ceiling and its
150 kbps floor. Tiny sources use one output. There is no backup codec or third
product preset. Browser WebRTC budgets the aggregate publication.
The embedded SFU forwards an existing suitable encoding to each subscriber.
LiveKit media components own its per-subscriber bandwidth estimation, allocation,
RTP projection, pacing and loss recovery; the LiveKit room service and Browser
SDK are not used. Direct-subscriber demand controls the publisher's active
output prefix through the current room signal. Target, currently forwarded and
recovery-preparation demand stay distinct from actual delivery. Viewport size
does not choose a layer because a Viewer may relay its received media.
Tracks received from a PeerConnection do not own capture constraints. Native
capture therefore retains source resolution and frame-rate ownership across its
loopback Browser preview. Native Host SFU publication uses the encoded source
directly and does not re-encode that preview through a Browser publisher.
Native parents and the SFU share the media forwarding adapter. Each Native
parent considers only its direct children and its admitted SFU publication.
A Native source with one rendition shares that encoding across its consumers.
Its encoder budget follows the largest active remote allocation within the source
ceiling. Local preview alone can use the ceiling, but cannot mask remote demand.
One shared rendition cannot provide different encoded qualities to its children.
Recovery-probe traffic is exploration, not a reduction of committed media
capacity. Allocation and encoder consumers retain the same budget through probe
settling. A locally rate-controlled output has unmet demand within its current
layer as well as demand for larger outputs; raw forwarding cannot synthesize it.
Compatible children reuse an available encoded output; a missing lower output
starts one shared decode/scale/encode group, while healthy forwarding retains
the original input without starting a decoder. The group produces the highest
needed output and its lower fallbacks and stops unused upper outputs. Each child
receives only its selected output. The forwarding SFU adds no server transcoder.
Downstream attachment or sending failure and retirement belong to that edge,
never its shared video/audio source or healthy siblings.
Native keyframe requests retain their output scope through coalescing; a relay
requests its single upstream stream once per batch while keeping local output
recovery separate.
Only actual independent output fulfills an encoder recovery request. A delayed
keyframe leaves the request pending while usable delta frames continue; it does
not itself fail a healthy output. Initial encoder admission still requires a
decodable starting point, and real encoding failures retain their existing owner.
Native relay assembly bounds both packet storage and stalled media progress.
An incomplete frame must not wait for a memory-sized packet window to fill before
requesting recovery; quiet input and ordinary reordering remain valid.
Native capture uses the same screen-share output construction within Host
ceilings. Its source, source clock and higher outputs remain independent of
lowest-output bitrate adaptation. The SFU upstream request is the maximum of
its direct-subscriber demands; Native Host combines it with direct Peer demand,
while the publication still has one aggregate upload budget. Multiple outputs
have real encode and upload costs; this is not a one-encode guarantee.
Packet identity and delivered counters belong to each outbound edge. Unused
outputs do not inflate that edge's FPS or bitrate. Bounded codec workers and
packet queues isolate slow children and retire with the source generation.
Windows shared local outputs use one complete stock WebRTC encoding/adaptation
pipeline each, including source restrictions, rate correction and resource
feedback. Resolution/FPS adaptation keeps the capture and transport identities;
actual output dimensions update forwarding metadata without resetting sibling
stream trackers. H264 uses native NV12/MFT and WebRTC's parsed-QP adaptation;
VP8 uses the library encoder. Windows tunes the stock QP history and sampling
for brief interruptions and low-frame-rate recovery; codec thresholds and the
adaptation controller remain WebRTC-owned. Other platform producers retain their
current fixed-output implementation pending equivalent physical acceptance.
Android shares one Projection and captured texture across demand-driven
MediaCodec outputs. Each output uses the pinned WebRTC FrameDropper before
encoder submission, with encoded-byte feedback and the current allocation;
dropping an output frame never stops the shared capture clock. Unsupported
optional encoders leave the original usable. Its fixed spatial outputs and
platform codec still bound extremely low-bandwidth delivery.
Each source groups compatible effective direct-child requests and keeps
incompatible weak budgets independent. Per-group rates change in place; joining
another group's output waits for accepted recovery and keeps the existing
PeerConnection, pacer and bandwidth estimator. Original received media stays
encoded, while a relay uses one decoder process for its independently activated
missing outputs. Source-generation retirement rejects old frames before they
can change attachment. Private physical slots are bounded by admitted consumers,
not fixed spatial presets, and unused codec workers retire independently.
This does not establish full Browser parity, hardware-overload acceptance or
seamless adaptation at extremely low bandwidth.
Native sender edges normally reuse the shared encoded source. A Native Viewer
forwards suitable H.264/VP8 and Opus payload unchanged and derives only a missing
lower video output; each outbound PeerConnection owns its RTP identity and
transport feedback. When an edge is
persistently degraded, the existing quality operation may prepare a Browser
WebRTC sender from the stable local bridge as that edge's candidate. The old
edge stays live until the Viewer completes the route owner's relative quality proof; a failed
candidate rolls back, and a later operation may return the edge to the shared
native source. This gives one difficult path stock per-sender adaptation without
lowering the shared representation for healthy paths. It adds no quality score,
timer, or room-wide media setting.
Piik does not maintain an application bitrate/resolution ladder, scene
detector, periodic quality controller, manual SFU layer selector, or
application-defined whole-room lowest-common-denominator target.
## Screen Audio
The Host's playback volume adjusts the share's mixed source sound and optional
commentary from 0% to 200%, starting at 100% for each share. Browser gain precedes
outgoing fanout; native gain precedes the shared Opus encoder. Source replacement
preserves the level, and room voice remains independent. Viewer volume adds only
local listening gain.
Piik supports mono and stereo Opus content through the existing audio
track. Mono inputs remain valid; Browser and Native mixing use a stereo output.
A stereo receive preference or two-channel declaration does not prove distinct
source channels. [Fidelity evidence](../research/media-fidelity.md#stereo) owns
decoded-channel checks. Surround delivery is outside the current scope; it needs
capture, channel-layout, mixing, codec and playback support, not only a channel
count setting.
Display audio uses `contentHint = "music"`. 2.0 keeps 64/128/192 kbps
shortcuts and the 128 kbps default, with a custom numeric ceiling in the same
sound settings. Current Browser/native senders support 6..320 kbps; the numeric
wire format uses Opus's 6..510 kbps bounds independently of those shortcuts.
The native 20 ms encoder also bounds each Opus payload to 1152 bytes, leaving
48 bytes for RTP/extensions/SRTP within a 1200-byte datagram. An average bitrate
ceiling alone does not bound VBR peaks; Opus RTP keeps each encoded frame intact.
A request above the current sender's bitrate ceiling fails that operation
without retiring native control.
An audio-only update retains capture, media connections and video startup state.
Browser, Native and SFU receive answers request Opus stereo and the full Opus
receive range, including renegotiation. Browser senders enforce a smaller
negotiated receive limit on their own encoding, falling back to libwebrtc's
mode-dependent default when no valid limit is declared. Native/SFU unchanged forwarding
requires a receiver that can accept the shared source's full range; a smaller
or undeclared limit rejects that edge before binding, without reducing the source or
its healthy siblings. An omitted preference does not mean unrestricted reception.
These receive preferences are independent of the offer's receive preferences.
The SFU publication uses stereo, DTX disabled, and RED
disabled; this accepts less burst-loss resilience in exchange for bounded
publisher traffic. The Browser and source still decide whether an audio track
exists and what is actually delivered.
A Native audio-process failure does not end healthy video. A later explicit
source replacement resumes audio through the existing track and encoder owner;
it does not trigger an automatic capture retry or change room audio topology.
Optional Windows screen-audio exclusion binds one selected process tree to its
PID and creation time under [ADR-0008](../adr/0008-window-scoped-audio-capture.md).
The selection lasts for the share, survives source-audio off/on and refresh,
and is never saved across App runs or rebound by executable name. Changing to a
window source or explicitly selecting no exclusion clears it. A requested
exclusion retires previous source audio before replacement preparation; failure
or target exit leaves source audio silent while healthy video and the Host
microphone continue. Only an explicit audio/source selection resumes it. Live
sound controls reuse source replacement and its serialization owner; when the
video target and capture options are unchanged, update only the audio input.
Keep the video generation, encoder, media connections and quality evidence.
A missing
capability must reject the request, never discard the exclusion. Old pages keep
their existing audio behavior.
## Observable Truth
Requested resolution, frame rate, bitrate, content intent, codec, and audio
quality are inputs or ceilings. Sender parameter readback and current RTCStats
are the observable result. Connection detail may show actual path, codec,
resolution, FPS, bitrate, loss, jitter, RTT, and encode/decode behavior when the
Browser exposes them; missing or reset counters remain unknown.
Browser WebRTC and the shared Pion/LiveKit media adapter own media adaptation.
ADR-0005's native-edge convergence consumes only a persistent categorical sender limitation
and proof from the same Viewer over a real prepared candidate; it does not turn
quality metrics into media settings or a weighted/global route score.
Native categorical evidence includes the media framework's committed allocation
deficiency: fitting a reduced output into the available budget does not clear a
continuing framework limitation, including a live encoder restricted within its
current output. Source bitrate variation alone does not reduce a committed
allocation or prove congestion; an unsuccessful recovery probe does not change
the incumbent's quality category. Publication evidence considers only requested
encodings, so an intentionally inactive encoding is not a bandwidth failure.
Missing feedback or frame progress remains unknown. This category neither
infers a physical bottleneck nor ranks routes by configured quality ceilings.
Web pages cannot guarantee Host background capture, mobile background playback,
or relay execution after Browser/OS suspension. Those remain physical lifecycle
boundaries, not keepalive features.