From: qydysky Date: Sat, 7 May 2022 20:27:03 +0000 (+0800) Subject: Ass bug X-Git-Tag: v0.5.10~41^2~60 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=143c793959ea526c6148bf768c8885049d0e55d0;p=bili_danmu%2F.git Ass bug --- diff --git a/Reply/F.go b/Reply/F.go index d975036..32587ac 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -272,7 +272,6 @@ 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) } @@ -283,8 +282,14 @@ func init() { ) common.Roomid = roomid tmp.LoadConfig(common, c.C.Log) + //关于ass的回调 + tmp.Callback_start = func(ms *M4SStream) { + Ass_f(ms.Current_save_path, ms.Current_save_path+"0", time.Now()) //开始ass + } + tmp.Callback_stop = func(ms *M4SStream) { + Ass_f("", "", time.Now()) //停止ass + } streamO.Store(roomid, tmp) - Ass_f(tmp.Current_save_path, tmp.Current_save_path+"0", time.Now()) //开始ass go tmp.Start() } } else { diff --git a/Reply/stream.go b/Reply/stream.go index 10c4f79..6de4099 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -38,6 +38,8 @@ type M4SStream struct { first_m4s []byte //m4s起始块 common c.Common //通用配置副本 Current_save_path string //明确的直播流保存目录 + Callback_start func(*M4SStream) //开始的回调 + Callback_stop func(*M4SStream) //结束的回调 } type M4SStream_Config struct { @@ -90,7 +92,6 @@ 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 @@ -339,6 +340,7 @@ func (t *M4SStream) fetchParseM3U8() (m4s_links []*m4s_link_item, m3u8_addon []b func (t *M4SStream) saveStream() { // 设置保存路径 + t.Current_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 // 显示保存位置 @@ -348,6 +350,10 @@ func (t *M4SStream) saveStream() { t.log.L(`W: `, err) } + //开始,结束回调 + t.Callback_start(t) + defer t.Callback_stop(t) + // 获取流 if strings.Contains(t.common.Live[0], `m3u8`) { t.stream_expires = time.Now().Add(time.Minute * 2).Unix() // 流链接过期时间 @@ -487,7 +493,6 @@ func (t *M4SStream) saveStream() { }) p.FileMove(save_path+"0.m3u8.dtmp", save_path+"0.m3u8") } - } }