gbs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NotifyMethodUserActive 设备活跃状态通知
	NotifyMethodDevicesActive = "devices.active"
	// NotifyMethodUserRegister 设备注册通知
	NotifyMethodDevicesRegister = "devices.regiester"
	// NotifyMethodDeviceActive 通道活跃通知
	NotifyMethodChannelsActive = "channels.active"
	// NotifyMethodRecordStop 视频录制结束
	NotifyMethodRecordStop = "records.stop"
)

Variables

View Source
var (
	ErrXMLDecode = errors.New("xml decode error")
	ErrDatabase  = errors.New("database error")
)
View Source
var (
	ErrDeviceNotExist  = errors.New("device not exist")
	ErrChannelNotExist = errors.New("channel not exist")

	ErrDeviceOffline  = errors.New("device offline")
	ErrChannelOffline = errors.New("channel offline")
)
View Source
var MODDEBUG = "DEBUG"

MODDEBUG MODDEBUG

View Source
var RecordList apiRecordList

key:ssrc value=channel 记录流录制

View Source
var StreamList streamsList

Functions

func CheckStreams

func CheckStreams()

定时检查未关闭的流 检查规则: 1. 数据库查询当前status=0在推流状态的所有流信息 2. 比对当前streamlist中存在的流,如果不在streamlist或者ssrc与channelid不匹配则关闭

func ClearFiles

func ClearFiles()

func LoadSYSInfo

func LoadSYSInfo()

func SipStopPlay

func SipStopPlay(ssrc string)

sip 停止播放

func Start

func Start()

func SyncDevicesCodec

func SyncDevicesCodec(ssrc, deviceid string)

同步摄像头编码格式

Types

type ActiveDevices

type ActiveDevices struct {
	sync.Map
}

ActiveDevices 记录当前活跃设备,请求播放时设备必须处于活跃状态

func (*ActiveDevices) Get

func (a *ActiveDevices) Get(key string) (Devices, bool)

Get Get

type Channel

type Channel struct {
	ChannelID string
	// contains filtered or unexported fields
}

func (*Channel) Conn

func (c *Channel) Conn() sip.Connection

Conn implements Targeter.

func (*Channel) Source

func (c *Channel) Source() net.Addr

Source implements Targeter.

func (*Channel) To

func (c *Channel) To() *sip.Address

To implements Targeter.

type Channels

type Channels struct {
	// db.DBModel
	// ChannelID 通道编码
	ChannelID string `xml:"DeviceID" json:"channelid" gorm:"column:channelid"`
	// DeviceID 设备编号
	DeviceID string `xml:"-" json:"deviceid"  gorm:"column:deviceid"`
	// Memo 备注(用来标示通道信息)
	MeMo string `json:"memo"  gorm:"column:memo"`
	// Name 通道名称(设备端设置名称)
	Name         string `xml:"Name" json:"name"  gorm:"column:name"`
	Manufacturer string `xml:"Manufacturer" json:"manufacturer"  gorm:"column:manufacturer"`
	Model        string `xml:"Model" json:"model"  gorm:"column:model"`
	Owner        string `xml:"Owner"  json:"owner"  gorm:"column:owner"`
	CivilCode    string `xml:"CivilCode" json:"civilcode"  gorm:"column:civilcode"`
	// Address ip地址
	Address     string `xml:"Address"  json:"address"  gorm:"column:address"`
	Parental    int    `xml:"Parental"  json:"parental"  gorm:"column:parental"`
	SafetyWay   int    `xml:"SafetyWay"  json:"safetyway"  gorm:"column:safetyway"`
	RegisterWay int    `xml:"RegisterWay"  json:"registerway"  gorm:"column:registerway"`
	Secrecy     int    `xml:"Secrecy" json:"secrecy"  gorm:"column:secrecy"`
	// Status 状态  on 在线
	Status string `xml:"Status"  json:"status"  gorm:"column:status"`
	// Active 最后活跃时间
	Active int64  `json:"active"  gorm:"column:active"`
	URIStr string ` json:"uri"  gorm:"column:uri"`

	// 视频编码格式
	VF string ` json:"vf"  gorm:"column:vf"`
	// 视频高
	Height int `json:"height"  gorm:"column:height"`
	// 视频宽
	Width int `json:"width"  gorm:"column:width"`
	// 视频FPS
	FPS int `json:"fps"  gorm:"column:fps"`
	//  pull 媒体服务器主动拉流,push 监控设备主动推流
	StreamType string `json:"streamtype"  gorm:"column:streamtype"`
	// streamtype=pull时,拉流地址
	URL string `json:"url"  gorm:"column:url"`
	// contains filtered or unexported fields
}

Channels 摄像头通道信息

type Client

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

Client 客户端链接信息等临时信息存储

func NewClient

func NewClient() *Client

func (*Client) Delete

func (c *Client) Delete(deviceID string)

func (*Client) GetChannel

func (c *Client) GetChannel(deviceID, channelID string) (*Channel, bool)

func (*Client) Load

