tuner

package
v0.0.0-...-2e79410 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tuner implements an ATSC tuner that outputs WebRTC video and audio tracks.

Index

Constants

This section is empty.

Variables

View Source
var (
	// VideoCodecCapability represents the RTP codec settings for the video signal
	// produced by the tuner.
	VideoCodecCapability = webrtc.RTPCodecCapability{
		MimeType:    webrtc.MimeTypeH264,
		ClockRate:   90_000,
		SDPFmtpLine: videoCodecFMTP,
	}

	// AudioCodecCapability represents the RTP codec settings for the audio signal
	// produced by the tuner.
	AudioCodecCapability = webrtc.RTPCodecCapability{
		MimeType:  webrtc.MimeTypeOpus,
		ClockRate: 48_000,
		Channels:  2,
	}
)
View Source
var ErrChannelNotFound error = errors.New("channel not found")

ErrChannelNotFound is returned when tuning to a channel whose name is not in the tuner's channel list.

Functions

This section is empty.

Types

type State

type State int

State represents the current state of the tuner.

const (
	// StateStopped means the tuner is switched off.
	StateStopped State = iota
	// StateStarting means that the tuner is trying to lock onto a signal and
	// start streaming.
	StateStarting
	// StatePlaying means that the tuner is locked onto a singal and is actively
	// streaming video.
	StatePlaying
)

type Status

type Status struct {
	State       State
	ChannelName string
	Error       error
}

Status represents the public state of the tuner for reading by clients.

type Tracks

type Tracks struct {
	Video webrtc.TrackLocal
	Audio webrtc.TrackLocal
}

Tracks represents the current set of video and audio tracks for use by WebRTC clients.

type Tuner

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

Tuner represents an ATSC tuner whose video and audio signals are encoded for use by WebRTC clients, and whose consumers are notified of ongoing state changes.

func NewTuner

func NewTuner(channels []atsc.Channel, videoPipeline VideoPipeline) *Tuner

NewTuner creates a new Tuner that can tune to any of the provided channels.

func (*Tuner) ChannelNames

func (t *Tuner) ChannelNames() []string

ChannelNames returns the names of channels that are known to this tuner and may be passed to Tune.

func (*Tuner) Stop

func (t *Tuner) Stop() error

Stop ends any active stream and releases the DVB device associated with this tuner.

func (*Tuner) Tune

func (t *Tuner) Tune(channelName string) (err error)

Tune attempts to start a stream for the named channel.

func (*Tuner) WatchStatus

func (t *Tuner) WatchStatus(handler func(Status)) watch.Watch

WatchStatus sets up a handler function to continuously receive the status of the tuner as it is updated. See the watch package documentation for details.

func (*Tuner) WatchTracks

func (t *Tuner) WatchTracks(handler func(Tracks)) watch.Watch

WatchTracks sets up a handler function to continuously receive the tuner's WebRTC tracks as they are updated. See the watch package documentation for details.

type VideoPipeline

type VideoPipeline string

VideoPipeline controls which pipeline Hypcast uses to process video.

const (
	// VideoPipelineDefault performs software-based video processing. It should
	// work on a wide variety of machines with little to no additional
	// configuration.
	VideoPipelineDefault VideoPipeline = "default"

	// VideoPipelineLowPower performs software-based video processing with limits
	// on bitrate, frame rate, and video size. This creates a smoother viewing
	// experience on servers with limited CPU power, but produces very
	// low-quality output.
	VideoPipelineLowPower VideoPipeline = "lowpower"

	// VideoPipelineVAAPI performs hardware accelerated video processing using
	// the Video Acceleration API (VA-API). It is more performant than the
	// default pipeline, but requires installation of gstreamer-vaapi plugins and
	// may require additional configuration to select an appropriate device and
	// driver. See GStreamer documentation for details.
	VideoPipelineVAAPI VideoPipeline = "vaapi"
)

func ParseVideoPipeline

func ParseVideoPipeline(name string) VideoPipeline

ParseVideoPipeline selects a VideoPipeline by name. Unknown names will return the default pipeline.

Jump to

Keyboard shortcuts

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