初始
This commit is contained in:
48
api/video_hat/ws2/ws2.5.2.go
Normal file
48
api/video_hat/ws2/ws2.5.2.go
Normal file
@ -0,0 +1,48 @@
|
||||
package ws2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gorilla/websocket"
|
||||
|
||||
"github.com/tiger1103/gfast/v3/api/constant"
|
||||
)
|
||||
|
||||
type OffPushFlowReq struct {
|
||||
g.Meta `path:"/device/off" method:"post" tags:"视频安全帽相关" summary:"关闭推流"`
|
||||
DevNum string `json:"devNum" dc:"设备id"`
|
||||
}
|
||||
|
||||
type OffPushFlowRes struct {
|
||||
}
|
||||
|
||||
func (w WsRouter) OffPushFlow(ctx context.Context, req *OffPushFlowReq) (res *OffPushFlowRes, err error) {
|
||||
SendDeviceOffPushFlow(constant.Conn, req.DevNum)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 设备关闭推流
|
||||
func SendDeviceOffPushFlow(conn *websocket.Conn, DeviceId string) {
|
||||
activeDevicesMessage := map[string]string{
|
||||
"act": "ma_stop_rtsp",
|
||||
"device_id": DeviceId,
|
||||
}
|
||||
|
||||
conn.WriteJSON(activeDevicesMessage)
|
||||
}
|
||||
|
||||
// MaStopRtspCommand 定义了停止RTSP流的命令结构体
|
||||
type MaStopRtspCommand struct {
|
||||
Cmd string `json:"cmd"` // cmd 指令标识
|
||||
DeviceID string `json:"device_id"` // device_id 设备ID
|
||||
Status bool `json:"status"` // status 返回状态
|
||||
Msg string `json:"msg"` // msg 返回消息
|
||||
MsgCode string `json:"msg_code"` // msg_code 返回消息码
|
||||
}
|
||||
|
||||
func HandStopPush(jsonString string) {
|
||||
var response MaStopRtspCommand
|
||||
json.Unmarshal([]byte(jsonString), &response)
|
||||
|
||||
}
|
Reference in New Issue
Block a user