diff --git a/internal/conf/rtsp_transport.go b/internal/conf/rtsp_transport.go index bda08c36..65c368ec 100644 --- a/internal/conf/rtsp_transport.go +++ b/internal/conf/rtsp_transport.go @@ -8,6 +8,10 @@ import ( "github.com/bluenviron/mediamtx/internal/conf/jsonwrapper" ) +func ptrOf[T any](v T) *T { + return &v +} + // RTSPTransport is the rtspTransport parameter. type RTSPTransport struct { *gortsplib.Protocol @@ -44,16 +48,13 @@ func (d *RTSPTransport) UnmarshalJSON(b []byte) error { switch in { case "udp": - v := gortsplib.ProtocolUDP - d.Protocol = &v + d.Protocol = ptrOf(gortsplib.ProtocolUDP) case "multicast": - v := gortsplib.ProtocolUDPMulticast - d.Protocol = &v + d.Protocol = ptrOf(gortsplib.ProtocolUDPMulticast) case "tcp": - v := gortsplib.ProtocolTCP - d.Protocol = &v + d.Protocol = ptrOf(gortsplib.ProtocolTCP) case "automatic": d.Protocol = nil diff --git a/internal/recordstore/segment_test.go b/internal/recordstore/segment_test.go index 6d1e18df..0e5768c4 100644 --- a/internal/recordstore/segment_test.go +++ b/internal/recordstore/segment_test.go @@ -11,6 +11,10 @@ import ( "github.com/stretchr/testify/require" ) +func ptrOf[T any](v T) *T { + return &v +} + func TestFindAllPathsWithSegments(t *testing.T) { dir, err := os.MkdirTemp("", "mediamtx-recordstore") require.NoError(t, err) @@ -93,14 +97,11 @@ func TestFindSegments(t *testing.T) { case "no filtering": case "filtering": - tmp1 := time.Date(2015, 5, 19, 22, 18, 25, 427000, time.Local) - start = &tmp1 - tmp2 := start.Add(60 * time.Minute) - end = &tmp2 + start = ptrOf(time.Date(2015, 5, 19, 22, 18, 25, 427000, time.Local)) + end = ptrOf(start.Add(60 * time.Minute)) case "start before first": - tmp1 := time.Date(2014, 5, 19, 22, 18, 25, 427000, time.Local) - start = &tmp1 + start = ptrOf(time.Date(2014, 5, 19, 22, 18, 25, 427000, time.Local)) } segments, err := FindSegments(