Fix exec handler run pipe instead of rtsp
This commit is contained in:
+16
-16
@@ -49,34 +49,34 @@ func Init() {
|
|||||||
|
|
||||||
func execHandle(rawURL string) (core.Producer, error) {
|
func execHandle(rawURL string) (core.Producer, error) {
|
||||||
var path string
|
var path string
|
||||||
|
var query url.Values
|
||||||
|
|
||||||
rawURL, rawQuery, _ := strings.Cut(rawURL, "#")
|
// RTSP flow should have `{output}` inside URL
|
||||||
|
// pipe flow may have `#{params}` inside URL
|
||||||
args := shell.QuoteSplit(rawURL[5:]) // remove `exec:`
|
if i := strings.Index(rawURL, "{output}"); i > 0 {
|
||||||
for i, arg := range args {
|
if rtsp.Port == "" {
|
||||||
if arg == "{output}" {
|
return nil, errors.New("exec: rtsp module disabled")
|
||||||
if rtsp.Port == "" {
|
|
||||||
return nil, errors.New("rtsp module disabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
sum := md5.Sum([]byte(rawURL))
|
|
||||||
path = "/" + hex.EncodeToString(sum[:])
|
|
||||||
args[i] = "rtsp://127.0.0.1:" + rtsp.Port + path
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sum := md5.Sum([]byte(rawURL))
|
||||||
|
path = "/" + hex.EncodeToString(sum[:])
|
||||||
|
rawURL = rawURL[:i] + "rtsp://127.0.0.1:" + rtsp.Port + path + rawURL[i+8:]
|
||||||
|
} else if i = strings.IndexByte(rawURL, '#'); i > 0 {
|
||||||
|
query = streams.ParseQuery(rawURL[i+1:])
|
||||||
|
rawURL = rawURL[:i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args := shell.QuoteSplit(rawURL[5:]) // remove `exec:`
|
||||||
cmd := exec.Command(args[0], args[1:]...)
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
if log.Debug().Enabled() {
|
if log.Debug().Enabled() {
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == "" {
|
if path == "" {
|
||||||
query := streams.ParseQuery(rawQuery)
|
|
||||||
return handlePipe(rawURL, cmd, query)
|
return handlePipe(rawURL, cmd, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleRTSP(rawURL, path, cmd)
|
return handleRTSP(rawURL, cmd, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePipe(_ string, cmd *exec.Cmd, query url.Values) (core.Producer, error) {
|
func handlePipe(_ string, cmd *exec.Cmd, query url.Values) (core.Producer, error) {
|
||||||
@@ -101,7 +101,7 @@ func handlePipe(_ string, cmd *exec.Cmd, query url.Values) (core.Producer, error
|
|||||||
return prod, err
|
return prod, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleRTSP(url, path string, cmd *exec.Cmd) (core.Producer, error) {
|
func handleRTSP(url string, cmd *exec.Cmd, path string) (core.Producer, error) {
|
||||||
if log.Trace().Enabled() {
|
if log.Trace().Enabled() {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user