Documentation
¶
Overview ¶
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.
Index ¶
- Variables
- func AuthMiddleware(secret string, authURL string, handler ...web.HandlerOption) gin.HandlerFunc
- func NewEventCore(db *gorm.DB, conf *conf.Bootstrap, notifier event.Dispatcher) event.Core
- func NewEventCoreWithNotifier(conf *conf.Bootstrap, db *gorm.DB, notifier event.Dispatcher) event.Core
- func NewGBAdapter(store ipc.Storer, uni uniqueid.Core) ipc.Adapter
- func NewHTTPHandler(uc *Usecase) http.Handler
- func NewIPCProviderAdapter(ipcBundle IPCBundle) recording.IPCProvider
- func NewIPCStore(db *gorm.DB) ipc.Storer
- func NewNotifier(conf *conf.Bootstrap) *push.Notifier
- func NewPlayProviderAdapter(smsCore sms.Core) recording.PlayProvider
- func NewProxyCore(db *gorm.DB, uni uniqueid.Core) *proxy.Core
- func NewRecordingCore(store recording.Storer, cfg *conf.Bootstrap, provider recording.SMSProvider, ...) recording.Core
- func NewRecordingStore(db *gorm.DB) recording.Storer
- func NewSMSCore(db *gorm.DB, cfg *conf.Bootstrap) sms.Core
- func NewSMSProviderAdapter(smsCore sms.Core) recording.SMSProvider
- func NewUniqueID(db *gorm.DB) uniqueid.Core
- func RegisterEvent(g gin.IRouter, api EventAPI, handler ...gin.HandlerFunc)
- func RegisterRecording(g gin.IRouter, api RecordingAPI, handler ...gin.HandlerFunc)
- func RegisterRecordingVideoOnly(g gin.IRouter, api RecordingAPI, handler ...gin.HandlerFunc)
- func RegisterUser(r gin.IRouter, api UserAPI, mid ...gin.HandlerFunc)
- type AIBoundingBox
- type AIDetection
- type AIDetectionInput
- type AIGlobalStats
- type AIKeepaliveInput
- type AINormBox
- type AIStartedInput
- type AIStoppedInput
- type AIWebhookAPI
- func (a *AIWebhookAPI) ReloadAITask(ctx context.Context, ch *ipc.Channel) error
- func (a *AIWebhookAPI) StartAIDetection(ctx context.Context, ch *ipc.Channel, rtspURL string) (*protos.StartCameraResponse, error)
- func (a *AIWebhookAPI) StartAISyncLoop(ctx context.Context, smsCore sms.Core)
- func (a *AIWebhookAPI) StopAIDetection(ctx context.Context, channelID string) error
- type AIWebhookOutput
- type ConfigAPI
- type Data
- type DefaultOutput
- type EventAPI
- type IOWriter
- type IPCAPI
- type IPCBundle
- type KV
- type OriginSock
- type ProxyAPI
- type PushAPI
- type RecordingAPI
- type Secret
- type SmsAPI
- type Tracks
- type Usecase
- type UserAPI
- type WebHookAPI
Constants ¶
This section is empty.
Variables ¶
var ( ErrAIGlobalDisabled = reason.NewError("ErrAIGlobalDisabled", "AI 功能已在全局配置中禁用") ErrAIServiceNotReady = reason.NewError("ErrAIServiceNotReady", "AI 服务未初始化或连接失败") ErrChannelNotSupported = reason.NewError("ErrChannelNotSupported", "不支持的通道类型") )
var ( ProviderVersionSet = wire.NewSet(versionapi.NewVersionCore) ProviderSet = wire.NewSet( wire.Struct(new(Usecase), "*"), NewHTTPHandler, versionapi.New, NewSMSCore, NewSmsAPI, NewWebHookAPI, NewUniqueID, gbs.NewServer, NewIPCStore, NewGBAdapter, NewIPCCoreWithProtocols, NewIPCAPI, NewConfigAPI, NewUserAPI, NewAIWebhookAPIWithDeps, NewNotifier, NewEventCoreWithNotifier, NewEventAPI, NewRecordingStore, NewSMSProviderAdapter, NewIPCProviderAdapter, NewPlayProviderAdapter, NewRecordingCore, NewRecordingAPI, metadataapi.NewMetadataCore, metadataapi.NewMetadataAPI, ) )
var ErrDevice = reason.NewError("ErrDevice", "设备错误")
Functions ¶
func AuthMiddleware ¶ added in v1.3.34
func AuthMiddleware(secret string, authURL string, handler ...web.HandlerOption) gin.HandlerFunc
AuthMiddleware 鉴权 handler 可以拦截请求,返回 true 则跳过默认鉴权行为,可以通过此参数自定义鉴权方案 开启第三方鉴权时,两者任何一个通过,则鉴权通过! 优先尝试 JWT(开销小),失败后再尝试 authURL(开销大)
func NewEventCore ¶
func NewEventCoreWithNotifier ¶ added in v1.4.0
func NewEventCoreWithNotifier(conf *conf.Bootstrap, db *gorm.DB, notifier event.Dispatcher) event.Core
NewEventCoreWithNotifier 在 NewEventCore 基础上注入 webhook 推送器 notifier 为 nil 时,CreateEventAndNotify 只入库不推送
func NewIPCProviderAdapter ¶ added in v1.4.21
func NewIPCProviderAdapter(ipcBundle IPCBundle) recording.IPCProvider
NewIPCProviderAdapter 创建 IPC 适配器,将 ipc.Core 适配为 recording.IPCProvider 用于录制同步时查询应录制的在线通道
func NewNotifier ¶ added in v1.4.0
NewNotifier 创建 webhook 推送器,Targets 为空时返回 nil(不推送)
func NewPlayProviderAdapter ¶ added in v1.4.21
func NewPlayProviderAdapter(smsCore sms.Core) recording.PlayProvider
NewPlayProviderAdapter 创建 Play 适配器,桥接拉流能力给录制同步使用 通过 ZLM getSnap 取最新快照触发拉流,所有协议通用
func NewRecordingCore ¶ added in v1.3.34
func NewRecordingCore( store recording.Storer, cfg *conf.Bootstrap, provider recording.SMSProvider, ipcProvider recording.IPCProvider, playProvider recording.PlayProvider, ) recording.Core
NewRecordingCore 创建录像管理核心服务 依赖 recording.SMSProvider 接口而非 sms.Core,避免循环依赖
func NewRecordingStore ¶ added in v1.3.34
NewRecordingStore 创建录像存储层
func NewSMSProviderAdapter ¶ added in v1.3.34
func NewSMSProviderAdapter(smsCore sms.Core) recording.SMSProvider
NewSMSProviderAdapter 创建 SMS 适配器,将 sms.Core 适配为 recording.SMSProvider 通过接口解耦 recording 领域与 sms 领域,避免循环依赖
func RegisterEvent ¶
func RegisterEvent(g gin.IRouter, api EventAPI, handler ...gin.HandlerFunc)
func RegisterRecording ¶ added in v1.3.34
func RegisterRecording(g gin.IRouter, api RecordingAPI, handler ...gin.HandlerFunc)
func RegisterRecordingVideoOnly ¶ added in v1.3.34
func RegisterRecordingVideoOnly(g gin.IRouter, api RecordingAPI, handler ...gin.HandlerFunc)
RegisterRecordingVideoOnly 注册纯视频静态文件服务 需要在 RegisterRecording 之后调用
func RegisterUser ¶
func RegisterUser(r gin.IRouter, api UserAPI, mid ...gin.HandlerFunc)
Types ¶
type AIBoundingBox ¶
type AIBoundingBox struct {
XMin int `json:"x_min"`
YMin int `json:"y_min"`
XMax int `json:"x_max"`
YMax int `json:"y_max"`
}
AIBoundingBox 像素坐标边界框
type AIDetection ¶
type AIDetection struct {
Label string `json:"label"` // 物体类别
Confidence float64 `json:"confidence"` // 置信度 (0.0 - 1.0)
Box AIBoundingBox `json:"box"` // 像素坐标边界框
Area int `json:"area"` // 边界框像素面积
NormBox *AINormBox `json:"norm_box"` // 归一化边界框
}
AIDetection 检测对象
type AIDetectionInput ¶
type AIDetectionInput struct {
CameraID string `json:"camera_id"` // 摄像头 ID
Timestamp orm.Time `json:"timestamp"` // Unix 时间戳 (毫秒)
Detections []AIDetection `json:"detections"` // 检测结果列表
Snapshot string `json:"snapshot"` // Base64 编码的快照 (JPEG)
SnapshotWidth int `json:"snapshot_width"` // 快照宽度
SnapshotHeight int `json:"snapshot_height"` // 快照高度
}
AIDetectionInput 检测事件回调请求体
type AIGlobalStats ¶
type AIGlobalStats struct {
ActiveStreams int `json:"active_streams"` // 活跃流数量
TotalDetections int64 `json:"total_detections"` // 总检测次数
UptimeSeconds int64 `json:"uptime_seconds"` // 运行时间 (秒)
}
AIGlobalStats 全局统计信息
type AIKeepaliveInput ¶
type AIKeepaliveInput struct {
Timestamp int64 `json:"timestamp"` // Unix 时间戳 (毫秒)
Stats *AIGlobalStats `json:"stats"` // 全局统计信息
Message string `json:"message"` // 附加消息
}
AIKeepaliveInput 心跳回调请求体
type AINormBox ¶
type AINormBox struct {
X float64 `json:"x"` // 中心点 X 坐标
Y float64 `json:"y"` // 中心点 Y 坐标
W float64 `json:"w"` // 宽度
H float64 `json:"h"` // 高度
}
AINormBox 归一化边界框
type AIStartedInput ¶
type AIStartedInput struct {
Timestamp int64 `json:"timestamp"` // Unix 时间戳 (毫秒)
Message string `json:"message"` // 启动消息
}
AIStartedInput 服务启动回调请求体
type AIStoppedInput ¶
type AIStoppedInput struct {
CameraID string `json:"camera_id"` // 摄像头 ID
Timestamp orm.Time `json:"timestamp"` // Unix 时间戳 (毫秒)
Reason string `json:"reason"` // 停止原因 (user_requested, error)
Message string `json:"message"` // 详细信息
}
AIStoppedInput 任务停止回调请求体
type AIWebhookAPI ¶
type AIWebhookAPI struct {
// contains filtered or unexported fields
}
AIWebhookAPI 处理 AI 分析服务的回调请求
func NewAIWebhookAPI ¶
NewAIWebhookAPI 创建 AI Webhook API 实例
func NewAIWebhookAPIWithDeps ¶
func NewAIWebhookAPIWithDeps(conf *conf.Bootstrap, eventCore event.Core, ipcBundle IPCBundle) AIWebhookAPI
NewAIWebhookAPIWithDeps 创建带依赖的 AI Webhook API
func (*AIWebhookAPI) ReloadAITask ¶ added in v1.3.34
ReloadAITask 停止再重启指定通道的 AI 任务,使区域、标签等配置立即生效 需要 StartAISyncLoop 已调用(smsCore 已注入)
func (*AIWebhookAPI) StartAIDetection ¶
func (a *AIWebhookAPI) StartAIDetection(ctx context.Context, ch *ipc.Channel, rtspURL string) (*protos.StartCameraResponse, error)
StartAIDetection 启动 AI 检测任务,供外部调用(如 ipc.go 中的 enableAI)
func (*AIWebhookAPI) StartAISyncLoop ¶
func (a *AIWebhookAPI) StartAISyncLoop(ctx context.Context, smsCore sms.Core)
StartAISyncLoop 启动 AI 任务同步协程,启动后立即执行一次同步,之后每 5 分钟检测一次 立即执行是为了在服务重启后尽快恢复之前开启的 AI 分析任务
func (*AIWebhookAPI) StopAIDetection ¶
func (a *AIWebhookAPI) StopAIDetection(ctx context.Context, channelID string) error
StopAIDetection 停止 AI 检测任务,供外部调用(如 ipc.go 中的 disableAI)
type AIWebhookOutput ¶
AIWebhookOutput 通用响应体
type Data ¶
type Data struct {
Buffer int `json:"Buffer"`
BufferLikeString int `json:"BufferLikeString"`
BufferList int `json:"BufferList"`
BufferRaw int `json:"BufferRaw"`
Frame int `json:"Frame"`
FrameImp int `json:"FrameImp"`
MediaSource int `json:"MediaSource"`
MultiMediaSourceMuxer int `json:"MultiMediaSourceMuxer"`
RtmpPacket int `json:"RtmpPacket"`
RtpPacket int `json:"RtpPacket"`
Socket int `json:"Socket"`
TCPClient int `json:"TcpClient"`
TCPServer int `json:"TcpServer"`
TCPSession int `json:"TcpSession"`
UDPServer int `json:"UdpServer"`
UDPSession int `json:"UdpSession"`
}
type DefaultOutput ¶
type EventAPI ¶
type EventAPI struct {
// contains filtered or unexported fields
}
EventAPI 为 http 提供业务方法
type IPCAPI ¶
type IPCAPI struct {
// contains filtered or unexported fields
}
func (IPCAPI) ListChannelsForDevice ¶ added in v1.4.21
type IPCBundle ¶ added in v1.3.34
type IPCBundle struct {
Core ipc.Core
Protocols map[string]ipc.Protocoler
}
IPCBundle 包含 ipc.Core 和 Protocols,用于解决循环依赖
func NewIPCCoreWithProtocols ¶ added in v1.3.34
func NewIPCCoreWithProtocols(store ipc.Storer, uni uniqueid.Core, adapter ipc.Adapter, smsCore sms.Core, gbsServer *gbs.Server, conf *conf.Bootstrap) IPCBundle
NewIPCCoreWithProtocols 创建 IPC Core 和 Protocols 先用临时 Core 构建 protocols(adapter 仅存引用,运行时才调用方法),再创建含 protocols 的最终 Core
type OriginSock ¶
type ProxyAPI ¶
type ProxyAPI struct {
// contains filtered or unexported fields
}
func NewProxyAPI ¶
type RecordingAPI ¶ added in v1.3.34
type RecordingAPI struct {
// contains filtered or unexported fields
}
RecordingAPI 为 http 提供业务方法
func NewRecordingAPI ¶ added in v1.3.34
func NewRecordingAPI(core recording.Core, conf *conf.Bootstrap) RecordingAPI
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
func (*Secret) GetOrCreatePublicKey ¶
TODO: 有概率存在过期导致登录解密识别
type Tracks ¶
type Tracks struct {
Channels int `json:"channels,omitempty"`
CodecID int `json:"codec_id"`
CodecIDName string `json:"codec_id_name"`
CodecType int `json:"codec_type"`
Ready bool `json:"ready"`
SampleBit int `json:"sample_bit,omitempty"`
SampleRate int `json:"sample_rate,omitempty"`
Fps float32 `json:"fps,omitempty"`
Height int `json:"height,omitempty"`
Width int `json:"width,omitempty"`
}
type Usecase ¶
type Usecase struct {
Conf *conf.Bootstrap
DB *gorm.DB
Version versionapi.API
SMSAPI SmsAPI
WebHookAPI WebHookAPI
UniqueID uniqueid.Core
GB28181API IPCAPI
ConfigAPI ConfigAPI
SipServer *gbs.Server
UserAPI UserAPI
AIWebhookAPI AIWebhookAPI
EventAPI EventAPI
RecordingAPI RecordingAPI
MetadataAPI metadataapi.MetadataAPI
}