From a17a6a88aeab034a9197ef37194acef2af734267 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 8 May 2022 01:37:10 +0800 Subject: [PATCH] =?utf8?q?Ass=E4=BF=9D=E5=AD=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 6 ++++++ Reply/stream.go | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Reply/F.go b/Reply/F.go index 7416720..d975036 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -249,6 +249,7 @@ func dtos(t time.Duration) string { //https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming var streamO psync.Map +// 获取实例的Common func StreamOCommon(roomid int) (array []c.Common) { if roomid != -1 { //返回特定房间 if v, ok := streamO.Load(roomid); ok { @@ -263,6 +264,7 @@ func StreamOCommon(roomid int) (array []c.Common) { return } +// 实例操作 func init() { //使用带tag的消息队列在功能间传递消息 c.C.Danmu_Main_mq.Pull_tag(msgq.FuncMap{ @@ -270,6 +272,7 @@ func init() { if roomid, ok := data.(int); ok { if v, ok := streamO.Load(roomid); ok { if v.(*M4SStream).Status.Islive() { + Ass_f("", "", time.Now()) //停止ass v.(*M4SStream).Stop() streamO.Delete(roomid) } @@ -281,6 +284,7 @@ func init() { common.Roomid = roomid tmp.LoadConfig(common, c.C.Log) streamO.Store(roomid, tmp) + Ass_f(tmp.Current_save_path, tmp.Current_save_path+"0", time.Now()) //开始ass go tmp.Start() } } else { @@ -291,11 +295,13 @@ func init() { }) } +// 获取实例的录制状态 func StreamOStatus(roomid int) bool { v, ok := streamO.Load(roomid) return ok && (v.(*M4SStream).Status.Islive() || v.(*M4SStream).exitSign.Islive()) } +// 停止实例 func StreamOStop(roomid int) { if roomid != -1 { // 针对某房间 if v, ok := streamO.Load(roomid); ok { diff --git a/Reply/stream.go b/Reply/stream.go index b3d1e7c..dbbd563 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -37,6 +37,7 @@ type M4SStream struct { Newst_m4s *msgq.Msgq //m4s消息 tag:m4s first_m4s []byte //m4s起始块 common c.Common //通用配置副本 + Current_save_path string //明确的直播流保存目录 } type M4SStream_Config struct { @@ -89,6 +90,7 @@ func (t *M4SStream) LoadConfig(common c.Common, l *log.Log_interface) { } } t.config.save_path = path + "/" + t.Current_save_path = path + "/" + strconv.Itoa(common.Roomid) + "_" + time.Now().Format("2006_01_02_15-04-05-000") + `/` } else { t.log.L(`E: `, `直播流保存位置错误`, err) return @@ -331,7 +333,7 @@ func (t *M4SStream) fetchParseM3U8() (m4s_links []*m4s_link_item, m3u8_addon []b func (t *M4SStream) saveStream() { // 设置保存路径 - var save_path = t.config.save_path + strconv.Itoa(t.common.Roomid) + "_" + time.Now().Format("2006_01_02_15-04-05-000") + `/` + var save_path = t.Current_save_path // 显示保存位置 if rel, err := filepath.Rel(t.config.save_path, save_path); err == nil { -- 2.39.2