mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-19 17:50:03 -08:00
update golangci-lint configuration (#5182)
This commit is contained in:
parent
ac1d4360b2
commit
ff187b6d8a
80 changed files with 294 additions and 309 deletions
|
|
@ -12,6 +12,7 @@ linters:
|
||||||
- gocritic
|
- gocritic
|
||||||
- lll
|
- lll
|
||||||
- misspell
|
- misspell
|
||||||
|
- modernize
|
||||||
- nilerr
|
- nilerr
|
||||||
- prealloc
|
- prealloc
|
||||||
- predeclared
|
- predeclared
|
||||||
|
|
@ -71,6 +72,12 @@ linters:
|
||||||
shadow:
|
shadow:
|
||||||
strict: true
|
strict: true
|
||||||
|
|
||||||
|
modernize:
|
||||||
|
disable:
|
||||||
|
- reflecttypefor
|
||||||
|
- stringsbuilder
|
||||||
|
- testingcontext
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
enable:
|
enable:
|
||||||
- gofmt
|
- gofmt
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/bluenviron/mediamtx/internal/servers/webrtc"
|
"github.com/bluenviron/mediamtx/internal/servers/webrtc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +220,7 @@ func (a *API) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (a *API) Log(level logger.Level, format string, args ...interface{}) {
|
func (a *API) Log(level logger.Level, format string, args ...any) {
|
||||||
a.Parent.Log(level, "[API] "+format, args...)
|
a.Parent.Log(level, "[API] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testParent struct {
|
type testParent struct {
|
||||||
log func(_ logger.Level, _ string, _ ...interface{})
|
log func(_ logger.Level, _ string, _ ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p testParent) Log(l logger.Level, s string, a ...interface{}) {
|
func (p testParent) Log(l logger.Level, s string, a ...any) {
|
||||||
if p.log != nil {
|
if p.log != nil {
|
||||||
p.log(l, s, a...)
|
p.log(l, s, a...)
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ func tempConf(t *testing.T, cnt string) *conf.Conf {
|
||||||
return cnf
|
return cnf
|
||||||
}
|
}
|
||||||
|
|
||||||
func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in interface{}, out interface{}) {
|
func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in any, out any) {
|
||||||
buf := func() io.Reader {
|
buf := func() io.Reader {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -74,10 +74,10 @@ func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in int
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkError(t *testing.T, msg string, body io.Reader) {
|
func checkError(t *testing.T, msg string, body io.Reader) {
|
||||||
var resErr map[string]interface{}
|
var resErr map[string]any
|
||||||
err := json.NewDecoder(body).Decode(&resErr)
|
err := json.NewDecoder(body).Decode(&resErr)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, map[string]interface{}{"error": msg}, resErr)
|
require.Equal(t, map[string]any{"error": msg}, resErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPreflightRequest(t *testing.T) {
|
func TestPreflightRequest(t *testing.T) {
|
||||||
|
|
@ -139,9 +139,9 @@ func TestInfo(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/info", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/info", nil, &out)
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"started": time.Date(2008, 11, 7, 11, 22, 0, 0, time.Local).Format(time.RFC3339),
|
"started": time.Date(2008, 11, 7, 11, 22, 0, 0, time.Local).Format(time.RFC3339),
|
||||||
"version": "v1.2.3",
|
"version": "v1.2.3",
|
||||||
}, out)
|
}, out)
|
||||||
|
|
@ -175,7 +175,7 @@ func TestConfigGlobalGet(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://myuser:mypass@localhost:9997/v3/config/global/get", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://myuser:mypass@localhost:9997/v3/config/global/get", nil, &out)
|
||||||
require.Equal(t, true, out["api"])
|
require.Equal(t, true, out["api"])
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ func TestConfigGlobalPatch(t *testing.T) {
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch",
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"rtmp": false,
|
"rtmp": false,
|
||||||
"readTimeout": "7s",
|
"readTimeout": "7s",
|
||||||
"protocols": []string{"tcp"},
|
"protocols": []string{"tcp"},
|
||||||
|
|
@ -211,11 +211,11 @@ func TestConfigGlobalPatch(t *testing.T) {
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/global/get", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/global/get", nil, &out)
|
||||||
require.Equal(t, false, out["rtmp"])
|
require.Equal(t, false, out["rtmp"])
|
||||||
require.Equal(t, "7s", out["readTimeout"])
|
require.Equal(t, "7s", out["readTimeout"])
|
||||||
require.Equal(t, []interface{}{"tcp"}, out["protocols"])
|
require.Equal(t, []any{"tcp"}, out["protocols"])
|
||||||
require.Equal(t, float64(4096), out["readBufferCount"])
|
require.Equal(t, float64(4096), out["readBufferCount"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +234,7 @@ func TestConfigGlobalPatchUnknownField(t *testing.T) { //nolint:dupl
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
|
||||||
b := map[string]interface{}{
|
b := map[string]any{
|
||||||
"test": "asd",
|
"test": "asd",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,7 +276,7 @@ func TestConfigPathDefaultsGet(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/pathdefaults/get", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/pathdefaults/get", nil, &out)
|
||||||
require.Equal(t, "publisher", out["source"])
|
require.Equal(t, "publisher", out["source"])
|
||||||
}
|
}
|
||||||
|
|
@ -301,13 +301,13 @@ func TestConfigPathDefaultsPatch(t *testing.T) {
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/pathdefaults/patch",
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/pathdefaults/patch",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"recordFormat": "fmp4",
|
"recordFormat": "fmp4",
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/pathdefaults/get", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/pathdefaults/get", nil, &out)
|
||||||
require.Equal(t, "fmp4", out["recordFormat"])
|
require.Equal(t, "fmp4", out["recordFormat"])
|
||||||
}
|
}
|
||||||
|
|
@ -334,7 +334,7 @@ func TestConfigPathsList(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
|
||||||
type pathConfig map[string]interface{}
|
type pathConfig map[string]any
|
||||||
|
|
||||||
type listRes struct {
|
type listRes struct {
|
||||||
ItemCount int `json:"itemCount"`
|
ItemCount int `json:"itemCount"`
|
||||||
|
|
@ -381,7 +381,7 @@ func TestConfigPathsGet(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
require.Equal(t, "my/path", out["name"])
|
require.Equal(t, "my/path", out["name"])
|
||||||
require.Equal(t, "myuser", out["readUser"])
|
require.Equal(t, "myuser", out["readUser"])
|
||||||
|
|
@ -407,14 +407,14 @@ func TestConfigPathsAdd(t *testing.T) {
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9999/mypath",
|
"source": "rtsp://127.0.0.1:9999/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
"disablePublisherOverride": true, // test setting a deprecated parameter
|
"disablePublisherOverride": true, // test setting a deprecated parameter
|
||||||
"rpiCameraVFlip": true,
|
"rpiCameraVFlip": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
require.Equal(t, "rtsp://127.0.0.1:9999/mypath", out["source"])
|
require.Equal(t, "rtsp://127.0.0.1:9999/mypath", out["source"])
|
||||||
require.Equal(t, true, out["sourceOnDemand"])
|
require.Equal(t, true, out["sourceOnDemand"])
|
||||||
|
|
@ -437,7 +437,7 @@ func TestConfigPathsAddUnknownField(t *testing.T) { //nolint:dupl
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer api.Close()
|
defer api.Close()
|
||||||
|
|
||||||
b := map[string]interface{}{
|
b := map[string]any{
|
||||||
"test": "asd",
|
"test": "asd",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,7 +480,7 @@ func TestConfigPathsPatch(t *testing.T) { //nolint:dupl
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9999/mypath",
|
"source": "rtsp://127.0.0.1:9999/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
"disablePublisherOverride": true, // test setting a deprecated parameter
|
"disablePublisherOverride": true, // test setting a deprecated parameter
|
||||||
|
|
@ -488,12 +488,12 @@ func TestConfigPathsPatch(t *testing.T) { //nolint:dupl
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/my/path",
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9998/mypath",
|
"source": "rtsp://127.0.0.1:9998/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
||||||
require.Equal(t, true, out["sourceOnDemand"])
|
require.Equal(t, true, out["sourceOnDemand"])
|
||||||
|
|
@ -521,7 +521,7 @@ func TestConfigPathsReplace(t *testing.T) { //nolint:dupl
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9999/mypath",
|
"source": "rtsp://127.0.0.1:9999/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
"disablePublisherOverride": true, // test setting a deprecated parameter
|
"disablePublisherOverride": true, // test setting a deprecated parameter
|
||||||
|
|
@ -529,12 +529,12 @@ func TestConfigPathsReplace(t *testing.T) { //nolint:dupl
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/replace/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/replace/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9998/mypath",
|
"source": "rtsp://127.0.0.1:9998/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
||||||
require.Equal(t, true, out["sourceOnDemand"])
|
require.Equal(t, true, out["sourceOnDemand"])
|
||||||
|
|
@ -562,12 +562,12 @@ func TestConfigPathsReplaceNonExisting(t *testing.T) { //nolint:dupl
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/replace/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/replace/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9998/mypath",
|
"source": "rtsp://127.0.0.1:9998/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
|
||||||
require.Equal(t, true, out["sourceOnDemand"])
|
require.Equal(t, true, out["sourceOnDemand"])
|
||||||
|
|
@ -595,7 +595,7 @@ func TestConfigPathsDelete(t *testing.T) {
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/my/path",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "rtsp://127.0.0.1:9999/mypath",
|
"source": "rtsp://127.0.0.1:9999/mypath",
|
||||||
"sourceOnDemand": true,
|
"sourceOnDemand": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
@ -655,27 +655,27 @@ func TestRecordingsList(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out interface{}
|
var out any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/recordings/list", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/recordings/list", nil, &out)
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"itemCount": float64(2),
|
"itemCount": float64(2),
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "mypath1",
|
"name": "mypath1",
|
||||||
"segments": []interface{}{
|
"segments": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "mypath2",
|
"name": "mypath2",
|
||||||
"segments": []interface{}{
|
"segments": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -719,15 +719,15 @@ func TestRecordingsGet(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
var out interface{}
|
var out any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/recordings/get/mypath1", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/recordings/get/mypath1", nil, &out)
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"name": "mypath1",
|
"name": "mypath1",
|
||||||
"segments": []interface{}{
|
"segments": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 0, 0, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 0, 0, time.Local).Format(time.RFC3339Nano),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2009, 11, 7, 11, 22, 0, 900000000, time.Local).Format(time.RFC3339Nano),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -840,7 +840,7 @@ func TestAuthError(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: &testParent{
|
Parent: &testParent{
|
||||||
log: func(l logger.Level, s string, i ...interface{}) {
|
log: func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func paginate2(itemsPtr interface{}, itemsPerPage int, page int) int {
|
func paginate2(itemsPtr any, itemsPerPage int, page int) int {
|
||||||
ritems := reflect.ValueOf(itemsPtr).Elem()
|
ritems := reflect.ValueOf(itemsPtr).Elem()
|
||||||
|
|
||||||
itemsLen := ritems.Len()
|
itemsLen := ritems.Len()
|
||||||
|
|
@ -19,22 +19,16 @@ func paginate2(itemsPtr interface{}, itemsPerPage int, page int) int {
|
||||||
pageCount++
|
pageCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
minVal := page * itemsPerPage
|
minVal := min(page*itemsPerPage, itemsLen)
|
||||||
if minVal > itemsLen {
|
|
||||||
minVal = itemsLen
|
|
||||||
}
|
|
||||||
|
|
||||||
maxVal := (page + 1) * itemsPerPage
|
maxVal := min((page+1)*itemsPerPage, itemsLen)
|
||||||
if maxVal > itemsLen {
|
|
||||||
maxVal = itemsLen
|
|
||||||
}
|
|
||||||
|
|
||||||
ritems.Set(ritems.Slice(minVal, maxVal))
|
ritems.Set(ritems.Slice(minVal, maxVal))
|
||||||
|
|
||||||
return pageCount
|
return pageCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func paginate(itemsPtr interface{}, itemsPerPageStr string, pageStr string) (int, error) {
|
func paginate(itemsPtr any, itemsPerPageStr string, pageStr string) (int, error) {
|
||||||
itemsPerPage := 100
|
itemsPerPage := 100
|
||||||
|
|
||||||
if itemsPerPageStr != "" {
|
if itemsPerPageStr != "" {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
func TestPaginate(t *testing.T) {
|
func TestPaginate(t *testing.T) {
|
||||||
func() {
|
func() {
|
||||||
items := make([]int, 5)
|
items := make([]int, 5)
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
items[i] = i
|
items[i] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ func TestPaginate(t *testing.T) {
|
||||||
|
|
||||||
func() {
|
func() {
|
||||||
items := make([]int, 5)
|
items := make([]int, 5)
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
items[i] = i
|
items[i] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ func TestPaginate(t *testing.T) {
|
||||||
|
|
||||||
func() {
|
func() {
|
||||||
items := make([]int, 6)
|
items := make([]int, 6)
|
||||||
for i := 0; i < 6; i++ {
|
for i := range 6 {
|
||||||
items[i] = i
|
items[i] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ func TestPaginate(t *testing.T) {
|
||||||
func FuzzPaginate(f *testing.F) {
|
func FuzzPaginate(f *testing.F) {
|
||||||
f.Fuzz(func(_ *testing.T, str1 string, str2 string) {
|
f.Fuzz(func(_ *testing.T, str1 string, str2 string) {
|
||||||
items := make([]int, 6)
|
items := make([]int, 6)
|
||||||
for i := 0; i < 6; i++ {
|
for i := range 6 {
|
||||||
items[i] = i
|
items[i] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -539,7 +539,7 @@ func TestAuthJWTRefresh(t *testing.T) {
|
||||||
JWTClaimKey: "my_permission_key",
|
JWTClaimKey: "my_permission_key",
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 2; i++ {
|
for range 2 {
|
||||||
key, err = rsa.GenerateKey(rand.Reader, 1024)
|
key, err = rsa.GenerateKey(rand.Reader, 1024)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testLogger struct {
|
type testLogger struct {
|
||||||
cb func(level logger.Level, format string, args ...interface{})
|
cb func(level logger.Level, format string, args ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *testLogger) Log(level logger.Level, format string, args ...interface{}) {
|
func (l *testLogger) Log(level logger.Level, format string, args ...any) {
|
||||||
l.cb(level, format, args...)
|
l.cb(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger returns a dummy logger.
|
// Logger returns a dummy logger.
|
||||||
func Logger(cb func(logger.Level, string, ...interface{})) logger.Writer {
|
func Logger(cb func(logger.Level, string, ...any)) logger.Writer {
|
||||||
return &testLogger{cb: cb}
|
return &testLogger{cb: cb}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ func TestH264RTPOversized(t *testing.T) {
|
||||||
logged := false
|
logged := false
|
||||||
|
|
||||||
p, err := New(1460, forma, false,
|
p, err := New(1460, forma, false,
|
||||||
Logger(func(_ logger.Level, s string, i ...interface{}) {
|
Logger(func(_ logger.Level, s string, i ...any) {
|
||||||
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
||||||
logged = true
|
logged = true
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ func TestH265RTPOversized(t *testing.T) {
|
||||||
logged := false
|
logged := false
|
||||||
|
|
||||||
p, err := New(1460, forma, false,
|
p, err := New(1460, forma, false,
|
||||||
Logger(func(_ logger.Level, s string, i ...interface{}) {
|
Logger(func(_ logger.Level, s string, i ...any) {
|
||||||
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
require.Equal(t, "RTP packets are too big, remuxing them into smaller ones", fmt.Sprintf(s, i...))
|
||||||
logged = true
|
logged = true
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,13 @@ func firstThatExists(paths []string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyStructFields(dest interface{}, source interface{}) {
|
func copyStructFields(dest any, source any) {
|
||||||
rvsource := reflect.ValueOf(source).Elem()
|
rvsource := reflect.ValueOf(source).Elem()
|
||||||
rvdest := reflect.ValueOf(dest)
|
rvdest := reflect.ValueOf(dest)
|
||||||
nf := rvsource.NumField()
|
nf := rvsource.NumField()
|
||||||
var zero reflect.Value
|
var zero reflect.Value
|
||||||
|
|
||||||
for i := 0; i < nf; i++ {
|
for i := range nf {
|
||||||
fnew := rvsource.Field(i)
|
fnew := rvsource.Field(i)
|
||||||
f := rvdest.Elem().FieldByName(rvsource.Type().Field(i).Name)
|
f := rvdest.Elem().FieldByName(rvsource.Type().Field(i).Name)
|
||||||
if f == zero {
|
if f == zero {
|
||||||
|
|
@ -508,7 +508,7 @@ func (conf Conf) Clone() *Conf {
|
||||||
|
|
||||||
type nilLogger struct{}
|
type nilLogger struct{}
|
||||||
|
|
||||||
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
|
func (nilLogger) Log(_ logger.Level, _ string, _ ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate checks the configuration for errors.
|
// Validate checks the configuration for errors.
|
||||||
|
|
|
||||||
6
internal/conf/env/env.go
vendored
6
internal/conf/env/env.go
vendored
|
|
@ -156,7 +156,7 @@ func loadEnvInternal(env map[string]string, prefix string, prv reflect.Value) er
|
||||||
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
flen := rt.NumField()
|
flen := rt.NumField()
|
||||||
for i := 0; i < flen; i++ {
|
for i := range flen {
|
||||||
f := rt.Field(i)
|
f := rt.Field(i)
|
||||||
jsonTag := f.Tag.Get("json")
|
jsonTag := f.Tag.Get("json")
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ func loadEnvInternal(env map[string]string, prefix string, prv reflect.Value) er
|
||||||
return fmt.Errorf("unsupported type: %v", rt)
|
return fmt.Errorf("unsupported type: %v", rt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadWithEnv(env map[string]string, prefix string, v interface{}) error {
|
func loadWithEnv(env map[string]string, prefix string, v any) error {
|
||||||
return loadEnvInternal(env, prefix, reflect.ValueOf(v).Elem())
|
return loadEnvInternal(env, prefix, reflect.ValueOf(v).Elem())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,6 +253,6 @@ func envToMap() map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the configuration from the environment.
|
// Load loads the configuration from the environment.
|
||||||
func Load(prefix string, v interface{}) error {
|
func Load(prefix string, v any) error {
|
||||||
return loadWithEnv(envToMap(), prefix, v)
|
return loadWithEnv(envToMap(), prefix, v)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ var globalValuesType = func() reflect.Type {
|
||||||
rt := reflect.TypeOf(Conf{})
|
rt := reflect.TypeOf(Conf{})
|
||||||
nf := rt.NumField()
|
nf := rt.NumField()
|
||||||
|
|
||||||
for i := 0; i < nf; i++ {
|
for i := range nf {
|
||||||
f := rt.Field(i)
|
f := rt.Field(i)
|
||||||
j := f.Tag.Get("json")
|
j := f.Tag.Get("json")
|
||||||
|
|
||||||
|
|
@ -26,13 +26,13 @@ var globalValuesType = func() reflect.Type {
|
||||||
return reflect.StructOf(fields)
|
return reflect.StructOf(fields)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func newGlobalValues() interface{} {
|
func newGlobalValues() any {
|
||||||
return reflect.New(globalValuesType).Interface()
|
return reflect.New(globalValuesType).Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global is the global part of Conf.
|
// Global is the global part of Conf.
|
||||||
type Global struct {
|
type Global struct {
|
||||||
Values interface{}
|
Values any
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements json.Marshaler.
|
// MarshalJSON implements json.Marshaler.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package conf
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
|
"github.com/bluenviron/mediamtx/internal/conf/jsonwrapper"
|
||||||
|
|
@ -39,12 +40,7 @@ func (d LogDestinations) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LogDestinations) contains(v logger.Destination) bool {
|
func (d *LogDestinations) contains(v logger.Destination) bool {
|
||||||
for _, item := range *d {
|
return slices.Contains(*d, v)
|
||||||
if item == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler.
|
// UnmarshalJSON implements json.Unmarshaler.
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ var optionalGlobalValuesType = func() reflect.Type {
|
||||||
rt := reflect.TypeOf(Conf{})
|
rt := reflect.TypeOf(Conf{})
|
||||||
nf := rt.NumField()
|
nf := rt.NumField()
|
||||||
|
|
||||||
for i := 0; i < nf; i++ {
|
for i := range nf {
|
||||||
f := rt.Field(i)
|
f := rt.Field(i)
|
||||||
j := f.Tag.Get("json")
|
j := f.Tag.Get("json")
|
||||||
|
|
||||||
|
|
@ -38,13 +38,13 @@ var optionalGlobalValuesType = func() reflect.Type {
|
||||||
return reflect.StructOf(fields)
|
return reflect.StructOf(fields)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func newOptionalGlobalValues() interface{} {
|
func newOptionalGlobalValues() any {
|
||||||
return reflect.New(optionalGlobalValuesType).Interface()
|
return reflect.New(optionalGlobalValuesType).Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptionalGlobal is a Conf whose values can all be optional.
|
// OptionalGlobal is a Conf whose values can all be optional.
|
||||||
type OptionalGlobal struct {
|
type OptionalGlobal struct {
|
||||||
Values interface{}
|
Values any
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler.
|
// UnmarshalJSON implements json.Unmarshaler.
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ var optionalPathValuesType = func() reflect.Type {
|
||||||
rt := reflect.TypeOf(Path{})
|
rt := reflect.TypeOf(Path{})
|
||||||
nf := rt.NumField()
|
nf := rt.NumField()
|
||||||
|
|
||||||
for i := 0; i < nf; i++ {
|
for i := range nf {
|
||||||
f := rt.Field(i)
|
f := rt.Field(i)
|
||||||
j := f.Tag.Get("json")
|
j := f.Tag.Get("json")
|
||||||
|
|
||||||
|
|
@ -39,13 +39,13 @@ var optionalPathValuesType = func() reflect.Type {
|
||||||
return reflect.StructOf(fields)
|
return reflect.StructOf(fields)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func newOptionalPathValues() interface{} {
|
func newOptionalPathValues() any {
|
||||||
return reflect.New(optionalPathValuesType).Interface()
|
return reflect.New(optionalPathValuesType).Interface()
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptionalPath is a Path whose values can all be optional.
|
// OptionalPath is a Path whose values can all be optional.
|
||||||
type OptionalPath struct {
|
type OptionalPath struct {
|
||||||
Values interface{}
|
Values any
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler.
|
// UnmarshalJSON implements json.Unmarshaler.
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func convertKeys(i interface{}) (interface{}, error) {
|
func convertKeys(i any) (any, error) {
|
||||||
switch x := i.(type) {
|
switch x := i.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[any]any:
|
||||||
m2 := map[string]interface{}{}
|
m2 := map[string]any{}
|
||||||
for k, v := range x {
|
for k, v := range x {
|
||||||
ks, ok := k.(string)
|
ks, ok := k.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
@ -26,8 +26,8 @@ func convertKeys(i interface{}) (interface{}, error) {
|
||||||
}
|
}
|
||||||
return m2, nil
|
return m2, nil
|
||||||
|
|
||||||
case []interface{}:
|
case []any:
|
||||||
a2 := make([]interface{}, len(x))
|
a2 := make([]any, len(x))
|
||||||
for i, v := range x {
|
for i, v := range x {
|
||||||
var err error
|
var err error
|
||||||
a2[i], err = convertKeys(v)
|
a2[i], err = convertKeys(v)
|
||||||
|
|
@ -42,12 +42,12 @@ func convertKeys(i interface{}) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal loads the configuration from YAML.
|
// Unmarshal loads the configuration from YAML.
|
||||||
func Unmarshal(buf []byte, dest interface{}) error {
|
func Unmarshal(buf []byte, dest any) error {
|
||||||
// load YAML into a generic map
|
// load YAML into a generic map
|
||||||
// from documentation:
|
// from documentation:
|
||||||
// "UnmarshalStrict is like Unmarshal except that any fields that are found in the data
|
// "UnmarshalStrict is like Unmarshal except that any fields that are found in the data
|
||||||
// that do not have corresponding struct members, or mapping keys that are duplicates, will result in an error."
|
// that do not have corresponding struct members, or mapping keys that are duplicates, will result in an error."
|
||||||
var temp interface{}
|
var temp any
|
||||||
err := yaml.UnmarshalStrict(buf, &temp)
|
err := yaml.UnmarshalStrict(buf, &temp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func checkClose(t *testing.T, closeFunc func() error) {
|
||||||
require.NoError(t, closeFunc())
|
require.NoError(t, closeFunc())
|
||||||
}
|
}
|
||||||
|
|
||||||
func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in interface{}, out interface{}) {
|
func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in any, out any) {
|
||||||
buf := func() io.Reader {
|
buf := func() io.Reader {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -66,10 +66,10 @@ func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in int
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkError(t *testing.T, msg string, body io.Reader) {
|
func checkError(t *testing.T, msg string, body io.Reader) {
|
||||||
var resErr map[string]interface{}
|
var resErr map[string]any
|
||||||
err := json.NewDecoder(body).Decode(&resErr)
|
err := json.NewDecoder(body).Decode(&resErr)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, map[string]interface{}{"error": msg}, resErr)
|
require.Equal(t, map[string]any{"error": msg}, resErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIPathsList(t *testing.T) {
|
func TestAPIPathsList(t *testing.T) {
|
||||||
|
|
@ -462,7 +462,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := range 3 {
|
||||||
/*source.WritePacketRTP(medi, &rtp.Packet{
|
/*source.WritePacketRTP(medi, &rtp.Packet{
|
||||||
Header: rtp.Header{
|
Header: rtp.Header{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
|
|
@ -604,40 +604,40 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
pa = "srtconns"
|
pa = "srtconns"
|
||||||
}
|
}
|
||||||
|
|
||||||
var out1 interface{}
|
var out1 any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/list", nil, &out1)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/list", nil, &out1)
|
||||||
|
|
||||||
switch ca {
|
switch ca {
|
||||||
case "rtsp conns":
|
case "rtsp conns":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
|
"session": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["session"],
|
||||||
"tunnel": "none",
|
"tunnel": "none",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "rtsp sessions":
|
case "rtsp sessions":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": float64(0),
|
"bytesReceived": float64(0),
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"state": "publish",
|
"state": "publish",
|
||||||
"transport": "UDP",
|
"transport": "UDP",
|
||||||
"profile": "AVP",
|
"profile": "AVP",
|
||||||
|
|
@ -654,35 +654,35 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "rtsps conns":
|
case "rtsps conns":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
|
"session": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["session"],
|
||||||
"tunnel": "none",
|
"tunnel": "none",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "rtsps sessions":
|
case "rtsps sessions":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": float64(0),
|
"bytesReceived": float64(0),
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"state": "publish",
|
"state": "publish",
|
||||||
"transport": "UDP",
|
"transport": "UDP",
|
||||||
"profile": "SAVP",
|
"profile": "SAVP",
|
||||||
|
|
@ -699,71 +699,71 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "rtmp":
|
case "rtmp":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"state": "publish",
|
"state": "publish",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "rtmps":
|
case "rtmps":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"state": "publish",
|
"state": "publish",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "hls":
|
case "hls":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"lastRequest": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["lastRequest"],
|
"lastRequest": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["lastRequest"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "webrtc":
|
case "webrtc":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
|
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
|
||||||
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
|
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"localCandidate": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["localCandidate"],
|
"localCandidate": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["localCandidate"],
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"peerConnectionEstablished": true,
|
"peerConnectionEstablished": true,
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"remoteCandidate": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteCandidate"],
|
"remoteCandidate": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteCandidate"],
|
||||||
"state": "read",
|
"state": "read",
|
||||||
"rtcpPacketsReceived": float64(0),
|
"rtcpPacketsReceived": float64(0),
|
||||||
"rtcpPacketsSent": float64(2),
|
"rtcpPacketsSent": float64(2),
|
||||||
|
|
@ -776,11 +776,11 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
}, out1)
|
}, out1)
|
||||||
|
|
||||||
case "srt":
|
case "srt":
|
||||||
require.Equal(t, map[string]interface{}{
|
require.Equal(t, map[string]any{
|
||||||
"itemCount": float64(1),
|
"itemCount": float64(1),
|
||||||
"pageCount": float64(1),
|
"pageCount": float64(1),
|
||||||
"items": []interface{}{
|
"items": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"byteMSS": float64(1500),
|
"byteMSS": float64(1500),
|
||||||
"bytesAvailReceiveBuf": float64(0),
|
"bytesAvailReceiveBuf": float64(0),
|
||||||
"bytesAvailSendBuf": float64(0),
|
"bytesAvailSendBuf": float64(0),
|
||||||
|
|
@ -797,13 +797,13 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
"bytesSendDrop": float64(0),
|
"bytesSendDrop": float64(0),
|
||||||
"bytesSent": float64(0),
|
"bytesSent": float64(0),
|
||||||
"bytesSentUnique": float64(0),
|
"bytesSentUnique": float64(0),
|
||||||
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
|
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
|
||||||
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
|
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
|
||||||
"mbpsLinkCapacity": float64(0),
|
"mbpsLinkCapacity": float64(0),
|
||||||
"mbpsMaxBW": float64(-1),
|
"mbpsMaxBW": float64(-1),
|
||||||
"mbpsReceiveRate": float64(0),
|
"mbpsReceiveRate": float64(0),
|
||||||
"mbpsSendRate": float64(0),
|
"mbpsSendRate": float64(0),
|
||||||
"msRTT": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["msRTT"],
|
"msRTT": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["msRTT"],
|
||||||
"msReceiveBuf": float64(0),
|
"msReceiveBuf": float64(0),
|
||||||
"msReceiveTsbPdDelay": float64(120),
|
"msReceiveTsbPdDelay": float64(120),
|
||||||
"msSendBuf": float64(0),
|
"msSendBuf": float64(0),
|
||||||
|
|
@ -812,7 +812,7 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
"packetsFlowWindow": float64(25600),
|
"packetsFlowWindow": float64(25600),
|
||||||
"packetsReceiveBuf": float64(0),
|
"packetsReceiveBuf": float64(0),
|
||||||
"packetsReceived": float64(1),
|
"packetsReceived": float64(1),
|
||||||
"packetsReceivedACK": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["packetsReceivedACK"],
|
"packetsReceivedACK": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["packetsReceivedACK"],
|
||||||
"packetsReceivedAvgBelatedTime": float64(0),
|
"packetsReceivedAvgBelatedTime": float64(0),
|
||||||
"packetsReceivedBelated": float64(0),
|
"packetsReceivedBelated": float64(0),
|
||||||
"packetsReceivedDrop": float64(0),
|
"packetsReceivedDrop": float64(0),
|
||||||
|
|
@ -830,13 +830,13 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
"packetsSendLoss": float64(0),
|
"packetsSendLoss": float64(0),
|
||||||
"packetsSendLossRate": float64(0),
|
"packetsSendLossRate": float64(0),
|
||||||
"packetsSent": float64(0),
|
"packetsSent": float64(0),
|
||||||
"packetsSentACK": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["packetsSentACK"],
|
"packetsSentACK": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["packetsSentACK"],
|
||||||
"packetsSentKM": float64(0),
|
"packetsSentKM": float64(0),
|
||||||
"packetsSentNAK": float64(0),
|
"packetsSentNAK": float64(0),
|
||||||
"packetsSentUnique": float64(0),
|
"packetsSentUnique": float64(0),
|
||||||
"path": "mypath",
|
"path": "mypath",
|
||||||
"query": "key=val",
|
"query": "key=val",
|
||||||
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
|
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
|
||||||
"state": "publish",
|
"state": "publish",
|
||||||
"usPacketsSendPeriod": float64(10.967254638671875),
|
"usPacketsSendPeriod": float64(10.967254638671875),
|
||||||
"usSndDuration": float64(0),
|
"usSndDuration": float64(0),
|
||||||
|
|
@ -845,19 +845,19 @@ func TestAPIProtocolListGet(t *testing.T) {
|
||||||
}, out1)
|
}, out1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var out2 interface{}
|
var out2 any
|
||||||
|
|
||||||
if ca == "hls" {
|
if ca == "hls" {
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/get/"+
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/get/"+
|
||||||
out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["path"].(string),
|
out1.(map[string]any)["items"].([]any)[0].(map[string]any)["path"].(string),
|
||||||
nil, &out2)
|
nil, &out2)
|
||||||
} else {
|
} else {
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/get/"+
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/get/"+
|
||||||
out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"].(string),
|
out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"].(string),
|
||||||
nil, &out2)
|
nil, &out2)
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Equal(t, out1.(map[string]interface{})["items"].([]interface{})[0], out2)
|
require.Equal(t, out1.(map[string]any)["items"].([]any)[0], out2)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ func (p *Core) Wait() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (p *Core) Log(level logger.Level, format string, args ...interface{}) {
|
func (p *Core) Log(level logger.Level, format string, args ...any) {
|
||||||
p.logger.Log(level, format, args...)
|
p.logger.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -482,7 +482,7 @@ webrtc_sessions_rtcp_packets_sent 0
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("servers disabled", func(t *testing.T) {
|
t.Run("servers disabled", func(t *testing.T) {
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch", map[string]interface{}{
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch", map[string]any{
|
||||||
"rtsp": false,
|
"rtsp": false,
|
||||||
"rtmp": false,
|
"rtmp": false,
|
||||||
"srt": false,
|
"srt": false,
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ func (pa *path) wait() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (pa *path) Log(level logger.Level, format string, args ...interface{}) {
|
func (pa *path) Log(level logger.Level, format string, args ...any) {
|
||||||
pa.parent.Log(level, "[path "+pa.name+"] "+format, args...)
|
pa.parent.Log(level, "[path "+pa.name+"] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ func (pm *pathManager) close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (pm *pathManager) Log(level logger.Level, format string, args ...interface{}) {
|
func (pm *pathManager) Log(level logger.Level, format string, args ...any) {
|
||||||
pm.parent.Log(level, format, args...)
|
pm.parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,13 +134,13 @@ func TestPathConfigurationHotReload(t *testing.T) {
|
||||||
require.Equal(t, "all", pathData.ConfName)
|
require.Equal(t, "all", pathData.ConfName)
|
||||||
|
|
||||||
// Check the current configuration via API
|
// Check the current configuration via API
|
||||||
var allConfig map[string]interface{}
|
var allConfig map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/all", nil, &allConfig)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/all", nil, &allConfig)
|
||||||
require.Equal(t, false, allConfig["record"]) // Should be false from "all" config
|
require.Equal(t, false, allConfig["record"]) // Should be false from "all" config
|
||||||
|
|
||||||
// Add a new specific configuration for "undefined_stream" with record enabled
|
// Add a new specific configuration for "undefined_stream" with record enabled
|
||||||
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/undefined_stream",
|
httpRequest(t, hc, http.MethodPost, "http://localhost:9997/v3/config/paths/add/undefined_stream",
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"record": true,
|
"record": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ func TestPathConfigurationHotReload(t *testing.T) {
|
||||||
require.Equal(t, "undefined_stream", pathData.ConfName) // Should now use the specific config
|
require.Equal(t, "undefined_stream", pathData.ConfName) // Should now use the specific config
|
||||||
|
|
||||||
// Check the new configuration via API
|
// Check the new configuration via API
|
||||||
var newConfig map[string]interface{}
|
var newConfig map[string]any
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/undefined_stream", nil, &newConfig)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/undefined_stream", nil, &newConfig)
|
||||||
require.Equal(t, true, newConfig["record"]) // Should be true from new config
|
require.Equal(t, true, newConfig["record"]) // Should be true from new config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ func TestPathRunOnRead(t *testing.T) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for i := uint16(0); i < 3; i++ {
|
for i := range uint16(3) {
|
||||||
err2 := source.WritePacketRTP(media0, &rtp.Packet{
|
err2 := source.WritePacketRTP(media0, &rtp.Packet{
|
||||||
Header: rtp.Header{
|
Header: rtp.Header{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
|
|
@ -622,7 +622,7 @@ func TestPathRunOnRecordSegment(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
err = source.WritePacketRTP(media0, &rtp.Packet{
|
err = source.WritePacketRTP(media0, &rtp.Packet{
|
||||||
Header: rtp.Header{
|
Header: rtp.Header{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
|
|
@ -672,7 +672,7 @@ func TestPathMaxReaders(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
||||||
for i := 0; i < 2; i++ {
|
for i := range 2 {
|
||||||
var u *base.URL
|
var u *base.URL
|
||||||
u, err = base.ParseURL("rtsp://127.0.0.1:8554/mystream")
|
u, err = base.ParseURL("rtsp://127.0.0.1:8554/mystream")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -723,7 +723,7 @@ func TestPathRecord(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
err = source.WritePacketRTP(media0, &rtp.Packet{
|
err = source.WritePacketRTP(media0, &rtp.Packet{
|
||||||
Header: rtp.Header{
|
Header: rtp.Header{
|
||||||
Version: 2,
|
Version: 2,
|
||||||
|
|
@ -748,13 +748,13 @@ func TestPathRecord(t *testing.T) {
|
||||||
defer tr.CloseIdleConnections()
|
defer tr.CloseIdleConnections()
|
||||||
hc := &http.Client{Transport: tr}
|
hc := &http.Client{Transport: tr}
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/all_others", map[string]interface{}{
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/all_others", map[string]any{
|
||||||
"record": false,
|
"record": false,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/all_others", map[string]interface{}{
|
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/paths/patch/all_others", map[string]any{
|
||||||
"record": true,
|
"record": true,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
// sourceRedirect is a source that redirects to another one.
|
// sourceRedirect is a source that redirects to another one.
|
||||||
type sourceRedirect struct{}
|
type sourceRedirect struct{}
|
||||||
|
|
||||||
func (*sourceRedirect) Log(logger.Level, string, ...interface{}) {
|
func (*sourceRedirect) Log(logger.Level, string, ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// APISourceDescribe implements source.
|
// APISourceDescribe implements source.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type destination interface {
|
type destination interface {
|
||||||
log(time.Time, Level, string, ...interface{})
|
log(time.Time, Level, string, ...any)
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ func newDestinationFile(filePath string) (destination, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *destinationFile) log(t time.Time, level Level, format string, args ...interface{}) {
|
func (d *destinationFile) log(t time.Time, level Level, format string, args ...any) {
|
||||||
d.buf.Reset()
|
d.buf.Reset()
|
||||||
writeTime(&d.buf, t, false)
|
writeTime(&d.buf, t, false)
|
||||||
writeLevel(&d.buf, level, false)
|
writeLevel(&d.buf, level, false)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func newDestionationStdout() destination {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *destinationStdout) log(t time.Time, level Level, format string, args ...interface{}) {
|
func (d *destinationStdout) log(t time.Time, level Level, format string, args ...any) {
|
||||||
d.buf.Reset()
|
d.buf.Reset()
|
||||||
writeTime(&d.buf, t, d.useColor)
|
writeTime(&d.buf, t, d.useColor)
|
||||||
writeLevel(&d.buf, level, d.useColor)
|
writeLevel(&d.buf, level, d.useColor)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ func newDestinationSyslog(prefix string) (destination, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *destinationSysLog) log(t time.Time, level Level, format string, args ...interface{}) {
|
func (d *destinationSysLog) log(t time.Time, level Level, format string, args ...any) {
|
||||||
d.buf.Reset()
|
d.buf.Reset()
|
||||||
writeTime(&d.buf, t, false)
|
writeTime(&d.buf, t, false)
|
||||||
writeLevel(&d.buf, level, false)
|
writeLevel(&d.buf, level, false)
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,13 @@ func writeLevel(buf *bytes.Buffer, level Level, useColor bool) {
|
||||||
buf.WriteByte(' ')
|
buf.WriteByte(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeContent(buf *bytes.Buffer, format string, args []interface{}) {
|
func writeContent(buf *bytes.Buffer, format string, args []any) {
|
||||||
fmt.Fprintf(buf, format, args...)
|
fmt.Fprintf(buf, format, args...)
|
||||||
buf.WriteByte('\n')
|
buf.WriteByte('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log writes a log entry.
|
// Log writes a log entry.
|
||||||
func (lh *Logger) Log(level Level, format string, args ...interface{}) {
|
func (lh *Logger) Log(level Level, format string, args ...any) {
|
||||||
if level < lh.level {
|
if level < lh.level {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ package logger
|
||||||
|
|
||||||
// Writer is an object that provides a log method.
|
// Writer is an object that provides a log method.
|
||||||
type Writer interface {
|
type Writer interface {
|
||||||
Log(Level, string, ...interface{})
|
Log(Level, string, ...any)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/bluenviron/mediamtx/internal/protocols/httpp"
|
"github.com/bluenviron/mediamtx/internal/protocols/httpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ func (m *Metrics) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (m *Metrics) Log(level logger.Level, format string, args ...interface{}) {
|
func (m *Metrics) Log(level logger.Level, format string, args ...any) {
|
||||||
m.Parent.Log(level, "[metrics] "+format, args...)
|
m.Parent.Log(level, "[metrics] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ func TestAuthError(t *testing.T) {
|
||||||
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,7 @@ func (w *muxerFMP4) writeSample(
|
||||||
w.curTrack.samples = w.curTrack.samples[:0]
|
w.curTrack.samples = w.curTrack.samples[:0]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
duration := dts - w.curTrack.lastDTS
|
duration := max(dts-w.curTrack.lastDTS, 0)
|
||||||
if duration < 0 {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
w.curTrack.samples[len(w.curTrack.samples)-1].Duration = uint32(duration)
|
w.curTrack.samples[len(w.curTrack.samples)-1].Duration = uint32(duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,10 +125,7 @@ func (w *muxerFMP4) writeSample(
|
||||||
|
|
||||||
func (w *muxerFMP4) writeFinalDTS(dts int64) {
|
func (w *muxerFMP4) writeFinalDTS(dts int64) {
|
||||||
if len(w.curTrack.samples) != 0 && w.curTrack.firstDTS >= 0 {
|
if len(w.curTrack.samples) != 0 && w.curTrack.firstDTS >= 0 {
|
||||||
duration := dts - w.curTrack.lastDTS
|
duration := max(dts-w.curTrack.lastDTS, 0)
|
||||||
if duration < 0 {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
w.curTrack.samples[len(w.curTrack.samples)-1].Duration = uint32(duration)
|
w.curTrack.samples[len(w.curTrack.samples)-1].Duration = uint32(duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,7 @@ func (w *muxerMP4) writeSample(
|
||||||
if len(w.curTrack.Samples) == 0 {
|
if len(w.curTrack.Samples) == 0 {
|
||||||
w.curTrack.TimeOffset = int32(dts)
|
w.curTrack.TimeOffset = int32(dts)
|
||||||
} else {
|
} else {
|
||||||
duration := dts - w.curTrack.lastDTS
|
duration := max(dts-w.curTrack.lastDTS, 0)
|
||||||
if duration < 0 {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
w.curTrack.Samples[len(w.curTrack.Samples)-1].Duration = uint32(duration)
|
w.curTrack.Samples[len(w.curTrack.Samples)-1].Duration = uint32(duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,10 +84,7 @@ func (w *muxerMP4) writeSample(
|
||||||
|
|
||||||
func (w *muxerMP4) writeFinalDTS(dts int64) {
|
func (w *muxerMP4) writeFinalDTS(dts int64) {
|
||||||
if len(w.curTrack.Samples) != 0 {
|
if len(w.curTrack.Samples) != 0 {
|
||||||
duration := dts - w.curTrack.lastDTS
|
duration := max(dts-w.curTrack.lastDTS, 0)
|
||||||
if duration < 0 {
|
|
||||||
duration = 0
|
|
||||||
}
|
|
||||||
w.curTrack.Samples[len(w.curTrack.Samples)-1].Duration = uint32(duration)
|
w.curTrack.Samples[len(w.curTrack.Samples)-1].Duration = uint32(duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,20 +122,20 @@ func TestOnList(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||||
|
|
||||||
var out interface{}
|
var out any
|
||||||
err = json.NewDecoder(res.Body).Decode(&out)
|
err = json.NewDecoder(res.Body).Decode(&out)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
switch ca {
|
switch ca {
|
||||||
case "unfiltered", "start before first":
|
case "unfiltered", "start before first":
|
||||||
require.Equal(t, []interface{}{
|
require.Equal(t, []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(66),
|
"duration": float64(66),
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=66&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=66&path=mypath&start=" +
|
||||||
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
|
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(4),
|
"duration": float64(4),
|
||||||
"start": time.Date(2009, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2009, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=4&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=4&path=mypath&start=" +
|
||||||
|
|
@ -144,14 +144,14 @@ func TestOnList(t *testing.T) {
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
case "filtered":
|
case "filtered":
|
||||||
require.Equal(t, []interface{}{
|
require.Equal(t, []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(65),
|
"duration": float64(65),
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 1, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 1, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=65&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=65&path=mypath&start=" +
|
||||||
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 1, 500000000, time.Local).Format(time.RFC3339Nano)),
|
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 1, 500000000, time.Local).Format(time.RFC3339Nano)),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(2),
|
"duration": float64(2),
|
||||||
"start": time.Date(2009, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2009, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=2&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=2&path=mypath&start=" +
|
||||||
|
|
@ -160,8 +160,8 @@ func TestOnList(t *testing.T) {
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
case "filtered and gap":
|
case "filtered and gap":
|
||||||
require.Equal(t, []interface{}{
|
require.Equal(t, []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(4),
|
"duration": float64(4),
|
||||||
"start": time.Date(2008, 11, 7, 11, 24, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 24, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=4&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=4&path=mypath&start=" +
|
||||||
|
|
@ -170,14 +170,14 @@ func TestOnList(t *testing.T) {
|
||||||
}, out)
|
}, out)
|
||||||
|
|
||||||
case "different init":
|
case "different init":
|
||||||
require.Equal(t, []interface{}{
|
require.Equal(t, []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(62),
|
"duration": float64(62),
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=62&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=62&path=mypath&start=" +
|
||||||
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
|
url.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(1),
|
"duration": float64(1),
|
||||||
"start": time.Date(2008, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 23, 2, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=1&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=1&path=mypath&start=" +
|
||||||
|
|
@ -322,12 +322,12 @@ func TestOnListCachedDuration(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||||
|
|
||||||
var out interface{}
|
var out any
|
||||||
err = json.NewDecoder(res.Body).Decode(&out)
|
err = json.NewDecoder(res.Body).Decode(&out)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, []interface{}{
|
require.Equal(t, []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"duration": float64(50),
|
"duration": float64(50),
|
||||||
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
"start": time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano),
|
||||||
"url": "http://localhost:9996/get?duration=50&path=mypath&start=" +
|
"url": "http://localhost:9996/get?duration=50&path=mypath&start=" +
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ func segmentFMP4MuxParts(
|
||||||
var segmentDuration time.Duration
|
var segmentDuration time.Duration
|
||||||
breakAtNextMdat := false
|
breakAtNextMdat := false
|
||||||
|
|
||||||
_, err := amp4.ReadBoxStructure(r, func(h *amp4.ReadHandle) (interface{}, error) {
|
_, err := amp4.ReadBoxStructure(r, func(h *amp4.ReadHandle) (any, error) {
|
||||||
switch h.BoxInfo.Type.String() {
|
switch h.BoxInfo.Type.String() {
|
||||||
case "moof":
|
case "moof":
|
||||||
moofOffset = h.BoxInfo.Offset
|
moofOffset = h.BoxInfo.Offset
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func BenchmarkFMP4ReadHeader(b *testing.B) {
|
||||||
writeBenchInit(f)
|
writeBenchInit(f)
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
for n := 0; n < b.N; n++ {
|
for b.Loop() {
|
||||||
func() {
|
func() {
|
||||||
f, err = os.Open(f.Name())
|
f, err = os.Open(f.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func (s *Server) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[playback] "+format, args...)
|
s.Parent.Log(level, "[playback] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func TestAuthError(t *testing.T) {
|
||||||
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func (pp *PPROF) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (pp *PPROF) Log(level logger.Level, format string, args ...interface{}) {
|
func (pp *PPROF) Log(level logger.Level, format string, args ...any) {
|
||||||
pp.Parent.Log(level, "[pprof] "+format, args...)
|
pp.Parent.Log(level, "[pprof] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ func TestAuthError(t *testing.T) {
|
||||||
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
return &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
|
Parent: test.Logger(func(logger.Level, string, ...any) {
|
||||||
t.Error("should not happen")
|
t.Error("should not happen")
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
switch n {
|
switch n {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
|
Parent: test.Logger(func(logger.Level, string, ...any) {
|
||||||
t.Error("should not happen")
|
t.Error("should not happen")
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, "skipping track 2 (VP8)", fmt.Sprintf(format, args...))
|
require.Equal(t, "skipping track 2 (VP8)", fmt.Sprintf(format, args...))
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ func TestToStreamNoSupportedCodecs(t *testing.T) {
|
||||||
err = r.Initialize()
|
err = r.Initialize()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
l := test.Logger(func(logger.Level, string, ...interface{}) {
|
l := test.Logger(func(logger.Level, string, ...any) {
|
||||||
t.Error("should not happen")
|
t.Error("should not happen")
|
||||||
})
|
})
|
||||||
_, err = ToStream(r, nil, l)
|
_, err = ToStream(r, nil, l)
|
||||||
|
|
@ -202,7 +202,7 @@ func TestToStreamSkipUnsupportedTracks(t *testing.T) {
|
||||||
|
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
l := test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
l := test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, "skipping track 1 (unsupported codec)", fmt.Sprintf(format, args...))
|
require.Equal(t, "skipping track 1 (unsupported codec)", fmt.Sprintf(format, args...))
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func FromStream(
|
||||||
for _, forma := range media.Formats {
|
for _, forma := range media.Formats {
|
||||||
switch forma := forma.(type) {
|
switch forma := forma.(type) {
|
||||||
case *format.AV1:
|
case *format.AV1:
|
||||||
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCAV1))) {
|
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCAV1))) {
|
||||||
r.OnData(
|
r.OnData(
|
||||||
media,
|
media,
|
||||||
forma,
|
forma,
|
||||||
|
|
@ -71,7 +71,7 @@ func FromStream(
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.VP9:
|
case *format.VP9:
|
||||||
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCVP9))) {
|
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCVP9))) {
|
||||||
r.OnData(
|
r.OnData(
|
||||||
media,
|
media,
|
||||||
forma,
|
forma,
|
||||||
|
|
@ -91,7 +91,7 @@ func FromStream(
|
||||||
}
|
}
|
||||||
|
|
||||||
case *format.H265:
|
case *format.H265:
|
||||||
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCHEVC))) {
|
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCHEVC))) {
|
||||||
var videoDTSExtractor *h265.DTSExtractor
|
var videoDTSExtractor *h265.DTSExtractor
|
||||||
|
|
||||||
r.OnData(
|
r.OnData(
|
||||||
|
|
@ -179,7 +179,7 @@ func FromStream(
|
||||||
tracks = append(tracks, forma)
|
tracks = append(tracks, forma)
|
||||||
|
|
||||||
case *format.Opus:
|
case *format.Opus:
|
||||||
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCOpus))) {
|
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCOpus))) {
|
||||||
r.OnData(
|
r.OnData(
|
||||||
media,
|
media,
|
||||||
forma,
|
forma,
|
||||||
|
|
@ -303,7 +303,7 @@ func FromStream(
|
||||||
tracks = append(tracks, forma)
|
tracks = append(tracks, forma)
|
||||||
|
|
||||||
case *format.AC3:
|
case *format.AC3:
|
||||||
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCAC3))) {
|
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCAC3))) {
|
||||||
r.OnData(
|
r.OnData(
|
||||||
media,
|
media,
|
||||||
forma,
|
forma,
|
||||||
|
|
|
||||||
|
|
@ -655,7 +655,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
|
Parent: test.Logger(func(logger.Level, string, ...any) {
|
||||||
t.Error("should not happen")
|
t.Error("should not happen")
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
@ -679,7 +679,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, "skipping track 1 (VP8)", fmt.Sprintf(format, args...))
|
require.Equal(t, "skipping track 1 (VP8)", fmt.Sprintf(format, args...))
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
|
Parent: test.Logger(func(logger.Level, string, ...any) {
|
||||||
t.Error("should not happen")
|
t.Error("should not happen")
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
r := &stream.Reader{
|
r := &stream.Reader{
|
||||||
Parent: test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, "skipping track 2 (M-JPEG)", fmt.Sprintf(format, args...))
|
require.Equal(t, "skipping track 2 (M-JPEG)", fmt.Sprintf(format, args...))
|
||||||
|
|
|
||||||
|
|
@ -95,12 +95,12 @@ func (c *ServerConn) run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadJSON reads a JSON object.
|
// ReadJSON reads a JSON object.
|
||||||
func (c *ServerConn) ReadJSON(in interface{}) error {
|
func (c *ServerConn) ReadJSON(in any) error {
|
||||||
return c.wc.ReadJSON(in)
|
return c.wc.ReadJSON(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteJSON writes a JSON object.
|
// WriteJSON writes a JSON object.
|
||||||
func (c *ServerConn) WriteJSON(in interface{}) error {
|
func (c *ServerConn) WriteJSON(in any) error {
|
||||||
byts, err := json.Marshal(in)
|
byts, err := json.Marshal(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ func (c *Cleaner) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (c *Cleaner) Log(level logger.Level, format string, args ...interface{}) {
|
func (c *Cleaner) Log(level logger.Level, format string, args ...any) {
|
||||||
c.Parent.Log(level, "[record cleaner]"+format, args...)
|
c.Parent.Log(level, "[record cleaner]"+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ func (r *Recorder) Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (r *Recorder) Log(level logger.Level, format string, args ...interface{}) {
|
func (r *Recorder) Log(level logger.Level, format string, args ...any) {
|
||||||
r.Parent.Log(level, "[recorder] "+format, args...)
|
r.Parent.Log(level, "[recorder] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type recorderInstance struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (ri *recorderInstance) Log(level logger.Level, format string, args ...interface{}) {
|
func (ri *recorderInstance) Log(level logger.Level, format string, args ...any) {
|
||||||
ri.parent.Log(level, format, args...)
|
ri.parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func TestRecorder(t *testing.T) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
writeToStream := func(strm *stream.Stream, startDTS int64, startNTP time.Time) {
|
writeToStream := func(strm *stream.Stream, startDTS int64, startNTP time.Time) {
|
||||||
for i := 0; i < 2; i++ {
|
for i := range 2 {
|
||||||
pts := startDTS + int64(i)*100*90000/1000
|
pts := startDTS + int64(i)*100*90000/1000
|
||||||
ntp := startNTP.Add(time.Duration(i*60) * time.Second)
|
ntp := startNTP.Add(time.Duration(i*60) * time.Second)
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ func TestRecorder(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
for i := 0; i < 2; i++ {
|
for range 2 {
|
||||||
<-segCreated
|
<-segCreated
|
||||||
<-segDone
|
<-segDone
|
||||||
}
|
}
|
||||||
|
|
@ -365,7 +365,7 @@ func TestRecorderFMP4NegativeInitialDTS(t *testing.T) {
|
||||||
}
|
}
|
||||||
w.Initialize()
|
w.Initialize()
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := range 3 {
|
||||||
strm.WriteUnit(desc.Medias[0], desc.Medias[0].Formats[0], &unit.Unit{
|
strm.WriteUnit(desc.Medias[0], desc.Medias[0].Formats[0], &unit.Unit{
|
||||||
PTS: -50*90000/1000 + (int64(i) * 200 * 90000 / 1000),
|
PTS: -50*90000/1000 + (int64(i) * 200 * 90000 / 1000),
|
||||||
NTP: time.Date(2008, 5, 20, 22, 15, 25, 0, time.UTC),
|
NTP: time.Date(2008, 5, 20, 22, 15, 25, 0, time.UTC),
|
||||||
|
|
@ -538,7 +538,7 @@ func TestRecorderSkipTracksPartial(t *testing.T) {
|
||||||
|
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
l := test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
l := test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
require.Equal(t, "[recorder] skipping track 2 (VP8)", fmt.Sprintf(format, args...))
|
require.Equal(t, "[recorder] skipping track 2 (VP8)", fmt.Sprintf(format, args...))
|
||||||
|
|
@ -600,7 +600,7 @@ func TestRecorderSkipTracksFull(t *testing.T) {
|
||||||
|
|
||||||
n := 0
|
n := 0
|
||||||
|
|
||||||
l := test.Logger(func(l logger.Level, format string, args ...interface{}) {
|
l := test.Logger(func(l logger.Level, format string, args ...any) {
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
require.Equal(t, logger.Warn, l)
|
require.Equal(t, logger.Warn, l)
|
||||||
require.Equal(t, "[recorder] no supported tracks found, skipping recording", fmt.Sprintf(format, args...))
|
require.Equal(t, "[recorder] no supported tracks found, skipping recording", fmt.Sprintf(format, args...))
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func (s *httpServer) initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *httpServer) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *httpServer) Log(level logger.Level, format string, args ...any) {
|
||||||
s.parent.Log(level, format, args...)
|
s.parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ func (m *muxer) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (m *muxer) Log(level logger.Level, format string, args ...interface{}) {
|
func (m *muxer) Log(level logger.Level, format string, args ...any) {
|
||||||
m.parent.Log(level, "[muxer %s] "+format, append([]interface{}{m.pathName}, args...)...)
|
m.parent.Log(level, "[muxer %s] "+format, append([]any{m.pathName}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathName returns the path name.
|
// PathName returns the path name.
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func (mi *muxerInstance) initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (mi *muxerInstance) Log(level logger.Level, format string, args ...interface{}) {
|
func (mi *muxerInstance) Log(level logger.Level, format string, args ...any) {
|
||||||
mi.parent.Log(level, format, args...)
|
mi.parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
// ErrMuxerNotFound is returned when a muxer is not found.
|
// ErrMuxerNotFound is returned when a muxer is not found.
|
||||||
var ErrMuxerNotFound = errors.New("muxer not found")
|
var ErrMuxerNotFound = errors.New("muxer not found")
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ func (s *Server) Initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[HLS] "+format, args...)
|
s.Parent.Log(level, "[HLS] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ func TestServerRead(t *testing.T) {
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
strm.WriteUnit(test.MediaH264, test.FormatH264, &unit.Unit{
|
strm.WriteUnit(test.MediaH264, test.FormatH264, &unit.Unit{
|
||||||
NTP: time.Time{},
|
NTP: time.Time{},
|
||||||
PTS: int64(i) * 90000,
|
PTS: int64(i) * 90000,
|
||||||
|
|
@ -526,7 +526,7 @@ func TestAuthError(t *testing.T) {
|
||||||
return nil, &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
return nil, &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ func (c *conn) remoteAddr() net.Addr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
|
func (c *conn) Log(level logger.Level, format string, args ...any) {
|
||||||
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.nconn.RemoteAddr()}, args...)...)
|
c.parent.Log(level, "[conn %v] "+format, append([]any{c.nconn.RemoteAddr()}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conn) ip() net.IP {
|
func (c *conn) ip() net.IP {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
// ErrConnNotFound is returned when a connection is not found.
|
// ErrConnNotFound is returned when a connection is not found.
|
||||||
var ErrConnNotFound = errors.New("connection not found")
|
var ErrConnNotFound = errors.New("connection not found")
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,14 +163,14 @@ func (s *Server) Initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
label := func() string {
|
label := func() string {
|
||||||
if s.IsTLS {
|
if s.IsTLS {
|
||||||
return "RTMPS"
|
return "RTMPS"
|
||||||
}
|
}
|
||||||
return "RTMP"
|
return "RTMP"
|
||||||
}()
|
}()
|
||||||
s.Parent.Log(level, "[%s] "+format, append([]interface{}{label}, args...)...)
|
s.Parent.Log(level, "[%s] "+format, append([]any{label}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the server.
|
// Close closes the server.
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ func (c *conn) initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
|
func (c *conn) Log(level logger.Level, format string, args ...any) {
|
||||||
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.rconn.NetConn().RemoteAddr()}, args...)...)
|
c.parent.Log(level, "[conn %v] "+format, append([]any{c.rconn.NetConn().RemoteAddr()}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conn returns the RTSP connection.
|
// Conn returns the RTSP connection.
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ var ErrConnNotFound = errors.New("connection not found")
|
||||||
// ErrSessionNotFound is returned when a session is not found.
|
// ErrSessionNotFound is returned when a session is not found.
|
||||||
var ErrSessionNotFound = errors.New("session not found")
|
var ErrSessionNotFound = errors.New("session not found")
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,14 +170,14 @@ func (s *Server) Initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
label := func() string {
|
label := func() string {
|
||||||
if s.IsTLS {
|
if s.IsTLS {
|
||||||
return "RTSPS"
|
return "RTSPS"
|
||||||
}
|
}
|
||||||
return "RTSP"
|
return "RTSP"
|
||||||
}()
|
}()
|
||||||
s.Parent.Log(level, "[%s] "+format, append([]interface{}{label}, args...)...)
|
s.Parent.Log(level, "[%s] "+format, append([]any{label}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the server.
|
// Close closes the server.
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,7 @@ func TestAuthError(t *testing.T) {
|
||||||
WriteTimeout: conf.Duration(10 * time.Second),
|
WriteTimeout: conf.Duration(10 * time.Second),
|
||||||
WriteQueueSize: 512,
|
WriteQueueSize: 512,
|
||||||
PathManager: pathManager,
|
PathManager: pathManager,
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if atomic.AddInt64(n, 1) == 3 {
|
if atomic.AddInt64(n, 1) == 3 {
|
||||||
require.Regexp(t, "authentication failed: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "authentication failed: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,9 @@ func (s *session) remoteAddr() net.Addr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *session) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *session) Log(level logger.Level, format string, args ...any) {
|
||||||
id := hex.EncodeToString(s.uuid[:4])
|
id := hex.EncodeToString(s.uuid[:4])
|
||||||
s.parent.Log(level, "[session %s] "+format, append([]interface{}{id}, args...)...)
|
s.parent.Log(level, "[session %s] "+format, append([]any{id}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// onClose is called by rtspServer.
|
// onClose is called by rtspServer.
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ func (c *conn) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
|
func (c *conn) Log(level logger.Level, format string, args ...any) {
|
||||||
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.connReq.RemoteAddr()}, args...)...)
|
c.parent.Log(level, "[conn %v] "+format, append([]any{c.connReq.RemoteAddr()}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conn) ip() net.IP {
|
func (c *conn) ip() net.IP {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
// ErrConnNotFound is returned when a connection is not found.
|
// ErrConnNotFound is returned when a connection is not found.
|
||||||
var ErrConnNotFound = errors.New("connection not found")
|
var ErrConnNotFound = errors.New("connection not found")
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ func (s *Server) Initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[SRT] "+format, args...)
|
s.Parent.Log(level, "[SRT] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func (s *streamID) unmarshal(raw string) error {
|
||||||
// standard syntax
|
// standard syntax
|
||||||
// https://github.com/Haivision/srt/blob/master/docs/features/access-control.md
|
// https://github.com/Haivision/srt/blob/master/docs/features/access-control.md
|
||||||
if strings.HasPrefix(raw, "#!::") {
|
if strings.HasPrefix(raw, "#!::") {
|
||||||
for _, kv := range strings.Split(raw[len("#!::"):], ",") {
|
for kv := range strings.SplitSeq(raw[len("#!::"):], ",") {
|
||||||
kv2 := strings.SplitN(kv, "=", 2)
|
kv2 := strings.SplitN(kv, "=", 2)
|
||||||
if len(kv2) != 2 {
|
if len(kv2) != 2 {
|
||||||
return fmt.Errorf("invalid value")
|
return fmt.Errorf("invalid value")
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ func (s *httpServer) initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *httpServer) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *httpServer) Log(level logger.Level, format string, args ...any) {
|
||||||
s.parent.Log(level, format, args...)
|
s.parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ const (
|
||||||
// ErrSessionNotFound is returned when a session is not found.
|
// ErrSessionNotFound is returned when a session is not found.
|
||||||
var ErrSessionNotFound = errors.New("session not found")
|
var ErrSessionNotFound = errors.New("session not found")
|
||||||
|
|
||||||
func interfaceIsEmpty(i interface{}) bool {
|
func interfaceIsEmpty(i any) bool {
|
||||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ func (s *Server) Initialize() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Server) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[WebRTC] "+format, args...)
|
s.Parent.Log(level, "[WebRTC] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -751,7 +751,7 @@ func TestAuthError(t *testing.T) {
|
||||||
return nil, &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
return nil, &auth.Error{Wrapped: fmt.Errorf("auth error")}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Parent: test.Logger(func(l logger.Level, s string, i ...interface{}) {
|
Parent: test.Logger(func(l logger.Level, s string, i ...any) {
|
||||||
if l == logger.Info {
|
if l == logger.Info {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@ func (s *session) initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *session) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *session) Log(level logger.Level, format string, args ...any) {
|
||||||
id := hex.EncodeToString(s.uuid[:4])
|
id := hex.EncodeToString(s.uuid[:4])
|
||||||
s.parent.Log(level, "[session %v] "+format, append([]interface{}{id}, args...)...)
|
s.parent.Log(level, "[session %v] "+format, append([]any{id}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) Close() {
|
func (s *session) Close() {
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ func (s *Handler) Stop(reason string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Handler) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Handler) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, format, args...)
|
s.Parent.Log(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[HLS source] "+format, args...)
|
s.Parent.Log(level, "[HLS source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[MPEG-TS source] "+format, args...)
|
s.Parent.Log(level, "[MPEG-TS source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[RPI Camera source] "+format, args...)
|
s.Parent.Log(level, "[RPI Camera source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[RTMP source] "+format, args...)
|
s.Parent.Log(level, "[RTMP source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[RTP source] "+format, args...)
|
s.Parent.Log(level, "[RTP source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[RTSP source] "+format, args...)
|
s.Parent.Log(level, "[RTSP source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[SRT source] "+format, args...)
|
s.Parent.Log(level, "[SRT source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ type Source struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (s *Source) Log(level logger.Level, format string, args ...interface{}) {
|
func (s *Source) Log(level logger.Level, format string, args ...any) {
|
||||||
s.Parent.Log(level, "[WebRTC source] "+format, args...)
|
s.Parent.Log(level, "[WebRTC source] "+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,21 @@ import "github.com/bluenviron/mediamtx/internal/logger"
|
||||||
|
|
||||||
type nilLogger struct{}
|
type nilLogger struct{}
|
||||||
|
|
||||||
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
|
func (nilLogger) Log(_ logger.Level, _ string, _ ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NilLogger is a logger to /dev/null
|
// NilLogger is a logger to /dev/null
|
||||||
var NilLogger logger.Writer = &nilLogger{}
|
var NilLogger logger.Writer = &nilLogger{}
|
||||||
|
|
||||||
type testLogger struct {
|
type testLogger struct {
|
||||||
cb func(level logger.Level, format string, args ...interface{})
|
cb func(level logger.Level, format string, args ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *testLogger) Log(level logger.Level, format string, args ...interface{}) {
|
func (l *testLogger) Log(level logger.Level, format string, args ...any) {
|
||||||
l.cb(level, format, args...)
|
l.cb(level, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger returns a dummy logger.
|
// Logger returns a dummy logger.
|
||||||
func Logger(cb func(logger.Level, string, ...interface{})) logger.Writer {
|
func Logger(cb func(logger.Level, string, ...any)) logger.Writer {
|
||||||
return &testLogger{cb: cb}
|
return &testLogger{cb: cb}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ type StaticSourceParent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log implements logger.Writer.
|
// Log implements logger.Writer.
|
||||||
func (*StaticSourceParent) Log(logger.Level, string, ...interface{}) {}
|
func (*StaticSourceParent) Log(logger.Level, string, ...any) {}
|
||||||
|
|
||||||
// Initialize initializes StaticSourceParent.
|
// Initialize initializes StaticSourceParent.
|
||||||
func (p *StaticSourceParent) Initialize() {
|
func (p *StaticSourceParent) Initialize() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue