mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-05 07:06:57 +08:00
优化网络IO使用buffer读取
This commit is contained in:
@@ -16,7 +16,8 @@ type Session struct {
|
||||
handle interface{}
|
||||
isPublisher bool
|
||||
|
||||
conn net.Conn
|
||||
conn net.Conn
|
||||
receiveBuffer *stream.ReceiveBuffer
|
||||
}
|
||||
|
||||
func (s *Session) generateSourceId(app, stream_ string) string {
|
||||
@@ -37,6 +38,9 @@ func (s *Session) OnPublish(app, stream_ string, response chan utils.HookState)
|
||||
//设置推流的音视频回调
|
||||
s.stack.SetOnPublishHandler(source)
|
||||
|
||||
//初始化放在add source前面, 以防add-init空窗期, 拉流队列空指针.
|
||||
source.Init(source.Input, source.Close, stream.ReceiveBufferTCPBlockCount)
|
||||
|
||||
//推流事件Source统一处理, 是否已经存在, Hook回调....
|
||||
_, state := stream.PreparePublishSource(source, true)
|
||||
if utils.HookStateOK != state {
|
||||
@@ -44,8 +48,8 @@ func (s *Session) OnPublish(app, stream_ string, response chan utils.HookState)
|
||||
} else {
|
||||
s.handle = source
|
||||
s.isPublisher = true
|
||||
s.receiveBuffer = stream.NewTCPReceiveBuffer()
|
||||
|
||||
source.Init(source.Input, source.Close)
|
||||
go source.LoopEvent()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user