Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

关于procotol/rtmp/stream.go中的TransStart()函数的问题 #222

Open
zhaojiajun193 opened this issue Feb 2, 2023 · 0 comments
Open

Comments

@zhaojiajun193
Copy link

s.ws.Range(func(key, val interface{}) bool {
v := val.(*PackWriterCloser)
fmt.Printf(key.(string) + "\n")
if !v.init {
if err = s.cache.Send(v.w); err != nil {
log.Debugf("[%s] send cache packet error: %v, remove", v.w.Info(), err)
s.ws.Delete(key)
return true
}
fmt.Printf("key:%v, value:%v", key, val)
v.init = true
} else {
newPacket := p
if err = v.w.Write(&newPacket); err != nil {
log.Debugf("[%s] write packet error: %v, remove", v.w.Info(), err)
s.ws.Delete(key)
}
}
return true
})
上述代码遍历了某个推流stream下的ws(sync.map),循环向每个想要拉流的tcp连接写入av.Packet,如此一来在连接数很多时是否会导致效率极低,甚至影响推流写入cache的速度,在多人直播间中应该如何优化呢,也可能是本人理解错误了,希望大佬帮忙回答下,感谢

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant