Documentation
¶
Overview ¶
Package homekit puts reostream's cameras in Apple's Home app (#32): one bridge, named reostream unless the config says otherwise, with a camera accessory per wired camera, so the Home app pairs once for all of them.
The HomeKit Accessory Protocol itself (pairing, the encrypted session, mDNS) is github.com/brutella/hap. This package decides what the bridge holds and answers the Home app's snapshot requests with the camera's own still.
Index ¶
Constants ¶
const DefaultPort = 51827
DefaultPort is the HomeKit server's port when the config sets none. A fixed one, so a firewall rule written for it keeps working.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is a running HomeKit bridge.
func (*Bridge) Alert ¶
Alert feeds the camera's motion sensor from the camera's own alerts: motion while the camera reports motion or any object. Some cameras send only objects (a pano reported vehicles and never plain motion, 12-01), so motion alone would leave their sensor dark. A camera the bridge does not hold is ignored.
type Camera ¶
type Camera struct {
Name string
Model string
// Motion is a camera whose motion reaches reostream: its own alert
// connection, or a motion_topic. Only it gets a motion sensor, since
// one that can never trip says "no motion" when nobody knows.
Motion bool
}
Camera is one camera the bridge offers.
type Feed ¶
Feed subscribes to a camera stream's access units in process: marshaled frames.Record values, the first a keyframe, until cancel. choice 0 is the camera's first choice for live view; a session that finds it H.265 asks for 1, and so on, until ok is false.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager runs the bridge the config asks for, and builds it again when the homekit section or the cameras it holds change, so the page's changes apply without a restart.
func NewManager ¶
func NewManager(opts ManagerOptions) *Manager
func (*Manager) Apply ¶
Apply follows cfg: starts, rebuilds or stops the bridge. It returns once the old bridge has let go of its port.
func (*Manager) Reset ¶
Reset forgets every pairing and the bridge's identity, so the Home app sees a new accessory and can add it again. The old one stays in the Home app, not responding, until it is removed there.
type ManagerOptions ¶
type ManagerOptions struct {
Dir string
Version string
Snap func(ctx context.Context, camera, stream string) ([]byte, error)
// Subscribe reads one camera stream's access units in process, as
// Feed does for a camera; nil offers stills only.
Subscribe func(camera, stream string) (records <-chan []byte, cancel func(), ok bool)
}
ManagerOptions are what the bridge needs beyond the config.
type Options ¶
type Options struct {
// Dir holds the pairing keys, the pairings, the setup code reostream
// made and the accessory ids: <data>/homekit.
Dir string
Name string
Port int
Pin string
Version string
Cameras []Camera
// Snap returns the camera's own still, stream "main" or "sub".
Snap func(ctx context.Context, camera, stream string) ([]byte, error)
// Feed is the camera's video for live view; nil offers stills only.
Feed Feed
}
Options are what Run needs.