func (c *Client) Load(deviceID string) (*Device, bool)

func (*Client) Store

func (c *Client) Store(deviceID string, in *Device)

type Device

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

func (*Device) Conn

func (d *Device) Conn() sip.Connection

Conn implements Targeter.

func (*Device) Source

func (d *Device) Source() net.Addr

Source implements Targeter.

func (*Device) To

func (d *Device) To() *sip.Address

To implements Targeter.

type Devices

type Devices struct {
	// db.DBModel
	// Name 设备名称
	Name string `json:"name" gorm:"column:name" `
	// DeviceID 设备id
	DeviceID string `json:"deviceid" gorm:"column:deviceid"`
	// Region 设备域
	Region string `json:"region" gorm:"column:region"`
	// Host Via 地址
	Host string `json:"host" gorm:"column:host"`
	// Port via 端口
	Port string `json:"port" gorm:"column:port"`
	// TransPort via transport
	TransPort string `json:"transport" gorm:"column:transport"`
	// Proto 协议
	Proto string `json:"proto" gorm:"column:proto"`
	// Rport via rport
	Rport string `json:"report" gorm:"column:report"`
	// RAddr via recevied
	RAddr string `json:"raddr"  gorm:"column:raddr"`
	// Manufacturer 制造厂商
	Manufacturer string `xml:"Manufacturer"  json:"manufacturer"  gorm:"column:manufacturer"`
	// 设备类型DVR,NVR
	DeviceType string `xml:"DeviceType"  json:"devicetype"  gorm:"column:devicetype"`
	// Firmware 固件版本
	Firmware string ` json:"firmware"  gorm:"column:firmware"`
	// Model 型号
	Model  string `json:"model"  gorm:"column:model"`
	URIStr string `json:"uri"  gorm:"column:uri"`
	// ActiveAt 最后心跳检测时间
	ActiveAt int64 `json:"active" gorm:"column:active"`
	// Regist 是否注册
	Regist bool `json:"regist"  gorm:"column:regist"`
	// PWD 密码
	PWD string `json:"pwd" gorm:"column:pwd"`
	// Source
	Source string `json:"source"  gorm:"column:source"`

	Sys m.SysInfo `json:"sysinfo" gorm:"-"`

	Expire string `json:"-"`
	// contains filtered or unexported fields
}

Devices NVR 设备信息

type Files

type Files struct {
	// db.DBModel
	Start  int64  `json:"start" bson:"start"`
	End    int64  `json:"end" bson:"end"`
	Stream string `json:"stream" bson:"stream"`
	FID    string `json:"fid" bson:"fid"`
	Status int    `json:"status" bson:"status"`
	File   string `json:"file" bson:"file"`
	Clear  bool   `json:"clear" bson:"clear"`
	// contains filtered or unexported fields
}

Files Files

type GB28181API

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

func NewGB28181API

func NewGB28181API(cfg *conf.Bootstrap, store gb28181.GB28181, sms *sms.NodeManager) *GB28181API

func (*GB28181API) Play

func (g *GB28181API) Play(in *PlayInput) error

func (*GB28181API) QueryCatalog

func (g *GB28181API) QueryCatalog(deviceID string) error

QueryCatalog 设备目录查询或订阅请求 GB/T28181 81 页 A.2.4.3

func (GB28181API) QueryDeviceInfo

func (g GB28181API) QueryDeviceInfo(ctx *sip.Context)

QueryDeviceInfo 设备信息查询请求 GB/T28181 81 页 A.2.4.4

func (*GB28181API) StopPlay

func (g *GB28181API) StopPlay(in *StopPlayInput) error

type MessageDeviceInfoResponse

type MessageDeviceInfoResponse struct {
	CmdType      string `xml:"CmdType"`
	SN           int    `xml:"SN"`
	DeviceID     string `xml:"DeviceID"`     // 目标设备的编码(必选)
	DeviceName   string `xml:"DeviceName"`   // 目标设备的名称(可选
	Manufacturer string `xml:"Manufacturer"` // 设备生产商(可选)
	Model        string `xml:"Model"`        // 设备型号(可选)
	Firmware     string `xml:"Firmware"`     // 设备固件版本(可选)
	Result       string `xml:"Result"`       // 査询结果(必选)
}

MessageDeviceInfoResponse 设备信息查询应答结构

type MessageDeviceListResponse

type MessageDeviceListResponse struct {
	XMLName  xml.Name   `xml:"Response"`
	CmdType  string     `xml:"CmdType"`
	SN       int        `xml:"SN"`
	DeviceID string     `xml:"DeviceID"`
	SumNum   int        `xml:"SumNum"`
	Item     []Channels `xml:"DeviceList>Item"`
}

MessageDeviceListResponse 设备明细列表返回结构

type MessageNotify

type MessageNotify struct {
	CmdType  string `xml:"CmdType"`
	SN       int    `xml:"SN"`
	DeviceID string `xml:"DeviceID"`
	Status   string `xml:"Status"`
	Info     string `xml:"Info"`
}

