api

package
v1.4.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: GPL-3.0 Imports: 82 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrAIGlobalDisabled    = reason.NewError("ErrAIGlobalDisabled", "AI 功能已在全局配置中禁用")
	ErrAIServiceNotReady   = reason.NewError("ErrAIServiceNotReady", "AI 服务未初始化或连接失败")
	ErrChannelNotSupported = reason.NewError("ErrChannelNotSupported", "不支持的通道类型")
)
View Source
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 NewEventCore(db *gorm.DB, conf *conf.Bootstrap, notifier event.Dispatcher) event.Core

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 NewGBAdapter

func NewGBAdapter(store ipc.Storer, uni uniqueid.Core) ipc.Adapter

func NewHTTPHandler

func NewHTTPHandler(uc *Usecase) http.Handler

NewHTTPHandler 生成Gin框架路由内容

func NewIPCProviderAdapter added in v1.4.21

func NewIPCProviderAdapter(ipcBundle IPCBundle) recording.IPCProvider

NewIPCProviderAdapter 创建 IPC 适配器,将 ipc.Core 适配为 recording.IPCProvider 用于录制同步时查询应录制的在线通道

func NewIPCStore

func NewIPCStore(db *gorm.DB) ipc.Storer

func NewNotifier added in v1.4.0

func NewNotifier(conf *conf.Bootstrap) *push.Notifier

NewNotifier 创建 webhook 推送器,Targets 为空时返回 nil(不推送)

func NewPlayProviderAdapter added in v1.4.21

func NewPlayProviderAdapter(smsCore sms.Core) recording.PlayProvider

NewPlayProviderAdapter 创建 Play 适配器,桥接拉流能力给录制同步使用 通过 ZLM getSnap 取最新快照触发拉流,所有协议通用

func NewProxyCore

func NewProxyCore(db *gorm.DB, uni uniqueid.Core) *proxy.Core

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

func NewRecordingStore(db *gorm.DB) recording.Storer

NewRecordingStore 创建录像存储层

func NewSMSCore

func NewSMSCore(db *gorm.DB, cfg *conf.Bootstrap) sms.Core

func NewSMSProviderAdapter added in v1.3.34

func NewSMSProviderAdapter(smsCore sms.Core) recording.SMSProvider

NewSMSProviderAdapter 创建 SMS 适配器,将 sms.Core 适配为 recording.SMSProvider 通过接口解耦 recording 领域与 sms 领域,避免循环依赖

func NewUniqueID

func NewUniqueID(db *gorm.DB) uniqueid.Core

NewUniqueID 唯一 id 生成器

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

func NewAIWebhookAPI(conf *conf.Bootstrap, eventCore event.Core, ipcCore ipc.Core) AIWebhookAPI

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

func (a *AIWebhookAPI) ReloadAITask(ctx context.Context, ch *ipc.Channel) error

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

type AIWebhookOutput struct {
	Code int    `json:"code"` // 错误代码,0 表示成功
	Msg  string `json:"msg"`  // 消息
}

AIWebhookOutput 通用响应体

type ConfigAPI

type ConfigAPI struct {
	// contains filtered or unexported fields
}

func NewConfigAPI

func NewConfigAPI(db *gorm.DB, conf *conf.Bootstrap) ConfigAPI

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 DefaultOutput struct {
	Code int    `json:"code"` // 错误代码,0 代表允许推流
	Msg  string `json:"msg"`  // 不允许推流时的错误提示
}

type EventAPI

type EventAPI struct {
	// contains filtered or unexported fields
}

EventAPI 为 http 提供业务方法

func NewEventAPI

func NewEventAPI(core event.Core, conf *conf.Bootstrap) EventAPI

type IOWriter

type IOWriter struct {
	// contains filtered or unexported fields
}

func (IOWriter) Write

func (w IOWriter) Write(b []byte) (int, error)

type IPCAPI

type IPCAPI struct {
	// contains filtered or unexported fields
}

func NewIPCAPI

func NewIPCAPI(bundle IPCBundle, recordingCore recording.Core) IPCAPI

func (IPCAPI) ListChannelsForDevice added in v1.4.21

func (a IPCAPI) ListChannelsForDevice(c *gin.Context, in *ipc.FindDeviceInput) (any, error)

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 KV

type KV struct {
	Key   string
	Value int64
}

type OriginSock

type OriginSock struct {
	Identifier string `json:"identifier"`
	LocalIP    string `json:"local_ip"`
	LocalPort  int    `json:"local_port"`
	PeerIP     string `json:"peer_ip"`
	PeerPort   int    `json:"peer_port"`
}

type ProxyAPI

type ProxyAPI struct {
	// contains filtered or unexported fields
}

func NewProxyAPI

func NewProxyAPI(proxyCore *proxy.Core) ProxyAPI

type PushAPI

type PushAPI struct {
	// contains filtered or unexported fields
}

func NewPushAPI

func NewPushAPI(mc push.Core, sc sms.Core, conf *conf.Bootstrap) PushAPI

NewPushAPI 媒体相关接口

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) Decrypt

func (s *Secret) Decrypt(ciphertext string) ([]byte, error)

func (*Secret) GetOrCreatePublicKey

func (s *Secret) GetOrCreatePublicKey() (*rsa.PublicKey, error)

TODO: 有概率存在过期导致登录解密识别

func (*Secret) MarshalPKIXPublicKey

func (s *Secret) MarshalPKIXPublicKey(key *rsa.PublicKey) []byte

type SmsAPI

type SmsAPI struct {
	// contains filtered or unexported fields
}

func NewSmsAPI

func NewSmsAPI(core sms.Core) SmsAPI

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
}

type UserAPI

type UserAPI struct {
	// contains filtered or unexported fields
}

func NewUserAPI

func NewUserAPI(conf *conf.Bootstrap) UserAPI

type WebHookAPI

type WebHookAPI struct {
	// contains filtered or unexported fields
}

func NewWebHookAPI

func NewWebHookAPI(core sms.Core, conf *conf.Bootstrap, gbs *gbs.Server, ipcBundle IPCBundle, recordingCore recording.Core, eventCore event.Core) WebHookAPI

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL