Documentation
¶
Index ¶
- Variables
- func SetAPIMetrics(m *metrics.Metrics)
- func SetUpdateChecker(c *update.Checker)
- func WriteError(w http.ResponseWriter, status int, msg string)
- type AIHandler
- type CPUStats
- type CameraHealthDetail
- type CameraHealthSummary
- type CloudAuthProxy
- type CloudAuthResult
- type CloudDeviceInfo
- type CloudVerificationRequired
- type ConditionalHandler
- type FLVStreamHandler
- type GB28181ByeSender
- type GB28181CascadeStatus
- type GB28181DeviceMedia
- type GB28181InviteSender
- type HLSStreamHandler
- func (h *HLSStreamHandler) CanHandle(codec model.Format) bool
- func (h *HLSStreamHandler) Name() string
- func (h *HLSStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
- func (h *HLSStreamHandler) StopStream(camID string) error
- func (h *HLSStreamHandler) StopStreamWithRecorder(camID string, rec model.Recorder) error
- type Handler
- func (h *Handler) Close()
- func (h *Handler) HandleTelemetry(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Routes() http.Handler
- func (h *Handler) SetAIHandler(ah *AIHandler)
- func (h *Handler) SetAPIKeyStore(s *middleware.APIKeyStore)
- func (h *Handler) SetDownloader(d TranscodeDownloader)
- func (h *Handler) SetEventBus(bus *event.EventBus)
- func (h *Handler) SetFLVManager(mgr *flv.Manager)
- func (h *Handler) SetGB28181ByeSender(s GB28181ByeSender)
- func (h *Handler) SetGB28181Cascade(s GB28181CascadeStatus)
- func (h *Handler) SetGB28181Catalog(c *gb28181.CatalogController)
- func (h *Handler) SetGB28181DeviceMedia(s GB28181DeviceMedia)
- func (h *Handler) SetGB28181Inviter(s GB28181InviteSender)
- func (h *Handler) SetGB28181PTZ(ptz *gb28181.PTZController)
- func (h *Handler) SetGB28181Timezone(loc *time.Location)
- func (h *Handler) SetHealthManager(mgr HealthManager)
- func (h *Handler) SetRelayManager(mgr *relay.Manager)
- func (h *Handler) SetRollingMergeMgr(mgr *merge.RollingMergeCoordinator)
- func (h *Handler) SetStabilityProvider(p StabilityProvider)
- func (h *Handler) SetStreamRegistry(reg *StreamRegistry)
- func (h *Handler) SetTimelapseMergeMgr(mgr *timelapse.RollingMergeManager)
- func (h *Handler) SetTranscodeManager(mgr TranscodeManagerAPI)
- func (h *Handler) SetVisionCoordinator(mgr *vision.Coordinator)
- func (h *Handler) SetWSManager(mgr *wsstream.Manager)
- func (h *Handler) SetWebRTCManager(mgr *webrtc.Manager)
- type HealthCheck
- type HealthManager
- type HealthResponse
- type LLHLSStreamHandler
- type LocalXiaomiAuth
- func (a *LocalXiaomiAuth) CheckVendor(_ context.Context, did string) (string, error)
- func (a *LocalXiaomiAuth) ListDevices(_ context.Context) ([]CloudDeviceInfo, error)
- func (a *LocalXiaomiAuth) SetCloudConfig(_ context.Context, userID, token, region string) error
- func (a *LocalXiaomiAuth) SignIn(_ context.Context, username, password, region string) (*CloudAuthResult, *CloudVerificationRequired, error)
- func (a *LocalXiaomiAuth) SubmitCaptcha(_ context.Context, sessionID, captchaCode string) (*CloudAuthResult, *CloudVerificationRequired, error)
- func (a *LocalXiaomiAuth) SubmitVerify(_ context.Context, sessionID, ticket string) (*CloudAuthResult, *CloudVerificationRequired, error)
- type MJPEGStreamHandler
- type MemoryStats
- type NetworkStats
- type ProtocolDetail
- type StabilityProvider
- type StreamHandler
- type StreamRegistry
- type StreamStartOptions
- type SystemStats
- type TranscodeDownloader
- type TranscodeManagerAPI
- type WSStreamHandler
- type WebRTCStreamHandler
Constants ¶
This section is empty.
Variables ¶
var SupportedTimelapseMergeDurations = []string{
"1h",
"8h",
"12h",
"24h",
"natural-day",
"7d",
"30d",
}
handleTimelapseStatus returns global timelapse merge defaults. GET /api/timelapse/status SupportedTimelapseMergeDurations is the canonical list of named merge-window values exposed to the frontend. Order matters — the first entry is the default shown in dropdowns. Mirrors config.ParseMergeDuration's named windows (1h + 8h/12h/24h/natural-day/7d/30d). Kept here (not in config) because it's an API contract, not a parsing concern.
Functions ¶
func SetAPIMetrics ¶ added in v0.8.0
SetAPIMetrics injects the Prometheus metrics instance into the API package.
func SetUpdateChecker ¶ added in v0.10.0
SetUpdateChecker injects the version checker into the API package. Called once from main after RunFree builds the app. Passing nil disables the endpoints' live data (they still report the running version + deployment).
func WriteError ¶ added in v0.9.0
func WriteError(w http.ResponseWriter, status int, msg string)
Types ¶
type AIHandler ¶ added in v0.7.1
type AIHandler struct {
// contains filtered or unexported fields
}
AIHandler holds dependencies for AI REST API endpoints. Only config management and ROI zone CRUD — no backend inference.
type CameraHealthDetail ¶ added in v0.4.0
type CameraHealthDetail struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Score int `json:"score"`
}
CameraHealthDetail is a per-camera summary included in /api/health.
type CameraHealthSummary ¶ added in v0.4.0
type CameraHealthSummary struct {
Total int `json:"total"`
Recording int `json:"recording"`
Reconnecting int `json:"reconnecting"`
Error int `json:"error"`
Offline int `json:"offline"`
Details []CameraHealthDetail `json:"details"`
}
CameraHealthSummary provides aggregated camera health in the /api/health response.
type CloudAuthProxy ¶ added in v0.3.0
type CloudAuthProxy interface {
// SetCloudConfig pushes cloud credentials (user_id, token, region) to the xiaomi package.
// underlying implementation (plugin process or local state).
SetCloudConfig(ctx context.Context, userID, token, region string) error
// SignIn authenticates with username/password. Returns (result, verification, error).
// If verification is non-nil, the user must complete captcha/2FA.
SignIn(ctx context.Context, username, password, region string) (*CloudAuthResult, *CloudVerificationRequired, error)
// SubmitCaptcha submits a captcha code for a pending session.
SubmitCaptcha(ctx context.Context, sessionID, captchaCode string) (*CloudAuthResult, *CloudVerificationRequired, error)
// SubmitVerify submits a 2FA ticket (SMS/email code) for a pending session.
SubmitVerify(ctx context.Context, sessionID, ticket string) (*CloudAuthResult, *CloudVerificationRequired, error)
// ListDevices returns the list of cloud devices for the authenticated user.
ListDevices(ctx context.Context) ([]CloudDeviceInfo, error)
// CheckVendor determines the vendor protocol for a Xiaomi device by DID.
// Returns vendor name ("cs2", "tutk", etc.) or error if unable to determine.
CheckVendor(ctx context.Context, did string) (string, error)
}
CloudAuthProxy abstracts cloud authentication operations. The API handler uses this interface to proxy cloud auth calls to the xiaomi package. The main process uses this interface to proxy cloud auth API calls, delegating to either a local in-process implementation or a gRPC plugin.
type CloudAuthResult ¶ added in v0.3.0
type CloudAuthResult struct {
UserID string `json:"user_id"`
PassToken string `json:"pass_token"`
Region string `json:"region"`
}
CloudAuthResult holds the result of a successful cloud authentication.
type CloudDeviceInfo ¶ added in v0.3.0
type CloudDeviceInfo struct {
DID string `json:"did"`
Name string `json:"name"`
Model string `json:"model"`
IP string `json:"localip"`
MAC string `json:"mac"`
IsOnline bool `json:"isOnline"`
}
CloudDeviceInfo represents a discovered cloud device (e.g. camera).
type CloudVerificationRequired ¶ added in v0.3.0
type CloudVerificationRequired struct {
Captcha []byte `json:"captcha,omitempty"`
VerifyPhone string `json:"verify_phone,omitempty"`
VerifyEmail string `json:"verify_email,omitempty"`
CaptchaSessionID string `json:"session_id,omitempty"`
}
CloudVerificationRequired is returned when authentication requires user interaction (captcha or two-factor verification).
type ConditionalHandler ¶ added in v0.4.0
type ConditionalHandler interface {
// SupportedCodec returns true if this handler would normally support the codec,
// regardless of current availability state.
SupportedCodec(codec model.Format) bool
UnavailabilityReason(codec model.Format) string
}
ConditionalHandler is an optional interface for StreamHandlers that may be unavailable even for supported codecs (e.g., LL-HLS when low-latency is disabled).
type FLVStreamHandler ¶ added in v0.3.1
type FLVStreamHandler struct{}
FLVStreamHandler implements StreamHandler for HTTP-FLV. FLV streams start/stop on-demand via GET /stream.flv, so StartStream and StopStream are no-ops. This registration exists purely for protocol discovery (so /api/cameras/{id}/protocols returns the correct list).
func (*FLVStreamHandler) CanHandle ¶ added in v0.3.1
func (h *FLVStreamHandler) CanHandle(codec model.Format) bool
func (*FLVStreamHandler) Name ¶ added in v0.3.1
func (h *FLVStreamHandler) Name() string
func (*FLVStreamHandler) StartStream ¶ added in v0.3.1
func (h *FLVStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
func (*FLVStreamHandler) StopStream ¶ added in v0.3.1
func (h *FLVStreamHandler) StopStream(camID string) error
type GB28181ByeSender ¶ added in v0.11.0
GB28181ByeSender stops a channel media session end-to-end (SIP BYE to the device, local receiver teardown, bound-camera recorder state). Implemented by the SIP server; declared here to avoid importing sip in Handler.
type GB28181CascadeStatus ¶ added in v0.11.0
type GB28181CascadeStatus interface {
Online() bool
RegistrationSince() (time.Duration, bool)
ForwardCount() int
}
GB28181CascadeStatus reports the lower-level cascade client's registration state. Implemented by the cascade service; declared here to avoid importing cascade in Handler.
type GB28181DeviceMedia ¶ added in v0.11.0
type GB28181DeviceMedia interface {
// QueryChannelRecords sends a RecordInfo query and collects the paged
// responses for a time range.
QueryChannelRecords(deviceID, channelID string, start, end time.Time) ([]manscdp.RecordItem, error)
// StartPlayback starts a fetch that muxes the device recording into the
// normal recordings pipeline of the bound camera.
StartPlayback(deviceID, channelID string, start, end time.Time) error
// StopPlayback stops a fetch (SIP BYE + finalize).
StopPlayback(channelID string) error
// PlaybackStatusFor reports fetch progress (ok=false when idle).
PlaybackStatusFor(channelID string) (gb28181.PlaybackInfo, bool)
// PlaybackControl sends a MANSRTSP control (pause/resume/seek).
PlaybackControl(channelID, action string, scale, position float64) error
// StartTalk establishes a voice intercom with a channel (audio-only
// INVITE; #341). Idempotent.
StartTalk(cameraID, deviceID, channelID string) error
// StopTalk ends the intercom (SIP BYE + socket close).
StopTalk(channelID string) error
// WriteTalkAudio packetizes one G.711 A-law frame to the device.
WriteTalkAudio(channelID string, alaw []byte)
// TalkStatusFor reports the intercom state of a camera.
TalkStatusFor(cameraID string) gb28181.TalkStatus
// GB28181Alarms returns the device's recent alarms (latest first).
GB28181Alarms(deviceID string) []event.GB28181AlarmEvent
// GB28181Positions returns the device's recent mobile positions.
GB28181Positions(deviceID string) []gb28181.GBPosition
}
GB28181DeviceMedia is the device-side recording API (RecordInfo query, playback INVITE fetch, MANSRTSP control) implemented by the SIP server; declared here to avoid importing sip in Handler (#337).
type GB28181InviteSender ¶ added in v0.11.0
GB28181InviteSender sends a SIP INVITE to start a media session on a channel. Implemented by the SIP server; declared here to avoid importing sip in Handler.
type HLSStreamHandler ¶ added in v0.3.1
HLSStreamHandler implements StreamHandler for HLS live streaming. It encapsulates the HLS-specific logic previously scattered across type-switch blocks in handlers_hls.go.
func (*HLSStreamHandler) CanHandle ¶ added in v0.3.1
func (h *HLSStreamHandler) CanHandle(codec model.Format) bool
CanHandle returns true for H.264 and H.265 formats (HLS supports both).
func (*HLSStreamHandler) Name ¶ added in v0.3.1
func (h *HLSStreamHandler) Name() string
Name returns the protocol identifier for HLS.
func (*HLSStreamHandler) StartStream ¶ added in v0.3.1
func (h *HLSStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
StartStream starts an HLS stream for the given camera. It extracts codec parameters from the recorder and subscribes the HLS manager to the recorder's StreamHub for frame delivery.
func (*HLSStreamHandler) StopStream ¶ added in v0.3.1
func (h *HLSStreamHandler) StopStream(camID string) error
StopStream implements StreamHandler.StopStream.
func (*HLSStreamHandler) StopStreamWithRecorder ¶ added in v0.3.1
func (h *HLSStreamHandler) StopStreamWithRecorder(camID string, rec model.Recorder) error
StopStreamWithRecorder stops the HLS stream for the given camera and unsubscribes from the recorder's StreamHub.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(db *storage.DB, store *storage.Manager, authMW func(http.Handler) http.Handler, cfg *config.Config, camMgr *camera.CameraManager, hlsMgr *hls.Manager, configPath string, mergeMgr *merge.MergeManager, cloudProxy CloudAuthProxy, mergeScheduler *timelapse.MergeScheduler, gb28181DeviceMgr *gb28181.DeviceManager, gb28181SessionMgr *gb28181.SessionManager) *Handler
func TestHandler ¶
TestHandler creates a Handler with a no-op auth middleware for testing.
func (*Handler) Close ¶ added in v0.10.0
func (h *Handler) Close()
Close cancels any in-flight timelapse merge goroutines and waits for them to exit. It must be called during application shutdown (after the HTTP server stops accepting requests) so merges don't outlive the storage tree — the App.Service contract requires all goroutines be released, and tests using t.TempDir for the storage root will otherwise hit "directory not empty" during RemoveAll (#143 / #125 class). Idempotent.
func (*Handler) HandleTelemetry ¶ added in v0.6.0
func (h *Handler) HandleTelemetry(w http.ResponseWriter, r *http.Request)
HandleTelemetry receives playback telemetry events and logs them via slog. It requires BasicAuth and is rate-limited to 10 requests/second per IP.
func (*Handler) SetAIHandler ¶ added in v0.7.1
SetAIHandler sets the AI handler on the Handler.
func (*Handler) SetAPIKeyStore ¶ added in v0.11.0
func (h *Handler) SetAPIKeyStore(s *middleware.APIKeyStore)
SetAPIKeyStore wires the live API key store. The generate/revoke handlers keep it in sync with the config so key changes apply on the next request without a service restart (#335); last-used timestamps surface in the key list API.
func (*Handler) SetDownloader ¶ added in v0.5.0
func (h *Handler) SetDownloader(d TranscodeDownloader)
SetDownloader sets the FFmpeg downloader on the handler.
func (*Handler) SetEventBus ¶ added in v0.6.0
SetEventBus sets the event bus on the handler.
func (*Handler) SetFLVManager ¶ added in v0.3.1
SetFLVManager sets the FLV manager on the handler.
func (*Handler) SetGB28181ByeSender ¶ added in v0.11.0
func (h *Handler) SetGB28181ByeSender(s GB28181ByeSender)
SetGB28181ByeSender wires the SIP server for the channel BYE endpoint.
func (*Handler) SetGB28181Cascade ¶ added in v0.11.0
func (h *Handler) SetGB28181Cascade(s GB28181CascadeStatus)
SetGB28181Cascade wires the cascade client for the status endpoint.
func (*Handler) SetGB28181Catalog ¶ added in v0.11.0
func (h *Handler) SetGB28181Catalog(c *gb28181.CatalogController)
SetGB28181Catalog wires the GB28181 catalog controller for the device catalog-refresh endpoint.
func (*Handler) SetGB28181DeviceMedia ¶ added in v0.11.0
func (h *Handler) SetGB28181DeviceMedia(s GB28181DeviceMedia)
SetGB28181DeviceMedia wires the SIP server for the device-recording endpoints.
func (*Handler) SetGB28181Inviter ¶ added in v0.11.0
func (h *Handler) SetGB28181Inviter(s GB28181InviteSender)
SetGB28181Inviter wires the SIP server for the channel INVITE endpoint.
func (*Handler) SetGB28181PTZ ¶ added in v0.11.0
func (h *Handler) SetGB28181PTZ(ptz *gb28181.PTZController)
SetGB28181PTZ wires the GB28181 PTZ controller for the channel PTZ endpoint.
func (*Handler) SetGB28181Timezone ¶ added in v0.11.0
SetGB28181Timezone pins the zone used to interpret/format naive GB/T 28181 device-clock timestamps (RecordInfo entries). nil keeps time.Local.
func (*Handler) SetHealthManager ¶ added in v0.4.0
func (h *Handler) SetHealthManager(mgr HealthManager)
SetHealthManager sets the health manager on the handler.
func (*Handler) SetRelayManager ¶ added in v0.8.0
SetRelayManager wires the relay manager for the relay-presets endpoints.
func (*Handler) SetRollingMergeMgr ¶ added in v0.9.0
func (h *Handler) SetRollingMergeMgr(mgr *merge.RollingMergeCoordinator)
SetRollingMergeMgr sets the recording rolling merge coordinator on the handler.
func (*Handler) SetStabilityProvider ¶ added in v0.4.0
func (h *Handler) SetStabilityProvider(p StabilityProvider)
SetStabilityProvider sets the stability data provider on the handler.
func (*Handler) SetStreamRegistry ¶ added in v0.3.1
func (h *Handler) SetStreamRegistry(reg *StreamRegistry)
SetStreamRegistry sets the stream registry on the handler for protocol queries.
func (*Handler) SetTimelapseMergeMgr ¶ added in v0.7.0
func (h *Handler) SetTimelapseMergeMgr(mgr *timelapse.RollingMergeManager)
SetTimelapseMergeMgr sets the timelapse rolling merge manager on the handler.
func (*Handler) SetTranscodeManager ¶ added in v0.5.0
func (h *Handler) SetTranscodeManager(mgr TranscodeManagerAPI)
SetTranscodeManager sets the transcode manager on the handler.
func (*Handler) SetVisionCoordinator ¶ added in v0.11.0
func (h *Handler) SetVisionCoordinator(mgr *vision.Coordinator)
SetVisionCoordinator sets the Vision push coordinator on the handler.
func (*Handler) SetWSManager ¶ added in v0.6.0
SetWSManager sets the WebSocket stream manager on the handler.
func (*Handler) SetWebRTCManager ¶ added in v0.3.1
SetWebRTCManager sets the WebRTC manager on the handler.
type HealthCheck ¶
type HealthCheck struct {
Status string `json:"status"` // "ok" | "warning" | "error"
Message string `json:"message,omitempty"`
}
HealthCheck represents the result of a single health check.
type HealthManager ¶ added in v0.4.0
type HealthManager interface {
GetAllHealth() map[string]*model.CameraHealth
GetCameraHealth(cameraID string) *model.CameraHealth
}
HealthManager provides camera health status data.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"` // "ok" | "degraded" | "unhealthy"
Checks map[string]HealthCheck `json:"checks"`
Uptime string `json:"uptime"`
SetupRequired bool `json:"setup_required"`
Cameras *CameraHealthSummary `json:"cameras,omitempty"`
// DeviceID / DeviceName give LAN clients a stable identity to anchor on
// instead of an IP address (#330). Empty until the config provides them
// (the ID is generated and persisted on first config load).
DeviceID string `json:"device_id,omitempty"`
DeviceName string `json:"device_name,omitempty"`
}
HealthResponse is the response from /api/health.
type LLHLSStreamHandler ¶ added in v0.4.0
type LLHLSStreamHandler struct {
HLSStreamHandler
}
LLHLSStreamHandler implements StreamHandler for Low-Latency HLS. It wraps HLSStreamHandler but is registered separately in the StreamRegistry so the frontend can discover LL-HLS as a distinct protocol.
LL-HLS is always advertised as available (H.264/H.265) — the backend muxer supports low-latency fMP4 unconditionally. Whether the browser can actually play it (e.g. H.265 via MSE) is a frontend capability concern, gated by the same browser-probe logic as HLS/FLV.
func (*LLHLSStreamHandler) CanHandle ¶ added in v0.4.0
func (h *LLHLSStreamHandler) CanHandle(codec model.Format) bool
CanHandle returns true for H.264 and H.265 — LL-HLS is always available.
func (*LLHLSStreamHandler) Name ¶ added in v0.4.0
func (h *LLHLSStreamHandler) Name() string
type LocalXiaomiAuth ¶ added in v0.3.0
type LocalXiaomiAuth struct {
// contains filtered or unexported fields
}
LocalXiaomiAuth implements CloudAuthProxy by calling the internal xiaomi package directly.
func NewLocalXiaomiAuth ¶ added in v0.3.0
func NewLocalXiaomiAuth(cfg *config.Config) *LocalXiaomiAuth
NewLocalXiaomiAuth creates a LocalXiaomiAuth and initializes cloud config. The config pointer is kept so auth results can update it in-place.
func (*LocalXiaomiAuth) CheckVendor ¶ added in v0.4.0
CheckVendor checks the vendor protocol for a Xiaomi device by DID.
func (*LocalXiaomiAuth) ListDevices ¶ added in v0.3.0
func (a *LocalXiaomiAuth) ListDevices(_ context.Context) ([]CloudDeviceInfo, error)
ListDevices returns Xiaomi cloud devices filtered to camera models.
func (*LocalXiaomiAuth) SetCloudConfig ¶ added in v0.3.0
func (a *LocalXiaomiAuth) SetCloudConfig(_ context.Context, userID, token, region string) error
SetCloudConfig pushes credentials to the xiaomi package's cloud state.
func (*LocalXiaomiAuth) SignIn ¶ added in v0.3.0
func (a *LocalXiaomiAuth) SignIn(_ context.Context, username, password, region string) (*CloudAuthResult, *CloudVerificationRequired, error)
SignIn calls the xiaomi cloud sign-in flow.
func (*LocalXiaomiAuth) SubmitCaptcha ¶ added in v0.3.0
func (a *LocalXiaomiAuth) SubmitCaptcha(_ context.Context, sessionID, captchaCode string) (*CloudAuthResult, *CloudVerificationRequired, error)
SubmitCaptcha submits a captcha code for a pending auth session.
func (*LocalXiaomiAuth) SubmitVerify ¶ added in v0.3.0
func (a *LocalXiaomiAuth) SubmitVerify(_ context.Context, sessionID, ticket string) (*CloudAuthResult, *CloudVerificationRequired, error)
SubmitVerify submits a 2FA ticket for a pending auth session.
type MJPEGStreamHandler ¶ added in v0.7.1
type MJPEGStreamHandler struct{}
MJPEGStreamHandler implements StreamHandler for live MJPEG streaming. MJPEG streams are proxied on-demand via GET /stream.mjpeg, so StartStream and StopStream are no-ops. This registration exists purely for protocol discovery (so /api/cameras/{id}/protocols returns the correct list).
func (*MJPEGStreamHandler) CanHandle ¶ added in v0.7.1
func (h *MJPEGStreamHandler) CanHandle(codec model.Format) bool
func (*MJPEGStreamHandler) Name ¶ added in v0.7.1
func (h *MJPEGStreamHandler) Name() string
func (*MJPEGStreamHandler) StartStream ¶ added in v0.7.1
func (h *MJPEGStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
func (*MJPEGStreamHandler) StopStream ¶ added in v0.7.1
func (h *MJPEGStreamHandler) StopStream(camID string) error
type MemoryStats ¶
type NetworkStats ¶
type ProtocolDetail ¶ added in v0.4.0
type ProtocolDetail struct {
Protocol string `json:"protocol"`
Available bool `json:"available"`
Reason string `json:"reason"`
}
ProtocolDetail describes a protocol's availability for the API response. json tags are snake_case like every other API response field (#332) — the Go field names used to leak through encoding/json's default naming.
type StabilityProvider ¶ added in v0.4.0
type StabilityProvider interface {
GetAllStability() map[string]*health.StabilityData
GetStability(cameraID string) *health.StabilityData
}
StabilityProvider provides camera stability quality data.
type StreamHandler ¶ added in v0.3.1
type StreamHandler interface {
// Name returns the protocol identifier (e.g. "hls", "webrtc", "flv", "ll-hls").
Name() string
// CanHandle returns true if this handler supports the given codec format.
CanHandle(codec model.Format) bool
// StartStream starts a live stream for the given camera using the provided recorder.
StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
// StopStream stops the live stream for the given camera.
StopStream(camID string) error
}
StreamHandler is a protocol-agnostic interface for live streaming handlers. Each streaming protocol (HLS, WebRTC, FLV, LL-HLS) implements this interface so the API layer can start/stop streams without type-switch spaghetti.
type StreamRegistry ¶ added in v0.3.1
type StreamRegistry struct {
// contains filtered or unexported fields
}
StreamRegistry manages registered stream handlers and provides protocol availability queries per codec format.
func NewStreamRegistry ¶ added in v0.3.1
func NewStreamRegistry() *StreamRegistry
NewStreamRegistry creates an empty StreamRegistry.
func (*StreamRegistry) ProtocolsDetailForCodec ¶ added in v0.4.0
func (r *StreamRegistry) ProtocolsDetailForCodec(codec model.Format) []ProtocolDetail
ProtocolsDetailForCodec returns detailed protocol availability for the given codec. Each handler contributes its availability and optional reason if unavailable.
func (*StreamRegistry) Register ¶ added in v0.3.1
func (r *StreamRegistry) Register(h StreamHandler)
Register adds a stream handler to the registry.
type StreamStartOptions ¶ added in v0.3.1
StreamStartOptions holds optional parameters for starting a stream.
type SystemStats ¶
type SystemStats struct {
CPU CPUStats `json:"cpu"`
Memory MemoryStats `json:"memory"`
Network NetworkStats `json:"network"`
Uptime string `json:"uptime"`
Timestamp int64 `json:"timestamp"`
}
SystemStats is the response from /api/stats/system.
type TranscodeDownloader ¶ added in v0.5.0
type TranscodeDownloader interface {
FFmpegPath() string
GetFFmpegStatus() transcoding.DownloadStatus
DownloadFFmpeg(ctx context.Context) error
}
TranscodeDownloader is the interface the API layer uses to interact with the FFmpeg downloader. This decouples handlers from the concrete type and makes testing straightforward.
type TranscodeManagerAPI ¶ added in v0.5.0
type TranscodeManagerAPI interface {
GetStatus() transcoding.ManagerStatus
Queue() transcoding.QueueAPI
}
TranscodeManagerAPI is the interface the API layer uses to interact with the transcoding manager. This decouples handlers from the concrete type.
type WSStreamHandler ¶ added in v0.6.0
type WSStreamHandler struct{}
WSStreamHandler implements StreamHandler for WebSocket streaming. WebSocket streams start/stop on-demand via GET /stream/ws, so StartStream and StopStream are no-ops. This registration exists purely for protocol discovery (so /api/cameras/{id}/protocols returns the correct list).
func (*WSStreamHandler) CanHandle ¶ added in v0.6.0
func (h *WSStreamHandler) CanHandle(codec model.Format) bool
func (*WSStreamHandler) Name ¶ added in v0.6.0
func (h *WSStreamHandler) Name() string
func (*WSStreamHandler) StartStream ¶ added in v0.6.0
func (h *WSStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
func (*WSStreamHandler) StopStream ¶ added in v0.6.0
func (h *WSStreamHandler) StopStream(camID string) error
type WebRTCStreamHandler ¶ added in v0.3.1
type WebRTCStreamHandler struct{}
WebRTCStreamHandler implements StreamHandler for WebRTC WHEP. WebRTC streams start/stop on-demand via WHEP POST/DELETE, so StartStream and StopStream are no-ops. This registration exists purely for protocol discovery (so /api/cameras/{id}/protocols returns the correct list).
func (*WebRTCStreamHandler) CanHandle ¶ added in v0.3.1
func (h *WebRTCStreamHandler) CanHandle(codec model.Format) bool
func (*WebRTCStreamHandler) Name ¶ added in v0.3.1
func (h *WebRTCStreamHandler) Name() string
func (*WebRTCStreamHandler) StartStream ¶ added in v0.3.1
func (h *WebRTCStreamHandler) StartStream(camID string, rec model.Recorder, opts StreamStartOptions) error
func (*WebRTCStreamHandler) StopStream ¶ added in v0.3.1
func (h *WebRTCStreamHandler) StopStream(camID string) error
Source Files
¶
- ai_handler.go
- cloud_auth.go
- events_handler.go
- handler.go
- handlers_ai.go
- handlers_archive.go
- handlers_camera.go
- handlers_flv.go
- handlers_gb28181.go
- handlers_health.go
- handlers_hls.go
- handlers_merge.go
- handlers_mjpeg.go
- handlers_onvif.go
- handlers_playback.go
- handlers_recording.go
- handlers_relay.go
- handlers_setup.go
- handlers_stream.go
- handlers_system.go
- handlers_timelapse.go
- handlers_transcode.go
- handlers_update.go
- handlers_vision.go
- handlers_vod.go
- handlers_webrtc.go
- handlers_ws.go
- handlers_xiaomi.go
- handlers_xiaomi_audio.go
- handlers_xiaomi_ptz.go
- telemetry.go
- xiaomi_local.go