source

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package source turns a user-supplied URL (YouTube Live or direct HLS) into a stream of packed RGB24 frames, sized for the half-block terminal renderer in internal/ascii. It is the URL counterpart to internal/calls, which ingests LiveKit tracks: same RGB24 frame contract, different front end.

A YouTube URL is resolved to a playable stream with `yt-dlp -g`; a direct .m3u8 is used as-is. The resolved URL is then decoded by ffmpeg into raw rgb24 frames. Every URL — the one the user typed and the one yt-dlp returns — is run through an SSRF guard (guardURL) before any connection is made.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind string

Kind classifies a source URL.

const (
	KindYouTube Kind = "youtube"
	KindHLS     Kind = "hls"
)

func Classify

func Classify(raw string) (Kind, error)

Classify decides how a raw URL is handled, and rejects anything that is not http(s). It does not touch the network.

func (Kind) String

func (k Kind) String() string

type Options

type Options struct {
	URL      string
	FPS      int
	PW, PH   int
	AllowHLS bool // permit direct .m3u8 / http(s) inputs (not just YouTube)
}

Options configures a worker. PW/PH are the pixel dimensions the decoder scales to — compute them with ascii.FitEven(cols, rows).

type Worker

type Worker struct {
	Frames chan []byte // each frame is PW*PH*3 bytes
	Status chan string // human-readable status, best-effort (non-blocking)
	Kind   Kind        // resolved source kind
	// contains filtered or unexported fields
}

Worker is one running decode pipeline: ffmpeg reading the resolved stream and emitting RGB24 frames on Frames. Mirrors internal/calls.session so the Phase 1 fan-out multiplexer can drive either source identically.

func Start

func Start(ctx context.Context, opts Options) (*Worker, error)

Start resolves the source and launches the ffmpeg decode pipeline. The returned Worker emits frames until the stream ends or Close is called.

func (*Worker) Close

func (w *Worker) Close()

Close tears down ffmpeg and stops the pump.

Jump to

Keyboard shortcuts

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