Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAlarmResponseXML(id string) string
- func BuildCatalogXML(sn int, id string) string
- func BuildDeviceInfoXML(sn int, id string) string
- func BuildDevicePositionXML(sn int, id string, interval int) string
- func BuildPresetListXML(sn int, id string) string
- func BuildRecordInfoXML(sn int, id string, start, end int64) string
- func CreateRequest(exposedId string, Method sip.RequestMethod, recipient *sip.Address, ...) (req sip.Request)
- func Explain(statusCode int) string
- func GetSipServer(transport string) gosip.Server
- func NewRecordQueryLink(resultTimeout time.Duration) *recordQueryLink
- func Pack(cmd, point byte) string
- func RequestForResponse(transport string, request sip.Request, ...) (sip.Response, error)
- func XmlEncode(v interface{}) (string, error)
- type Authorization
- type Channel
- func (channel *Channel) Bye(streamPath string) int
- func (channel *Channel) CanInvite() bool
- func (channel *Channel) Control(PTZCmd string) int
- func (channel *Channel) CreateRequst(Method sip.RequestMethod) (req sip.Request)
- func (channel *Channel) Invite(opt *InviteOptions) (code int, err error)
- func (c *Channel) MarshalJSON() ([]byte, error)
- func (channel *Channel) Pause(streamPath string) int
- func (channel *Channel) PlayAt(streamPath string, second uint) int
- func (channel *Channel) PlayForward(streamPath string, speed float32) int
- func (channel *Channel) PresetControl(ptzCode int, point byte) int
- func (channel *Channel) QueryPresetList() (sip.Response, error)
- func (channel *Channel) QueryRecord(startTime, endTime string) ([]*Record, error)
- func (channel *Channel) Resume(streamPath string) int
- func (channel *Channel) TryAutoInvite(opt *InviteOptions)
- type ChannelInfo
- type ChannelStatus
- type Device
- func (d *Device) Catalog() int
- func (d *Device) CreateRequest(Method sip.RequestMethod) (req sip.Request)
- func (d *Device) MarshalJSON() ([]byte, error)
- func (d *Device) MobilePositionSubscribe(id string, expires time.Duration, interval time.Duration) (code int)
- func (d *Device) QueryDeviceInfo()
- func (d *Device) SipRequestForResponse(request sip.Request) (sip.Response, error)
- func (d *Device) Subscribe() int
- func (d *Device) UpdateChannelPosition(channelId string, gpsTime string, lng string, lat string)
- func (d *Device) UpdateChannelStatus(deviceList []*notifyMessage)
- func (d *Device) UpdateChannels(list ...ChannelInfo)
- type DevicePosition
- type DeviceStatus
- type GB28181Config
- func (c *GB28181Config) API_bye(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_control(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_get_position(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_invite(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_list(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_play_forward(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_play_pause(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_play_resume(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_play_seek(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_position(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_preset_control(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_preset_list(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_ptz(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) API_records(w http.ResponseWriter, r *http.Request)
- func (c *GB28181Config) IsMediaNetworkTCP() bool
- func (c *GB28181Config) OnBye(req sip.Request, tx sip.ServerTransaction)
- func (c *GB28181Config) OnEvent(event any)
- func (c *GB28181Config) OnMessage(req sip.Request, tx sip.ServerTransaction)
- func (c *GB28181Config) OnNotify(req sip.Request, tx sip.ServerTransaction)
- func (c *GB28181Config) OnRegister(req sip.Request, tx sip.ServerTransaction)
- func (c *GB28181Config) ReadDevices()
- func (c *GB28181Config) RecoverDevice(d *Device, req sip.Request)
- func (c *GB28181Config) SaveDevices()
- func (c *GB28181Config) StoreDevice(id string, req sip.Request) (d *Device)
- type GB28181PositionConfig
- type InviteOptions
- type MessageEvent
- type MessagePtz
- type NotifyEvent
- type PortManager
- type Preset
- type PresetCmd
- type PresetInfo
- type PullStream
- type Record
Constants ¶
View Source
const ( ChannelOnStatus = "ON" ChannelOffStatus = "OFF" )
View Source
const ( INVIDE_MODE_MANUAL = iota INVIDE_MODE_AUTO INVIDE_MODE_ONSUBSCRIBE )
View Source
const ( DeviceRegisterStatus = "REGISTER" DeviceRecoverStatus = "RECOVER" DeviceOnlineStatus = "ONLINE" DeviceOfflineStatus = "OFFLINE" DeviceAlarmedStatus = "ALARMED" )
View Source
const ( PresetAddPoint = 0 PresetDelPoint = 1 PresetCallPoint = 2 )
View Source
const ( PresetSet = 0x81 PresetCall = 0x82 PresetDel = 0x83 )
View Source
const DeviceControl = "DeviceControl"
View Source
const MaxRegisterCount = 3
View Source
const PTZFirstByte = 0xA5
View Source
const TIME_LAYOUT = "2006-01-02T15:04:05"
Variables ¶
View Source
var ( Devices sync.Map DeviceNonce sync.Map //保存nonce防止设备伪造 DeviceRegisterCount sync.Map //设备注册次数 )
View Source
var ( // 获取预置位列表 PresentListXML = ` <?xml version="1.0"?> <Query> <CmdType>PresetQuery</CmdType> <SN>%d</SN> <DeviceID>%s</DeviceID> </Query> ` // CatalogXML 获取设备列表xml样式 CatalogXML = `<?xml version="1.0"?><Query> <CmdType>Catalog</CmdType> <SN>%d</SN> <DeviceID>%s</DeviceID> </Query> ` // RecordInfoXML 获取录像文件列表xml样式 RecordInfoXML = `` /* 191-byte string literal not displayed */ // DeviceInfoXML 查询设备详情xml样式 DeviceInfoXML = `<?xml version="1.0"?> <Query> <CmdType>DeviceInfo</CmdType> <SN>%d</SN> <DeviceID>%s</DeviceID> </Query> ` // DevicePositionXML 订阅设备位置 DevicePositionXML = `` /* 132-byte string literal not displayed */ )
View Source
var (
AlarmResponseXML = `<?xml version="1.0"?>
<Response>
<CmdType>Alarm</CmdType>
<SN>17430</SN>
<DeviceID>%s</DeviceID>
</Response>
`
)
AlarmResponseXML alarm response xml样式
View Source
var ErrNoAvailablePorts = errors.New("no available ports")
View Source
var GB28181Plugin = InstallPlugin(&conf)
View Source
var PullStreams sync.Map //拉流
View Source
var QUERY_RECORD_TIMEOUT = time.Second * 5
View Source
var RecordQueryLink = NewRecordQueryLink(time.Second * 60)
对于录像查询,通过 queryKey (即 deviceId + channelId + sn) 唯一区分一次请求和响应 并将其关联起来,以实现异步响应的目的 提供单例实例供调用
View Source
var SipUri *sip.SipUri
Functions ¶
func BuildAlarmResponseXML ¶
BuildRecordInfoXML 获取录像文件列表指令
func BuildDeviceInfoXML ¶
BuildDeviceInfoXML 获取设备详情指令
func BuildDevicePositionXML ¶
BuildDevicePositionXML 订阅设备位置
func BuildPresetListXML ¶ added in v4.4.6
func BuildRecordInfoXML ¶
BuildRecordInfoXML 获取录像文件列表指令
func CreateRequest ¶ added in v4.2.8
func GetSipServer ¶ added in v4.2.8
func NewRecordQueryLink ¶ added in v4.3.3
func RequestForResponse ¶ added in v4.2.8
Types ¶
type Authorization ¶
type Authorization struct {
*sip.Authorization
}
func (*Authorization) Verify ¶
func (a *Authorization) Verify(username, passwd, realm, nonce string) bool
type Channel ¶
type Channel struct { Device *Device `json:"-" yaml:"-"` // 所属设备 State atomic.Int32 `json:"-" yaml:"-"` // 通道状态,0:空闲,1:正在invite,2:正在播放/对讲 LiveSubSP string // 实时子码流,通过rtsp GpsTime time.Time // gps时间 Longitude string // 经度 Latitude string // 纬度 *log.Logger `json:"-" yaml:"-"` ChannelInfo }
func FindChannel ¶
func (*Channel) CreateRequst ¶
func (channel *Channel) CreateRequst(Method sip.RequestMethod) (req sip.Request)
func (*Channel) MarshalJSON ¶ added in v4.4.1
func (*Channel) PlayForward ¶ added in v4.3.5
func (*Channel) PresetControl ¶ added in v4.4.6
func (*Channel) QueryPresetList ¶ added in v4.4.6
func (*Channel) QueryRecord ¶
func (*Channel) TryAutoInvite ¶ added in v4.2.7
func (channel *Channel) TryAutoInvite(opt *InviteOptions)
type ChannelInfo ¶ added in v4.3.3
type ChannelInfo struct { DeviceID string // 通道ID ParentID string Name string Manufacturer string Model string Owner string CivilCode string Address string Port int Parental int SafetyWay int RegisterWay int Secrecy int Status ChannelStatus }
Channel 通道
type ChannelStatus ¶ added in v4.3.6
type ChannelStatus string
type Device ¶
type Device struct { ID string Name string Manufacturer string Model string Owner string RegisterTime time.Time UpdateTime time.Time LastKeepaliveAt time.Time Status DeviceStatus SN int Addr sip.Address `json:"-" yaml:"-"` SipIP string //设备对应网卡的服务器ip MediaIP string //设备对应网卡的服务器ip NetAddr string GpsTime time.Time //gps时间 Longitude string //经度 Latitude string //纬度 *log.Logger `json:"-" yaml:"-"` // contains filtered or unexported fields }
func (*Device) CreateRequest ¶
func (d *Device) CreateRequest(Method sip.RequestMethod) (req sip.Request)
func (*Device) MarshalJSON ¶ added in v4.2.3
func (*Device) MobilePositionSubscribe ¶
func (d *Device) MobilePositionSubscribe(id string, expires time.Duration, interval time.Duration) (code int)
MobilePositionSubscribe 移动位置订阅
func (*Device) QueryDeviceInfo ¶
func (d *Device) QueryDeviceInfo()
func (*Device) SipRequestForResponse ¶
func (*Device) UpdateChannelPosition ¶
UpdateChannelPosition 更新通道GPS坐标
func (*Device) UpdateChannelStatus ¶
func (d *Device) UpdateChannelStatus(deviceList []*notifyMessage)
UpdateChannelStatus 目录订阅消息处理:新增/移除/更新通道或者更改通道状态
func (*Device) UpdateChannels ¶
func (d *Device) UpdateChannels(list ...ChannelInfo)
type DevicePosition ¶ added in v4.2.0
type DeviceStatus ¶ added in v4.3.6
type DeviceStatus string
type GB28181Config ¶
type GB28181Config struct { InviteMode int `default:"1" desc:"拉流模式" enum:"0:手动拉流,1:预拉流,2:按需拉流"` //邀请模式,0:手动拉流,1:预拉流,2:按需拉流 InviteIDs string `default:"131,132" desc:"允许邀请的设备类型( 11~13位是设备类型编码),逗号分割"` //按照国标gb28181协议允许邀请的设备类型:132 摄像机 NVR ListenAddr string `default:"0.0.0.0" desc:"监听IP地址"` //监听地址 //sip服务器的配置 SipNetwork string `default:"udp" desc:"废弃,请使用 Port"` //传输协议,默认UDP,可选TCP SipIP string `desc:"sip 服务IP地址"` //sip 服务器公网IP SipPort sip.Port `default:"5060" desc:"废弃,请使用 Port"` //sip 服务器端口,默认 5060 Serial string `default:"34020000002000000001" desc:"sip 服务 id"` //sip 服务器 id, 默认 34020000002000000001 Realm string `default:"3402000000" desc:"sip 服务域"` //sip 服务器域,默认 3402000000 Username string `desc:"sip 服务账号"` //sip 服务器账号 Password string `desc:"sip 服务密码"` //sip 服务器密码 Port struct { Sip string `default:"udp:5060" desc:"sip服务端口号"` Media string `default:"tcp:58200-59200" desc:"媒体服务端口号"` Fdm bool `default:"false" desc:"多路复用"` } RegisterValidity time.Duration `default:"3600s" desc:"注册有效期"` //注册有效期,单位秒,默认 3600 HeartbeatInterval time.Duration `default:"60s" desc:"心跳间隔"` //心跳间隔,单位秒,默认 60 //媒体服务器配置 MediaIP string `desc:"媒体服务IP地址"` //媒体服务器地址 MediaPort uint16 `default:"58200" desc:"废弃,请使用 Port"` //媒体服务器端口 MediaNetwork string `default:"tcp" desc:"废弃,请使用 Port"` //媒体传输协议,默认UDP,可选TCP MediaPortMin uint16 `default:"58200" desc:"废弃,请使用 Port"` MediaPortMax uint16 `default:"59200" desc:"废弃,请使用 Port"` RemoveBanInterval time.Duration `default:"600s" desc:"移除禁止设备间隔"` //移除禁止设备间隔 DumpPath string `desc:"dump PS流本地文件路径"` //dump PS流本地文件路径 Ignores []string `desc:"忽略的设备ID"` //忽略的设备ID Position GB28181PositionConfig //关于定位的配置参数 // contains filtered or unexported fields }
func (*GB28181Config) API_bye ¶
func (c *GB28181Config) API_bye(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_control ¶
func (c *GB28181Config) API_control(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_get_position ¶ added in v4.2.0
func (c *GB28181Config) API_get_position(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_invite ¶
func (c *GB28181Config) API_invite(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_list ¶
func (c *GB28181Config) API_list(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_play_forward ¶ added in v4.3.5
func (c *GB28181Config) API_play_forward(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_play_pause ¶ added in v4.3.5
func (c *GB28181Config) API_play_pause(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_play_resume ¶ added in v4.3.5
func (c *GB28181Config) API_play_resume(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_play_seek ¶ added in v4.3.5
func (c *GB28181Config) API_play_seek(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_position ¶
func (c *GB28181Config) API_position(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_preset_control ¶ added in v4.4.6
func (c *GB28181Config) API_preset_control(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_preset_list ¶ added in v4.4.6
func (c *GB28181Config) API_preset_list(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_ptz ¶ added in v4.3.4
func (c *GB28181Config) API_ptz(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) API_records ¶
func (c *GB28181Config) API_records(w http.ResponseWriter, r *http.Request)
func (*GB28181Config) IsMediaNetworkTCP ¶
func (c *GB28181Config) IsMediaNetworkTCP() bool
func (*GB28181Config) OnBye ¶ added in v4.2.3
func (c *GB28181Config) OnBye(req sip.Request, tx sip.ServerTransaction)
func (*GB28181Config) OnEvent ¶
func (c *GB28181Config) OnEvent(event any)
func (*GB28181Config) OnMessage ¶
func (c *GB28181Config) OnMessage(req sip.Request, tx sip.ServerTransaction)
func (*GB28181Config) OnNotify ¶
func (c *GB28181Config) OnNotify(req sip.Request, tx sip.ServerTransaction)
OnNotify 订阅通知处理
func (*GB28181Config) OnRegister ¶
func (c *GB28181Config) OnRegister(req sip.Request, tx sip.ServerTransaction)
func (*GB28181Config) ReadDevices ¶ added in v4.2.3
func (c *GB28181Config) ReadDevices()
func (*GB28181Config) RecoverDevice ¶ added in v4.0.3
func (c *GB28181Config) RecoverDevice(d *Device, req sip.Request)
func (*GB28181Config) SaveDevices ¶ added in v4.2.3
func (c *GB28181Config) SaveDevices()
func (*GB28181Config) StoreDevice ¶
func (c *GB28181Config) StoreDevice(id string, req sip.Request) (d *Device)
type GB28181PositionConfig ¶ added in v4.2.0
type InviteOptions ¶ added in v4.0.1
type InviteOptions struct { Start int End int SSRC uint32 MediaPort uint16 StreamPath string // contains filtered or unexported fields }
func (*InviteOptions) CreateSSRC ¶ added in v4.0.1
func (o *InviteOptions) CreateSSRC()
func (InviteOptions) IsLive ¶ added in v4.0.1
func (o InviteOptions) IsLive() bool
func (InviteOptions) Record ¶ added in v4.0.1
func (o InviteOptions) Record() bool
func (InviteOptions) String ¶ added in v4.0.1
func (o InviteOptions) String() string
func (*InviteOptions) Validate ¶ added in v4.0.1
func (o *InviteOptions) Validate(start, end string) error
type MessageEvent ¶ added in v4.4.4
type MessagePtz ¶ added in v4.4.6
type NotifyEvent ¶ added in v4.4.4
type NotifyEvent MessageEvent
type PortManager ¶ added in v4.0.5
type PortManager struct { Valid bool // contains filtered or unexported fields }
func (*PortManager) GetPort ¶ added in v4.0.5
func (pm *PortManager) GetPort() (p uint16, err error)
func (*PortManager) Init ¶ added in v4.0.5
func (pm *PortManager) Init(start, end uint16)
func (*PortManager) Range ¶ added in v4.0.5
func (pm *PortManager) Range() uint16
func (*PortManager) Recycle ¶ added in v4.0.5
func (pm *PortManager) Recycle(p uint16) (err error)
type PresetInfo ¶ added in v4.4.6
type PullStream ¶ added in v4.3.0
type PullStream struct {
// contains filtered or unexported fields
}
func (*PullStream) Bye ¶ added in v4.3.0
func (p *PullStream) Bye() int
func (*PullStream) CreateRequest ¶ added in v4.3.5
func (p *PullStream) CreateRequest(method sip.RequestMethod) (req sip.Request)
func (*PullStream) PlayAt ¶ added in v4.3.5
func (p *PullStream) PlayAt(second uint) int
跳转到播放时间 second: 相对于起始点调整到第 sec 秒播放
func (*PullStream) PlayForward ¶ added in v4.3.5
func (p *PullStream) PlayForward(speed float32) int
快进/快退播放 speed 取值: 0.25 0.5 1 2 4 或者其对应的负数表示倒放
Source Files
¶
Click to show internal directories.
Click to hide internal directories.