media

package module
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package media receives source-element media on the source host and exposes bounded encoded packets for an embedding host's authenticated byte streams.

Index

Constants

View Source
const (
	WireVersion      = 1
	MaxHeaderBytes   = 16 * 1024
	MaxPacketBytes   = 2 * 1024 * 1024
	StreamChunkBytes = 16 * 1024
)

Variables

View Source
var ErrClosed = errors.New("media subscription closed")
View Source
var ErrInvalidPacket = errors.New("invalid media packet")
View Source
var ErrKeyframeRequired = errors.New("media video reference expired")

Functions

func WritePacket

func WritePacket(w io.Writer, p Packet) error

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

func NewCollector

func NewCollector(scope Scope, onTrack func(*Track)) (*Collector, error)

NewCollector binds a fresh source-host loopback socket. ICE-lite prevents outgoing checks to source-supplied candidates. It is never a remote carrier.

func (*Collector) Answer

func (c *Collector) Answer(ctx context.Context, offer string) (string, error)

func (*Collector) Close

func (c *Collector) Close() error

func (*Collector) RequestKeyframe

func (c *Collector) RequestKeyframe()
type Header struct {
	Version     int    `json:"version"`
	Target      string `json:"target"`
	View        string `json:"view"`
	Stream      string `json:"stream"`
	Node        int64  `json:"node"`
	Track       string `json:"track"`
	Codec       string `json:"codec"`
	TimestampUS int64  `json:"timestamp_us"`
	DurationUS  int64  `json:"duration_us"`
	Keyframe    bool   `json:"keyframe"`
	Width       int    `json:"width,omitempty"`
	Height      int    `json:"height,omitempty"`
	Description string `json:"description,omitempty"`
	Bytes       int    `json:"bytes"`
}

Header carries presentation identity, never credentials or source addresses. TimestampUS is relative to the source subscription's monotonic clock.

func (Header) Validate

func (h Header) Validate() error

type Packet

type Packet struct {
	Header Header
	Data   []byte
}

func ReadPacket

func ReadPacket(r io.Reader) (Packet, error)

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue belongs to one encoded track. A lost video reference invalidates all queued dependent frames. Canvas and audio have independent packet boundaries.

func NewQueue

func NewQueue(limits QueueLimits) *Queue

func (*Queue) Close

func (q *Queue) Close()

func (*Queue) Invalidate

func (q *Queue) Invalidate()

Invalidate discards dependent video frames after local capture packet loss.

func (*Queue) Next

func (q *Queue) Next(ctx context.Context) (Packet, error)

func (*Queue) Push

func (q *Queue) Push(p Packet) bool

Push takes ownership of packet.Data and never blocks source collection. A true result requests a fresh keyframe; the caller must not repeat input.

type QueueLimits

type QueueLimits struct {
	Packets, Bytes int
	Age            time.Duration
}

type Scope

type Scope struct {
	Target string `json:"target"`
	View   string `json:"view"`
	Stream string `json:"stream"`
	Node   int64  `json:"node"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

type Track

type Track struct {
	Kind, Codec string
	// contains filtered or unexported fields
}

Track is one encoded track. Its queue never waits for a remote consumer.

func (*Track) Next

func (t *Track) Next(ctx context.Context) (Packet, error)

func (*Track) RequestKeyframe

func (t *Track) RequestKeyframe()

Directories

Path Synopsis
cmd
floebrowser-media command
floebrowser-media is a local source helper.
floebrowser-media is a local source helper.

Jump to

Keyboard shortcuts

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