Documentation
¶
Overview ¶
Package wittytuner is a common way to reach TV tuners and IPTV: network tuners, M3U playlists and single streams, Linux DVB, V4L2 capture, Windows and macOS capture devices, SAT>IP, external backends over open protocols and a custom command.
A driver lists channels and opens one as either raw MPEG-TS or FFmpeg input options. Encrypted and copy-protected channels are detected and refused: nothing here decrypts or bypasses anything.
Index ¶
- Constants
- Variables
- func ArchiveURL(ch Channel, now time.Time) (string, error)
- func HelperLog() *slog.Logger
- func IsEncrypted(err error) bool
- func LocalPlaylist(place string) bool
- func ParseAVFDevices(out string) (video, audio []string)
- func ParseDShowDevices(out string) (video, audio []string)
- func RefusalMessage(name string, err error) error
- func SecretFields(driver string) []string
- func SplitCommand(s string) ([]string, error)
- type Channel
- type Config
- type Driver
- type EncryptedError
- type Env
- type Field
- type Found
- type Info
- type M3U
- type M3UEntry
- type Progress
- type ScanOptions
- type Source
- type Stream
- type Tuning
Constants ¶
const ( EncryptedLabel = "Encrypted: can't be played here" // EncryptedExplain is the same in one line, for lists. EncryptedExplain = encryptedBecause + ". " + encryptedPolicy )
What every client shows for an encrypted channel, so that nobody takes it for a fault in their setup.
const ScrambledReason = "the signal itself is scrambled"
ScrambledReason says why a stream stopped by the guard was refused.
Variables ¶
var ErrBusy = errors.New("all of this device's tuners are in use")
ErrBusy: every tuner of the source is in use.
var IntegrationJSON []byte
IntegrationJSON is what this module adds to the server (module API 5: docs/MODULES-API5.md in WittyMediaServer, "integration.json").
var ManifestJSON []byte
ManifestJSON is this module's manifest (docs/MODULES.md, "The manifest").
Functions ¶
func ArchiveURL ¶ added in v0.3.0
ArchiveURL is the address of what a channel showed from ArchiveStart to ArchiveEnd, built the way its source says. It refuses a channel with no catch-up, and a time the source no longer keeps or hasn't shown yet.
func HelperLog ¶ added in v0.4.0
HelperLog is the log of WittyTuner's service: stderr, which the server reads line by line, in the Live TV area and at the level the server asks for.
func IsEncrypted ¶
IsEncrypted reports whether err means a channel was refused for encryption.
func LocalPlaylist ¶ added in v0.2.0
LocalPlaylist says a playlist's place is on the owner's own network: a file, an address at home or on a private network, or a name only a local network can resolve. A name anyone can register can point anywhere, so it doesn't count, whatever it resolves to now. The owner typed this address, so a playlist from elsewhere can't choose it.
func ParseAVFDevices ¶
ParseAVFDevices reads the output of ffmpeg -f avfoundation -list_devices true.
func ParseDShowDevices ¶
ParseDShowDevices reads the output of ffmpeg -list_devices true -f dshow.
func RefusalMessage ¶
RefusalMessage turns a stream that a guard stopped into words for a person.
func SecretFields ¶
SecretFields lists settings a driver treats as passwords, never sent back to a browser.
func SplitCommand ¶
SplitCommand splits a line into arguments, with single and double quotes and nothing else special.
Types ¶
type Channel ¶
type Channel struct {
ID string `json:"id"` // stable within the source
Number string `json:"number"`
Name string `json:"name"`
Group string `json:"group,omitempty"`
CallSign string `json:"callsign,omitempty"`
Locator string `json:"locator,omitempty"` // how the driver finds it again
Logo string `json:"logo,omitempty"` // an address given by the source
EPGID string `json:"epgId,omitempty"` // XMLTV channel id
HD bool `json:"hd,omitempty"`
Radio bool `json:"radio,omitempty"`
Program int `json:"program,omitempty"` // MPEG program number
// Encrypted is why this channel cannot be tuned ("" = it can).
Encrypted string `json:"encrypted,omitempty"`
// Checked: the source says for itself whether this channel is protected,
// so no Encrypted reason means it is clear. Otherwise nobody knows until
// the channel is first tuned.
Checked bool `json:"checked,omitempty"`
// ATSC3: an ATSC 3.0 (NextGen TV) broadcast.
ATSC3 bool `json:"atsc3,omitempty"`
VideoCodec string `json:"videoCodec,omitempty"` // as the source names it: HEVC, MPEG2…
AudioCodec string `json:"audioCodec,omitempty"` // AC4, AC3…
// NoRecord is why the device says this channel may not be recorded.
NoRecord string `json:"noRecord,omitempty"`
// Catch-up: the source keeps what it showed for CatchupDays, and Catchup says how
// to ask for it (default, append, shift, flussonic or xc). CatchupSource is the
// source's own template for the address, which can hold a login as Locator can.
CatchupDays int `json:"catchupDays,omitempty"`
Catchup string `json:"catchup,omitempty"`
CatchupSource string `json:"catchupSource,omitempty"`
// ArchiveStart and ArchiveEnd (Unix seconds) are set by the host, and only to ask
// Open for what the channel showed then instead of what it shows now.
ArchiveStart int64 `json:"archiveStart,omitempty"`
ArchiveEnd int64 `json:"archiveEnd,omitempty"`
}
Channel is one channel a source offers.
func ParseChannelsConf ¶
ParseChannelsConf reads a file from dvbv5-scan (the [name] / key = value format) or the older colon-separated zap format. Encrypted entries are kept, marked, so people can see why they do not play.
type Driver ¶
type Driver struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
// Status is how well this has been tested: "tested", "mock" (against mock
// servers, no real device) or "untested".
Status string `json:"status"`
// Platforms it can run on; empty = all.
Platforms []string `json:"platforms,omitempty"`
Fields []Field `json:"fields"`
Scans bool `json:"scans"` // Scan does more than list what is known
// Planned drivers are listed so people can see they are known about.
Planned bool `json:"planned,omitempty"`
// Available is worked out for this machine.
Available bool `json:"available"`
Note string `json:"note,omitempty"`
// contains filtered or unexported fields
}
Driver describes one kind of tuner.
type EncryptedError ¶
EncryptedError says a channel was refused because it is encrypted or copy protected. It is never decrypted.
func (*EncryptedError) Error ¶
func (e *EncryptedError) Error() string
type Env ¶
type Env struct {
HTTP *http.Client // for short requests
// Stream is for long-lived streams: it must have no overall timeout.
Stream *http.Client
FFmpeg string
// Command prepares a process (the host hides console windows and so on).
Command func(ctx context.Context, name string, args ...string) *exec.Cmd
// AllowCommands: the owner has allowed the custom command driver.
AllowCommands bool
// Log is where drivers say what went wrong; nil says nothing. Records are
// written with the context the host passed in, so its session comes along.
Log *slog.Logger
// contains filtered or unexported fields
}
Env is what a driver gets from its host.
type Field ¶
type Field struct {
Key string `json:"key"`
Label string `json:"label"`
Kind string `json:"kind"` // text | url | path | password | select | number | textarea | toggle
Help string `json:"help,omitempty"`
Default string `json:"default,omitempty"`
Required bool `json:"required,omitempty"`
Options []string `json:"options,omitempty"`
}
Field describes one setting of a driver; forms are drawn from these.
type Found ¶
type Found struct {
Driver string `json:"driver"`
Name string `json:"name"`
Detail string `json:"detail,omitempty"`
Options map[string]string `json:"options"`
}
Found is a tuner discovered on this network or machine, ready to add.
func Discover ¶
Discover looks for tuners: on the local network and among this machine's devices. It takes a couple of seconds.
func DiscoverHere ¶ added in v0.2.0
DiscoverHere is the part of Discover that looks at this machine's own devices.
type Info ¶
type Info struct {
Driver string
Name string
MaxStreams int // how many channels it can stream at once; 0 = no known limit
Detail string // model, address: shown in Settings
GuideURL string // an XMLTV address the source offers
}
Info describes a configured source.
type Progress ¶
type Progress struct {
Percent int `json:"percent"`
Found int `json:"found"`
Message string `json:"message,omitempty"`
}
Progress is how far a scan has got.
type ScanOptions ¶
type ScanOptions struct {
Source string // Antenna | Cable: for tuners that ask
}
ScanOptions tune a scan.
type Source ¶
type Source interface {
Info() Info
// Channels is what the source knows now, without tuning anything.
Channels(ctx context.Context) ([]Channel, error)
// Scan looks for channels. It may take minutes, and is cancelled by ctx.
Scan(ctx context.Context, o ScanOptions, progress func(Progress)) ([]Channel, error)
// Open starts a channel. ErrBusy when no tuner is free, *EncryptedError
// when the channel is encrypted.
Open(ctx context.Context, ch Channel) (*Stream, error)
Close() error
}
Source is one configured tuner.
type Stream ¶
type Stream struct {
Reader io.ReadCloser
Input []string
// Guard watches a Reader for scrambling and collects guide data. Set
// OnEvent on it before reading to receive that data.
Guard *mpegts.Guard
// Verified: an Input stream was inspected on opening and found clear.
Verified bool
// Recheck looks again at an Input stream that can change while it plays. It says
// why the stream is now encrypted, or "", and how long until it's worth asking again.
// An error is a failure to find out, which says nothing about the stream.
Recheck func(ctx context.Context) (why string, next time.Duration, err error)
}
Stream is an open channel: Reader for raw MPEG-TS, else Input for FFmpeg.
type Tuning ¶
type Tuning struct {
System string
Frequency int64
Bandwidth int // Hz
SymbolRate int
Pol string
Modulation string
}
Tuning is what a channel needs to be found again. Frequency is in Hz; for satellite, kHz as broadcasters publish it.
func ParseLocator ¶
ParseLocator reads a kept tuning back.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api is WittyTuner's own HTTP API (module API 5): the routes WittyMediaServer passes to it at /api/modules/wittytuner/...
|
Package api is WittyTuner's own HTTP API (module API 5): the routes WittyMediaServer passes to it at /api/modules/wittytuner/... |
|
cmd
|
|
|
wittytuner-module
command
Command wittytuner-module is WittyTuner as a service (module API 5), which the server starts by itself: its own routes (Settings, Live TV & tuners, the first-run step), its SDUI pages' sources, the guide sources it fetches on a schedule, and the channels the server's live TV, recordings and catch-up open through it.
|
Command wittytuner-module is WittyTuner as a service (module API 5), which the server starts by itself: its own routes (Settings, Live TV & tuners, the first-run step), its SDUI pages' sources, the guide sources it fetches on a schedule, and the channels the server's live TV, recordings and catch-up open through it. |
|
Package mpegts reads the parts of an MPEG transport stream a TV tuner needs: the scrambling bits, what the stream says it carries (PAT, PMT, SDT, ATSC VCT) and the programme guide inside it (DVB EIT, ATSC PSIP).
|
Package mpegts reads the parts of an MPEG transport stream a TV tuner needs: the scrambling bits, what the stream says it carries (PAT, PMT, SDT, ATSC VCT) and the programme guide inside it (DVB EIT, ATSC PSIP). |
|
Package store is WittyTuner's own database (module API 5): a SQLite file in the module's own folder (WITTYMODULE_DATA), with migrations WittyTuner owns.
|
Package store is WittyTuner's own database (module API 5): a SQLite file in the module's own folder (WITTYMODULE_DATA), with migrations WittyTuner owns. |
|
Package ui is WittyTuner's server-driven UI (module API 5; WittyMediaServer docs/SDUI-MODULES.md): the tuner pages every app draws, the Apple TV and Android TV apps among them, which have no web view for the module's web part.
|
Package ui is WittyTuner's server-driven UI (module API 5; WittyMediaServer docs/SDUI-MODULES.md): the tuner pages every app draws, the Apple TV and Android TV apps among them, which have no web view for the module's web part. |
|
Package xmltv reads XMLTV guide files as they stream by, so a very large guide needs very little memory.
|
Package xmltv reads XMLTV guide files as they stream by, so a very large guide needs very little memory. |


