From 15577b9f41798b6c23b139b8edb7233460c4463d Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 4 Jul 2024 14:29:13 +0000 Subject: [PATCH] =?utf8?q?Improve=20=E5=A4=9A=E6=AC=A1=E6=8E=A5=E6=94=B6?= =?utf8?q?=E5=BC=80=E6=92=AD=E4=BF=A1=E6=81=AF=E4=B8=8D=E4=BC=9A=E5=88=87?= =?utf8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 59 +++++++++++++++++++++++++------------------------- Reply/Reply.go | 6 ++--- bili_danmu.go | 6 ++--- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index b3fb07c..b91b5de 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -319,38 +319,37 @@ func StreamOStart(common *c.Common, roomid int) { } // 停止实例 -// -// -2 其他房间 -// -1 所有房间 -// 针对某房间 -func StreamOStop(roomid int) { - switch roomid { - case -2: // 其他房间 - c.StreamO.Range(func(_roomid, v interface{}) bool { - if c.C.Roomid == _roomid { - return true - } - if !pctx.Done(v.(*M4SStream).Status) { - v.(*M4SStream).Stop() - } - c.StreamO.Delete(_roomid) - return true - }) - case -1: // 所有房间 - c.StreamO.Range(func(k, v interface{}) bool { - if !pctx.Done(v.(*M4SStream).Status) { - v.(*M4SStream).Stop() - } - c.StreamO.Delete(k) +func StreamOStopAll() { + c.StreamO.Range(func(k, v interface{}) bool { + if !pctx.Done(v.(*M4SStream).Status) { + v.(*M4SStream).Stop() + } + c.StreamO.Delete(k) + return true + }) +} + +// 停止实例 +func StreamOStopOther(roomid int) { + c.StreamO.Range(func(_roomid, v interface{}) bool { + if roomid == _roomid { return true - }) - default: // 针对某房间 - if v, ok := c.StreamO.Load(roomid); ok { - if !pctx.Done(v.(*M4SStream).Status) { - v.(*M4SStream).Stop() - } - c.StreamO.Delete(roomid) } + if !pctx.Done(v.(*M4SStream).Status) { + v.(*M4SStream).Stop() + } + c.StreamO.Delete(_roomid) + return true + }) +} + +// 停止实例 +func StreamOStop(roomid int) { + if v, ok := c.StreamO.Load(roomid); ok { + if !pctx.Done(v.(*M4SStream).Status) { + v.(*M4SStream).Stop() + } + c.StreamO.Delete(roomid) } } diff --git a/Reply/Reply.go b/Reply/Reply.go index 434d54e..7ece581 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -855,12 +855,10 @@ func (t replyF) live(s string) { //开始录制 go func() { if v, ok := t.common.K_v.LoadV(`仅保存当前直播间流`).(bool); ok && v { - StreamOStop(-2) //停止其他房间录制 + StreamOStopOther(t.common.Roomid) //停止其他房间录制 } if _, e := recStartEnd.RecStartCheck.Run(context.Background(), t.common); e == nil { - if StreamOStatus(t.common.Roomid) { - StreamOCut(t.common.Roomid) - } else { + if !StreamOStatus(t.common.Roomid) { StreamOStart(t.common.Copy(), t.common.Roomid) } } else { diff --git a/bili_danmu.go b/bili_danmu.go index 11dddfb..dd1a7e5 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -341,7 +341,7 @@ func Start() { exitSign = true ws_c.Close() danmulog.L(`I: `, "停止,等待服务器断开连接") - reply.StreamOStop(-1) //停止录制 + reply.StreamOStopAll() //停止录制 return true }, `exit_room`: func(_ any) bool { //退出当前房间 @@ -356,7 +356,7 @@ func Start() { exitloop = true ws_c.Close() if v, ok := c.C.K_v.LoadV(`仅保存当前直播间流`).(bool); ok && v { - reply.StreamOStop(-2) //停止其他房间录制 + reply.StreamOStopOther(c.C.Roomid) //停止其他房间录制 } return true }, @@ -414,7 +414,7 @@ func Start() { { //附加功能 直播流停止 ws信息保存 reply.SaveToJson.Close() - reply.StreamOStop(-1) + reply.StreamOStopAll() } } } -- 2.39.2