mirror of
https://github.com/gowvp/gb28181.git
synced 2026-04-22 15:07:10 +08:00
113 lines
3.5 KiB
Go
Executable File
113 lines
3.5 KiB
Go
Executable File
// Code generated by godddx, DO AVOID EDIT.
|
|
package ipc
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"encoding/json"
|
|
|
|
"github.com/gowvp/owl/internal/core/bz"
|
|
"github.com/ixugo/goddd/pkg/orm"
|
|
)
|
|
|
|
const (
|
|
TypeGB28181 = "GB28181"
|
|
TypeOnvif = "ONVIF"
|
|
TypeRTSP = "RTSP"
|
|
TypeRTMP = "RTMP"
|
|
)
|
|
|
|
func GetType(stream string) string {
|
|
switch true {
|
|
case bz.IsGB28181(stream):
|
|
return TypeGB28181
|
|
case bz.IsOnvif(stream):
|
|
return TypeOnvif
|
|
case bz.IsRTSP(stream):
|
|
return TypeRTSP
|
|
case bz.IsRTMP(stream):
|
|
return TypeRTMP
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
// DeviceExt domain model
|
|
type DeviceExt struct {
|
|
Manufacturer string `json:"manufacturer"` // 生产厂商
|
|
Model string `json:"model"` // 型号
|
|
Firmware string `json:"firmware"` // 固件版本
|
|
Name string `json:"name"` // 设备名
|
|
GBVersion string `json:"gb_version"` // GB版本
|
|
Zones []Zone `json:"zones"` // 区域
|
|
EnabledAI bool `json:"enabled_ai"` // 是否启用 AI
|
|
|
|
// 空串表示 always
|
|
RecordMode string `json:"record_mode"` // 录像模式, 一直录制:always, 按AI触发:ai, 不录制:none
|
|
}
|
|
|
|
func (e *DeviceExt) GetRecordMode() string {
|
|
if e.RecordMode == "" {
|
|
return "always"
|
|
}
|
|
return e.RecordMode
|
|
}
|
|
|
|
func (e *DeviceExt) IsAlwaysRecord() bool {
|
|
return e.RecordMode == "always" || e.RecordMode == ""
|
|
}
|
|
|
|
func (e *DeviceExt) IsAIRecord() bool {
|
|
return e.RecordMode == "ai"
|
|
}
|
|
|
|
func (e *DeviceExt) IsNoneRecord() bool {
|
|
return e.RecordMode == "none"
|
|
}
|
|
|
|
// Scan implements orm.Scaner.
|
|
func (i *DeviceExt) Scan(input any) error {
|
|
return orm.JSONUnmarshal(input, i)
|
|
}
|
|
|
|
func (i DeviceExt) Value() (driver.Value, error) {
|
|
return json.Marshal(i)
|
|
}
|
|
|
|
type Zone struct {
|
|
Name string `json:"name"` // 区域名称
|
|
Coordinates []float32 `json:"coordinates"` // 坐标
|
|
Color string `json:"color"` // 颜色,支持 hex 颜色值,如 #FF0000
|
|
Labels []string `json:"labels"` // 标签
|
|
}
|
|
|
|
// StreamConfig 流配置,用于 RTMP 推流和 RTSP 拉流代理
|
|
type StreamConfig struct {
|
|
// RTMP 推流配置
|
|
IsAuthDisabled bool `json:"is_auth_disabled"` // 是否禁用推流鉴权
|
|
Session string `json:"session,omitempty"` // 推流鉴权参数(由推流客户端携带)
|
|
PushedAt *orm.Time `json:"pushed_at"` // 最后推流时间
|
|
StoppedAt *orm.Time `json:"stopped_at"` // 最后停止时间
|
|
MediaServerID string `json:"media_server_id"` // 媒体服务器 ID
|
|
PushAddr string `json:"push_addr,omitempty"` // 推流地址(动态生成,不持久化)
|
|
|
|
// RTSP 拉流配置
|
|
SourceURL string `json:"source_url"` // 原始 URL
|
|
Transport int `json:"transport"` // 拉流方式 (0:tcp, 1:udp)
|
|
TimeoutS int `json:"timeout_s"` // 超时时间
|
|
EnabledAudio bool `json:"enabled_audio"` // 是否启用音频
|
|
EnabledRemoveNoneReader bool `json:"enabled_remove_none_reader"` // 无人观看时删除
|
|
EnabledDisabledNoneReader bool `json:"enabled_disabled_none_reader"` // 无人观看时禁用
|
|
StreamKey string `json:"stream_key"` // ZLM 返回的 key
|
|
Enabled bool `json:"enabled"` // 是否启用
|
|
}
|
|
|
|
// Scan implements orm.Scanner
|
|
func (s *StreamConfig) Scan(input any) error {
|
|
return orm.JSONUnmarshal(input, s)
|
|
}
|
|
|
|
// Value implements driver.Valuer
|
|
func (s StreamConfig) Value() (driver.Value, error) {
|
|
return json.Marshal(s)
|
|
}
|