mirror of https://github.com/q191201771/lal.git
1. [feat] 配置文件中支持配置是否清除过期流的HLS文件 2. [feat] 增加HTTP API接口`/api/ctrl/kick_out_session`,用于踢掉指定的session 3. [feat] HTTP Notify事件回调中的session结构体都增加session id字段
parent
adcb4935ad
commit
a58a2ce60c
@ -0,0 +1,52 @@
|
||||
// Copyright 2020, Chef. All rights reserved.
|
||||
// https://github.com/q191201771/lal
|
||||
//
|
||||
// Use of this source code is governed by a MIT-style license
|
||||
// that can be found in the License file.
|
||||
//
|
||||
// Author: Chef (191201771@qq.com)
|
||||
|
||||
package datamanager
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/q191201771/naza/pkg/nazalog"
|
||||
)
|
||||
|
||||
type DataManagerMemory struct {
|
||||
mutex sync.Mutex
|
||||
pubStream2ServerID map[string]string
|
||||
}
|
||||
|
||||
func NewDataManagerMemory() *DataManagerMemory {
|
||||
return &DataManagerMemory{
|
||||
pubStream2ServerID: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DataManagerMemory) AddPub(streamName, serverID string) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
nazalog.Infof("add pub. streamName=%s, serverID=%s", streamName, serverID)
|
||||
d.pubStream2ServerID[streamName] = serverID
|
||||
}
|
||||
|
||||
func (d *DataManagerMemory) DelPub(streamName, serverID string) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
// 清除用户推流对应的节点信息
|
||||
cacheServerID, exist := d.pubStream2ServerID[streamName]
|
||||
if !exist || serverID != cacheServerID {
|
||||
nazalog.Errorf("del pub but server id dismatch. streamName=%s, serverID=%s, cache id=%s", streamName, serverID, cacheServerID)
|
||||
return
|
||||
}
|
||||
delete(d.pubStream2ServerID, streamName)
|
||||
}
|
||||
|
||||
func (d *DataManagerMemory) QueryPub(streamName string) (serverID string, exist bool) {
|
||||
d.mutex.Lock()
|
||||
defer d.mutex.Unlock()
|
||||
serverID, exist = d.pubStream2ServerID[streamName]
|
||||
return
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// Copyright 2020, Chef. All rights reserved.
|
||||
// https://github.com/q191201771/lal
|
||||
//
|
||||
// Use of this source code is governed by a MIT-style license
|
||||
// that can be found in the License file.
|
||||
//
|
||||
// Author: Chef (191201771@qq.com)
|
||||
|
||||
package datamanager
|
||||
|
||||
type DataManger interface {
|
||||
AddPub(streamName, serverID string)
|
||||
DelPub(streamName, serverID string)
|
||||
QueryPub(streamName string) (serverID string, exist bool)
|
||||
}
|
||||
|
||||
type DataManagerType int
|
||||
|
||||
const (
|
||||
DMTMemory DataManagerType = iota
|
||||
)
|
||||
|
||||
func NewDataManager(t DataManagerType) DataManger {
|
||||
switch t {
|
||||
case DMTMemory:
|
||||
return NewDataManagerMemory()
|
||||
default:
|
||||
panic("invalid data manager type")
|
||||
}
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
github.com/q191201771/naza v0.15.3 h1:6IAE0J/z6vWxy1kiC4u5RFFvONa4oWgwJ+IDa5QeSPY=
|
||||
github.com/q191201771/naza v0.15.3/go.mod h1:SE14GBGO9mAn6JZl3NlfWGtNOT7xQjxOG7f3YOdBThM=
|
||||
github.com/q191201771/naza v0.15.4 h1:m9nQ08todkK08gb3sbfXSUxdvoYWRj0SpPILNOXkKV0=
|
||||
github.com/q191201771/naza v0.15.4/go.mod h1:SE14GBGO9mAn6JZl3NlfWGtNOT7xQjxOG7f3YOdBThM=
|
||||
|
@ -0,0 +1,30 @@
|
||||
// Copyright 2020, Chef. All rights reserved.
|
||||
// https://github.com/q191201771/lal
|
||||
//
|
||||
// Use of this source code is governed by a MIT-style license
|
||||
// that can be found in the License file.
|
||||
//
|
||||
// Author: Chef (191201771@qq.com)
|
||||
|
||||
package base
|
||||
|
||||
import "github.com/q191201771/naza/pkg/unique"
|
||||
|
||||
const (
|
||||
UKPRTMPServerSession = "RTMPPUBSUB"
|
||||
UKPRTSPPubSession = "RTSPPUB"
|
||||
UKPFLVSubSession = "FLVSUB"
|
||||
UKPTSSubSession = "TSSUB"
|
||||
UKPRTSPSubSession = "RTSPSUB"
|
||||
UKPRTMPPushSession = "RTMPPUSH"
|
||||
UKPRTMPPullSession = "RTMPPULL"
|
||||
UKPFLVPullSession = "FLVPULL"
|
||||
|
||||
UKPGroup = "GROUP"
|
||||
UKPHLSMuxer = "HLSMUXER"
|
||||
UKPStreamer = "STREAMER"
|
||||
)
|
||||
|
||||
func GenUniqueKey(prefix string) string {
|
||||
return unique.GenUniqueKey(prefix)
|
||||
}
|
Loading…
Reference in New Issue