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 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)
- func UI() *sdui.Module
- type Channel
- type Config
- type Driver
- type EncryptedError
- type Env
- type Field
- type Found
- type HelperCall
- type HelperDoc
- type HelperOpen
- 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 ModuleID = "wittytuner"
ModuleID is this module's ID, the same as module.json's.
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 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 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.
func UI ¶ added in v0.3.0
UI is WittyTuner's part of every app (module API 4, WittyMediaServer docs/SDUI-MODULES.md), written to sdui.json beside module.json. It is only the theme scope, on purpose:
- The live TV pages, the guide, recordings and the tuner settings are the server's own, so a page or menu entry here would only show them twice.
- The helper reads no settings of its own: everything about a tuner comes with each call, from the server's Channels & tuners settings.
- It answers no data source. A tuner isn't any kind of item a card shows, discovery takes seconds and keeps nothing, and the tuners it finds are for the admin adding one in the server's settings, not for every profile's pages.
The scope still names the module for the theme editor, so an admin can colour anything that later carries it.
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 HelperCall ¶ added in v0.2.0
type HelperCall struct {
Driver string `json:"driver,omitempty"`
Name string `json:"name,omitempty"`
Options map[string]string `json:"options,omitempty"`
Channel *Channel `json:"channel,omitempty"` // "open" and "recheck"
Source string `json:"source,omitempty"` // "scan": ScanOptions.Source
// What it can't find out for itself.
FFmpeg string `json:"ffmpeg,omitempty"`
AllowCommands bool `json:"allowCommands,omitempty"`
}
HelperCall is what a helper is asked: which tuner, since it keeps nothing, and what for.
type HelperDoc ¶ added in v0.2.0
type HelperDoc struct {
Progress *Progress `json:"progress,omitempty"`
Channels []Channel `json:"channels,omitempty"`
Info *Info `json:"info,omitempty"`
GuideHeaders http.Header `json:"guideHeaders,omitempty"`
Found []Found `json:"found,omitempty"`
Drivers []Driver `json:"drivers,omitempty"`
Why string `json:"why,omitempty"` // "recheck": why it's encrypted now
Next int64 `json:"next,omitempty"` // "recheck": seconds until it's worth asking again
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
Done bool `json:"done,omitempty"`
}
HelperDoc is one document of an answer. Progress may come any number of times; any other document ends the answer.
type HelperOpen ¶ added in v0.2.0
type HelperOpen struct {
Input []string `json:"input,omitempty"`
// Verified: it was inspected on opening and found clear. Recheck: it can change while it
// plays, so it's worth asking again.
Verified bool `json:"verified,omitempty"`
Recheck bool `json:"recheck,omitempty"`
}
HelperOpen is the answer to "open" for a stream FFmpeg should open by itself. The server holds what it asks for to its own rules before FFmpeg sees any of it.
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 |
|---|---|
|
cmd
|
|
|
wittytuner-module
command
Command wittytuner-module is WittyTuner as a helper process: the only way a server reaches it.
|
Command wittytuner-module is WittyTuner as a helper process: the only way a server reaches 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 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. |


