mirror of
https://github.com/Monibuca/plugin-rtmp.git
synced 2025-09-26 19:51:38 +08:00
修复续推时的内存泄露
This commit is contained in:
19
media.go
19
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
|
||||
|
@@ -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 // 当前写的字节
|
||||
|
Reference in New Issue
Block a user