1
0
Fork 0
forked from External/mediamtx

deprecate path.playback parameter (#3217)

this has become useless after the introduction of the new
authentication system, that already allows to select which paths are
available for playback
This commit is contained in:
Alessandro Ros 2024-04-09 10:04:12 +02:00 committed by GitHub
parent a50642c669
commit 0b5519d30c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 10 additions and 47 deletions

View file

@ -223,11 +223,9 @@ components:
fallback:
type: string
# Record and playback
# Record
record:
type: boolean
playback:
type: boolean
recordPath:
type: string
recordFormat:

View file

@ -1128,11 +1128,6 @@ func (a *API) onRecordingsGet(ctx *gin.Context) {
return
}
if !pathConf.Playback {
a.writeError(ctx, http.StatusBadRequest, fmt.Errorf("playback is disabled on path '%s'", pathName))
return
}
ctx.JSON(http.StatusOK, recordingEntry(pathConf, pathName))
}
@ -1155,11 +1150,6 @@ func (a *API) onRecordingDeleteSegment(ctx *gin.Context) {
return
}
if !pathConf.Playback {
a.writeError(ctx, http.StatusBadRequest, fmt.Errorf("playback is disabled on path '%s'", pathName))
return
}
pathFormat := record.PathAddExtension(
strings.ReplaceAll(pathConf.RecordPath, "%path", pathName),
pathConf.RecordFormat,

View file

@ -103,7 +103,6 @@ func getAllPathsWithRecordings(paths map[string]*conf.Path) []string {
pathNames := []string{}
for _, pathConf := range paths {
if pathConf.Playback {
if pathConf.Regexp == nil {
if fixedPathHasRecordings(pathConf) {
pathNames = append(pathNames, pathConf.Name)
@ -112,7 +111,6 @@ func getAllPathsWithRecordings(paths map[string]*conf.Path) []string {
pathNames = append(pathNames, regexpPathGetRecordings(pathConf)...)
}
}
}
return removeDuplicatesAndSort(pathNames)
}

View file

@ -52,7 +52,6 @@ func TestConfFromFile(t *testing.T) {
Source: "publisher",
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
Playback: true,
RecordPath: "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f",
RecordFormat: RecordFormatFMP4,
RecordPartDuration: 100000000,

View file

@ -95,9 +95,9 @@ type Path struct {
SRTReadPassphrase string `json:"srtReadPassphrase"`
Fallback string `json:"fallback"`
// Record and playback
// Record
Record bool `json:"record"`
Playback bool `json:"playback"`
Playback *bool `json:"playback,omitempty"` // deprecated
RecordPath string `json:"recordPath"`
RecordFormat RecordFormat `json:"recordFormat"`
RecordPartDuration StringDuration `json:"recordPartDuration"`
@ -187,8 +187,7 @@ func (pconf *Path) setDefaults() {
pconf.SourceOnDemandStartTimeout = 10 * StringDuration(time.Second)
pconf.SourceOnDemandCloseAfter = 10 * StringDuration(time.Second)
// Record and playback
pconf.Playback = true
// Record
pconf.RecordPath = "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f"
pconf.RecordFormat = RecordFormatFMP4
pconf.RecordPartDuration = 100 * StringDuration(time.Millisecond)

View file

@ -250,7 +250,6 @@ func TestOnGet(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{
"mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},
@ -345,7 +344,6 @@ func TestOnGetDifferentInit(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{
"mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},
@ -421,7 +419,6 @@ func TestOnGetNTPCompensation(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{
"mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},

View file

@ -96,11 +96,6 @@ func (p *Server) onList(ctx *gin.Context) {
return
}
if !pathConf.Playback {
p.writeError(ctx, http.StatusBadRequest, fmt.Errorf("playback is disabled on path '%s'", pathName))
return
}
segments, err := FindSegments(pathConf, pathName)
if err != nil {
if errors.Is(err, errNoSegmentsFound) {

View file

@ -31,7 +31,6 @@ func TestOnList(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{
"mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},
@ -90,7 +89,6 @@ func TestOnListDifferentInit(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{
"mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"),
},
},

View file

@ -1,7 +1,6 @@
package playback
import (
"fmt"
"io/fs"
"path/filepath"
"sort"
@ -24,10 +23,6 @@ func findSegmentsInTimespan(
start time.Time,
duration time.Duration,
) ([]*Segment, error) {
if !pathConf.Playback {
return nil, fmt.Errorf("playback is disabled on path '%s'", pathName)
}
recordPath := record.PathAddExtension(
strings.ReplaceAll(pathConf.RecordPath, "%path", pathName),
pathConf.RecordFormat,
@ -99,10 +94,6 @@ func FindSegments(
pathConf *conf.Path,
pathName string,
) ([]*Segment, error) {
if !pathConf.Playback {
return nil, fmt.Errorf("playback is disabled on path '%s'", pathName)
}
recordPath := record.PathAddExtension(
strings.ReplaceAll(pathConf.RecordPath, "%path", pathName),
pathConf.RecordFormat,

View file

@ -372,12 +372,10 @@ pathDefaults:
fallback:
###############################################
# Default path settings -> Record and playback
# Default path settings -> Record
# Record streams to disk.
record: no
# Enable serving recordings with the playback server.
playback: yes
# Path of recording segments.
# Extension is added automatically.
# Available variables are %path (path name), %Y %m %d %H %M %S %f %s (time in strftime format)