mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-13 20:33:44 +08:00
fix: avoid auth puller
This commit is contained in:
2
io.go
2
io.go
@@ -214,7 +214,7 @@ func (io *IO) receive(streamPath string, specific common.IIO) error {
|
|||||||
io.Info("publish", zap.String("ptr", fmt.Sprintf("%p", iPub)))
|
io.Info("publish", zap.String("ptr", fmt.Sprintf("%p", iPub)))
|
||||||
s.pubLocker.Lock()
|
s.pubLocker.Lock()
|
||||||
defer s.pubLocker.Unlock()
|
defer s.pubLocker.Unlock()
|
||||||
if config.Global.EnableAuth {
|
if _, isPuller := specific.(IPuller); config.Global.EnableAuth && !isPuller {
|
||||||
onAuthPub := OnAuthPub
|
onAuthPub := OnAuthPub
|
||||||
if auth, ok := specific.(AuthPub); ok {
|
if auth, ok := specific.(AuthPub); ok {
|
||||||
onAuthPub = auth.OnAuth
|
onAuthPub = auth.OnAuth
|
||||||
|
@@ -321,7 +321,15 @@ func (s *Subscriber) PlayBlock(subType byte) {
|
|||||||
subMode, _ = strconv.Atoi(s.Args.Get(conf.SubModeArgName))
|
subMode, _ = strconv.Atoi(s.Args.Get(conf.SubModeArgName))
|
||||||
}
|
}
|
||||||
var initState = 0
|
var initState = 0
|
||||||
var videoFrame, audioFrame *AVFrame
|
var videoFrame, audioFrame ,lastSentAF, lastSentVF *AVFrame
|
||||||
|
defer func(){
|
||||||
|
if lastSentVF != nil {
|
||||||
|
lastSentVF.ReaderLeave()
|
||||||
|
}
|
||||||
|
if lastSentAF != nil {
|
||||||
|
lastSentAF.ReaderLeave()
|
||||||
|
}
|
||||||
|
}()
|
||||||
for ctx.Err() == nil {
|
for ctx.Err() == nil {
|
||||||
if hasVideo {
|
if hasVideo {
|
||||||
for ctx.Err() == nil {
|
for ctx.Err() == nil {
|
||||||
@@ -343,6 +351,7 @@ func (s *Subscriber) PlayBlock(subType byte) {
|
|||||||
if audioFrame != nil {
|
if audioFrame != nil {
|
||||||
if util.Conditoinal(conf.SyncMode == 0, videoFrame.Timestamp > audioFrame.Timestamp, videoFrame.WriteTime.After(audioFrame.WriteTime)) {
|
if util.Conditoinal(conf.SyncMode == 0, videoFrame.Timestamp > audioFrame.Timestamp, videoFrame.WriteTime.After(audioFrame.WriteTime)) {
|
||||||
// fmt.Println("switch audio", audioFrame.CanRead)
|
// fmt.Println("switch audio", audioFrame.CanRead)
|
||||||
|
lastSentAF = audioFrame
|
||||||
sendAudioFrame(audioFrame)
|
sendAudioFrame(audioFrame)
|
||||||
audioFrame = nil
|
audioFrame = nil
|
||||||
break
|
break
|
||||||
@@ -353,6 +362,7 @@ func (s *Subscriber) PlayBlock(subType byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !conf.IFrameOnly || videoFrame.IFrame {
|
if !conf.IFrameOnly || videoFrame.IFrame {
|
||||||
|
lastSentVF = videoFrame
|
||||||
sendVideoFrame(videoFrame)
|
sendVideoFrame(videoFrame)
|
||||||
} else {
|
} else {
|
||||||
// fmt.Println("skip video", frame.Sequence)
|
// fmt.Println("skip video", frame.Sequence)
|
||||||
@@ -389,12 +399,14 @@ func (s *Subscriber) PlayBlock(subType byte) {
|
|||||||
}
|
}
|
||||||
if hasVideo && videoFrame != nil {
|
if hasVideo && videoFrame != nil {
|
||||||
if util.Conditoinal(conf.SyncMode == 0, audioFrame.Timestamp > videoFrame.Timestamp, audioFrame.WriteTime.After(videoFrame.WriteTime)) {
|
if util.Conditoinal(conf.SyncMode == 0, audioFrame.Timestamp > videoFrame.Timestamp, audioFrame.WriteTime.After(videoFrame.WriteTime)) {
|
||||||
|
lastSentVF = videoFrame
|
||||||
sendVideoFrame(videoFrame)
|
sendVideoFrame(videoFrame)
|
||||||
videoFrame = nil
|
videoFrame = nil
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if audioFrame.Timestamp >= s.AudioReader.SkipTs {
|
if audioFrame.Timestamp >= s.AudioReader.SkipTs {
|
||||||
|
lastSentAF = audioFrame
|
||||||
sendAudioFrame(audioFrame)
|
sendAudioFrame(audioFrame)
|
||||||
} else {
|
} else {
|
||||||
// fmt.Println("skip audio", frame.AbsTime, s.AudioReader.SkipTs)
|
// fmt.Println("skip audio", frame.AbsTime, s.AudioReader.SkipTs)
|
||||||
@@ -402,12 +414,7 @@ func (s *Subscriber) PlayBlock(subType byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if videoFrame != nil {
|
|
||||||
videoFrame.ReaderLeave()
|
|
||||||
}
|
|
||||||
if audioFrame != nil {
|
|
||||||
audioFrame.ReaderLeave()
|
|
||||||
}
|
|
||||||
stopReason = zap.Error(ctx.Err())
|
stopReason = zap.Error(ctx.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user