MessageNotify 心跳包xml结构

type MessageRecordInfoResponse

type MessageRecordInfoResponse struct {
	CmdType  string       `xml:"CmdType"`
	SN       int          `xml:"SN"`
	DeviceID string       `xml:"DeviceID"`
	SumNum   int          `xml:"SumNum"`
	Item     []RecordItem `xml:"RecordList>Item"`
}

MessageRecordInfoResponse 目录列表

type Notify

type Notify struct {
	Method string      `json:"method"`
	Data   interface{} `json:"data"`
}

Notify 消息通知结构

type PlayInput

type PlayInput struct {
	Channel    *gb28181.Channel
	SMS        *sms.MediaServer
	StreamMode int8
}

type RecordDate

type RecordDate struct {
	// 日期
	Date string `json:"date"`
	// 时间段
	Items []RecordInfo `json:"items"`
}

type RecordInfo

type RecordInfo struct {
	Start int64 `json:"start" bson:"start"`
	End   int64 `json:"end" bson:"end"`
}

RecordInfo RecordInfo

type RecordItem

type RecordItem struct {
	// DeviceID 设备编号
	DeviceID string `xml:"DeviceID" bson:"DeviceID" json:"DeviceID"`
	// Name 设备名称
	Name      string `xml:"Name" bson:"Name" json:"Name"`
	FilePath  string `xml:"FilePath" bson:"FilePath" json:"FilePath"`
	Address   string `xml:"Address" bson:"Address" json:"Address"`
	StartTime string `xml:"StartTime" bson:"StartTime" json:"StartTime"`
	EndTime   string `xml:"EndTime" bson:"EndTime" json:"EndTime"`
	Secrecy   int    `xml:"Secrecy" bson:"Secrecy" json:"Secrecy"`
	Type      string `xml:"Type" bson:"Type" json:"Type"`
}

RecordItem 目录详情

type Records

type Records struct {
	// 存在录像的天数
	DayTotal int          `json:"daynum"`
	TimeNum  int          `json:"timenum"`
	Data     []RecordDate `json:"list"`
}

Records Records

func SipRecordList

func SipRecordList(to *Channels, start, end int64) (*Records, error)

获取录像文件列表

type RequestOption

type RequestOption func(*sip.Request)

type Server

type Server struct {
	*sip.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *conf.Bootstrap, store gb28181.GB28181, sc sms.Core) (*Server, func())

func (*Server) Play

func (s *Server) Play(in *PlayInput) error

func (*Server) QueryCatalog

func (s *Server) QueryCatalog(deviceID string) error

QueryCatalog 查询 catalog

func (*Server) StopPlay

func (s *Server) StopPlay(in *StopPlayInput) error

type StopPlayInput

type StopPlayInput struct {
	Channel *gb28181.Channel
}

type Streams

type Streams struct {
	// 0  直播 1 历史
	T int `json:"t" gorm:"column:t"`
	// 设备ID
	DeviceID string `json:"deviceid" gorm:"column:deviceid"`
	// 通道ID
	ChannelID string `json:"channelid" gorm:"column:channelid"`
	//  pull 媒体服务器主动拉流,push 监控设备主动推流
	StreamType string `json:"streamtype" gorm:"column:streamtype"`
	// 0正常 1关闭 -1 尚未开始
	Status int `json:"status" gorm:"column:status"`
	// header from params
	// Ftag db.M `gorm:"column:ftag" sql:"type:json" json:"-"`
	// header to params
	// Ttag db.M `gorm:"column:ttag" sql:"type:json" json:"-"`
	// header callid
	CallID string `json:"callid" gorm:"column:callid"`
	// 是否停止
	Stop   bool   `json:"stop" gorm:"column:stop"`
	Msg    string `json:"msg" gorm:"column:msg"`
	CseqNo uint32 `json:"cseqno" gorm:"column:cseqno"`
	// 视频流ID gb28181的ssrc
	StreamID string `json:"streamid"  gorm:"column:streamid"`
	// m3u8播放地址
	HTTP string `json:"http" gorm:"column:http"`
	// rtmp 播放地址
	RTMP string `json:"rtmp" gorm:"column:rtmp"`
	// rtsp 播放地址
	RTSP string `json:"rtsp" gorm:"column:rtsp"`
	// flv 播放地址
	WSFLV string `json:"wsflv" gorm:"column:wsflv"`
	// zlm是否收到流
	Stream bool `json:"stream" gorm:"column:stream"`

	// ---
	S, E time.Time `json:"-" gorm:"-"`

	Ext  int64         `json:"-" gorm:"-"` // 流等待过期时间
	Resp *sip.Response `json:"-" gorm:"-"`
	// contains filtered or unexported fields
}

Streams Streams

func SipPlay

func SipPlay(data *Streams) (*Streams, error)

sip 请求播放

type Targeter

type Targeter interface {
	To() *sip.Address
	Conn() sip.Connection
	Source() net.Addr
}

Directories

Path Synopsis
m

Jump to

Keyboard shortcuts

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