testsrc

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 5 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 testsrc provides deterministic synthetic capture sources for tests and for the engine's fake devices: a moving test pattern with a frame counter drawn into the picture, and a sine tone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pattern

func Pattern(w, h int, n uint32) *capture.Frame

Pattern renders frame n of the test sequence: a diagonal colour gradient that scrolls, a bouncing box and, in the top-left, the 16-bit frame counter as black/white blocks.

func ReadCounter

func ReadCounter(img *image.YCbCr) (counter uint16, ok bool)

ReadCounter reads the frame counter drawn by Pattern from a luma plane of any size. ok is false when the blocks are not clearly black or white (a damaged or non-pattern picture).

func ToneLevel

func ToneLevel(pcm []int16, channels, rate int, hz float64) float64

ToneLevel returns the share (0..1) of the signal's energy at hz, measured with a Goertzel filter on mono PCM, used by tests to check that the tone arrived.

Types

type Audio

type Audio struct {
	Rate     int
	Channels int
	Hz       float64
	Amp      float64 // 0..1
	Chunk    time.Duration

	Label string
	// contains filtered or unexported fields
}

Audio is a capture.AudioSource producing a sine tone in real time.

func NewTone

func NewTone(hz float64) *Audio

NewTone returns a mono 48 kHz sine tone source.

func (*Audio) Err

func (a *Audio) Err() error

func (*Audio) Info

func (a *Audio) Info() capture.DeviceInfo

func (*Audio) Start

func (a *Audio) Start(c capture.AudioConstraints) (<-chan *capture.AudioChunk, error)

func (*Audio) Stop

func (a *Audio) Stop() error

type Video

type Video struct {
	W, H int
	FPS  float64
	// Keep stores the last N frames by counter (for PSNR comparisons in tests); 0 keeps none.
	Keep int

	Label string
	// contains filtered or unexported fields
}

Video is a capture.VideoSource producing a moving pattern at a fixed rate.

func NewVideo

func NewVideo(w, h int, fps float64) *Video

NewVideo returns a source of w x h frames at fps.

func (*Video) Err

func (v *Video) Err() error

func (*Video) Frames

func (v *Video) Frames() uint32

Frames returns how many frames have been produced.

func (*Video) Info

func (v *Video) Info() capture.DeviceInfo

func (*Video) Kept

func (v *Video) Kept(counter uint16) *capture.Frame

Kept returns the stored frame with a counter value, if still kept.

func (*Video) Start

func (v *Video) Start(c capture.VideoConstraints) (<-chan *capture.Frame, error)

func (*Video) Stop

func (v *Video) Stop() error

Jump to

Keyboard shortcuts

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