完善rtmp拉流

This commit is contained in:
yangjie
2023-11-26 22:06:40 +08:00
parent e84df324bf
commit 8485f6c857
5 changed files with 68 additions and 30 deletions

View File

@@ -18,21 +18,21 @@ type Session interface {
type SessionImpl struct {
hookImpl
stream string //stream id
protocol string //推拉流协议
remoteAddr string //peer地址
Stream string //stream id
Protocol string //推拉流协议
RemoteAddr string //peer地址
}
// AddInfoParams 为每个需要通知的时间添加必要的信息
func (s *SessionImpl) AddInfoParams(data map[string]interface{}) {
data["stream"] = s.stream
data["protocol"] = s.protocol
data["remoteAddr"] = s.remoteAddr
data["stream"] = s.Stream
data["protocol"] = s.Protocol
data["remoteAddr"] = s.RemoteAddr
}
func (s *SessionImpl) OnPublish(source_ ISource, pra map[string]interface{}, success func(), failure func(state utils.HookState)) {
//streamId 已经被占用
source := SourceManager.Find(s.stream)
source := SourceManager.Find(s.Stream)
if source != nil {
failure(utils.HookStateOccupy)
return
@@ -76,11 +76,11 @@ func (s *SessionImpl) OnPublishDone() {
func (s *SessionImpl) OnPlay(sink ISink, pra map[string]interface{}, success func(), failure func(state utils.HookState)) {
f := func() {
source := SourceManager.Find(s.stream)
source := SourceManager.Find(s.Stream)
if source == nil {
AddSinkToWaitingQueue(s.stream, nil)
AddSinkToWaitingQueue(s.Stream, sink)
} else {
source.AddSink(nil)
source.AddSink(sink)
}
}