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: fallback:
type: string type: string
# Record and playback # Record
record: record:
type: boolean type: boolean
playback:
type: boolean
recordPath: recordPath:
type: string type: string
recordFormat: recordFormat:

View file

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

View file

@ -103,14 +103,12 @@ func getAllPathsWithRecordings(paths map[string]*conf.Path) []string {
pathNames := []string{} pathNames := []string{}
for _, pathConf := range paths { for _, pathConf := range paths {
if pathConf.Playback { if pathConf.Regexp == nil {
if pathConf.Regexp == nil { if fixedPathHasRecordings(pathConf) {
if fixedPathHasRecordings(pathConf) { pathNames = append(pathNames, pathConf.Name)
pathNames = append(pathNames, pathConf.Name)
}
} else {
pathNames = append(pathNames, regexpPathGetRecordings(pathConf)...)
} }
} else {
pathNames = append(pathNames, regexpPathGetRecordings(pathConf)...)
} }
} }

View file

@ -52,7 +52,6 @@ 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),
Playback: true,
RecordPath: "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f", RecordPath: "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f",
RecordFormat: RecordFormatFMP4, RecordFormat: RecordFormatFMP4,
RecordPartDuration: 100000000, RecordPartDuration: 100000000,

View file

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

View file

@ -250,7 +250,6 @@ func TestOnGet(t *testing.T) {
ReadTimeout: conf.StringDuration(10 * time.Second), ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{ PathConfs: map[string]*conf.Path{
"mypath": { "mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"), 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), ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{ PathConfs: map[string]*conf.Path{
"mypath": { "mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"), 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), ReadTimeout: conf.StringDuration(10 * time.Second),
PathConfs: map[string]*conf.Path{ PathConfs: map[string]*conf.Path{
"mypath": { "mypath": {
Playback: true,
RecordPath: filepath.Join(dir, "%path/%Y-%m-%d_%H-%M-%S-%f"), 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 return
} }
if !pathConf.Playback {
p.writeError(ctx, http.StatusBadRequest, fmt.Errorf("playback is disabled on path '%s'", pathName))
return
}
segments, err := FindSegments(pathConf, pathName) segments, err := FindSegments(pathConf, pathName)
if err != nil { if err != nil {
if errors.Is(err, errNoSegmentsFound) { if errors.Is(err, errNoSegmentsFound) {

View file

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

View file

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

View file

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