Documentation
¶
Overview ¶
Package hdhomerun enables interacting with SiliconDust HDHomeRun devices.
Index ¶
- Constants
- func IsNotExist(err error) bool
- func ParseDeviceID(id string) ([]byte, error)
- type CableCARDStatus
- type Client
- func (c *Client) Close() error
- func (c *Client) Execute(req *Packet) (*Packet, error)
- func (c *Client) ForEachTuner(fn func(t *Tuner) error) error
- func (c *Client) Model() (string, error)
- func (c *Client) Query(query string) ([]byte, error)
- func (c *Client) SetTimeout(d time.Duration)
- func (c *Client) Tuner(n int) *Tuner
- type DeviceStatus
- type DeviceType
- type DiscoveredDevice
- type Discoverer
- type DiscovererOption
- type Error
- type NetworkStatus
- type Packet
- type StopReason
- type Tag
- type TransportStreamStatus
- type Tuner
- type TunerDebug
- type TunerStatus
Examples ¶
Constants ¶
const ( DeviceTypeTuner = DeviceType(libhdhomerun.DeviceTypeTuner) DeviceTypeStorage = DeviceType(libhdhomerun.DeviceTypeStorage) // DeviceTypeWildcard is used during discovery to request that all // types of devices reply to the request. DeviceTypeWildcard = DeviceType(libhdhomerun.DeviceTypeWildcard) )
Possible DeviceType values.
const DeviceIDWildcard = "ffffffff" // libhdhomerun.DeviceIdWildcard
DeviceIDWildcard is used during discovery to request that a device with any ID reply to the request.
Variables ¶
This section is empty.
Functions ¶
func IsNotExist ¶
IsNotExist determines if an error occurred during Client.Query because the specified key does not exist.
func ParseDeviceID ¶
ParseDeviceID parses an eight character hexadecimal string into its byte representation for transmission in a Packet.
Types ¶
type CableCARDStatus ¶
CableCARDStatus is the status of a CableCARD, if one is present in the device.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is an HDHomeRun client. It can be used to perform various operations on HDHomeRun devices. Clients are safe for concurrent use.
func Dial ¶
Dial dials a TCP connection to an HDHomeRun device.
For more control over the Client, use a net.Conn with NewClient instead.
func (*Client) Execute ¶
Execute sends a single request to an HDHomeRun device, and reads a single reply from the device.
Execute is a low-level method that does no request validation, and should be used with great caution.
Most users should use the Query method instead.
func (*Client) ForEachTuner ¶
ForEachTuner invokes the input function for each tuner available to an HDHomeRun device. Iteration stops when no more tuners are available.
func (*Client) Query ¶
Query performs a read-only query to retrieve information from an HDHomeRun device. A list of possible query values can be found by sending "help" as the query parameter.
If the query tries to read a key that does not exist, IsNotExist can be used to check this error.
func (*Client) SetTimeout ¶
SetTimeout sets a per-request timeout for a combined write and read interaction with an HDHomeRun device. For finer control, use a pre-configured net.Conn with NewClient.
SetTimeout will override any deadlines configured on a net.Conn used with NewClient.
type DeviceStatus ¶
DeviceStatus is the status of the tuner while processing a stream.
type DeviceType ¶
type DeviceType uint32
A DeviceType is a constant indicating the type of an HDHomeRun device, such as a tuner or storage unit.
func (DeviceType) String ¶
func (t DeviceType) String() string
String returns the string representation of a DeviceType.
type DiscoveredDevice ¶
type DiscoveredDevice struct { // ID is the unique ID of this device. ID string // Addr is the network address of this device. Addr string // Type is the type of device discovered, such as a tuner or storage unit. Type DeviceType // URL, if available, is the URL for the device's web UI. URL *url.URL // Tuners is the number of TV tuners available to the device. Tuners int }
A DiscoveredDevice is a device encountered during discovery. Its network address can be used with Dial to initiate a direct connection to a device.
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
A Discoverer can discover HDHomeRun devices on a network.
Example (Discover) ¶
This example demonstrates the use of a Discoverer to discover devices until a timeout elapses.
package main import ( "context" "io" "log" "time" "github.com/joydip/hdhomerun" ) func main() { // Discover devices of any type with any ID. d, err := hdhomerun.NewDiscoverer() if err != nil { log.Fatalf("error starting discovery: %v", err) } // Discover devices for up to 2 seconds or until canceled. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() for { // Note: Discover blocks until a device is found or its context is // canceled. Always pass a context with a cancel function, deadline, // or timeout. // // io.EOF is returned when the context is canceled. device, err := d.Discover(ctx) switch err { case nil: // Found a device. // If only one device is expected, invoke cancel here. log.Println("device:", device) case io.EOF: // Context canceled; no more devices to be found. return default: log.Fatalf("error during discovery: %v", err) } } }
Output:
func NewDiscoverer ¶
func NewDiscoverer(options ...DiscovererOption) (*Discoverer, error)
NewDiscoverer creates a Discoverer that can discover devices using a UDP multicast mechanism. By default, the Discoverer will look for any type of device with any ID.
If needed, DiscovererOptions can be provided to modify the behavior of the Discoverer.
func (*Discoverer) Discover ¶
func (d *Discoverer) Discover(ctx context.Context) (*DiscoveredDevice, error)
Discover discovers HDHomeRun devices over a network. Discover will block indefinitely until a device is found, or the context is canceled. If the context is canceled, an io.EOF error will be returned.
type DiscovererOption ¶
type DiscovererOption func(d *Discoverer) error
A DiscovererOption is an option which modifies the behavior of a Discoverer.
func DiscoverDeviceID ¶
func DiscoverDeviceID(id string) DiscovererOption
DiscoverDeviceID requests that a Discoverer only search for devices with the specified ID.
func DiscoverDeviceType ¶
func DiscoverDeviceType(t DeviceType) DiscovererOption
DiscoverDeviceType requests that a Discoverer only search for devices with the specified type.
type Error ¶
type Error struct {
Message string
}
An Error is an error message returned by an HDHomeRun device.
type NetworkStatus ¶
type NetworkStatus struct { PacketsPerSecond int Errors int Stop StopReason }
NetworkStatus is the status of an outgoing network stream from the tuner.
type Packet ¶
type Packet struct { // Type specifies the type of message this Packet carries. Type uint16 // Tags specifies zero or more tags containing optional attributes. Tags []Tag }
A Packet is a network packet used to communicate with HDHomeRun devices.
func (*Packet) MarshalBinary ¶
MarshalBinary marshals a Packet into its binary form.
func (*Packet) UnmarshalBinary ¶
UnmarshalBinary unmarshals a Packet from its binary form.
type StopReason ¶
type StopReason int
A StopReason is a reason why a tuner's network stream has stopped.
const ( StopReasonNotStopped StopReason = 0 StopReasonIntentional StopReason = 1 StopReasonICMPReject StopReason = 2 StopReasonConnectionLoss StopReason = 3 StopReasonHTTPConnectionClose StopReason = 4 )
Possible StopReason values.
type Tag ¶
type Tag struct { // Type specifies the type of payload this Tag carries. Type uint8 // Data is an arbitrary byte payload. Data []byte }
A Tag is an attribute carried by a Packet.
type TransportStreamStatus ¶
TransportStreamStatus is the status of an incoming video stream from the tuner.
type Tuner ¶
type Tuner struct { Index int // contains filtered or unexported fields }
A Tuner is an HDHomeRun TV tuner. The Index field specifies which tuner will be queried. Tuners should be constructed using the Tuner method of the Client type.
func (*Tuner) Debug ¶
func (t *Tuner) Debug() (*TunerDebug, error)
Debug retrieves a variety of debugging information about the Tuner, specified by its index.
type TunerDebug ¶
type TunerDebug struct { Tuner *TunerStatus Device *DeviceStatus CableCARD *CableCARDStatus TransportStream *TransportStreamStatus Network *NetworkStatus }
TunerDebug contains debugging information about an HDHomeRun TV tuner.
If information about a particular component is not available, the field's value will be nil.
Information about particular fields can be found in the HDHomeRun Development Guide: https://www.silicondust.com/hdhomerun/hdhomerun_development.pdf.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
hdhrctl
Command hdhrctl provides a basic HDHomeRun device querying utility.
|
Command hdhrctl provides a basic HDHomeRun device querying utility. |
internal
|
|
libhdhomerun
Package libhdhomerun is an auto-generated package which contains constants and types from libhdhomerun to interact with SiliconDust HDHomeRun devices.
|
Package libhdhomerun is an auto-generated package which contains constants and types from libhdhomerun to interact with SiliconDust HDHomeRun devices. |