|
|
|
@ -14,22 +14,103 @@ import (
|
|
|
|
|
type Live struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type argsPush struct {
|
|
|
|
|
App string `json:"app"`
|
|
|
|
|
Appid int64 `json:"appid"`
|
|
|
|
|
Appname string `json:"appname"`
|
|
|
|
|
ChannelID string `json:"channel_id"`
|
|
|
|
|
Errcode int64 `json:"errcode"`
|
|
|
|
|
Errmsg string `json:"errmsg"`
|
|
|
|
|
EventTime int64 `json:"event_time"`
|
|
|
|
|
EventType int64 `json:"event_type"`
|
|
|
|
|
Height int64 `json:"height"`
|
|
|
|
|
IdcID int64 `json:"idc_id"`
|
|
|
|
|
Node string `json:"node"`
|
|
|
|
|
Sequence string `json:"sequence"`
|
|
|
|
|
SetID int64 `json:"set_id"`
|
|
|
|
|
Sign string `json:"sign"`
|
|
|
|
|
StreamID string `json:"stream_id"`
|
|
|
|
|
StreamParam string `json:"stream_param"`
|
|
|
|
|
T int64 `json:"t"`
|
|
|
|
|
UserIP string `json:"user_ip"`
|
|
|
|
|
Width int64 `json:"width"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *Live) Push(c *gin.Context) {
|
|
|
|
|
log.Println("push:start")
|
|
|
|
|
log.Println("data:", c.Request.RequestURI)
|
|
|
|
|
log.Println("data:", c.Request.PostForm)
|
|
|
|
|
all, err := ioutil.ReadAll(c.Request.Body)
|
|
|
|
|
log.Println(string(all), err)
|
|
|
|
|
log.Println("push:end")
|
|
|
|
|
data, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
|
|
log.Println("直播开始/继续:", string(data))
|
|
|
|
|
//args := argsPush{}
|
|
|
|
|
//if err := json.Unmarshal(data, &args); err != nil {
|
|
|
|
|
// log.Println("json序列化失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//query, err := url.ParseQuery(args.StreamParam)
|
|
|
|
|
//if err != nil {
|
|
|
|
|
// log.Println("参数序列化失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//liveItemId, _ := strconv.ParseUint(query.Get("liveItemId"), 10, 64)
|
|
|
|
|
//
|
|
|
|
|
//liveItemModel := &live.LiveItem{}
|
|
|
|
|
//liveItemInfo := liveItemModel.FindById(uint(liveItemId))
|
|
|
|
|
//if liveItemInfo.Id <= 0 {
|
|
|
|
|
// log.Println("直播场次获取失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//live2.ImLogic.SendLiveGroupMessage(liveItemInfo.RoomId, live2.LiveGroupMsgTypePlay, gin.H{
|
|
|
|
|
// "type": "play",
|
|
|
|
|
// "time": time.Now().UnixNano(),
|
|
|
|
|
//})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type argsCutout struct {
|
|
|
|
|
App string `json:"app"`
|
|
|
|
|
Appid int64 `json:"appid"`
|
|
|
|
|
Appname string `json:"appname"`
|
|
|
|
|
ChannelID string `json:"channel_id"`
|
|
|
|
|
Errcode int64 `json:"errcode"`
|
|
|
|
|
Errmsg string `json:"errmsg"`
|
|
|
|
|
EventTime int64 `json:"event_time"`
|
|
|
|
|
EventType int64 `json:"event_type"`
|
|
|
|
|
Height int64 `json:"height"`
|
|
|
|
|
IdcID int64 `json:"idc_id"`
|
|
|
|
|
Node string `json:"node"`
|
|
|
|
|
PushDuration string `json:"push_duration"`
|
|
|
|
|
Sequence string `json:"sequence"`
|
|
|
|
|
SetID int64 `json:"set_id"`
|
|
|
|
|
Sign string `json:"sign"`
|
|
|
|
|
StreamID string `json:"stream_id"`
|
|
|
|
|
StreamParam string `json:"stream_param"`
|
|
|
|
|
T int64 `json:"t"`
|
|
|
|
|
UserIP string `json:"user_ip"`
|
|
|
|
|
Width int64 `json:"width"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *Live) Cutout(c *gin.Context) {
|
|
|
|
|
log.Println("cutout:start")
|
|
|
|
|
log.Println("data:", c.Request.RequestURI)
|
|
|
|
|
log.Println("data:", c.Request.PostForm)
|
|
|
|
|
all, err := ioutil.ReadAll(c.Request.Body)
|
|
|
|
|
log.Println(string(all), err)
|
|
|
|
|
log.Println("cutout:end")
|
|
|
|
|
data, _ := ioutil.ReadAll(c.Request.Body)
|
|
|
|
|
log.Println("直播暂停:", string(data))
|
|
|
|
|
//args := argsCutout{}
|
|
|
|
|
//if err := json.Unmarshal(data, &args); err != nil {
|
|
|
|
|
// log.Println("json序列化失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//query, err := url.ParseQuery(args.StreamParam)
|
|
|
|
|
//if err != nil {
|
|
|
|
|
// log.Println("参数序列化失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//liveItemId, _ := strconv.ParseUint(query.Get("liveItemId"), 10, 64)
|
|
|
|
|
//
|
|
|
|
|
//liveItemModel := &live.LiveItem{}
|
|
|
|
|
//liveItemInfo := liveItemModel.FindById(uint(liveItemId))
|
|
|
|
|
//if liveItemInfo.Id <= 0 {
|
|
|
|
|
// log.Println("直播场次获取失败,err:", err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
//live2.ImLogic.SendLiveGroupMessage(liveItemInfo.RoomId, live2.LiveGroupMsgTypePlay, gin.H{
|
|
|
|
|
// "type": "pause",
|
|
|
|
|
// "time": time.Now().UnixNano(),
|
|
|
|
|
//})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type argsTranscribe struct {
|
|
|
|
@ -79,10 +160,18 @@ func (l *Live) Transcribe(c *gin.Context) {
|
|
|
|
|
log.Println("直播场次获取失败,err:", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
liveItemModel.UpdateById(liveItemInfo.Id, map[string]interface{}{
|
|
|
|
|
"file_id": args.FileID,
|
|
|
|
|
"video_url": args.VideoURL,
|
|
|
|
|
})
|
|
|
|
|
if liveItemInfo.TranscribeType == live.LIVE_Transcribe_Type_ing {
|
|
|
|
|
liveItemModel.UpdateById(liveItemInfo.Id, map[string]interface{}{
|
|
|
|
|
"file_id": args.FileID,
|
|
|
|
|
"video_url": args.VideoURL,
|
|
|
|
|
"transcribe_type": live.LIVE_Transcribe_Type_finish,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
liveItemModel.UpdateById(liveItemInfo.Id, map[string]interface{}{
|
|
|
|
|
"file_id": args.FileID,
|
|
|
|
|
"video_url": args.VideoURL,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if liveItemInfo.Status == live.LIVE_STATUS_ing {
|
|
|
|
|
// 尚未结束直播
|
|
|
|
|
if err := live2.LiveLogic.Stop(liveItemInfo.UserId, liveItemInfo.Id); err != nil {
|
|
|
|
@ -93,12 +182,6 @@ func (l *Live) Transcribe(c *gin.Context) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *Live) ScreenShot(c *gin.Context) {
|
|
|
|
|
log.Println("screenshot:start")
|
|
|
|
|
log.Println("data:", c.Request.RequestURI)
|
|
|
|
|
log.Println("data:", c.Request.PostForm)
|
|
|
|
|
all, err := ioutil.ReadAll(c.Request.Body)
|
|
|
|
|
log.Println(string(all), err)
|
|
|
|
|
log.Println("screenshot:end")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *Live) Identify(c *gin.Context) {
|
|
|
|
|