media

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 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,
	0x20,
	0x00,
	0xF0,
	0x00,
	0xF0,
}

VP9BlackKeyframe is the minimum VP9 frame whose uncompressed header satisfies pion's github.com/pion/rtp/codecs/vp9.Header.Unmarshal success path so github.com/pion/rtp/codecs.VP9Payloader doesn't drop the sample. The 9 bytes encode:

  • frame_marker = 0b10 (required value 2)
  • profile = 0 (8-bit, no extra bits)
  • show_existing_frame = 0
  • frame_type = 0 (KEYFRAME)
  • show_frame = 1
  • error_resilient_mode = 0
  • sync_code = 0x49 0x83 0x42 (required by VP9 spec)
  • color_config: ColorSpace=1 (BT.601), ColorRange=0
  • frame_size: 16x16 (width_minus_1=15, height_minus_1=15)

The bytes after this header don't have to be valid VP9 bitstream — pion only parses the uncompressed header and forwards the rest as RTP payload data verbatim. SFUs that "keyframe-gate" forwarding also look only at the descriptor + uncompressed header to detect keyframes.

2026-05-27 — added when migrating the goloom tunnel from VP8 to VP9. Replaces VP8BlackKeyframe for transports where VP9 is negotiated.

View Source
var VP9InterframeHeader = []byte{0x86}

VP9InterframeHeader is the minimum byte sequence whose VP9 uncompressed header satisfies pion's github.com/pion/rtp/codecs/vp9.Header.Unmarshal success path with NonKeyFrame=1 — i.e. the frame is parsed as an inter-frame (P-frame). pion's github.com/pion/rtp/codecs.VP9Payloader then produces a 3-byte RTP descriptor (no Scalability Structure) instead of the 11-byte descriptor used for keyframes. This is the statistically realistic frame type for ~98% of a real video stream.

The single byte encodes:

  • frame_marker = 0b10 (required value 2, bits 7-6)
  • profile_low_bit = 0 (bit 5)
  • profile_high_bit = 0 (bit 4) — profile = 0
  • show_existing_frame = 0 (bit 3)
  • NonKeyFrame = 1 (bit 2) — INTER-FRAME
  • ShowFrame = 1 (bit 1)
  • ErrorResilientMode = 0 (bit 0)

Total binary: 0b10000110 = 0x86.

pion's Unmarshal exits successfully right after reading these 8 bits when NonKeyFrame=1 (it skips sync_code / color_config / frame_size which are only encoded for keyframes). So this single byte is enough for the packetizer to recognise an inter-frame and pass everything after it through as RTP payload.

2026-05-28 — added to fix the "100% keyframes" DPI fingerprint. Real WebRTC video sources emit ~1 keyframe every 60-90 frames; we now match that ratio by using VP9BlackKeyframe (9 bytes) for periodic keyframes and this 1-byte interframe header for all other data frames.

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