Documentation ¶
Index ¶
- Variables
- func GetTXKey(msg *sip.Message) (key string)
- type Config
- type Core
- func (c *Core) GetTX(key string) *GBTx
- func (c *Core) HandleReceiveMessage(p *transport.Packet) (err error)
- func (c *Core) MustTX(key string) *GBTx
- func (c *Core) NewTX(key string) *GBTx
- func (c *Core) RegistHandler(method Method, handler RequestHandler)
- func (c *Core) Request(req *Request) (*GBTx, error)
- func (c *Core) ResolveAddress(msg *Message) (destAddr net.Addr, err error)
- func (c *Core) Respond(resp *Response) (*GBTx, error)
- func (c *Core) SipRequestForResponse(req *Request) (response *Response, err error)
- func (c *Core) StartAndWait()
- type GBTx
- func (tx *GBTx) Close()
- func (tx *GBTx) GetResponse() *sip.Response
- func (tx *GBTx) Key() string
- func (tx *GBTx) ReceiveResponse(msg *sip.Response)
- func (tx *GBTx) Request(req *sip.Request) error
- func (tx *GBTx) Respond(res *sip.Response) error
- func (tx *GBTx) SipRequestForResponse(req *sip.Request) (response *sip.Response, err error)
- func (tx *GBTx) SipResponse() (*sip.Response, error)
- type GBTxs
- type RequestHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorSyntax = errors.New("message syntax error") ErrorCheck = errors.New("message check failed") ErrorParse = errors.New("message parse failed") ErrorUnknown = errors.New("message unknown") )
transaction 的错误定义
Functions ¶
Types ¶
type Config ¶
type Config struct { //sip服务器的配置 SipNetwork string //传输协议,默认UDP,可选TCP SipIP string //sip 服务器公网IP SipPort uint16 //sip 服务器端口,默认 5060 Serial string //sip 服务器 id, 默认 34020000002000000001 Realm string //sip 服务器域,默认 3402000000 Username string //sip 服务器账号 Password string //sip 服务器密码 AckTimeout uint16 //sip 服务应答超时,单位秒 RegisterValidity int //注册有效期,单位秒,默认 3600 RegisterInterval int //注册间隔,单位秒,默认 60 HeartbeatInterval int //心跳间隔,单位秒,默认 60 HeartbeatRetry int //心跳超时次数,默认 3 //媒体服务器配置 MediaIP string //媒体服务器地址 MediaPort uint16 //媒体服务器端口 MediaPortMin uint16 MediaPortMax uint16 MediaIdleTimeout uint16 //推流超时时间,超过则断开链接,让设备重连 AudioEnable bool //是否开启音频 LogVerbose bool WaitKeyFrame bool //是否等待关键帧,如果等待,则在收到第一个关键帧之前,忽略所有媒体流 RemoveBanInterval int //移除禁止设备间隔 UdpCacheSize int //udp缓存大小 }
type Core ¶
type Core struct { *Config //sip server配置信息 OnRegister func(msg *Request, tx *GBTx) OnMessage func(msg *Request, tx *GBTx) // contains filtered or unexported fields }
Core: transactions manager 管理所有 transactions,以及相关全局参数、运行状态机
func NewCore ¶
初始化一个 Core,需要能响应请求,也要能发起请求 client 发起请求 server 响应请求 TODO:根据角色,增加相关配置信息 TODO:通过context管理子线程 TODO:单元测试
func (*Core) HandleReceiveMessage ¶
接收到的消息处理 收到消息有两种:1、请求消息 2、响应消息 请求消息则直接响应处理。 响应消息则需要匹配到请求,让请求的transaction来处理。 TODO:参考srs和osip的流程,以及文档,做最终处理。需要将逻辑分成两层:TU 层和 transaction 层
func (*Core) RegistHandler ¶ added in v3.0.4
func (c *Core) RegistHandler(method Method, handler RequestHandler)
RegistHandler RegistHandler
func (*Core) ResolveAddress ¶ added in v3.0.8
func (*Core) SipRequestForResponse ¶ added in v3.0.4
func (*Core) StartAndWait ¶ added in v3.0.4
func (c *Core) StartAndWait()
type GBTx ¶ added in v3.0.4
type GBTx struct { *Core // contains filtered or unexported fields }
GBTx Gb28181 Transaction
func NewTransaction ¶ added in v3.0.4
NewTransaction create a new GBtx
func (*GBTx) Close ¶ added in v3.0.4
func (tx *GBTx) Close()
Close the Close function closes the GBTx
func (*GBTx) GetResponse ¶ added in v3.0.4
GetResponse GetResponse
func (*GBTx) ReceiveResponse ¶ added in v3.0.4
ReceiveResponse receive a Response
func (*GBTx) SipRequestForResponse ¶ added in v3.0.4
type GBTxs ¶ added in v3.0.4
GBTxs a GBTxs stands for a Gb28181 Transaction collection
var ActiveTX *GBTxs
type RequestHandler ¶ added in v3.0.4
type RequestHandler func(req *Request, tx *GBTx)
Click to show internal directories.
Click to hide internal directories.