mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-11-02 20:14:01 +08:00
fix: publisher pause twice
This commit is contained in:
14
alias.go
14
alias.go
@@ -7,7 +7,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"gorm.io/gorm"
|
|
||||||
"m7s.live/v5/pb"
|
"m7s.live/v5/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,9 +24,8 @@ func (a *AliasStream) GetKey() string {
|
|||||||
// StreamAliasDB 用于存储流别名的数据库模型
|
// StreamAliasDB 用于存储流别名的数据库模型
|
||||||
type StreamAliasDB struct {
|
type StreamAliasDB struct {
|
||||||
AliasStream
|
AliasStream
|
||||||
CreatedAt time.Time `yaml:"-"`
|
CreatedAt time.Time `yaml:"-"`
|
||||||
UpdatedAt time.Time `yaml:"-"`
|
UpdatedAt time.Time `yaml:"-"`
|
||||||
DeletedAt gorm.DeletedAt `yaml:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (StreamAliasDB) TableName() string {
|
func (StreamAliasDB) TableName() string {
|
||||||
@@ -99,7 +97,9 @@ func (s *Server) SetStreamAlias(ctx context.Context, req *pb.SetStreamAliasReque
|
|||||||
}
|
}
|
||||||
// 更新数据库中的别名
|
// 更新数据库中的别名
|
||||||
if s.DB != nil {
|
if s.DB != nil {
|
||||||
s.DB.Model(&StreamAliasDB{}).Where("alias = ?", req.Alias).Updates(req)
|
s.DB.Where("alias = ?", req.Alias).Assign(aliasInfo).FirstOrCreate(&StreamAliasDB{
|
||||||
|
AliasStream: *aliasInfo,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
s.Info("modify alias", "alias", req.Alias, "oldStreamPath", oldStreamPath, "streamPath", req.StreamPath, "replace", ok && canReplace)
|
s.Info("modify alias", "alias", req.Alias, "oldStreamPath", oldStreamPath, "streamPath", req.StreamPath, "replace", ok && canReplace)
|
||||||
} else { // create alias
|
} else { // create alias
|
||||||
@@ -232,7 +232,9 @@ func (s *Subscriber) processAliasOnStart() (hasInvited bool, done bool) {
|
|||||||
}
|
}
|
||||||
server.AliasStreams.Set(&as)
|
server.AliasStreams.Set(&as)
|
||||||
if server.DB != nil {
|
if server.DB != nil {
|
||||||
server.DB.Where("alias = ?", s.StreamPath).Assign(as).FirstOrCreate(&StreamAliasDB{})
|
server.DB.Where("alias = ?", s.StreamPath).Assign(as).FirstOrCreate(&StreamAliasDB{
|
||||||
|
AliasStream: as,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if publisher, ok := server.Streams.Get(streamPath); ok {
|
if publisher, ok := server.Streams.Get(streamPath); ok {
|
||||||
publisher.AddSubscriber(s)
|
publisher.AddSubscriber(s)
|
||||||
|
|||||||
@@ -707,11 +707,17 @@ func (p *Publisher) NoAudio() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Publisher) Pause() {
|
func (p *Publisher) Pause() {
|
||||||
|
if p.Paused != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
p.Paused = util.NewPromise(p)
|
p.Paused = util.NewPromise(p)
|
||||||
p.pauseTime = time.Now()
|
p.pauseTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Publisher) Resume() {
|
func (p *Publisher) Resume() {
|
||||||
|
if p.Paused == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
p.Paused.Resolve()
|
p.Paused.Resolve()
|
||||||
p.Paused = nil
|
p.Paused = nil
|
||||||
p.VideoTrack.pausedTime += time.Since(p.pauseTime)
|
p.VideoTrack.pausedTime += time.Since(p.pauseTime)
|
||||||
|
|||||||
Reference in New Issue
Block a user