mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Add the process domain to the bas path in placeholders and cleanup rules
This commit is contained in:
100
app/api/api.go
100
app/api/api.go
@@ -47,6 +47,7 @@ import (
|
||||
"github.com/datarhei/core/v16/service"
|
||||
"github.com/datarhei/core/v16/session"
|
||||
"github.com/datarhei/core/v16/srt"
|
||||
srturl "github.com/datarhei/core/v16/srt/url"
|
||||
"github.com/datarhei/core/v16/update"
|
||||
|
||||
"github.com/caddyserver/certmagic"
|
||||
@@ -858,11 +859,21 @@ func (a *api) start() error {
|
||||
})
|
||||
|
||||
a.replacer.RegisterReplaceFunc("diskfs", func(params map[string]string, config *restreamapp.Config, section string) string {
|
||||
return a.diskfs.Metadata("base")
|
||||
path := a.diskfs.Metadata("base")
|
||||
if len(config.Domain) != 0 {
|
||||
path = filepath.Join(path, config.Domain)
|
||||
}
|
||||
|
||||
return path
|
||||
}, nil)
|
||||
|
||||
a.replacer.RegisterReplaceFunc("fs:disk", func(params map[string]string, config *restreamapp.Config, section string) string {
|
||||
return a.diskfs.Metadata("base")
|
||||
path := a.diskfs.Metadata("base")
|
||||
if len(config.Domain) != 0 {
|
||||
path = filepath.Join(path, config.Domain)
|
||||
}
|
||||
|
||||
return path
|
||||
}, nil)
|
||||
|
||||
a.replacer.RegisterReplaceFunc("memfs", func(params map[string]string, config *restreamapp.Config, section string) string {
|
||||
@@ -886,6 +897,10 @@ func (a *api) start() error {
|
||||
u.User = url.User(config.Owner)
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
u = u.JoinPath(config.Domain)
|
||||
}
|
||||
|
||||
return u.String()
|
||||
}, nil)
|
||||
|
||||
@@ -910,6 +925,10 @@ func (a *api) start() error {
|
||||
u.User = url.User(config.Owner)
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
u = u.JoinPath(config.Domain)
|
||||
}
|
||||
|
||||
return u.String()
|
||||
}, nil)
|
||||
|
||||
@@ -923,13 +942,21 @@ func (a *api) start() error {
|
||||
if len(config.Owner) == 0 {
|
||||
identity = a.iam.GetDefaultVerifier()
|
||||
} else {
|
||||
identity, _ = a.iam.GetVerifier(config.Owner)
|
||||
var err error = nil
|
||||
identity, err = a.iam.GetVerifier(config.Owner)
|
||||
if err != nil {
|
||||
identity = nil
|
||||
}
|
||||
}
|
||||
|
||||
if identity != nil {
|
||||
u.User = url.UserPassword(config.Owner, identity.GetServiceBasicAuth())
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
u = u.JoinPath(config.Domain)
|
||||
}
|
||||
|
||||
return u.String()
|
||||
}, nil)
|
||||
}
|
||||
@@ -940,25 +967,39 @@ func (a *api) start() error {
|
||||
host = "localhost"
|
||||
}
|
||||
|
||||
template := "rtmp://" + host + ":" + port
|
||||
if cfg.RTMP.App != "/" {
|
||||
template += cfg.RTMP.App
|
||||
u := &url.URL{
|
||||
Scheme: "rtmp:",
|
||||
Host: host + ":" + port,
|
||||
Path: "/",
|
||||
}
|
||||
template += "/" + params["name"]
|
||||
|
||||
if cfg.RTMP.App != "/" {
|
||||
u = u.JoinPath(cfg.RTMP.App)
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
u = u.JoinPath(config.Domain)
|
||||
}
|
||||
|
||||
u = u.JoinPath(params["name"])
|
||||
|
||||
var identity iamidentity.Verifier = nil
|
||||
|
||||
if len(config.Owner) == 0 {
|
||||
identity = a.iam.GetDefaultVerifier()
|
||||
} else {
|
||||
identity, _ = a.iam.GetVerifier(config.Owner)
|
||||
var err error = nil
|
||||
identity, err = a.iam.GetVerifier(config.Owner)
|
||||
if err != nil {
|
||||
identity = nil
|
||||
}
|
||||
}
|
||||
|
||||
if identity != nil {
|
||||
template += "/" + identity.GetServiceToken()
|
||||
u = u.JoinPath(identity.GetServiceToken())
|
||||
}
|
||||
|
||||
return template
|
||||
return u.String()
|
||||
}, map[string]string{
|
||||
"name": "",
|
||||
})
|
||||
@@ -969,9 +1010,30 @@ func (a *api) start() error {
|
||||
host = "localhost"
|
||||
}
|
||||
|
||||
template := "srt://" + host + ":" + port + "?mode=caller&transtype=live&latency=" + params["latency"] + "&streamid=" + params["name"]
|
||||
u := srturl.URL{
|
||||
Scheme: "srt:",
|
||||
Host: host + ":" + port,
|
||||
}
|
||||
|
||||
options := url.Values{}
|
||||
|
||||
options.Set("mode", "caller")
|
||||
options.Set("transtype", "live")
|
||||
|
||||
if len(cfg.SRT.Passphrase) != 0 {
|
||||
options.Set("passphrase", cfg.SRT.Passphrase)
|
||||
}
|
||||
|
||||
streamid := srturl.StreamInfo{}
|
||||
|
||||
if section == "output" {
|
||||
template += ",mode:publish"
|
||||
streamid.Mode = "publish"
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
streamid.Resource = config.Domain + "/" + params["name"]
|
||||
} else {
|
||||
streamid.Resource = params["name"]
|
||||
}
|
||||
|
||||
var identity iamidentity.Verifier = nil
|
||||
@@ -979,18 +1041,18 @@ func (a *api) start() error {
|
||||
if len(config.Owner) == 0 {
|
||||
identity = a.iam.GetDefaultVerifier()
|
||||
} else {
|
||||
identity, _ = a.iam.GetVerifier(config.Owner)
|
||||
var err error = nil
|
||||
identity, err = a.iam.GetVerifier(config.Owner)
|
||||
if err != nil {
|
||||
identity = nil
|
||||
}
|
||||
}
|
||||
|
||||
if identity != nil {
|
||||
template += ",token:" + identity.GetServiceToken()
|
||||
streamid.Token = identity.GetServiceToken()
|
||||
}
|
||||
|
||||
if len(cfg.SRT.Passphrase) != 0 {
|
||||
template += "&passphrase=" + url.QueryEscape(cfg.SRT.Passphrase)
|
||||
}
|
||||
|
||||
return template
|
||||
return u.String()
|
||||
}, map[string]string{
|
||||
"name": "",
|
||||
"latency": "20000", // 20 milliseconds, FFmpeg requires microseconds
|
||||
|
@@ -721,6 +721,10 @@ func (r *restream) setCleanup(id app.ProcessID, config *app.Config) {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(config.Domain) != 0 {
|
||||
path = filepath.Join(config.Domain, path)
|
||||
}
|
||||
|
||||
// Support legacy names
|
||||
if name == "diskfs" {
|
||||
name = "disk"
|
||||
|
Reference in New Issue
Block a user