fix: bad publish

This commit is contained in:
langhuihui
2024-01-19 14:56:47 +08:00
parent 93973f2479
commit 2fc87b15dc
2 changed files with 8 additions and 13 deletions

View File

@@ -133,22 +133,16 @@ type RTMPReceiver struct {
}
func (r *RTMPReceiver) OnEvent(event any) {
switch v := event.(type) {
switch 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)
}
if r.AudioTrack != nil {
r.AudioTrack.SetStuff(r.bytePool)
}
if r.VideoTrack != nil {
r.VideoTrack.SetStuff(r.bytePool)
}
default:
r.IO.OnEvent(event)
}
r.Publisher.OnEvent(event)
}
func (r *RTMPReceiver) Response(tid uint64, code, level string) error {

View File

@@ -143,6 +143,7 @@ func (config *RTMPConfig) ServeTCP(conn net.Conn) {
receiver.Begin()
err = receiver.Response(cmd.TransactionId, NetStream_Publish_Start, Level_Status)
} else {
delete(receivers, cmd.StreamId)
err = receiver.Response(cmd.TransactionId, NetStream_Publish_BadName, Level_Error)
}
case *PlayMessage: