Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

关于protocol/rmtp/stream.go下的TransStart()函数的问题 #223

Open
zhaojiajun193 opened this issue Feb 2, 2023 · 1 comment
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的速度,在多人直播间中应该如何优化呢,也可能是本人理解错误了,希望大佬帮忙回答下,感谢

@Justyell
Copy link

Justyell commented May 11, 2023

v.w.Write的逻辑本质上是写入到一个chan里面,如果chan满了会做丢包处理,所以代码层面上这里本身不会引起阻塞从而有性能问题

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

No branches or pull requests

2 participants