完善sink断开处理

This commit is contained in:
yangjiechina
2024-04-09 16:00:48 +08:00
parent 0376ccf604
commit 8dc824494e
10 changed files with 287 additions and 106 deletions

View File

@@ -1,6 +1,7 @@
package stream
import (
"fmt"
"github.com/yangjiechina/avformat/utils"
"github.com/yangjiechina/live-server/log"
"net"
@@ -43,7 +44,10 @@ type ISink interface {
// DesiredVideoCodecId DescribeVideoCodecId 允许客户端拉取指定的视频流
DesiredVideoCodecId() utils.AVCodecID
// Close 关闭释放Sink, 从传输流或等待队列中删除sink
Close()
PrintInfo() string
}
// GenerateSinkId 根据网络地址生成SinkId IPV4使用一个uint64, IPV6使用String
@@ -184,6 +188,10 @@ func (s *SinkImpl) Close() {
}
}
func (s *SinkImpl) PrintInfo() string {
return fmt.Sprintf("%s-%v source:%s", s.ProtocolStr(), s.Id_, s.SourceId_)
}
func (s *SinkImpl) Play(sink ISink, success func(), failure func(state utils.HookState)) {
f := func() {
source := SourceManager.Find(sink.SourceId())