Browse Source

rename disablePublisherOverride into overridePublisher (#2164)

pull/2101/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
d6058ae469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apidocs/openapi.yaml
  2. 3
      internal/conf/conf_test.go
  3. 10
      internal/conf/path.go
  4. 2
      internal/core/path.go
  5. 2
      internal/core/rtsp_server_test.go
  6. 4
      mediamtx.yml

2
apidocs/openapi.yaml

@ -218,7 +218,7 @@ components:
type: string type: string
# publisher # publisher
disablePublisherOverride: overridePublisher:
type: boolean type: boolean
fallback: fallback:
type: string type: string

3
internal/conf/conf_test.go

@ -51,6 +51,7 @@ func TestConfFromFile(t *testing.T) {
Source: "publisher", Source: "publisher",
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second), SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second), SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
OverridePublisher: true,
RPICameraWidth: 1920, RPICameraWidth: 1920,
RPICameraHeight: 1080, RPICameraHeight: 1080,
RPICameraContrast: 1, RPICameraContrast: 1,
@ -120,6 +121,7 @@ func TestConfFromFileAndEnv(t *testing.T) {
Source: "rtsp://testing", Source: "rtsp://testing",
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second), SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second), SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
OverridePublisher: true,
RPICameraWidth: 1920, RPICameraWidth: 1920,
RPICameraHeight: 1080, RPICameraHeight: 1080,
RPICameraContrast: 1, RPICameraContrast: 1,
@ -150,6 +152,7 @@ func TestConfFromEnvOnly(t *testing.T) {
Source: "rtsp://testing", Source: "rtsp://testing",
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second), SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second), SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
OverridePublisher: true,
RPICameraWidth: 1920, RPICameraWidth: 1920,
RPICameraHeight: 1080, RPICameraHeight: 1080,
RPICameraContrast: 1, RPICameraContrast: 1,

10
internal/conf/path.go

@ -61,7 +61,8 @@ type PathConf struct {
ReadIPs IPsOrCIDRs `json:"readIPs"` ReadIPs IPsOrCIDRs `json:"readIPs"`
// publisher // publisher
DisablePublisherOverride bool `json:"disablePublisherOverride"` OverridePublisher bool `json:"overridePublisher"`
DisablePublisherOverride bool `json:"disablePublisherOverride"` // deprecated
Fallback string `json:"fallback"` Fallback string `json:"fallback"`
// rtsp // rtsp
@ -262,6 +263,10 @@ func (pconf *PathConf) check(conf *Conf, name string) error {
} }
} }
if pconf.DisablePublisherOverride {
pconf.OverridePublisher = true
}
if pconf.Fallback != "" { if pconf.Fallback != "" {
if strings.HasPrefix(pconf.Fallback, "/") { if strings.HasPrefix(pconf.Fallback, "/") {
err := IsValidPathName(pconf.Fallback[1:]) err := IsValidPathName(pconf.Fallback[1:])
@ -380,6 +385,9 @@ func (pconf *PathConf) UnmarshalJSON(b []byte) error {
pconf.SourceOnDemandStartTimeout = 10 * StringDuration(time.Second) pconf.SourceOnDemandStartTimeout = 10 * StringDuration(time.Second)
pconf.SourceOnDemandCloseAfter = 10 * StringDuration(time.Second) pconf.SourceOnDemandCloseAfter = 10 * StringDuration(time.Second)
// publisher
pconf.OverridePublisher = true
// raspberry pi camera // raspberry pi camera
pconf.RPICameraWidth = 1920 pconf.RPICameraWidth = 1920
pconf.RPICameraHeight = 1080 pconf.RPICameraHeight = 1080

2
internal/core/path.go

@ -761,7 +761,7 @@ func (pa *path) handleAddPublisher(req pathAddPublisherReq) {
} }
if pa.source != nil { if pa.source != nil {
if pa.conf.DisablePublisherOverride { if !pa.conf.OverridePublisher {
req.res <- pathAddPublisherRes{err: fmt.Errorf("someone is already publishing to path '%s'", pa.name)} req.res <- pathAddPublisherRes{err: fmt.Errorf("someone is already publishing to path '%s'", pa.name)}
return return
} }

2
internal/core/rtsp_server_test.go

@ -287,7 +287,7 @@ func TestRTSPServerPublisherOverride(t *testing.T) {
" all:\n" " all:\n"
if ca == "disabled" { if ca == "disabled" {
conf += " disablePublisherOverride: yes\n" conf += " overridePublisher: no\n"
} }
p, ok := newInstance(conf) p, ok := newInstance(conf)

4
mediamtx.yml

@ -306,8 +306,8 @@ paths:
############################################### ###############################################
# Publisher path parameters (when source is "publisher") # Publisher path parameters (when source is "publisher")
# do not allow another client to disconnect the current publisher and publish in its place. # allow another client to disconnect the current publisher and publish in its place.
disablePublisherOverride: no overridePublisher: yes
# if no one is publishing, redirect readers to this path. # if no one is publishing, redirect readers to this path.
# It can be can be a relative path (i.e. /otherstream) or an absolute RTSP URL. # It can be can be a relative path (i.e. /otherstream) or an absolute RTSP URL.
fallback: fallback:

Loading…
Cancel
Save