Browse Source

remove pathEnvVariable

pull/80/head
aler9 6 years ago
parent
commit
161f1ec2bd
  1. 4
      client.go
  2. 9
      conf.go
  3. 2
      main.go
  4. 2
      path.go
  5. 23
      rtsp-simple-server.yml

4
client.go

@ -830,7 +830,7 @@ func (c *client) runPlay(path string) {
if confp.RunOnRead != "" { if confp.RunOnRead != "" {
onReadCmd = exec.Command("/bin/sh", "-c", confp.RunOnRead) onReadCmd = exec.Command("/bin/sh", "-c", confp.RunOnRead)
onReadCmd.Env = append(os.Environ(), onReadCmd.Env = append(os.Environ(),
c.p.conf.PathEnvVariable+"="+path, "RTSP_SERVER_PATH="+path,
) )
onReadCmd.Stdout = os.Stdout onReadCmd.Stdout = os.Stdout
onReadCmd.Stderr = os.Stderr onReadCmd.Stderr = os.Stderr
@ -932,7 +932,7 @@ func (c *client) runRecord(path string) {
if confp.RunOnPublish != "" { if confp.RunOnPublish != "" {
onPublishCmd = exec.Command("/bin/sh", "-c", confp.RunOnPublish) onPublishCmd = exec.Command("/bin/sh", "-c", confp.RunOnPublish)
onPublishCmd.Env = append(os.Environ(), onPublishCmd.Env = append(os.Environ(),
c.p.conf.PathEnvVariable+"="+path, "RTSP_SERVER_PATH="+path,
) )
onPublishCmd.Stdout = os.Stdout onPublishCmd.Stdout = os.Stdout
onPublishCmd.Stderr = os.Stderr onPublishCmd.Stderr = os.Stderr

9
conf.go

@ -41,7 +41,6 @@ type conf struct {
RunOnConnect string `yaml:"runOnConnect"` RunOnConnect string `yaml:"runOnConnect"`
ReadTimeout time.Duration `yaml:"readTimeout"` ReadTimeout time.Duration `yaml:"readTimeout"`
WriteTimeout time.Duration `yaml:"writeTimeout"` WriteTimeout time.Duration `yaml:"writeTimeout"`
PathEnvVariable string `yaml:"pathEnvVariable"`
AuthMethods []string `yaml:"authMethods"` AuthMethods []string `yaml:"authMethods"`
authMethodsParsed []gortsplib.AuthMethod `` authMethodsParsed []gortsplib.AuthMethod ``
Metrics bool `yaml:"metrics"` Metrics bool `yaml:"metrics"`
@ -133,14 +132,6 @@ func loadConf(fpath string, stdin io.Reader) (*conf, error) {
conf.WriteTimeout = 5 * time.Second conf.WriteTimeout = 5 * time.Second
} }
if conf.PathEnvVariable == "" {
conf.PathEnvVariable = "RTSP_SERVER_PATH"
}
re := regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
if !re.MatchString(conf.PathEnvVariable) {
return nil, fmt.Errorf("pathEnvVariable must consist of only alphanumerics and underscores, and should not begin with a digit")
}
if len(conf.AuthMethods) == 0 { if len(conf.AuthMethods) == 0 {
conf.AuthMethods = []string{"basic", "digest"} conf.AuthMethods = []string{"basic", "digest"}
} }

2
main.go

@ -266,7 +266,7 @@ func newProgram(args []string, stdin io.Reader) (*program, error) {
if confp.RunOnInit != "" { if confp.RunOnInit != "" {
onInitCmd := exec.Command("/bin/sh", "-c", confp.RunOnInit) onInitCmd := exec.Command("/bin/sh", "-c", confp.RunOnInit)
onInitCmd.Env = append(os.Environ(), onInitCmd.Env = append(os.Environ(),
conf.PathEnvVariable+"="+path, "RTSP_SERVER_PATH="+path,
) )
onInitCmd.Stdout = os.Stdout onInitCmd.Stdout = os.Stdout
onInitCmd.Stderr = os.Stderr onInitCmd.Stderr = os.Stderr

2
path.go

@ -123,7 +123,7 @@ func (pa *path) describe(client *client) {
pa.lastActivation = time.Now() pa.lastActivation = time.Now()
pa.onDemandCmd = exec.Command("/bin/sh", "-c", pa.confp.RunOnDemand) pa.onDemandCmd = exec.Command("/bin/sh", "-c", pa.confp.RunOnDemand)
pa.onDemandCmd.Env = append(os.Environ(), pa.onDemandCmd.Env = append(os.Environ(),
pa.p.conf.PathEnvVariable+"="+pa.id, "RTSP_SERVER_PATH="+pa.id,
) )
pa.onDemandCmd.Stdout = os.Stdout pa.onDemandCmd.Stdout = os.Stdout
pa.onDemandCmd.Stderr = os.Stderr pa.onDemandCmd.Stderr = os.Stderr

23
rtsp-simple-server.yml

@ -7,18 +7,20 @@ rtspPort: 8554
rtpPort: 8000 rtpPort: 8000
# port of the UDP RTCP listener # port of the UDP RTCP listener
rtcpPort: 8001 rtcpPort: 8001
# command to run when a client connects.
# this is terminated with SIGINT when a client disconnects.
runOnConnect:
# timeout of read operations # timeout of read operations
readTimeout: 10s readTimeout: 10s
# timeout of write operations # timeout of write operations
writeTimeout: 5s writeTimeout: 5s
# name of environment variable used to pass the path to runOnInit/Demand/Publish/Read
pathEnvVariable: RTSP_SERVER_PATH
# supported authentication methods # supported authentication methods
# WARNING: both methods are insecure, use RTSP inside a VPN to enforce security. # WARNING: both methods are insecure, use RTSP inside a VPN to enforce security.
authMethods: [basic, digest] authMethods: [basic, digest]
# command to run when a client connects.
# this is terminated with SIGINT when a client disconnects.
runOnConnect:
# enable Prometheus-compatible metrics on port 9998 # enable Prometheus-compatible metrics on port 9998
metrics: false metrics: false
# enable pprof on port 9999 to monitor performances # enable pprof on port 9999 to monitor performances
@ -45,26 +47,23 @@ paths:
# command to run when this path is loaded by the program. # command to run when this path is loaded by the program.
# this can be used, for example, to publish a stream and keep it always opened. # this can be used, for example, to publish a stream and keep it always opened.
# This is terminated with SIGINT when the program closes. # This is terminated with SIGINT when the program closes.
# The path is available as an environment variable configured by pathEnvVariable # The path can be accessed with the variable RTSP_SERVER_PATH
runOnInit: runOnInit:
# command to run when this path is requested. # command to run when this path is requested.
# This can be used, for example, to publish a stream on demand. # This can be used, for example, to publish a stream on demand.
# This is terminated with SIGINT when the path is not requested anymore. # This is terminated with SIGINT when the path is not requested anymore.
# The actual path from the request (useful for wildcard paths) is available as an # The path can be accessed with the variable RTSP_SERVER_PATH
# environment variable configured by pathEnvVariable
runOnDemand: runOnDemand:
# command to run when a client starts publishing. # command to run when a client starts publishing.
# This is terminated with SIGINT when a client stops publishing. # This is terminated with SIGINT when a client stops publishing.
# The actual path from the client (useful for wildcard paths) is available as an # The path can be accessed with the variable RTSP_SERVER_PATH
# environment variable configured by pathEnvVariable
runOnPublish: runOnPublish:
# command to run when a clients starts reading. # command to run when a clients starts reading.
# This is terminated with SIGINT when a client stops reading. # This is terminated with SIGINT when a client stops reading.
# The actual path from the client (useful for wildcard paths) is available as an # The path can be accessed with the variable RTSP_SERVER_PATH
# environment variable configured by pathEnvVariable
runOnRead: runOnRead:
# username required to publish # username required to publish

Loading…
Cancel
Save