## Problem and outcome / 问题与结果 This phase adds lightweight room interaction without making media depend on chat, and adds Windows source-audio exclusion and optional SFU-only hosting at their existing owners. It also corrects confirmed encoder/capture ownership and native color-conversion defects. Host microphone commentary remains on the shared media path; room voice and 4K are outside this phase. ## Release notes ### 中文 这是一次功能更新:Piik 加入了文字聊天与表情互动,并完善了 Windows 声音采集、画面颜色和自部署选项。 #### 新功能 - **边看边聊。** 在可移动、可缩放的聊天窗口中发送消息,或开启弹幕。停止分享后,房间中的朋友仍可继续聊天。 - **表情互动。** 点击沙发上的人物,给自己发表情,或把番茄等表情送给朋友;各端按同一事件显示动画。 - **排除应用声音。** Windows App 分享整个屏幕时,可排除一个应用及其子进程的声音,适合同时使用语音软件。所选应用退出后,来源声音停止,避免恢复为未过滤的系统声音。 - **可选的纯 SFU 模式。** 自部署管理员可让共享画面和声音统一通过媒体服务器转发。默认仍为优先 P2P;App 公网邀请保持纯 P2P。 - **Windows HDR 转 SDR。** 原生采集与缩略图自动将 HDR 来源转换为 SDR,沿用现有观看链路。 #### 修复与改进 - 修复原生颜色转换的范围与矩阵处理,避免已复现的暗部丢失、高光裁切和颜色偏差。 - 修复共享编码器切换时使用过期需求或过期帧信息的问题,保护正在观看的画面;修复换源后旧采集事件可能影响新来源的问题。 - 统一新控件、浮窗与来源选择文案,补充中英文使用说明。 #### 使用与升级 聊天与表情需要新版站点页面和 Server;声音排除需要新版页面与支持此能力的 Windows App。聊天只保留本页最近收到的消息,刷新后清空,不补发历史,且不提供端到端加密。 HDR 转换输出为 SDR,不代表端到端 HDR 或多声道支持。既有房主麦克风与立体声能力保留。 ### English This feature update brings text chat and reactions to Piik, alongside improvements to Windows audio capture, picture colors and self-hosting options. #### New features - **Chat while watching.** Send messages in a movable, resizable window, or enable on-screen chat. Friends can keep chatting after the host stops sharing. - **Reactions.** Select a person on the sofa to react above yourself or send a tomato and other reactions to a friend. Participants animate the same shared event. - **Exclude application audio.** When sharing a whole screen with Windows App, exclude one application and its child processes, useful when using a separate voice app. Source audio stops if the selected app exits, preventing a return to unfiltered system sound. - **Optional SFU-only hosting.** Site operators can require shared video and audio to pass through the media server. P2P-first remains the default; App Public invite remains P2P-only. - **Windows HDR-to-SDR conversion.** Native capture and source thumbnails automatically convert HDR sources to SDR for the existing viewing path. #### Fixes and improvements - Correct native color-conversion ranges and matrices, addressing reproduced crushed shadows, clipped highlights and color shifts. - Correct stale demand and frame evidence during shared-encoder handoffs to protect the current picture. Prevent events from a replaced capture from affecting its successor. - Align new controls, floating panels and source-picker copy, with updated Chinese and English guides. #### Using this update Chat and reactions require updated site pages and Server. Audio exclusion requires updated pages and a Windows App that supports the capability. Chat retains only recent messages received by the current page, clears on refresh and does not replay history. It is not end-to-end encrypted. HDR conversion produces SDR; it does not add end-to-end HDR or surround sound. Existing host microphone commentary and stereo support remain available. ## Verification / 验证 - Web type checks, 78 test files / 1275 tests and production build: PASS. - Go core tests, formatting/vet and target builds: PASS; Darwin cgo remains platform-limited on this Windows runner. - Native build/check/color probes and synthetic HDR-to-SDR H.264/VP8 browser reception: PASS. - Access/privacy gate, Native H.264 SFU-only media gate and local Auto/H.264 Host gate: PASS. - Three real production pages: chat/reactions, stop/resume, idle-room join, host departure/return, offline draft recovery and invitation revocation: PASS. - Synthetic parent/child process-audio exclusion and target lifetime: PASS; no raw audio retained. - Windows candidate archive extraction and packaged Local startup/shutdown: PASS. - Documentation and website build: PASS. - [Candidate CI](https://github.com/TNTcraftHIM/Piik/actions/runs/36873766646) at `f26cd208d03bc0dcbe353f8cac217f993216b0a3`: Go core and race checks, Web tests, Server/container checks and Windows/macOS/Linux App packaging all PASS. Publication was skipped as intended. The owner accepted the UI/model and bounded local walkthrough for phase closure. Physical HDR/mixed displays, mobile keyboard, real voice applications across output devices and macOS/Linux capture remain unverified. Existing field reports without matched evidence are not claimed resolved. The owner authorized v1.7.0 publication on 2026-10-02. The final documentation-only commit records that authorization; product code matches the verified candidate above. ## Impact / 影响 Authorized version: **v1.7.0**, matching the local release planner. Current wire contracts remain Browser/server 23, Native control 9 and capture 7. Optional capabilities gate new functionality; existing room/media authority remains owned by the existing services. No new ports, message persistence, room voice or automatic room creation on page visit. Updated README, guides, standards, research evidence and TODO stay with the candidate phase.
24 KiB
Native App Media Evidence
- Reviewed: 2026-10-01
- Scope: platform capture, shared encoded sources, Pion transport and Browser decode; current behavior belongs to media quality
- Status: Windows physical native Host and Viewer gates passed; macOS and Linux adapters compile and package but still require physical media gates
Windows Audio Exclusion
A Windows 11 build 26200 check used two independent WinMM processes emitting 500 Hz and 1500 Hz tones, through the production capture helper and Go PCM reader. Default-device loopback captured both at approximately 1799 amplitude; process inclusion retained the first with under 0.3 amplitude of the other, and exclusion retained the second with under 0.04 of the excluded tone. Target exit retired capture in about 42 ms; attempting the stale identity failed. No raw audio was saved. The extended capability probe completed in 300 ms.
A parent/child follow-up used a silent selected parent with a 1900 Hz child, plus an independent 2900 Hz process. Process-scoped reference amplitudes were about 1799; exclusion retained the independent tone at 1800 and reduced the selected child's tone to 9.3 (under 0.6%). Parent exit retired capture in 64 ms; its stale identity was rejected. The reference uses each signal's own process capture: default-device loopback also includes unrelated playback and endpoint processing, so its amplitude is not a process-capture gain reference.
The session fixture separately verifies failed exclusion replacement mutes source audio while preserving video, microphone and encoded audio output; pause and audio-profile changes retain the selected input. These checks establish a local Windows implementation and one direct child, not coverage of every voice application's process tree or simultaneous playback across several output devices. Those remain device acceptance boundaries. ADR-0008 owns the platform choice.
The Windows activation contract accepts one PID and its process tree, not a list of unrelated processes. The win-capture-audio implementation supports broader exclusion by tracking audio sessions, capturing non-matching processes and mixing them. Applying that design here would require session discovery, process-tree deduplication and bounded multi-input mixing; Piik's current source-plus-microphone mixer does not own that inventory. Multiple exclusions therefore require a capture design change, not just a multi-select control. Combining exclusion streams does not itself exclude their combined set.
Initial Physical Evidence (2026-09-05)
These checks established the original native media paths. The Browser-mediated SFU and loopback v8 observations below are historical. ADR-0013 owns the SFU replacement; versioning owns the current wire contract.
Piik App can own one process-isolated Windows capture and hardware H.264 encoder, feed its Annex-B access units into one Pion source, and deliver that source through independent WebRTC transports to unmodified Chrome receivers. The Browser remains the room, route, and signaling authority.
The same App can run the Local authority, open the normal Host page, and
attach that native source to the current route. A remote Pion Viewer then
received 30 packets over a selected srflx-to-srflx pair. The validation
session carried signaling through a temporary reverse SSH path only; media was
negotiated directly by ICE.
On 2026-09-05, a separate Windows Local gate used a Browser Host with synthetic 1280x720 motion and an App-activated Viewer. The Viewer exclusively claimed the v8 loopback control session and real Chrome decoded 621 frames at 1280x720. This proves the Browser-to-Native receive/local-bridge path rather than a silent Browser fallback. A Pion integration gate separately forwards the same H.264 and Opus payload from one inbound receiver source to a bounded downstream edge, while dropping upstream connection-local extensions so each outbound Pion interceptor writes its own negotiated TWCC header.
The one-link form carried the current signaling protocol through its temporary public WSS origin to an independent Linux Pion Viewer. Repeated runs delivered 30+ packets over selected direct paths using a reflexive candidate; the Quick Tunnel carried no media.
An isolated LiveKit 1.13.6 gate carried the same native source through one
reserved local Pion edge into the existing Browser SfuPublisher; an ordinary
LiveKit Viewer received the default 1080p source, then 15 consecutive 854x480
frames after one live Native/SFU profile change. The direct native P2P path,
Browser, App, LiveKit process, ports, and profiles all cleaned up.
The opt-in gate:app-media run proved, in order:
- WGC capture and adapter-bound Media Foundation H.264 became active;
- 30+ encoded 1280x720 frames crossed the bounded process protocol;
- a PLI caused a later recovery unit;
- the packaged App exposed only separately probed video, process-audio, system-audio, and hardware-H.264 capability booleans before control connected;
- two Pion ICE/DTLS/SRTP edges each delivered 30+ decoded 1280x720 frames to Chrome from that one encoded source;
- the self-hosted STUN endpoint produced ordinary
hostandsrflxcandidates; - process-loopback audio produced non-zero PCM, Opus RTP, and non-zero decoded audio energy on both native edges; the same checks pass for a display using system loopback;
- closing the captured source ended its share, released the old media path, and a second capture generation in the same room delivered a different media object plus 30 new frames to the existing Viewer;
- App, capture, Browser, ports, and the isolated profile all closed.
Unit coverage separately enforces the supplied edge capacity, forwards PLI/FIR to the shared video source, validates the same PeerConnection's Opus section, and bounds the pure-Go Opus encoder's steady-state allocations. The native Host session starts the target-appropriate loopback audio only when the capture probe advertises it; an audio start failure leaves the video session alive. The cross-NAT result proves reachability and RTP delivery, not heterogeneous congestion behavior or a paired no-Site Browser media session.
The audio adapter uses github.com/thesyncim/gopus behind the private
nativeaudio boundary. It accepts fixed 48 kHz stereo PCM16/20 ms frames,
encodes into a caller-owned Opus buffer, and can be replaced without changing
the media edge or control wire. The dependency is BSD-3-Clause licensed and
requires Go 1.25; App CI uses Go 1.26.6.
Current Boundary
Windows supports hardware H264 and software VP8 behind the same capture, source and Pion transport boundary. The pinned WebRTC encoder pipeline supplies libvpx; VP8 reads NV12 through a reusable staging texture and converts to I420. Separate real Browser gates proved manual VP8 and Auto-selected H264, including live presets, pause/resume, source replacement and exact RTP codec preservation. Auto uses a bounded synthetic target-profile cadence check, not a score or a runtime codec switch. GPU-heavy selection and cross-device startup remain open acceptance work.
A 2026-09-28 check on Ryzen 7 9700X / RTX 4070 SUPER / Windows 11 26200
used the animated Browser gate source at a 1080p, 8 Mbps ceiling. With asynchronous
MFT readiness and no timeBeginPeriod(1) request, Auto selected NVIDIA H264 at
30 and 60 fps, reaching active in 1.851 and 1.855 s respectively. Full Browser
gates passed Auto, manual H264 and VP8 with source/profile replacement and
retirement. The helper-cost measurement below uses asynchronous CPU sampling:
blocking the probe's encoded-output reader while querying process statistics
distorts sustained cadence and must not be used for performance comparison.
Native Auto now observes the live pipeline's output, including the frame dropper implicated by the Browser AMD evidence. Cold-start work is excluded from steady cadence, while the selection deadline reaches MFT input/output waits. Synchronous driver activation/configuration and shutdown cannot be preempted by that deadline. Slow-output rejection has fixture coverage; native AMD/Intel physical acceptance and game-load behavior remain open. This evidence does not establish the cause of reported system-wide lag.
The Windows Browser gate now also keeps two native PeerConnections alive while the source changes from 720p30 to 1440p60, then changes to 480p15 while paused and resumes both Viewers. It proves the same Pion source survives two hardware capture/encoder generations; direct capture probes also produced every current resolution/FPS extreme, and the same route survives an explicit native source switch. The result does not yet prove macOS/Linux physical capture or endurance. Native Host media is exposed only through an explicit App-launched Host selection; an ordinary Web Host retains Browser capture.
Native Host publication now sends its encoded source directly to the embedded SFU. The local Browser bridge supplies preview and Browser quality candidates; it does not supply the ordinary Native SFU publication. Received tracks still cannot own capture constraints. Media quality owns the current output and adaptation contract.
A shared encode cannot independently adapt one bitstream for unequal paths. Rather than lower every Native child, a quality operation originating from a persistently degraded Native sender edge may prepare one Browser WebRTC sender from the stable local bridge. The existing overlapping candidate comparison alone commits or rolls it back, and a later quality operation can return that edge to Native. Healthy Native edges keep sharing the hardware encode. This is implemented without a new route reason, timer, score, or representation ladder; controlled weak-path physical acceptance remains open.
Native edges now use the shared Pion/LiveKit forwarding adapter for transport feedback, allocation, pacing and recovery. The former no-op-pacer and source-payload-versus-GCC comparison are no longer the product implementation. Observable truth owns current quality evidence, including committed allocation deficiency and unknown feedback.
No-Site Internet control can use the one-link mode owned by ADR-0010. Its remote Pion gate proves public signaling plus direct media, but not decoded Browser media on a physical second device. Cloudflare carries HTTPS/WebSocket control and provides public STUN, while DTLS-SRTP media remains direct. STUN alone cannot replace SFU/TURN on a restricted pair.
Native shares use the same Pion UDP socket for all edges. Site and one-link shares make one bounded, best-effort PCP, UPnP, or NAT-PMP mapping through NetBird's standalone Go NAT package; pure LAN Local mode does not. A physical router created and removed an ephemeral UPnP mapping; the Apache-2.0 dependency added about 0.38 MiB to the stripped Windows App. Mapping and the supplemental STUN survey now run alongside ordinary candidate gathering; neither delays the offer or ordinary candidates. End-of-candidates waits for both owners. Mapping refresh and retirement remain engine-owned; NAT evidence records the current dependency and reachability limits. The returned port is advertised once per observed public address as a lower-priority candidate. Only the three explicit same-socket survey candidates feed NAT prediction; the mapped candidate does not. This proves lifecycle and signaling, not that the mapped candidate has yet rescued a pair that public STUN alone could not connect.
The retained hardware fixture also changed one live NVIDIA MFT through
3 Mbps -> 1.5 Mbps -> 3 Mbps without recreating it. Equal 120-frame phases
produced about 1.00 MB -> 0.68 MB -> 0.97 MB, while ordered 30 fps output and
the pinned profile remained intact. Both AMD MFT candidates failed activation
before this probe, so the evidence is not a cross-vendor dynamic-rate contract.
With the failing AMD candidate preferred, bounded product selection now reaches
the working NVIDIA H264 encoder without changing codec. A local native Host gate
also passes decoded Viewer output, quality changes and source replacement. This
establishes the selection defect and repair, not the unknown reporter's cause.
This earlier fixture proves dynamic hardware rate changes, not the current
multi-output allocation policy or cross-vendor performance.
The Windows source boundary now enumerates displays and windows and returns a bounded best-effort preview. A display uses WGC plus default render-device loopback audio; a window uses WGC plus process-tree loopback when that actual capability probe succeeds. Preview failure is advisory and cannot tear down the control session.
A controlled 144 fps window on Windows build 26200 exposed two capture-cadence
failures: WGC's zero MinUpdateInterval delivered 48 fps, and sampling from the
last emitted timestamp reduced 48 fps input to 24 fps for a 30 fps profile.
Using WGC's supported non-zero interval plus a phase-continuous output cadence
delivered 29.99 fps and 60.00 fps from the same source. Older Windows versions
without the optional session interface retain their existing WGC behavior.
A Browser-capture/Pion fanout gate exposed a separate RTP input defect:
payload-empty padding was rejected and ended the video or audio reader. Chrome
then fell to a 30 kbps video target even at zero media loss and about 1 ms RTT.
Discarding padding kept the reader alive but introduced downstream sequence
gaps, NACKs and reduced decoded cadence. Forwarding valid padding through Pion's
existing WriteRTP, while excluding it from media-frame counts, restored two
1080p Viewers to about 30 fps with zero packet loss. The same gate passed live
quality, pause/resume, audio-presence source changes and App-exit fallback.
Native payload-capacity evidence does not require decoded dimensions; encoded
receivers can supply real transport evidence without opening a decoder.
DevTools accepted weak-network emulation commands in this loopback run, but RTP traffic exceeded the requested limit without the requested loss. That run does not establish weak-network quality or automatic fallback performance.
Non-Windows capture keeps the existing process/frame boundary and replaces only
the platform sidecar. The macOS adapter enumerates SCShareableContent, fences
the selected process/window generation, receives change-driven
CMSampleBuffers, and requires VideoToolbox constrained-baseline hardware H.264.
It retains one latest pixel buffer so an existing PLI/FIR can encode a fresh IDR
even while the screen is unchanged; capture timestamps drive the shared Pion RTP
clock. A GitHub macos-15 arm64 runner compiled the sidecar, created the same
hardware-only encoder, and encoded an in-memory 420v frame into a validated
42c01f SPS/PPS/IDR. The current adapter also emits ScreenCaptureKit application
or display audio through the common PCM boundary. ScreenCaptureKit permissions,
real video/audio capture, static-frame recovery, and endurance still require a
physical Mac.
The Linux adapter lets the XDG ScreenCast Portal own source selection, consumes its restricted PipeWire stream through one bounded GStreamer pipeline, and requires an installed element classified as a hardware H.264 encoder. It emits the same Annex-B protocol and can use the PulseAudio-compatible default monitor for system audio; it does not claim per-process audio. GitHub Linux CI compiles, probes, packages, starts, and stops the candidate. A real Portal desktop, hardware encoder, audio source, Browser decode, and recovery still require a physical Linux gate. GStreamer stays a system dependency: bundling another RTC or an 80+ MB media runtime would defeat the thin-adapter boundary, while an unavailable dependency cleanly leaves Browser capture available.
Windows Helper Cost (2026-09-29)
At 89a03e64 on Ryzen 7 9700X / RTX 4070 SUPER / Windows 11 26200,
an instrumented Release helper captured a controlled animated Browser window
and an offline CS2 scene window. Each run used one 1920x1080 output with an
8 Mbps ceiling; CPU sampling did not block the encoded-output reader. CPU below
is a percentage of one logical core, not total-machine use. The scene runs
are sequential observations, not matched gameplay or a cross-device benchmark.
| Source / codec | Target fps | WGC interval | Sample | Admitted / encoded fps | Helper CPU |
|---|---|---|---|---|---|
| Browser / H264 | 30 | 4 ms | 15.8 s | 30.0 / 30.1 | 4.6% |
| Browser / H264 | 60 | 4 ms | 15.8 s | 60.1 / 60.0 | 9.6% |
| Browser / VP8 | 60 | 4 ms | 15.7 s | 60.0 / 60.0 | 75.6% |
| CS2 / H264 | 60 | 4 ms | 45.8 s | 54.8 / 52.7 | 5.7% |
| CS2 / H264 | 60 | 8 ms | 45.8 s | 53.0 / 51.4 | 5.3% |
| CS2 / VP8 | 60 | 4 ms | 20.9 s | 54.9 / 53.3 | 82.9% |
Across these runs, NV12 conversion API work averaged 0.060–0.226 ms per frame, including texture/view creation; owned-input allocation/copy submission averaged 0.044–0.048 ms. These are CPU-side call durations, not GPU completion timings. They do not justify adding a texture pool. In particular, MFT input samples may remain referenced after submission; one mutable reused surface would discard the current ownership guarantee. The 8 ms trial establishes no worthwhile gain and does not supersede the earlier 144 Hz cadence evidence or the existing 4 ms setting, also used by Sunshine.
At 60 fps, explicitly requesting recovery every 250 ms retained 59.9 encoded fps on the Browser source and 56.9 on the CS2 source, with normal capture exits. A separate unchanged window stayed active for over 20 seconds in each codec; recovery requests produced fresh H264 keyframes from its retained image. These are one-output stress/idle checks, not proof of multi-output recovery cost or endurance. Code tracing also confirms membership/demand changes use recovery to wake a quiet source and apply its next output plan; SFU demand emits only on change. Removing these requests solely as redundant keyframes is unsafe.
H264 frame-rate bitrate compensation matches Chromium's MFT approach: compensate for the fixed configured frame rate without restarting the encoder. An adjusted API value above the requested bitrate is not by itself wire-rate overshoot. The measured aggregate H264 payload stayed below 8 Mbps, including recovery stress; this does not establish every short-window burst or driver behavior.
No automatic capture termination was reproduced. Admitted capture input stayed below 60 fps during the CS2 runs; these observations do not separate game render cadence, WGC delivery and capture sampling. They also do not measure game FPS impact, exclusive fullscreen/display changes, saturated GPU behavior, end-to-end decoded media or other GPUs. Software encoding costs more CPU here, but neither that result nor the allocation timings establish the reported system-wide lag's cause. Retain the existing implementation; reopen optimization from a matched bottleneck.
Native H.264 Motion Quality
Issue #432 reports more visible blocking with native H.264 than VP8 on v1.6.7. Review of its attached Browser report confirms 720p30 in both comparison windows, roughly 11 Mbps received, and no reported packet loss; the 1080p60 H.264 window receives roughly 10 Mbps. Those samples establish delivered format and transport observations, not equal source content or objective picture quality. No encoded stream, reference frames or QP measurements accompany that report.
The reporter retracted the initial CBR bitrate-ceiling diagnosis after finding
that the experimental fixture changed bitrate during the measured interval.
That switching belongs to PIIK_H264_FIXTURE in windows/main.cpp, not live
capture. The corrected experiment reports CBR reaching its requested bitrate.
Production h264_encoder.cpp explicitly requests and validates Baseline; the
Browser's negotiated profile-level-id alone is not an inspection of emitted
SPS. The later experimental CABAC result cannot establish the production
Baseline bitstream's behavior. Microsoft's encoder reference
distinguishes profile, rate control and optional quality/speed settings.
The original 720p comparison remains unresolved. An equal-content comparison must preserve actual bitrate, frame rate, latency and production codec settings, inspect the resulting bitstream and retain reference/decoded pictures. Raising the bitrate ceiling, lowering the default frame rate or changing profile is not justified by these logs alone; those changes have bandwidth, motion and receiver compatibility consequences.
Implementation Boundary
nativecaptureowns the child process, source identity, and bounded frame protocol.mediaedgeowns the stable Pion API, one UDP mux, shared encoded sources, and independent PeerConnections.nativehostowns the current capture generation and its bounded stable edges.nativeviewerowns one native inbound media source and its encoded child edges; it does not own room or route state.nativecontrolmaps local source/share/receive/edge commands and exact native sender quality windows, live profile updates, and source replacement to the current loopback wire.
The deleted sender application, UI, room client, and old wire are not compatibility inputs. Historical measurements remain in the separately marked native sender evidence.
Primary Sources
- Windows Graphics Capture
- WGC
MinUpdateInterval - Sunshine WGC update interval
- WGC
CreateForWindow - WASAPI process loopback
- OBS application-audio capture guide
- Media Foundation hardware MFTs
- MFT input sample ownership
- Chromium MFT frame-rate compensation
- Pion v4.2.18 stats implementation
- WebRTC Stats target bitrate and limitation semantics
- WebRTC remote-track constraints
- Pion single-port ICE
- Pion broadcast relay
- gopus pure-Go Opus codec
- Tailscale port mapper
- libp2p NAT port mapping
- NetBird standalone Go NAT
- WebRTC signaling and ICE
- Apple ScreenCaptureKit
- ScreenCaptureKit audio output
- ScreenCaptureKit idle frames
- Apple VideoToolbox hardware encoder requirement
- XDG ScreenCast Portal
- libportal
- PipeWire DMA-BUF contract
- GStreamer PipeWire source