media

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package media holds tiny hardcoded payloads used as send-side filler so the SFU sees periodic RTP and doesn't tear down our publisher PC for inactivity.

These are NOT meant to decode to anything sensible. The SFU forwards bytes verbatim and other peers' decoders may complain — that's fine for PoC #1, where the only success criterion is that goloom keeps the connection alive.

Index

Constants

This section is empty.

Variables

View Source
var OpusSilence = []byte{0xf8, 0xff, 0xfe}

OpusSilence is a single 20 ms Opus packet with the SILK NB mode TOC byte (0xf8 = config 31, mono, code 0) followed by a one-byte filler payload. Decoders interpret this as a frame of silence.

View Source
var VP8BlackKeyframe = []byte{
	0x10, 0x02, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00, 0x10, 0x00,
	0x00, 0x47, 0x08, 0x85, 0x85, 0x88, 0x85, 0x84, 0x88, 0x02,
	0x02, 0x00, 0x0c, 0x0d, 0x60, 0x00, 0xfe, 0xfc, 0x5c, 0xd0,
}

VP8BlackKeyframe is a minimal valid VP8 I-frame for a 16×16 black image, pre-encoded by libvpx with default settings. We push it down our publisher video track during warmup so the SFU sees a "real" keyframe and starts forwarding subsequent packets to other subscribers. Without this, our tunnel frames (which look like inter-frames to a VP8 parser because payload byte 0 happens to have key_frame=1 set in RFC 6386's inverted convention) are dropped by goloom's keyframe-gated forwarder.

Source: equivalent to `ffmpeg -f lavfi -i color=black:s=16x16:r=1 -t 1 -c:v vp8 out.ivf` then extracting the first frame's payload (byte range after the 32-byte IVF file header + 12-byte IVF frame header).

View Source
var VP8Stub = make([]byte, 64)

VP8Stub is a placeholder payload sent in the video track at low frame rate solely to keep the publisher transceiver "active" from the SFU's liveness perspective. It is NOT a valid VP8 keyframe — downstream decoders will drop it. PoC #1 only needs the SFU to keep the connection open; once we move to PoC #2 (real media tunneling) this gets replaced by a proper encoder pipeline.

View Source
var VP9BlackKeyframe = []byte{
	0x82, 0x49, 0x83, 0x42, 0x00, 0x0f, 0xf0, 0x08,
	0xf6, 0x00, 0x38, 0x24, 0x1c, 0x18, 0x42, 0x00,
	0x00, 0x50, 0x61, 0xf6, 0x30, 0x00, 0x00, 0x67,
	0x1b, 0x14, 0xcd, 0x27, 0x77, 0x16, 0x8b, 0x16,
	0xd8, 0x69, 0x65, 0x00,
}

VP9BlackKeyframe is a REAL, fully decodable VP9 keyframe (256x144 solid black), produced by libvpx-vp9 (`ffmpeg -f lavfi -i color=black:s=256x144 -c:v libvpx-vp9`). It is NOT a hand-crafted header stub — libvpx decodes it to an actual black frame, so `framesDecoded` increments for any subscriber (browser / SFU) that decodes our published track.

WHY THIS MATTERS (2026-07-23): the previous value was a 9-byte uncompressed- header stub with no compressed coefficient data. pion's VP9 packetizer parsed it, so packets flowed — but any real decoder rejects it ("Corrupt frame detected"), so framesDecoded stayed 0 forever. Telemost's SFU forwards our undecodable publisher on faith for a ~60 s grace period, then stops forwarding it (the "SFU detects our frames are garbage" cutoff). Emitting a genuinely decodable keyframe removes that signal. Verified against the exact decoder browsers use (libvpx-vp9): a bare keyframe decodes 1 frame / 0 errors.

This value is written two ways:

  • BARE, as a periodic keyframe-refresh / PLI response / handshake priming sample (session.RunKeyframeRefresh, SendInitialKeyframes, MakeKeyframePusher). A bare real keyframe decodes standalone.
  • As the leading frame of a VP9 SUPERFRAME that also carries hidden tunnel data (tunnel.Sender.wrapPayload). The superframe index declares ONLY this 36-byte frame, so the decoder decodes the black keyframe and ignores the WireGuard bytes packed after it. See tunnel.superframeHide.

The receiver (tunnel.Receiver.walkFrames) strips exactly len(VP9BlackKeyframe) bytes off the front of a keyframe sample before reading tunnel frames, so the length here is load-bearing on BOTH ends — keep sender and receiver builds in lockstep when changing it.

2026-05-27 introduced (as a 9-byte stub) during the VP8→VP9 migration. 2026-07-23 replaced with this real decodable frame to defeat the SFU's undecodable-stream cutoff.

View Source
var VP9InterframeHeader = []byte{
	0x86, 0x00, 0x40, 0x92, 0x9c, 0x00, 0x49, 0x40,
	0x00, 0x03, 0x20, 0x00, 0x00, 0x5a, 0x33, 0xb7,
	0x57, 0x0a, 0x40,
}

VP9InterframeHeader is a REAL, fully decodable VP9 inter-frame (P-frame, 256x144 solid black) produced by libvpx-vp9 in the same encode as VP9BlackKeyframe (it references that keyframe's reconstructed buffers). It is NOT a 1-byte header stub — libvpx decodes it to a black frame, provided a keyframe was decoded first, which our stream guarantees (periodic VP9BlackKeyframe refreshes + SendInitialKeyframes at startup).

Verified against libvpx-vp9 (the browser decoder): a stream of 1 keyframe followed by 59 of these interframes — each carrying different hidden tunnel data via a superframe index — decodes 60/60 frames with 0 errors, and 3 back-to-back GOPs decode 180/180 with no drift.

It is used as [tunnel.Sender.InterframePrefix]: ~98% of data samples lead with this frame (only every KeyframePeriod-th sample uses the keyframe), so the published stream keeps a realistic ~1.6% keyframe ratio while every frame remains decodable. As with the keyframe, the tunnel data is hidden after this frame inside a VP9 superframe whose index declares only these 19 bytes (see tunnel.superframeHide); the decoder decodes the black P-frame and ignores the WireGuard bytes.

The receiver strips exactly len(VP9InterframeHeader) bytes off the front of an interframe sample, so the length is load-bearing on both ends.

2026-05-28 introduced (as the 1-byte 0x86 header) for the keyframe-ratio fix. 2026-07-23 replaced with this real decodable inter-frame to defeat the SFU's undecodable-stream cutoff (the header stub decoded to nothing).

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL