rename disablePublisherOverride into overridePublisher (#2164)

This commit is contained in:
Alessandro Ros 2023-08-06 21:29:16 +02:00 committed by GitHub
parent 7d7cedc509
commit d6058ae469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 6 deletions

View File

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

View File

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

View File

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

View File

@ -761,7 +761,7 @@ func (pa *path) handleAddPublisher(req pathAddPublisherReq) {
}
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)}
return
}

View File

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

View File

@ -306,8 +306,8 @@ paths:
###############################################
# Publisher path parameters (when source is "publisher")
# do not allow another client to disconnect the current publisher and publish in its place.
disablePublisherOverride: no
# allow another client to disconnect the current publisher and publish in its place.
overridePublisher: yes
# 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.
fallback: