From fb8eb106d6793c035636360f52552e836de4eec0 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Sun, 8 Oct 2023 13:13:34 +0800 Subject: [PATCH] chore: puller already exists log add streamState --- lang/zh.yaml | 1 + puller.go | 10 ++++++++-- stream.go | 2 +- track/h264.go | 6 ------ track/h265.go | 6 ------ 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lang/zh.yaml b/lang/zh.yaml index 017a74d..6837e0b 100644 --- a/lang/zh.yaml +++ b/lang/zh.yaml @@ -28,6 +28,7 @@ initialize: 初始化 created: 已创建 create: 创建 timeout: 超时 +"track available": 轨道可用 track: 轨道 "track timeout": 轨道超时 "last writetime": 最后写入时间 diff --git a/puller.go b/puller.go index a70e2f0..9636527 100644 --- a/puller.go +++ b/puller.go @@ -48,8 +48,14 @@ func (pub *Puller) startPull(puller IPuller) { if i := strings.Index(streamPath, "?"); i >= 0 { streamPath = streamPath[:i] } - if _, loaded := Pullers.LoadOrStore(streamPath, puller); loaded { - puller.Error("puller already exists") + if oldPuller, loaded := Pullers.LoadOrStore(streamPath, puller); loaded { + pub := oldPuller.(IPuller).GetPublisher() + stream = pub.Stream + if stream != nil { + puller.Error("puller already exists", zap.Int8("streamState", int8(stream.State))) + } else { + puller.Error("puller already exists", zap.Time("createAt", pub.StartTime)) + } return } defer func() { diff --git a/stream.go b/stream.go index a9f76ae..d4d6d90 100644 --- a/stream.go +++ b/stream.go @@ -80,7 +80,7 @@ var StreamFSM = [len(StateNames)]map[StreamAction]StreamState{ { ACTION_TRACKAVAILABLE: STATE_PUBLISHING, ACTION_TIMEOUT: STATE_CLOSED, - ACTION_LASTLEAVE: STATE_CLOSED, + ACTION_LASTLEAVE: STATE_WAITCLOSE, ACTION_CLOSE: STATE_CLOSED, }, { diff --git a/track/h264.go b/track/h264.go index d71c60d..4ff2da2 100644 --- a/track/h264.go +++ b/track/h264.go @@ -64,18 +64,12 @@ func (vt *H264) WriteSliceBytes(slice []byte) { b.Write(vt.Video.PPS) vt.WriteSequenceHead(b) case codec.NALU_IDR_Picture: - if vt.Value.AUList.ByteLength > 0 && !vt.Value.IFrame { - vt.Flush() - } vt.Value.IFrame = true vt.AppendAuBytes(slice) case codec.NALU_Non_IDR_Picture, codec.NALU_Data_Partition_A, codec.NALU_Data_Partition_B, codec.NALU_Data_Partition_C: - if vt.Value.AUList.ByteLength > 0 { - vt.Flush() - } vt.Value.IFrame = false vt.AppendAuBytes(slice) case codec.NALU_SEI: diff --git a/track/h265.go b/track/h265.go index 1fc2a8d..b1b0163 100644 --- a/track/h265.go +++ b/track/h265.go @@ -66,15 +66,9 @@ func (vt *H265) WriteSliceBytes(slice []byte) { codec.NAL_UNIT_CODED_SLICE_IDR, codec.NAL_UNIT_CODED_SLICE_IDR_N_LP, codec.NAL_UNIT_CODED_SLICE_CRA: - if vt.Value.AUList.ByteLength > 0 && !vt.Value.IFrame { - vt.Flush() - } vt.Value.IFrame = true vt.AppendAuBytes(slice) case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9: - if vt.Value.AUList.ByteLength > 0 { - vt.Flush() - } vt.Value.IFrame = false vt.AppendAuBytes(slice) case codec.NAL_UNIT_SEI, codec.NAL_UNIT_SEI_SUFFIX: