update golangci-lint configuration (#5182)

This commit is contained in:
Alessandro Ros 2025-11-11 23:57:52 +01:00 committed by GitHub
parent ac1d4360b2
commit ff187b6d8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
80 changed files with 294 additions and 309 deletions

View file

@ -12,6 +12,7 @@ linters:
- gocritic
- lll
- misspell
- modernize
- nilerr
- prealloc
- predeclared
@ -71,6 +72,12 @@ linters:
shadow:
strict: true
modernize:
disable:
- reflecttypefor
- stringsbuilder
- testingcontext
formatters:
enable:
- gofmt

View file

@ -30,7 +30,7 @@ import (
"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()
}
@ -220,7 +220,7 @@ func (a *API) Close() {
}
// 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...)
}

View file

@ -20,10 +20,10 @@ import (
)
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 {
p.log(l, s, a...)
}
@ -42,7 +42,7 @@ func tempConf(t *testing.T, cnt string) *conf.Conf {
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 {
if in == 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) {
var resErr map[string]interface{}
var resErr map[string]any
err := json.NewDecoder(body).Decode(&resErr)
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) {
@ -139,9 +139,9 @@ func TestInfo(t *testing.T) {
defer tr.CloseIdleConnections()
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)
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),
"version": "v1.2.3",
}, out)
@ -175,7 +175,7 @@ func TestConfigGlobalGet(t *testing.T) {
defer tr.CloseIdleConnections()
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)
require.Equal(t, true, out["api"])
@ -202,7 +202,7 @@ func TestConfigGlobalPatch(t *testing.T) {
hc := &http.Client{Transport: tr}
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/global/patch",
map[string]interface{}{
map[string]any{
"rtmp": false,
"readTimeout": "7s",
"protocols": []string{"tcp"},
@ -211,11 +211,11 @@ func TestConfigGlobalPatch(t *testing.T) {
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)
require.Equal(t, false, out["rtmp"])
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"])
}
@ -234,7 +234,7 @@ func TestConfigGlobalPatchUnknownField(t *testing.T) { //nolint:dupl
require.NoError(t, err)
defer api.Close()
b := map[string]interface{}{
b := map[string]any{
"test": "asd",
}
@ -276,7 +276,7 @@ func TestConfigPathDefaultsGet(t *testing.T) {
defer tr.CloseIdleConnections()
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)
require.Equal(t, "publisher", out["source"])
}
@ -301,13 +301,13 @@ func TestConfigPathDefaultsPatch(t *testing.T) {
hc := &http.Client{Transport: tr}
httpRequest(t, hc, http.MethodPatch, "http://localhost:9997/v3/config/pathdefaults/patch",
map[string]interface{}{
map[string]any{
"recordFormat": "fmp4",
}, nil)
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)
require.Equal(t, "fmp4", out["recordFormat"])
}
@ -334,7 +334,7 @@ func TestConfigPathsList(t *testing.T) {
require.NoError(t, err)
defer api.Close()
type pathConfig map[string]interface{}
type pathConfig map[string]any
type listRes struct {
ItemCount int `json:"itemCount"`
@ -381,7 +381,7 @@ func TestConfigPathsGet(t *testing.T) {
defer tr.CloseIdleConnections()
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)
require.Equal(t, "my/path", out["name"])
require.Equal(t, "myuser", out["readUser"])
@ -407,14 +407,14 @@ func TestConfigPathsAdd(t *testing.T) {
hc := &http.Client{Transport: tr}
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",
"sourceOnDemand": true,
"disablePublisherOverride": true, // test setting a deprecated parameter
"rpiCameraVFlip": true,
}, 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)
require.Equal(t, "rtsp://127.0.0.1:9999/mypath", out["source"])
require.Equal(t, true, out["sourceOnDemand"])
@ -437,7 +437,7 @@ func TestConfigPathsAddUnknownField(t *testing.T) { //nolint:dupl
require.NoError(t, err)
defer api.Close()
b := map[string]interface{}{
b := map[string]any{
"test": "asd",
}
@ -480,7 +480,7 @@ func TestConfigPathsPatch(t *testing.T) { //nolint:dupl
hc := &http.Client{Transport: tr}
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",
"sourceOnDemand": true,
"disablePublisherOverride": true, // test setting a deprecated parameter
@ -488,12 +488,12 @@ func TestConfigPathsPatch(t *testing.T) { //nolint:dupl
}, nil)
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",
"sourceOnDemand": true,
}, 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)
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
require.Equal(t, true, out["sourceOnDemand"])
@ -521,7 +521,7 @@ func TestConfigPathsReplace(t *testing.T) { //nolint:dupl
hc := &http.Client{Transport: tr}
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",
"sourceOnDemand": true,
"disablePublisherOverride": true, // test setting a deprecated parameter
@ -529,12 +529,12 @@ func TestConfigPathsReplace(t *testing.T) { //nolint:dupl
}, nil)
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",
"sourceOnDemand": true,
}, 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)
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
require.Equal(t, true, out["sourceOnDemand"])
@ -562,12 +562,12 @@ func TestConfigPathsReplaceNonExisting(t *testing.T) { //nolint:dupl
hc := &http.Client{Transport: tr}
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",
"sourceOnDemand": true,
}, 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)
require.Equal(t, "rtsp://127.0.0.1:9998/mypath", out["source"])
require.Equal(t, true, out["sourceOnDemand"])
@ -595,7 +595,7 @@ func TestConfigPathsDelete(t *testing.T) {
hc := &http.Client{Transport: tr}
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",
"sourceOnDemand": true,
}, nil)
@ -655,27 +655,27 @@ func TestRecordingsList(t *testing.T) {
defer tr.CloseIdleConnections()
hc := &http.Client{Transport: tr}
var out interface{}
var out any
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),
"pageCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"items": []any{
map[string]any{
"name": "mypath1",
"segments": []interface{}{
map[string]interface{}{
"segments": []any{
map[string]any{
"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),
},
},
},
map[string]interface{}{
map[string]any{
"name": "mypath2",
"segments": []interface{}{
map[string]interface{}{
"segments": []any{
map[string]any{
"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()
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)
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"name": "mypath1",
"segments": []interface{}{
map[string]interface{}{
"segments": []any{
map[string]any{
"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),
},
},
@ -840,7 +840,7 @@ func TestAuthError(t *testing.T) {
},
},
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -6,7 +6,7 @@ import (
"strconv"
)
func paginate2(itemsPtr interface{}, itemsPerPage int, page int) int {
func paginate2(itemsPtr any, itemsPerPage int, page int) int {
ritems := reflect.ValueOf(itemsPtr).Elem()
itemsLen := ritems.Len()
@ -19,22 +19,16 @@ func paginate2(itemsPtr interface{}, itemsPerPage int, page int) int {
pageCount++
}
minVal := page * itemsPerPage
if minVal > itemsLen {
minVal = itemsLen
}
minVal := min(page*itemsPerPage, itemsLen)
maxVal := (page + 1) * itemsPerPage
if maxVal > itemsLen {
maxVal = itemsLen
}
maxVal := min((page+1)*itemsPerPage, itemsLen)
ritems.Set(ritems.Slice(minVal, maxVal))
return pageCount
}
func paginate(itemsPtr interface{}, itemsPerPageStr string, pageStr string) (int, error) {
func paginate(itemsPtr any, itemsPerPageStr string, pageStr string) (int, error) {
itemsPerPage := 100
if itemsPerPageStr != "" {

View file

@ -9,7 +9,7 @@ import (
func TestPaginate(t *testing.T) {
func() {
items := make([]int, 5)
for i := 0; i < 5; i++ {
for i := range 5 {
items[i] = i
}
@ -21,7 +21,7 @@ func TestPaginate(t *testing.T) {
func() {
items := make([]int, 5)
for i := 0; i < 5; i++ {
for i := range 5 {
items[i] = i
}
@ -33,7 +33,7 @@ func TestPaginate(t *testing.T) {
func() {
items := make([]int, 6)
for i := 0; i < 6; i++ {
for i := range 6 {
items[i] = i
}
@ -56,7 +56,7 @@ func TestPaginate(t *testing.T) {
func FuzzPaginate(f *testing.F) {
f.Fuzz(func(_ *testing.T, str1 string, str2 string) {
items := make([]int, 6)
for i := 0; i < 6; i++ {
for i := range 6 {
items[i] = i
}

View file

@ -539,7 +539,7 @@ func TestAuthJWTRefresh(t *testing.T) {
JWTClaimKey: "my_permission_key",
}
for i := 0; i < 2; i++ {
for range 2 {
key, err = rsa.GenerateKey(rand.Reader, 1024)
require.NoError(t, err)

View file

@ -15,15 +15,15 @@ import (
)
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...)
}
// 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}
}
@ -202,7 +202,7 @@ func TestH264RTPOversized(t *testing.T) {
logged := 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...))
logged = true
}))

View file

@ -202,7 +202,7 @@ func TestH265RTPOversized(t *testing.T) {
logged := 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...))
logged = true
}))

View file

@ -48,13 +48,13 @@ func firstThatExists(paths []string) string {
return ""
}
func copyStructFields(dest interface{}, source interface{}) {
func copyStructFields(dest any, source any) {
rvsource := reflect.ValueOf(source).Elem()
rvdest := reflect.ValueOf(dest)
nf := rvsource.NumField()
var zero reflect.Value
for i := 0; i < nf; i++ {
for i := range nf {
fnew := rvsource.Field(i)
f := rvdest.Elem().FieldByName(rvsource.Type().Field(i).Name)
if f == zero {
@ -508,7 +508,7 @@ func (conf Conf) Clone() *Conf {
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
func (nilLogger) Log(_ logger.Level, _ string, _ ...any) {
}
// Validate checks the configuration for errors.

View file

@ -156,7 +156,7 @@ func loadEnvInternal(env map[string]string, prefix string, prv reflect.Value) er
case reflect.Struct:
flen := rt.NumField()
for i := 0; i < flen; i++ {
for i := range flen {
f := rt.Field(i)
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)
}
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())
}
@ -253,6 +253,6 @@ func envToMap() map[string]string {
}
// 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)
}

View file

@ -10,7 +10,7 @@ var globalValuesType = func() reflect.Type {
rt := reflect.TypeOf(Conf{})
nf := rt.NumField()
for i := 0; i < nf; i++ {
for i := range nf {
f := rt.Field(i)
j := f.Tag.Get("json")
@ -26,13 +26,13 @@ var globalValuesType = func() reflect.Type {
return reflect.StructOf(fields)
}()
func newGlobalValues() interface{} {
func newGlobalValues() any {
return reflect.New(globalValuesType).Interface()
}
// Global is the global part of Conf.
type Global struct {
Values interface{}
Values any
}
// MarshalJSON implements json.Marshaler.

View file

@ -3,6 +3,7 @@ package conf
import (
"encoding/json"
"fmt"
"slices"
"strings"
"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 {
for _, item := range *d {
if item == v {
return true
}
}
return false
return slices.Contains(*d, v)
}
// UnmarshalJSON implements json.Unmarshaler.

View file

@ -13,7 +13,7 @@ var optionalGlobalValuesType = func() reflect.Type {
rt := reflect.TypeOf(Conf{})
nf := rt.NumField()
for i := 0; i < nf; i++ {
for i := range nf {
f := rt.Field(i)
j := f.Tag.Get("json")
@ -38,13 +38,13 @@ var optionalGlobalValuesType = func() reflect.Type {
return reflect.StructOf(fields)
}()
func newOptionalGlobalValues() interface{} {
func newOptionalGlobalValues() any {
return reflect.New(optionalGlobalValuesType).Interface()
}
// OptionalGlobal is a Conf whose values can all be optional.
type OptionalGlobal struct {
Values interface{}
Values any
}
// UnmarshalJSON implements json.Unmarshaler.

View file

@ -14,7 +14,7 @@ var optionalPathValuesType = func() reflect.Type {
rt := reflect.TypeOf(Path{})
nf := rt.NumField()
for i := 0; i < nf; i++ {
for i := range nf {
f := rt.Field(i)
j := f.Tag.Get("json")
@ -39,13 +39,13 @@ var optionalPathValuesType = func() reflect.Type {
return reflect.StructOf(fields)
}()
func newOptionalPathValues() interface{} {
func newOptionalPathValues() any {
return reflect.New(optionalPathValuesType).Interface()
}
// OptionalPath is a Path whose values can all be optional.
type OptionalPath struct {
Values interface{}
Values any
}
// UnmarshalJSON implements json.Unmarshaler.

View file

@ -8,10 +8,10 @@ import (
"gopkg.in/yaml.v2"
)
func convertKeys(i interface{}) (interface{}, error) {
func convertKeys(i any) (any, error) {
switch x := i.(type) {
case map[interface{}]interface{}:
m2 := map[string]interface{}{}
case map[any]any:
m2 := map[string]any{}
for k, v := range x {
ks, ok := k.(string)
if !ok {
@ -26,8 +26,8 @@ func convertKeys(i interface{}) (interface{}, error) {
}
return m2, nil
case []interface{}:
a2 := make([]interface{}, len(x))
case []any:
a2 := make([]any, len(x))
for i, v := range x {
var err error
a2[i], err = convertKeys(v)
@ -42,12 +42,12 @@ func convertKeys(i interface{}) (interface{}, error) {
}
// 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
// from documentation:
// "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."
var temp interface{}
var temp any
err := yaml.UnmarshalStrict(buf, &temp)
if err != nil {
return err

View file

@ -34,7 +34,7 @@ func checkClose(t *testing.T, closeFunc func() error) {
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 {
if in == 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) {
var resErr map[string]interface{}
var resErr map[string]any
err := json.NewDecoder(body).Decode(&resErr)
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) {
@ -462,7 +462,7 @@ func TestAPIProtocolListGet(t *testing.T) {
go func() {
time.Sleep(500 * time.Millisecond)
for i := 0; i < 3; i++ {
for i := range 3 {
/*source.WritePacketRTP(medi, &rtp.Packet{
Header: rtp.Header{
Version: 2,
@ -604,40 +604,40 @@ func TestAPIProtocolListGet(t *testing.T) {
pa = "srtconns"
}
var out1 interface{}
var out1 any
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/"+pa+"/list", nil, &out1)
switch ca {
case "rtsp conns":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
"items": []any{
map[string]any{
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
"session": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["session"],
"tunnel": "none",
},
},
}, out1)
case "rtsp sessions":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"items": []any{
map[string]any{
"bytesReceived": float64(0),
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"path": "mypath",
"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",
"transport": "UDP",
"profile": "AVP",
@ -654,35 +654,35 @@ func TestAPIProtocolListGet(t *testing.T) {
}, out1)
case "rtsps conns":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
"session": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["session"],
"items": []any{
map[string]any{
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
"session": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["session"],
"tunnel": "none",
},
},
}, out1)
case "rtsps sessions":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"items": []any{
map[string]any{
"bytesReceived": float64(0),
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"path": "mypath",
"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",
"transport": "UDP",
"profile": "SAVP",
@ -699,71 +699,71 @@ func TestAPIProtocolListGet(t *testing.T) {
}, out1)
case "rtmp":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"items": []any{
map[string]any{
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"path": "mypath",
"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",
},
},
}, out1)
case "rtmps":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"pageCount": float64(1),
"itemCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"items": []any{
map[string]any{
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"path": "mypath",
"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",
},
},
}, out1)
case "hls":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"itemCount": float64(1),
"pageCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"lastRequest": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["lastRequest"],
"items": []any{
map[string]any{
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"lastRequest": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["lastRequest"],
"path": "mypath",
},
},
}, out1)
case "webrtc":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"itemCount": float64(1),
"pageCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"bytesReceived": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesReceived"],
"bytesSent": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["bytesSent"],
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"localCandidate": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["localCandidate"],
"items": []any{
map[string]any{
"bytesReceived": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesReceived"],
"bytesSent": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["bytesSent"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"localCandidate": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["localCandidate"],
"path": "mypath",
"peerConnectionEstablished": true,
"query": "key=val",
"remoteAddr": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteAddr"],
"remoteCandidate": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["remoteCandidate"],
"remoteAddr": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteAddr"],
"remoteCandidate": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["remoteCandidate"],
"state": "read",
"rtcpPacketsReceived": float64(0),
"rtcpPacketsSent": float64(2),
@ -776,11 +776,11 @@ func TestAPIProtocolListGet(t *testing.T) {
}, out1)
case "srt":
require.Equal(t, map[string]interface{}{
require.Equal(t, map[string]any{
"itemCount": float64(1),
"pageCount": float64(1),
"items": []interface{}{
map[string]interface{}{
"items": []any{
map[string]any{
"byteMSS": float64(1500),
"bytesAvailReceiveBuf": float64(0),
"bytesAvailSendBuf": float64(0),
@ -797,13 +797,13 @@ func TestAPIProtocolListGet(t *testing.T) {
"bytesSendDrop": float64(0),
"bytesSent": float64(0),
"bytesSentUnique": float64(0),
"created": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["created"],
"id": out1.(map[string]interface{})["items"].([]interface{})[0].(map[string]interface{})["id"],
"created": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["created"],
"id": out1.(map[string]any)["items"].([]any)[0].(map[string]any)["id"],
"mbpsLinkCapacity": float64(0),
"mbpsMaxBW": float64(-1),
"mbpsReceiveRate": 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),
"msReceiveTsbPdDelay": float64(120),
"msSendBuf": float64(0),
@ -812,7 +812,7 @@ func TestAPIProtocolListGet(t *testing.T) {
"packetsFlowWindow": float64(25600),
"packetsReceiveBuf": float64(0),
"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),
"packetsReceivedBelated": float64(0),
"packetsReceivedDrop": float64(0),
@ -830,13 +830,13 @@ func TestAPIProtocolListGet(t *testing.T) {
"packetsSendLoss": float64(0),
"packetsSendLossRate": 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),
"packetsSentNAK": float64(0),
"packetsSentUnique": float64(0),
"path": "mypath",
"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",
"usPacketsSendPeriod": float64(10.967254638671875),
"usSndDuration": float64(0),
@ -845,19 +845,19 @@ func TestAPIProtocolListGet(t *testing.T) {
}, out1)
}
var out2 interface{}
var out2 any
if ca == "hls" {
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)
} else {
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)
}
require.Equal(t, out1.(map[string]interface{})["items"].([]interface{})[0], out2)
require.Equal(t, out1.(map[string]any)["items"].([]any)[0], out2)
})
}
}

View file

@ -197,7 +197,7 @@ func (p *Core) Wait() {
}
// 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...)
}

View file

@ -482,7 +482,7 @@ webrtc_sessions_rtcp_packets_sent 0
})
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,
"rtmp": false,
"srt": false,

View file

@ -150,7 +150,7 @@ func (pa *path) wait() {
}
// 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...)
}

View file

@ -149,7 +149,7 @@ func (pm *pathManager) close() {
}
// 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...)
}

View file

@ -134,13 +134,13 @@ func TestPathConfigurationHotReload(t *testing.T) {
require.Equal(t, "all", pathData.ConfName)
// 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)
require.Equal(t, false, allConfig["record"]) // Should be false from "all" config
// 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",
map[string]interface{}{
map[string]any{
"record": true,
}, nil)
@ -154,7 +154,7 @@ func TestPathConfigurationHotReload(t *testing.T) {
require.Equal(t, "undefined_stream", pathData.ConfName) // Should now use the specific config
// 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)
require.Equal(t, true, newConfig["record"]) // Should be true from new config

View file

@ -487,7 +487,7 @@ func TestPathRunOnRead(t *testing.T) {
defer conn.Close()
go func() {
for i := uint16(0); i < 3; i++ {
for i := range uint16(3) {
err2 := source.WritePacketRTP(media0, &rtp.Packet{
Header: rtp.Header{
Version: 2,
@ -622,7 +622,7 @@ func TestPathRunOnRecordSegment(t *testing.T) {
require.NoError(t, err)
defer source.Close()
for i := 0; i < 4; i++ {
for i := range 4 {
err = source.WritePacketRTP(media0, &rtp.Packet{
Header: rtp.Header{
Version: 2,
@ -672,7 +672,7 @@ func TestPathMaxReaders(t *testing.T) {
require.NoError(t, err)
defer source.Close()
for i := 0; i < 2; i++ {
for i := range 2 {
var u *base.URL
u, err = base.ParseURL("rtsp://127.0.0.1:8554/mystream")
require.NoError(t, err)
@ -723,7 +723,7 @@ func TestPathRecord(t *testing.T) {
require.NoError(t, err)
defer source.Close()
for i := 0; i < 4; i++ {
for i := range 4 {
err = source.WritePacketRTP(media0, &rtp.Packet{
Header: rtp.Header{
Version: 2,
@ -748,13 +748,13 @@ func TestPathRecord(t *testing.T) {
defer tr.CloseIdleConnections()
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,
}, nil)
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,
}, nil)

View file

@ -8,7 +8,7 @@ import (
// sourceRedirect is a source that redirects to another one.
type sourceRedirect struct{}
func (*sourceRedirect) Log(logger.Level, string, ...interface{}) {
func (*sourceRedirect) Log(logger.Level, string, ...any) {
}
// APISourceDescribe implements source.

View file

@ -19,6 +19,6 @@ const (
)
type destination interface {
log(time.Time, Level, string, ...interface{})
log(time.Time, Level, string, ...any)
close()
}

View file

@ -22,7 +22,7 @@ func newDestinationFile(filePath string) (destination, error) {
}, 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()
writeTime(&d.buf, t, false)
writeLevel(&d.buf, level, false)

View file

@ -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()
writeTime(&d.buf, t, d.useColor)
writeLevel(&d.buf, level, d.useColor)

View file

@ -22,7 +22,7 @@ func newDestinationSyslog(prefix string) (destination, error) {
}, 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()
writeTime(&d.buf, t, false)
writeLevel(&d.buf, level, false)

View file

@ -135,13 +135,13 @@ func writeLevel(buf *bytes.Buffer, level Level, useColor bool) {
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...)
buf.WriteByte('\n')
}
// 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 {
return
}

View file

@ -2,5 +2,5 @@ package logger
// Writer is an object that provides a log method.
type Writer interface {
Log(Level, string, ...interface{})
Log(Level, string, ...any)
}

View file

@ -20,7 +20,7 @@ import (
"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()
}
@ -130,7 +130,7 @@ func (m *Metrics) Close() {
}
// 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...)
}

View file

@ -379,7 +379,7 @@ func TestAuthError(t *testing.T) {
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -80,10 +80,7 @@ func (w *muxerFMP4) writeSample(
w.curTrack.samples = w.curTrack.samples[:0]
}
} else {
duration := dts - w.curTrack.lastDTS
if duration < 0 {
duration = 0
}
duration := max(dts-w.curTrack.lastDTS, 0)
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) {
if len(w.curTrack.samples) != 0 && w.curTrack.firstDTS >= 0 {
duration := dts - w.curTrack.lastDTS
if duration < 0 {
duration = 0
}
duration := max(dts-w.curTrack.lastDTS, 0)
w.curTrack.samples[len(w.curTrack.samples)-1].Duration = uint32(duration)
}
}

View file

@ -62,10 +62,7 @@ func (w *muxerMP4) writeSample(
if len(w.curTrack.Samples) == 0 {
w.curTrack.TimeOffset = int32(dts)
} else {
duration := dts - w.curTrack.lastDTS
if duration < 0 {
duration = 0
}
duration := max(dts-w.curTrack.lastDTS, 0)
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) {
if len(w.curTrack.Samples) != 0 {
duration := dts - w.curTrack.lastDTS
if duration < 0 {
duration = 0
}
duration := max(dts-w.curTrack.lastDTS, 0)
w.curTrack.Samples[len(w.curTrack.Samples)-1].Duration = uint32(duration)
}
}

View file

@ -122,20 +122,20 @@ func TestOnList(t *testing.T) {
require.Equal(t, http.StatusOK, res.StatusCode)
var out interface{}
var out any
err = json.NewDecoder(res.Body).Decode(&out)
require.NoError(t, err)
switch ca {
case "unfiltered", "start before first":
require.Equal(t, []interface{}{
map[string]interface{}{
require.Equal(t, []any{
map[string]any{
"duration": float64(66),
"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.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
},
map[string]interface{}{
map[string]any{
"duration": float64(4),
"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=" +
@ -144,14 +144,14 @@ func TestOnList(t *testing.T) {
}, out)
case "filtered":
require.Equal(t, []interface{}{
map[string]interface{}{
require.Equal(t, []any{
map[string]any{
"duration": float64(65),
"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.QueryEscape(time.Date(2008, 11, 7, 11, 22, 1, 500000000, time.Local).Format(time.RFC3339Nano)),
},
map[string]interface{}{
map[string]any{
"duration": float64(2),
"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=" +
@ -160,8 +160,8 @@ func TestOnList(t *testing.T) {
}, out)
case "filtered and gap":
require.Equal(t, []interface{}{
map[string]interface{}{
require.Equal(t, []any{
map[string]any{
"duration": float64(4),
"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=" +
@ -170,14 +170,14 @@ func TestOnList(t *testing.T) {
}, out)
case "different init":
require.Equal(t, []interface{}{
map[string]interface{}{
require.Equal(t, []any{
map[string]any{
"duration": float64(62),
"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.QueryEscape(time.Date(2008, 11, 7, 11, 22, 0, 500000000, time.Local).Format(time.RFC3339Nano)),
},
map[string]interface{}{
map[string]any{
"duration": float64(1),
"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=" +
@ -322,12 +322,12 @@ func TestOnListCachedDuration(t *testing.T) {
require.Equal(t, http.StatusOK, res.StatusCode)
var out interface{}
var out any
err = json.NewDecoder(res.Body).Decode(&out)
require.NoError(t, err)
require.Equal(t, []interface{}{
map[string]interface{}{
require.Equal(t, []any{
map[string]any{
"duration": float64(50),
"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=" +

View file

@ -431,7 +431,7 @@ func segmentFMP4MuxParts(
var segmentDuration time.Duration
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() {
case "moof":
moofOffset = h.BoxInfo.Offset

View file

@ -59,7 +59,7 @@ func BenchmarkFMP4ReadHeader(b *testing.B) {
writeBenchInit(f)
f.Close()
for n := 0; n < b.N; n++ {
for b.Loop() {
func() {
f, err = os.Open(f.Name())
if err != nil {

View file

@ -73,7 +73,7 @@ func (s *Server) Close() {
}
// 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...)
}

View file

@ -67,7 +67,7 @@ func TestAuthError(t *testing.T) {
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -76,7 +76,7 @@ func (pp *PPROF) Close() {
}
// 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...)
}

View file

@ -110,7 +110,7 @@ func TestAuthError(t *testing.T) {
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -20,7 +20,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
}}}
r := &stream.Reader{
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
Parent: test.Logger(func(logger.Level, string, ...any) {
t.Error("should not happen")
}),
}
@ -52,7 +52,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
n := 0
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)
switch n {
case 0:

View file

@ -19,7 +19,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
}}}
r := &stream.Reader{
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
Parent: test.Logger(func(logger.Level, string, ...any) {
t.Error("should not happen")
}),
}
@ -43,7 +43,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
n := 0
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)
if n == 0 {
require.Equal(t, "skipping track 2 (VP8)", fmt.Sprintf(format, args...))

View file

@ -168,7 +168,7 @@ func TestToStreamNoSupportedCodecs(t *testing.T) {
err = r.Initialize()
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")
})
_, err = ToStream(r, nil, l)
@ -202,7 +202,7 @@ func TestToStreamSkipUnsupportedTracks(t *testing.T) {
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)
if n == 0 {
require.Equal(t, "skipping track 1 (unsupported codec)", fmt.Sprintf(format, args...))

View file

@ -51,7 +51,7 @@ func FromStream(
for _, forma := range media.Formats {
switch forma := forma.(type) {
case *format.AV1:
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCAV1))) {
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCAV1))) {
r.OnData(
media,
forma,
@ -71,7 +71,7 @@ func FromStream(
}
case *format.VP9:
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCVP9))) {
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCVP9))) {
r.OnData(
media,
forma,
@ -91,7 +91,7 @@ func FromStream(
}
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
r.OnData(
@ -179,7 +179,7 @@ func FromStream(
tracks = append(tracks, forma)
case *format.Opus:
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCOpus))) {
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCOpus))) {
r.OnData(
media,
forma,
@ -303,7 +303,7 @@ func FromStream(
tracks = append(tracks, forma)
case *format.AC3:
if slices.Contains(conn.FourCcList, interface{}(fourCCToString(message.FourCCAC3))) {
if slices.Contains(conn.FourCcList, any(fourCCToString(message.FourCCAC3))) {
r.OnData(
media,
forma,

View file

@ -655,7 +655,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
}}}
r := &stream.Reader{
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
Parent: test.Logger(func(logger.Level, string, ...any) {
t.Error("should not happen")
}),
}
@ -679,7 +679,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
n := 0
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)
if n == 0 {
require.Equal(t, "skipping track 1 (VP8)", fmt.Sprintf(format, args...))

View file

@ -22,7 +22,7 @@ func TestFromStreamNoSupportedCodecs(t *testing.T) {
}}}
r := &stream.Reader{
Parent: test.Logger(func(logger.Level, string, ...interface{}) {
Parent: test.Logger(func(logger.Level, string, ...any) {
t.Error("should not happen")
}),
}
@ -46,7 +46,7 @@ func TestFromStreamSkipUnsupportedTracks(t *testing.T) {
n := 0
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)
if n == 0 {
require.Equal(t, "skipping track 2 (M-JPEG)", fmt.Sprintf(format, args...))

View file

@ -95,12 +95,12 @@ func (c *ServerConn) run() {
}
// ReadJSON reads a JSON object.
func (c *ServerConn) ReadJSON(in interface{}) error {
func (c *ServerConn) ReadJSON(in any) error {
return c.wc.ReadJSON(in)
}
// WriteJSON writes a JSON object.
func (c *ServerConn) WriteJSON(in interface{}) error {
func (c *ServerConn) WriteJSON(in any) error {
byts, err := json.Marshal(in)
if err != nil {
return err

View file

@ -44,7 +44,7 @@ func (c *Cleaner) Close() {
}
// 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...)
}

View file

@ -71,7 +71,7 @@ func (r *Recorder) Initialize() {
}
// 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...)
}

View file

@ -42,7 +42,7 @@ type recorderInstance struct {
}
// 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...)
}

View file

@ -73,7 +73,7 @@ func TestRecorder(t *testing.T) {
}}
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
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
<-segDone
}
@ -365,7 +365,7 @@ func TestRecorderFMP4NegativeInitialDTS(t *testing.T) {
}
w.Initialize()
for i := 0; i < 3; i++ {
for i := range 3 {
strm.WriteUnit(desc.Medias[0], desc.Medias[0].Formats[0], &unit.Unit{
PTS: -50*90000/1000 + (int64(i) * 200 * 90000 / 1000),
NTP: time.Date(2008, 5, 20, 22, 15, 25, 0, time.UTC),
@ -538,7 +538,7 @@ func TestRecorderSkipTracksPartial(t *testing.T) {
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 {
require.Equal(t, logger.Warn, l)
require.Equal(t, "[recorder] skipping track 2 (VP8)", fmt.Sprintf(format, args...))
@ -600,7 +600,7 @@ func TestRecorderSkipTracksFull(t *testing.T) {
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 {
require.Equal(t, logger.Warn, l)
require.Equal(t, "[recorder] no supported tracks found, skipping recording", fmt.Sprintf(format, args...))

View file

@ -76,7 +76,7 @@ func (s *httpServer) initialize() error {
}
// 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...)
}

View file

@ -98,8 +98,8 @@ func (m *muxer) Close() {
}
// Log implements logger.Writer.
func (m *muxer) Log(level logger.Level, format string, args ...interface{}) {
m.parent.Log(level, "[muxer %s] "+format, append([]interface{}{m.pathName}, args...)...)
func (m *muxer) Log(level logger.Level, format string, args ...any) {
m.parent.Log(level, "[muxer %s] "+format, append([]any{m.pathName}, args...)...)
}
// PathName returns the path name.

View file

@ -73,7 +73,7 @@ func (mi *muxerInstance) initialize() error {
}
// 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...)
}

View file

@ -18,7 +18,7 @@ import (
// ErrMuxerNotFound is returned when a muxer is 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()
}
@ -150,7 +150,7 @@ func (s *Server) Initialize() error {
}
// 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...)
}

View file

@ -285,7 +285,7 @@ func TestServerRead(t *testing.T) {
time.Sleep(100 * time.Millisecond)
for i := 0; i < 4; i++ {
for i := range 4 {
strm.WriteUnit(test.MediaH264, test.FormatH264, &unit.Unit{
NTP: time.Time{},
PTS: int64(i) * 90000,
@ -526,7 +526,7 @@ func TestAuthError(t *testing.T) {
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -71,8 +71,8 @@ func (c *conn) remoteAddr() net.Addr {
}
// Log implements logger.Writer.
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.nconn.RemoteAddr()}, args...)...)
func (c *conn) Log(level logger.Level, format string, args ...any) {
c.parent.Log(level, "[conn %v] "+format, append([]any{c.nconn.RemoteAddr()}, args...)...)
}
func (c *conn) ip() net.IP {

View file

@ -25,7 +25,7 @@ import (
// ErrConnNotFound is returned when a connection is 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()
}
@ -163,14 +163,14 @@ func (s *Server) Initialize() error {
}
// 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 {
if s.IsTLS {
return "RTMPS"
}
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.

View file

@ -100,8 +100,8 @@ func (c *conn) initialize() {
}
// Log implements logger.Writer.
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.rconn.NetConn().RemoteAddr()}, args...)...)
func (c *conn) Log(level logger.Level, format string, args ...any) {
c.parent.Log(level, "[conn %v] "+format, append([]any{c.rconn.NetConn().RemoteAddr()}, args...)...)
}
// Conn returns the RTSP connection.

View file

@ -32,7 +32,7 @@ var ErrConnNotFound = errors.New("connection not found")
// ErrSessionNotFound is returned when a session is 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()
}
@ -170,14 +170,14 @@ func (s *Server) Initialize() error {
}
// 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 {
if s.IsTLS {
return "RTSPS"
}
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.

View file

@ -414,7 +414,7 @@ func TestAuthError(t *testing.T) {
WriteTimeout: conf.Duration(10 * time.Second),
WriteQueueSize: 512,
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 atomic.AddInt64(n, 1) == 3 {
require.Regexp(t, "authentication failed: auth error$", fmt.Sprintf(s, i...))

View file

@ -117,9 +117,9 @@ func (s *session) remoteAddr() net.Addr {
}
// 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])
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.

View file

@ -85,8 +85,8 @@ func (c *conn) Close() {
}
// Log implements logger.Writer.
func (c *conn) Log(level logger.Level, format string, args ...interface{}) {
c.parent.Log(level, "[conn %v] "+format, append([]interface{}{c.connReq.RemoteAddr()}, args...)...)
func (c *conn) Log(level logger.Level, format string, args ...any) {
c.parent.Log(level, "[conn %v] "+format, append([]any{c.connReq.RemoteAddr()}, args...)...)
}
func (c *conn) ip() net.IP {

View file

@ -23,7 +23,7 @@ import (
// ErrConnNotFound is returned when a connection is 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()
}
@ -145,7 +145,7 @@ func (s *Server) Initialize() error {
}
// 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...)
}

View file

@ -24,7 +24,7 @@ func (s *streamID) unmarshal(raw string) error {
// standard syntax
// https://github.com/Haivision/srt/blob/master/docs/features/access-control.md
if strings.HasPrefix(raw, "#!::") {
for _, kv := range strings.Split(raw[len("#!::"):], ",") {
for kv := range strings.SplitSeq(raw[len("#!::"):], ",") {
kv2 := strings.SplitN(kv, "=", 2)
if len(kv2) != 2 {
return fmt.Errorf("invalid value")

View file

@ -113,7 +113,7 @@ func (s *httpServer) initialize() error {
}
// 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...)
}

View file

@ -39,7 +39,7 @@ const (
// ErrSessionNotFound is returned when a session is 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()
}
@ -324,7 +324,7 @@ func (s *Server) Initialize() error {
}
// 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...)
}

View file

@ -751,7 +751,7 @@ func TestAuthError(t *testing.T) {
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 n == 1 {
require.Regexp(t, "failed to authenticate: auth error$", fmt.Sprintf(s, i...))

View file

@ -88,9 +88,9 @@ func (s *session) initialize() {
}
// 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])
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() {

View file

@ -211,7 +211,7 @@ func (s *Handler) Stop(reason string) {
}
// 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...)
}

View file

@ -31,7 +31,7 @@ type Source struct {
}
// 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...)
}

View file

@ -33,7 +33,7 @@ type Source struct {
}
// 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...)
}

View file

@ -115,7 +115,7 @@ type Source struct {
}
// 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...)
}

View file

@ -33,7 +33,7 @@ type Source struct {
}
// 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...)
}

View file

@ -35,7 +35,7 @@ type Source struct {
}
// 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...)
}

View file

@ -79,7 +79,7 @@ type Source struct {
}
// 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...)
}

View file

@ -28,7 +28,7 @@ type Source struct {
}
// 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...)
}

View file

@ -33,7 +33,7 @@ type Source struct {
}
// 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...)
}

View file

@ -4,21 +4,21 @@ import "github.com/bluenviron/mediamtx/internal/logger"
type nilLogger struct{}
func (nilLogger) Log(_ logger.Level, _ string, _ ...interface{}) {
func (nilLogger) Log(_ logger.Level, _ string, _ ...any) {
}
// NilLogger is a logger to /dev/null
var NilLogger logger.Writer = &nilLogger{}
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...)
}
// 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}
}

View file

@ -15,7 +15,7 @@ type StaticSourceParent struct {
}
// Log implements logger.Writer.
func (*StaticSourceParent) Log(logger.Level, string, ...interface{}) {}
func (*StaticSourceParent) Log(logger.Level, string, ...any) {}
// Initialize initializes StaticSourceParent.
func (p *StaticSourceParent) Initialize() {