|
|
|
@ -7,6 +7,7 @@ import (
@@ -7,6 +7,7 @@ import (
|
|
|
|
|
"net" |
|
|
|
|
"os" |
|
|
|
|
"os/exec" |
|
|
|
|
"runtime" |
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
"sync/atomic" |
|
|
|
@ -229,7 +230,13 @@ var errRunRecord = errors.New("record")
@@ -229,7 +230,13 @@ var errRunRecord = errors.New("record")
|
|
|
|
|
func (c *client) run() { |
|
|
|
|
var onConnectCmd *exec.Cmd |
|
|
|
|
if c.p.conf.RunOnConnect != "" { |
|
|
|
|
onConnectCmd = exec.Command("/bin/sh", "-c", c.p.conf.RunOnConnect) |
|
|
|
|
var substitutedCommand = strings.ReplaceAll(c.p.conf.RunOnConnect, "$RTSP_SERVER_PATH", c.path.name) |
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
var command = strings.Fields(substitutedCommand) |
|
|
|
|
onConnectCmd = exec.Command(command[0], command[1:]...) |
|
|
|
|
} else { |
|
|
|
|
onConnectCmd = exec.Command("/bin/sh", "-c", substitutedCommand) |
|
|
|
|
} |
|
|
|
|
onConnectCmd.Stdout = os.Stdout |
|
|
|
|
onConnectCmd.Stderr = os.Stderr |
|
|
|
|
err := onConnectCmd.Start() |
|
|
|
@ -926,10 +933,13 @@ func (c *client) runPlay() bool {
@@ -926,10 +933,13 @@ func (c *client) runPlay() bool {
|
|
|
|
|
|
|
|
|
|
var onReadCmd *exec.Cmd |
|
|
|
|
if c.path.confp.RunOnRead != "" { |
|
|
|
|
onReadCmd = exec.Command("/bin/sh", "-c", c.path.confp.RunOnRead) |
|
|
|
|
onReadCmd.Env = append(os.Environ(), |
|
|
|
|
"RTSP_SERVER_PATH="+c.path.name, |
|
|
|
|
) |
|
|
|
|
var substitutedCommand = strings.ReplaceAll(c.path.confp.RunOnRead, "$RTSP_SERVER_PATH", c.path.name) |
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
var command = strings.Fields(substitutedCommand) |
|
|
|
|
onReadCmd = exec.Command(command[0], command[1:]...) |
|
|
|
|
} else { |
|
|
|
|
onReadCmd = exec.Command("/bin/sh", "-c", substitutedCommand) |
|
|
|
|
} |
|
|
|
|
onReadCmd.Stdout = os.Stdout |
|
|
|
|
onReadCmd.Stderr = os.Stderr |
|
|
|
|
err := onReadCmd.Start() |
|
|
|
@ -1074,10 +1084,13 @@ func (c *client) runRecord() bool {
@@ -1074,10 +1084,13 @@ func (c *client) runRecord() bool {
|
|
|
|
|
|
|
|
|
|
var onPublishCmd *exec.Cmd |
|
|
|
|
if c.path.confp.RunOnPublish != "" { |
|
|
|
|
onPublishCmd = exec.Command("/bin/sh", "-c", c.path.confp.RunOnPublish) |
|
|
|
|
onPublishCmd.Env = append(os.Environ(), |
|
|
|
|
"RTSP_SERVER_PATH="+c.path.name, |
|
|
|
|
) |
|
|
|
|
var substitutedCommand = strings.ReplaceAll(c.path.confp.RunOnPublish, "$RTSP_SERVER_PATH", c.path.name) |
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
var command = strings.Fields(substitutedCommand) |
|
|
|
|
onPublishCmd = exec.Command(command[0], command[1:]...) |
|
|
|
|
} else { |
|
|
|
|
onPublishCmd = exec.Command("/bin/sh", "-c", substitutedCommand) |
|
|
|
|
} |
|
|
|
|
onPublishCmd.Stdout = os.Stdout |
|
|
|
|
onPublishCmd.Stderr = os.Stderr |
|
|
|
|
err := onPublishCmd.Start() |
|
|
|
|