Documentation
¶
Overview ¶
Package media provides bounded, transport-free media primitives shared by local system capture and playback implementations.
Index ¶
- Constants
- Variables
- func Annotate(frame Frame, boxes []Annotation, maxBytes, maxPixels int) ([]byte, error)
- func ContactSheet(frames []Frame, options ContactSheetOptions) ([]byte, error)
- func WAV(p PCM16, maxBytes int) ([]byte, error)
- type Annotation
- type ContactSheetOptions
- type Frame
- type FrameConsumer
- type FrameMetadata
- type FrameSource
- type FrameSourceFunc
- type PCM16
- type Recorder
- type Recording
- type RecordingOptions
- type Region
- type SampleManifest
- type SampleOptions
- type VideoDecoder
- type VideoFrame
- type VideoManifest
- type VideoOptions
Constants ¶
const ( // DefaultRecordingDuration bounds one caller-started recording. DefaultRecordingDuration = time.Minute // MaxRecordingDuration is the library ceiling for a recording. MaxRecordingDuration = time.Hour // DefaultRecordingBytes bounds a retained recording. DefaultRecordingBytes int64 = 128 << 20 // MaxRecordingBytes is the library ceiling for a recording. MaxRecordingBytes int64 = 1 << 30 )
Variables ¶
var ErrRecordingLimit = errors.New("recording limit exceeded")
ErrRecordingLimit reports that a recording hit its duration or byte bound.
Functions ¶
func Annotate ¶
func Annotate(frame Frame, boxes []Annotation, maxBytes, maxPixels int) ([]byte, error)
Annotate draws bounded element boxes without mutating the source frame.
func ContactSheet ¶
func ContactSheet(frames []Frame, options ContactSheetOptions) ([]byte, error)
ContactSheet creates a deterministic finite PNG. Labels and other presentation choices remain consumer concerns.
Types ¶
type Annotation ¶
type ContactSheetOptions ¶
type Frame ¶
Frame is one caller-owned encoded image with its local target identity and coordinate system. Capture implementations return bytes directly; network envelopes, storage IDs, and retention policy belong to consumers.
func Around ¶
func Around(ctx context.Context, source FrameSource, operation func(context.Context) error) (before, after Frame, err error)
Around captures before and after one caller-supplied local operation. It still returns post-operation evidence after an operation error when the context permits it; callers decide how to interpret dispatch uncertainty.
type FrameConsumer ¶
type FrameConsumer func(context.Context, Frame, FrameMetadata) error
FrameConsumer processes one retained frame. Persistence, references, and transport remain entirely outside this package.
type FrameMetadata ¶
type FrameMetadata struct {
Sequence int `json:"sequence"`
ObservedAt time.Time `json:"observed_at"`
Target string `json:"target"`
CoordinateSpace string `json:"coordinate_space"`
Width int `json:"width"`
Height int `json:"height"`
Bytes int `json:"bytes"`
SHA256 string `json:"sha256"`
ChangedFraction float64 `json:"changed_fraction"`
ChangedBounds *Region `json:"changed_bounds,omitempty"`
}
type FrameSource ¶
FrameSource captures from a target already selected by its caller.
type FrameSourceFunc ¶
type PCM16 ¶
PCM16 contains signed little-endian interleaved samples. Data is finite and caller-owned; PCM16 opens no capture device, player, file, or connection.
type Recorder ¶
type Recorder interface {
Record(context.Context, RecordingOptions) (Recording, error)
}
Recorder starts a recording from the desktop or surface its implementation owns. The caller supplies the bounds, output format, and lifetime.
type Recording ¶
type Recording interface {
io.ReadCloser
Stop(context.Context) error
}
Recording is a bounded, caller-owned stream of encoded output. Reading is transport-free; persistence, publishing, and retention belong to the caller. Stop ends the native recording and must be safe to call after an error.
type RecordingOptions ¶
type RecordingOptions struct {
Format string
FrameRate int
MaxDuration time.Duration
MaxBytes int64
}
RecordingOptions selects a caller-owned recording. Format names a container; the backend rejects a format it cannot produce rather than substituting one.
func (RecordingOptions) Normalize ¶
func (o RecordingOptions) Normalize() (RecordingOptions, error)
Normalize supplies defaults and rejects unsupported values.
type Region ¶
type SampleManifest ¶
type SampleManifest struct {
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
Sampled int `json:"sampled"`
Retained int `json:"retained"`
SampledBytes int64 `json:"sampled_bytes"`
Frames []FrameMetadata `json:"frames"`
Complete bool `json:"complete"`
StopReason string `json:"stop_reason"`
}
func Sample ¶
func Sample(ctx context.Context, source FrameSource, options SampleOptions, consume FrameConsumer) (manifest SampleManifest, err error)
Sample performs captures under explicit time, frame, pixel, and byte limits. Manifest metrics include samples discarded by change filtering.
type SampleOptions ¶
type SampleOptions struct {
MaxFrames int
MaxDuration time.Duration
Interval time.Duration
Heartbeat time.Duration
MaxFrameBytes int
MaxTotalBytes int64
MaxPixels int
MinChange float64
}
func (SampleOptions) Validate ¶
func (o SampleOptions) Validate() error
type VideoDecoder ¶
VideoDecoder borrows a caller-selected decoder and media resource. It does not open a path, fetch a URL, or launch a codec. FrameAt must apply its own decoding limits before returning a PNG frame.
type VideoFrame ¶
type VideoFrame struct {
OffsetMS int64 `json:"offset_ms"`
Metadata FrameMetadata `json:"metadata"`
}
type VideoManifest ¶
type VideoManifest struct {
Frames []VideoFrame `json:"frames"`
Bytes int64 `json:"bytes"`
Complete bool `json:"complete"`
}
func SampleVideo ¶
func SampleVideo(ctx context.Context, decoder VideoDecoder, options VideoOptions, consume FrameConsumer) (VideoManifest, error)
SampleVideo extracts caller-selected increasing timestamps exactly once.