From ac4de208b85407ceed7add01f7e032b50cc22d69 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Wed, 19 Apr 2023 13:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=AD=E6=8E=A8=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media.go | 19 +++++++++++++++++++ netConnection.go | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/media.go b/media.go index 3adcf6f..e5f0389 100644 --- a/media.go +++ b/media.go @@ -121,6 +121,25 @@ type RTMPReceiver struct { NetStream } +func (r *RTMPReceiver) OnEvent(event any) { + switch v := event.(type) { + case IPublisher: + if r.Equal(v) { //第一任 + + } else { // 使用前任的track,因为订阅者都挂在前任的上面 + r.Publisher.OnEvent(event) + if r.AudioTrack != nil { + r.AudioTrack.SetStuff(r.bytePool) + } + if r.VideoTrack != nil { + r.VideoTrack.SetStuff(r.bytePool) + } + } + default: + r.IO.OnEvent(event) + } +} + func (r *RTMPReceiver) Response(tid uint64, code, level string) error { m := new(ResponsePublishMessage) m.CommandName = Response_OnStatus diff --git a/netConnection.go b/netConnection.go index 68c58fa..2ecced2 100644 --- a/netConnection.go +++ b/netConnection.go @@ -45,8 +45,8 @@ const ( ) type NetConnection struct { - *bufio.Reader `json:"-"` - net.Conn `json:"-"` + *bufio.Reader `json:"-" yaml:"-"` + net.Conn `json:"-" yaml:"-"` bandwidth uint32 readSeqNum uint32 // 当前读的字节 writeSeqNum uint32 // 当前写的字节