From f526be83e91f926f2ffa30bef0ec97764ccf4789 Mon Sep 17 00:00:00 2001 From: ydajiang Date: Fri, 5 Sep 2025 10:18:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BA=A7=E8=81=94=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stream/forward_sink.go | 7 +++---- stream/rtp_stream.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/stream/forward_sink.go b/stream/forward_sink.go index 5cedbf8..2973aed 100644 --- a/stream/forward_sink.go +++ b/stream/forward_sink.go @@ -81,12 +81,11 @@ func (f *ForwardSink) Write(index int, data []*collections.ReferenceCounter[[]by f.rtpBuffer = NewRtpBuffer(1024) } - processedData = make([]*collections.ReferenceCounter[[]byte], 0, len(data)) } else if f.rtpBuffer == nil { f.rtpBuffer = NewRtpBuffer(1) } - for i, datum := range data { + for _, datum := range data { src := datum.Get() counter := f.rtpBuffer.Get() bytes := counter.Get() @@ -103,7 +102,7 @@ func (f *ForwardSink) Write(index int, data []*collections.ReferenceCounter[[]by } else { counter.ResetData(bytes[:length]) counter.Refer() - processedData[i] = counter + processedData = append(processedData, counter) } } @@ -169,7 +168,7 @@ func NewForwardSink(transportType TransportType, protocol TransStreamProtocol, s BaseSink: BaseSink{ID: sinkId, SourceID: sourceId, State: SessionStateCreated, Protocol: protocol}, transportType: transportType, ssrc: ssrc, - requireSSRCMatch: true, // 默认要求ssrc一致 + requireSSRCMatch: false, // 默认允许ssrc可以不一致 } if transportType == TransportTypeUDP { diff --git a/stream/rtp_stream.go b/stream/rtp_stream.go index f21a94d..484fe75 100644 --- a/stream/rtp_stream.go +++ b/stream/rtp_stream.go @@ -23,7 +23,7 @@ func (f *RtpStream) Input(packet *avformat.AVPacket, _ int) ([]*collections.Refe bytes := counter.Get() binary.BigEndian.PutUint16(bytes, size-2) copy(bytes[2:], packet.Data) - counter.ResetData(bytes[:2+len(bytes)]) + counter.ResetData(bytes[:size]) // 每帧都当关键帧, 直接发给上级 return []*collections.ReferenceCounter[[]byte]{counter}, -1, true, nil