model

package
v0.0.0-...-40e65af Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

+build srs

+build srs

Index

Constants

This section is empty.

Variables

View Source
var (
	// GRWLock 数据库全局读写锁
	GRWLock *sync.RWMutex
)

Functions

func GetDbHandler

func GetDbHandler() (db *gorm.DB, err error)

GetDbHandler 获取数据库句柄

Types

type Device

type Device struct {
	ID                 string `json:"ID"`
	Name               string `json:"Name"`
	Manufacturer       string `json:"Manufacturer"`
	Type               string `json:"Type"`
	Password           string `json:"Password"`
	MediaTransport     string `json:"MediaTransport"`
	MediaTransportMode string `json:"MediaTransportMode"`
	CommandTransport   string `json:"CommandTransport"`
	RemoteIP           string `json:"RemoteIP"`
	RemotePort         int    `json:"RemotePort"`
	Online             bool   `json:"Online"`
	RecordCenter       bool   `json:"RecordCenter"`
	RecordIndistinct   bool   `json:"RecordIndistinct"`
	CivilCodeFirst     bool   `json:"CivilCodeFirst"`
	ChannelCount       int    `json:"ChannelCount"`
	RecvStreamIP       string `json:"RecvStreamIP"`
	SMSID              string `json:"SMSID"`
	ContactIP          string `json:"ContactIP"`
	Charset            string `json:"Charset"`
	CatalogInterval    int    `json:"CatalogInterval"`
	SubscribeInterval  int    `json:"SubscribeInterval"`
	Longitude          int    `json:"Longitude"`
	Latitude           int    `json:"Latitude"`
	LastRegisterAt     MyTime `json:"LastRegisterAt" gorm:"type:datetime"`
	LastKeepaliveAt    MyTime `json:"LastKeepaliveAt" gorm:"type:datetime"`
	CreatedAt          MyTime `json:"CreatedAt" gorm:"type:datetime"`
	UpdatedAt          MyTime `json:"UpdatedAt" gorm:"type:datetime"`
}

Device 设备字段

func DeviceList

func DeviceList() ([]*Device, error)

DeviceList 查询设备列表

func (*Device) ChannelList

func (d *Device) ChannelList() ([]*DeviceChannel, error)

ChannelList 查询设备通道列表

func (*Device) DeviceInfo

func (d *Device) DeviceInfo() error

DeviceInfo 查询设备

type DeviceChannel

type DeviceChannel struct {
	ID             string `json:"ID"`           //通道编号
	DeviceID       string `json:"DeviceID"`     //设备编号
	DeviceName     string `json:"DeviceName"`   //设备名称
	DeviceOnline   bool   `json:"DeviceOnline"` //设备在线状态
	Channel        int    `json:"Channel"`      //通道序号
	Name           string `json:"Name"`         //通道名称
	Address        string `json:"Address"`
	Altitude       int    `json:"Altitude"`
	AudioEnable    bool   `json:"AudioEnable"`
	BatteryLevel   int    `json:"BatteryLevel"`
	Block          string `json:"Block"`
	CivilCode      string `json:"CivilCode"`
	CloudRecord    bool   `json:"CloudRecord"`
	CreatedAt      string `json:"CreatedAt"`
	Custom         bool   `json:"Custom"`
	CustomName     string `json:"CustomName"`
	CustomPTZType  int    `json:"CustomPTZType"`
	CustomParentID string `json:"CustomParentID"`
	Direction      int    `json:"Direction,omitempty"`
	DownloadSpeed  string `json:"DownloadSpeed"`
	Latitude       int    `json:"Latitude"`
	Longitude      int    `json:"Longitude"`
	Manufacturer   string `json:"Manufacturer"`
	Model          string `json:"Model"`
	NumOutputs     int    `json:"NumOutputs"`
	Ondemand       bool   `json:"Ondemand"`
	Owner          string `json:"Owner"`
	PTZType        int    `json:"PTZType"`
	ParentID       string `json:"ParentID"`
	Parental       int    `json:"Parental"`
	Quality        string `json:"Quality"`
	RegisterWay    int    `json:"RegisterWay"`
	Secrecy        int    `json:"Secrecy"`
	Shared         bool   `json:"Shared"`
	SignalLevel    int    `json:"SignalLevel"`
	SnapURL        string `json:"SnapURL,omitempty"` //通道快照链接
	Speed          int    `json:"Speed"`
	Status         string `json:"Status"`
	StreamID       string `json:"StreamID,omitempty"` //直播流ID, 有值表示正在直播
	SubCount       int    `json:"SubCount"`           //子节点数, SubCount > 0 表示该通道为子目录
	UpdatedAt      string `json:"UpdatedAt"`
}

