2 Star 0 Fork 0

slh92 / plugin-sip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
device_ctrl.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
slh92 提交于 2024-04-23 16:37 . update:新增控制指令定义
package sip
import (
"bytes"
"encoding/xml"
"gitee.com/slh1992/plugin-sip/utils"
"golang.org/x/net/html/charset"
)
type LiveType int
type ExecType int
const (
LIVE_STREAM_PUSH LiveType = iota
LIVE_CDN_PUSH
ExecStop ExecType = iota
ExecPlay
)
func (l LiveType) String() string {
switch l {
case LIVE_STREAM_PUSH:
return "LIVE_STREAM_PUSH"
case LIVE_CDN_PUSH:
return "LIVE_CDN_PUSH"
}
return "LIVE_UNKNOWN"
}
func (e ExecType) String() string {
switch e {
case ExecStop:
return "ExecStop"
case ExecPlay:
return "ExecPlay"
}
return "ExecUnknown"
}
type CmdCdnLiver struct {
XMLName xml.Name `xml:"Control"`
CmdType string
DeviceID string
SN string
LiveType LiveType //直播类型: 0:流媒体推流 1:CDN推流
ExecCmd ExecType // 执行类型: 0:stop 1:start
Endtimes uint64 //结束时间
}
type CmdCdnLiveResult struct {
XMLName xml.Name `xml:"Reponse"`
CmdType string
DeviceID string
SN string
Result string
Extends string //扩展数据
}
func (c *CmdCdnLiver) String() string {
xmlStr, err := XmlMashal(c)
if err != nil {
return ""
}
return xmlStr
}
func (c *CmdCdnLiver) Decode(data string) error {
decoder := xml.NewDecoder(bytes.NewReader([]byte(data)))
decoder.CharsetReader = charset.NewReaderLabel
err := decoder.Decode(c)
if err != nil {
err = utils.DecodeGbk(c, []byte(data))
if err != nil {
return err
}
}
return nil
}
func (r *CmdCdnLiveResult) String() string {
xmlStr, err := XmlMashal(r)
if err != nil {
return ""
}
return xmlStr
}
func (r *CmdCdnLiveResult) Decode(data string) error {
decoder := xml.NewDecoder(bytes.NewReader([]byte(data)))
decoder.CharsetReader = charset.NewReaderLabel
err := decoder.Decode(r)
if err != nil {
err = utils.DecodeGbk(r, []byte(data))
if err != nil {
return err
}
}
return nil
}
Go
1
https://gitee.com/slh1992/plugin-sip.git
git@gitee.com:slh1992/plugin-sip.git
slh1992
plugin-sip
plugin-sip
v1.3.9

搜索帮助