livefeed

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TranscodeToJPEG

func TranscodeToJPEG(data []byte, quality int) ([]byte, error)

TranscodeToJPEG converts raw image data to JPEG format. If the input is already JPEG, it validates and returns as-is.

func ValidateJPEG

func ValidateJPEG(data []byte) error

ValidateJPEG validates that the data is a complete JPEG image.

Types

type Frame

type Frame struct {
	Timestamp   time.Time         `json:"timestamp"`
	Data        []byte            `json:"data"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	FrameNumber int64             `json:"frame_number"`
	Format      FrameFormat       `json:"format,omitempty"`
}

func CaptureScreenshot

func CaptureScreenshot(captureFn func() ([]byte, error), quality int) (Frame, error)

CaptureScreenshot captures a screenshot with format validation. If JPEG validation fails, it delegates to ParseFrame for repair/transcoding.

func ParseFrame

func ParseFrame(data []byte, frameNum int64, quality int) (Frame, error)

ParseFrame validates and processes frame data, returning a properly formatted frame. It validates the format and transcodes to JPEG if necessary.

type FrameFormat

type FrameFormat string

FrameFormat represents the detected format of a frame.

const (
	FormatJPEG    FrameFormat = "jpeg"
	FormatRAW     FrameFormat = "raw"
	FormatUnknown FrameFormat = "unknown"
)

func DetectFrameFormat

func DetectFrameFormat(data []byte) FrameFormat

DetectFrameFormat detects the format of frame data using magic bytes.

type FrameGetter

type FrameGetter interface {
	GetFrame(timeout time.Duration) (Frame, error)
}

type Stats

type Stats struct {
	FramesReceived atomic.Int64
	FramesDropped  atomic.Int64
	BytesReceived  atomic.Int64
	// contains filtered or unexported fields
}

func (*Stats) FPS

func (s *Stats) FPS() float64

func (*Stats) Snapshot

func (s *Stats) Snapshot(bufferLen int, connected bool) map[string]any

Jump to

Keyboard shortcuts

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