type DiskInfo

type DiskInfo struct {
	Name      string `json:"Name"`
	Unit      string `json:"Unit"`
	Size      string `json:"Size"`
	FreeSpace string `json:"FreeSpace"`
	Used      string `json:"Used"`
	Percent   string `json:"Percent"`
	Threshold string `json:"Threshold"`
}

DiskInfo 存储使用

func DiskStore

func DiskStore() []*DiskInfo

DiskStore disk

type MyTime

type MyTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

MyTime 自定义时间格式

func (MyTime) MarshalJSON

func (nt MyTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json Valuer interface

func (*MyTime) Scan

func (nt *MyTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (MyTime) String

func (nt MyTime) String() string

String implements the interface to string

func (*MyTime) UnmarshalJSON

func (nt *MyTime) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the Json interface

func (MyTime) Value

func (nt MyTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type ResourceUsage

type ResourceUsage struct {
	Time string  `json:"time"`
	Use  float64 `json:"use"`
}

ResourceUsage CPU OR Memory

func CPUUsage

func CPUUsage() []*ResourceUsage

CPUUsage xx

func MemUsage

func MemUsage() []*ResourceUsage

MemUsage 内存占用

type Stream

type Stream struct {
	DeviceID              string `json:"DeviceID"`  //设备编号
	ChannelID             string `json:"ChannelID"` //通道编号
	AudioEnable           bool   `json:"AudioEnable"`
	CDN                   string `json:"CDN"`
	CascadeSize           int    `json:"CascadeSize"`
	ChannelCustomName     string `json:"ChannelCustomName"`
	ChannelName           string `json:"ChannelName"`
	ChannelPTZType        int    `json:"ChannelPTZType"`
	Duration              int    `json:"Duration"`
	FLV                   string `json:"FLV"`
	HLS                   string `json:"HLS"`
	InBitRate             int    `json:"InBitRate"`
	InBytes               int    `json:"InBytes"`
	NumOutputs            int    `json:"NumOutputs"`
	Ondemand              bool   `json:"Ondemand"`
	OutBytes              int    `json:"OutBytes"`
	RTMP                  string `json:"RTMP"`
	RTSP                  string `json:"RTSP"`
	RecordStartAt         string `json:"RecordStartAt"`
	RelaySize             int    `json:"RelaySize"`
	SnapURL               string `json:"SnapURL"`
	SourceAudioCodecName  string `json:"SourceAudioCodecName"`
	SourceAudioSampleRate int    `json:"SourceAudioSampleRate"`
	SourceVideoCodecName  string `json:"SourceVideoCodecName"`
	SourceVideoFrameRate  int    `json:"SourceVideoFrameRate"`
	SourceVideoHeight     int    `json:"SourceVideoHeight"`
	SourceVideoWidth      int    `json:"SourceVideoWidth"`
	StartAt               string `json:"StartAt"`
	StreamID              string `json:"StreamID"`
	Transport             string `json:"Transport"`
	WSFLV                 string `json:"WS_FLV"`
}

func (*Stream) Start

func (s *Stream) Start() error

Start 获取拉流地址

func (*Stream) Stop

func (s *Stream) Stop() error

Stop 停止BYE 获取拉流地址

type User

type User struct {
	gorm.Model
	Username      string    `form:"username" gorm:"type:varchar(255);unique_index" binding:"required" `
	Password      string    `form:"password" gorm:"type:varchar(255)" binding:"required" `
	Role          string    `form:"-" gorm:"type:varchar(255)"`
	Enable        bool      `form:"-" gorm:"DEFAULT:true"`
	HasAllChannel bool      `form:"-" `
	Creator       string    `form:"-" gorm:"type:varchar(255)"`
	LastLoginAt   time.Time `form:"-" `
	URLTokenOnly  bool      `form:"url_token_only" gorm:"-"`
}

User 用户信息

func (*User) GetPasswordHash

func (u *User) GetPasswordHash() string

GetPasswordHash 获取密码hash

func (User) TableName

func (User) TableName() string

TableName

func (*User) Verify

func (u *User) Verify() bool

Verify 验证密码

Jump to

Keyboard shortcuts

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