cadence

package
v1.13.0 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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveSource

func DeriveSource(requestType string) string

DeriveSource buckets a requestType into "web" or "sdk", or "" if unknown.

func Dump

func Dump()

Dump writes the collected stats as JSON to AVSYNC_STATS_PATH (default /tmp/avsync-stats.json), intended for t.Cleanup at the end of TestEgress.

func IntegerLag

func IntegerLag(expected [][]string, actual []*Bucket) int64

IntegerLag returns the candidate lag (0..maxIntLag) that best aligns actual buckets to expected plan slots. Smallest lag wins ties.

func Record

func Record(s Stats)

Record appends a Stats row to the global slice. Safe for concurrent calls.

func Score

func Score(s Stats) float64

Score collapses Stats into a 0–100 score, rounded to 1 decimal.

Types

type Bucket

type Bucket struct {
	Beeps   map[string][]avsync.Beep
	Flashes map[string][]avsync.Flash
	Center  time.Duration
}

type Observation

type Observation struct {
	Buckets []*Bucket
	Offset  time.Duration
	// contains filtered or unexported fields
}

Observation bins detected beeps and flashes by integer second of recording PTS. Offset is the global median fractional offset; beepRefs/flashRefs are per-participant medians used by hasOutlier (so systematic cross-track/cross-participant offsets don't block stabilization — those are measured separately as av-sync).

func Quantize

func Quantize(result *avsync.Result) *Observation

Quantize bins beeps/flashes from the analyzer result into per-second Buckets centered on the median fractional PTS offset.

func (*Observation) TimeToStabilize

func (obs *Observation) TimeToStabilize() (int, time.Duration)

TimeToStabilize finds the first run of 3 consecutive non-empty non-outlier buckets and returns (bucketIndex, earliestPTS), or (-1, 0) if no such run exists. Empty buckets are skipped entirely: they don't count toward the run, but don't reset it either (so intentional silence in multi-participant recordings is tolerated).

type Stats

type Stats struct {
	// Identity
	IntegrationType string
	Test            string
	RequestType     string
	Source          string
	Output          string
	Format          string
	AudioCodec      string
	VideoCodec      string
	Layout          string
	AudioOnly       bool
	VideoOnly       bool
	Tracks          int

	// Sanity counters
	FlashCount int
	BeepCount  int

	// Stabilization
	Locked       bool
	TimeToStable time.Duration

	// Post-stable steady state
	AudioJitter  time.Duration
	VideoJitter  time.Duration
	StableAVSync time.Duration // signed; positive = video lags audio
	AVSyncStdDev time.Duration
	MaxAVSync    time.Duration

	// Composite
	Score float64
}

Stats is one row of metrics per output (file/stream/segments). Identity fields are set by the caller; Compute fills in the rest.

func Compute

func Compute(obs *Observation, audioOnly, videoOnly bool) Stats

Compute derives stats from the quantized Observation. audioOnly / videoOnly come from the recording's intended track set and shape the score (missing video isn't penalized in audio-only outputs).

Jump to

Keyboard shortcuts

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