api

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: GPL-3.0 Imports: 69 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 NewEventCore

func NewEventCore(db *gorm.DB, conf *conf.Bootstrap) event.Core

func NewGBAdapter

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

func NewHTTPHandler

func NewHTTPHandler(uc *Usecase) http.Handler

NewHTTPHandler 生成Gin框架路由内容

func NewIPCCore

func NewIPCCore(store ipc.Storer, uni uniqueid.Core, protocols map[string]ipc.Protocoler) ipc.Core

func NewIPCStore

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

func NewProtocols

func NewProtocols(adapter ipc.Adapter, sms sms.Core, ipcCore ipc.Core, gbs *gbs.Server) map[string]ipc.Protocoler

NewProtocols 创建协议适配器映射

func NewProxyCore

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

func NewSMSCore

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

func NewUniqueID

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

NewUniqueID 唯一 id 生成器

func RegisterEvent

func RegisterEvent(g gin.IRouter, api EventAPI, handler ...gin.HandlerFunc)

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, ipcCore ipc.Core) AIWebhookAPI

NewAIWebhookAPIWithDeps 创建带依赖的 AI Webhook API

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 分钟检测一次数据库中 enabled_ai 状态与内存 aiTasks 的差异并同步

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(core ipc.Core) IPCAPI

func (IPCAPI) FindChannelsForDevice

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

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 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
}

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, ipcCore ipc.Core, protocols map[string]ipc.Protocoler) WebHookAPI

Jump to

Keyboard shortcuts

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