Skip to content

Fix Xiaomi CS2 audio payload writes - #2406

Draft
RuiFG wants to merge 1 commit into
AlexxIT:masterfrom
RuiFG:agent/fix-xiaomi-cs2-payload
Draft

Fix Xiaomi CS2 audio payload writes#2406
RuiFG wants to merge 1 commit into
AlexxIT:masterfrom
RuiFG:agent/fix-xiaomi-cs2-payload

Conversation

@RuiFG

@RuiFG RuiFG commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • copy the encrypted audio payload into Xiaomi CS2 media packets
  • add a regression test that verifies both the media header and payload on the wire

Root cause

WritePacket allocates space for hdrSize + len(payload), but the second copy used hdr again. As a result, the camera received encrypted media-header bytes followed by zero padding instead of the encrypted Opus payload, which produced extremely loud static during two-way audio.

User impact

This restores the speaker payload for Xiaomi cameras using the MISS/CS2 transport. The fix was verified end-to-end with xiaomi.camera.083ac1 on go2rtc 1.9.14 through Scrypted and HomeKit; two-way audio works after applying this change.

Fixes #2175.

Validation

  • go test ./pkg/xiaomi/miss/cs2
  • go test ./pkg/xiaomi/miss/...
  • go build -trimpath .
  • manual end-to-end test on xiaomi.camera.083ac1

go test ./... was also run on Windows; unrelated existing failures remain in FFmpeg expectations and platform/build-tag-dependent packages. The focused Xiaomi CS2 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xiaomi two-way audio not working, the camera side only outputs extremely loud noise

1 participant