diff --git a/go.mod b/go.mod index fa6b7b5d..09abcfc5 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/bluenviron/gohlslib/v2 v2.2.4 github.com/bluenviron/gortmplib v0.1.2 github.com/bluenviron/gortsplib/v5 v5.2.1 - github.com/bluenviron/mediacommon/v2 v2.5.3 + github.com/bluenviron/mediacommon/v2 v2.6.0 github.com/datarhei/gosrt v0.9.0 github.com/fsnotify/fsnotify v1.9.0 github.com/gin-contrib/pprof v1.5.3 diff --git a/go.sum b/go.sum index 4126f831..4bcf025e 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/bluenviron/gortmplib v0.1.2 h1:bJ+5pUxKnHjEoKPbNs7lDLyYy5R9Z1lISJ1n54 github.com/bluenviron/gortmplib v0.1.2/go.mod h1:oVOWgfs7wsZNoKYLttyqLar7a71ZTohO1JOVXkNxtHg= github.com/bluenviron/gortsplib/v5 v5.2.1 h1:VrFC5RU8npiyKiqLFKXZmdUFChSmbjO5eZBfOUgxwjo= github.com/bluenviron/gortsplib/v5 v5.2.1/go.mod h1:sK4+00XQaSpU2iPIKjmhj6Yye+sVbNWEU2IJWYEZI9U= -github.com/bluenviron/mediacommon/v2 v2.5.3 h1:espW+MsV1IYH6WE3QGa1UgPnIp13JuJG4VqGvoqseBU= -github.com/bluenviron/mediacommon/v2 v2.5.3/go.mod h1:5V15TiOfeaNVmZPVuOqAwqQSWyvMV86/dijDKu5q9Zs= +github.com/bluenviron/mediacommon/v2 v2.6.0 h1:wZAPXwv7V78Cx2x7cToYIHOLToHl6APcvHbdQT+gOkg= +github.com/bluenviron/mediacommon/v2 v2.6.0/go.mod h1:5V15TiOfeaNVmZPVuOqAwqQSWyvMV86/dijDKu5q9Zs= github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ= github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA= github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA= diff --git a/internal/core/api_test.go b/internal/core/api_test.go index bb363358..b3d6b4ea 100644 --- a/internal/core/api_test.go +++ b/internal/core/api_test.go @@ -19,6 +19,7 @@ import ( "github.com/bluenviron/gortsplib/v5/pkg/description" "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" srt "github.com/datarhei/gosrt" "github.com/google/uuid" "github.com/pion/rtp" @@ -557,7 +558,7 @@ func TestAPIProtocolListGet(t *testing.T) { defer conn.Close() track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } bw := bufio.NewWriter(conn) @@ -1084,7 +1085,7 @@ func TestAPIProtocolKick(t *testing.T) { defer conn.Close() track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } bw := bufio.NewWriter(conn) diff --git a/internal/core/metrics_test.go b/internal/core/metrics_test.go index d4e44ebd..35754603 100644 --- a/internal/core/metrics_test.go +++ b/internal/core/metrics_test.go @@ -17,6 +17,7 @@ import ( "github.com/bluenviron/gortsplib/v5/pkg/description" "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" srt "github.com/datarhei/gosrt" "github.com/pion/rtp" pwebrtc "github.com/pion/webrtc/v4" @@ -318,7 +319,7 @@ webrtc_sessions_rtcp_packets_sent 0 defer publisher.Close() track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } bw := bufio.NewWriter(publisher) diff --git a/internal/playback/muxer_mp4_test.go b/internal/playback/muxer_mp4_test.go index 1b23a2df..3727a588 100644 --- a/internal/playback/muxer_mp4_test.go +++ b/internal/playback/muxer_mp4_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediamtx/internal/test" "github.com/stretchr/testify/require" ) @@ -23,7 +23,7 @@ func TestMuxerMP4EmptyTracks(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -31,7 +31,7 @@ func TestMuxerMP4EmptyTracks(t *testing.T) { { ID: 2, TimeScale: 48000, - Codec: &mp4.CodecOpus{}, + Codec: &mcodecs.Opus{}, }, }, } diff --git a/internal/playback/on_get_test.go b/internal/playback/on_get_test.go index be5cb365..c0139e90 100644 --- a/internal/playback/on_get_test.go +++ b/internal/playback/on_get_test.go @@ -14,7 +14,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4/seekablebuffer" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediacommon/v2/pkg/formats/pmp4" "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/recordstore" @@ -29,7 +29,7 @@ func writeSegment1(t *testing.T, fpath string) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -37,7 +37,7 @@ func writeSegment1(t *testing.T, fpath string) { { ID: 2, TimeScale: 48000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -107,7 +107,7 @@ func writeSegment2(t *testing.T, fpath string) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -115,7 +115,7 @@ func writeSegment2(t *testing.T, fpath string) { { ID: 2, TimeScale: 48000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -195,7 +195,7 @@ func writeSegment3(t *testing.T, fpath string) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -251,7 +251,7 @@ func TestOnGet(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -259,7 +259,7 @@ func TestOnGet(t *testing.T) { { ID: 2, TimeScale: 48000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -629,7 +629,7 @@ func TestOnGet(t *testing.T) { ID: 1, TimeScale: 90000, TimeOffset: -90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -658,7 +658,7 @@ func TestOnGet(t *testing.T) { ID: 2, TimeScale: 48000, TimeOffset: 48000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -791,7 +791,7 @@ func TestOnGetInMiddleOfLastSample(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -887,7 +887,7 @@ func TestOnGetBetweenSegments(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, diff --git a/internal/playback/on_list_test.go b/internal/playback/on_list_test.go index 8f71750b..6a92f0ca 100644 --- a/internal/playback/on_list_test.go +++ b/internal/playback/on_list_test.go @@ -13,9 +13,8 @@ import ( "time" amp4 "github.com/abema/go-mp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediamtx/internal/auth" "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/test" @@ -274,7 +273,7 @@ func TestOnListCachedDuration(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, diff --git a/internal/playback/segment_fmp4_test.go b/internal/playback/segment_fmp4_test.go index 3cb7bf58..9edb6792 100644 --- a/internal/playback/segment_fmp4_test.go +++ b/internal/playback/segment_fmp4_test.go @@ -9,7 +9,7 @@ import ( amp4 "github.com/abema/go-mp4" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediamtx/internal/recordstore" "github.com/bluenviron/mediamtx/internal/test" "github.com/stretchr/testify/require" @@ -21,7 +21,7 @@ func writeBenchInit(f io.WriteSeeker) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -29,7 +29,7 @@ func writeBenchInit(f io.WriteSeeker) { { ID: 2, TimeScale: 90000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -88,7 +88,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -96,7 +96,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 2, TimeScale: 48000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, @@ -110,7 +110,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -326,7 +326,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -340,7 +340,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 2, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -358,7 +358,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -372,7 +372,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 48000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -390,7 +390,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -404,7 +404,7 @@ func TestSegmentFMP4CanBeConcatenated(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: mpeg4audio.ObjectTypeAACLC, SampleRate: 48000, diff --git a/internal/protocols/hls/to_stream_test.go b/internal/protocols/hls/to_stream_test.go index ee1b4a7d..71e5e287 100644 --- a/internal/protocols/hls/to_stream_test.go +++ b/internal/protocols/hls/to_stream_test.go @@ -11,6 +11,7 @@ import ( "github.com/bluenviron/gortsplib/v5/pkg/description" "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/stream" "github.com/bluenviron/mediamtx/internal/test" @@ -28,7 +29,7 @@ func TestToStreamNoSupportedCodecs(t *testing.T) { func TestToStream(t *testing.T) { track1 := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } s := &http.Server{ diff --git a/internal/protocols/mpegts/enhanced_reader.go b/internal/protocols/mpegts/enhanced_reader.go index 835c2acd..bde7ebfa 100644 --- a/internal/protocols/mpegts/enhanced_reader.go +++ b/internal/protocols/mpegts/enhanced_reader.go @@ -5,6 +5,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" mcmpegts "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/bluenviron/mediacommon/v2/pkg/rewindablereader" ) @@ -32,7 +33,7 @@ func (r *EnhancedReader) Initialize() error { tracksToParse := 0 for _, track := range mr.Tracks() { - if _, ok := track.Codec.(*mcmpegts.CodecMPEG4AudioLATM); ok { + if _, ok := track.Codec.(*tscodecs.MPEG4AudioLATM); ok { cpid := track.PID done := false tracksToParse++ diff --git a/internal/protocols/mpegts/from_stream.go b/internal/protocols/mpegts/from_stream.go index f75aa112..46d69c15 100644 --- a/internal/protocols/mpegts/from_stream.go +++ b/internal/protocols/mpegts/from_stream.go @@ -13,6 +13,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/h265" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" mcmpegts "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" srt "github.com/datarhei/gosrt" "github.com/bluenviron/mediamtx/internal/logger" @@ -53,7 +54,7 @@ func FromStream( switch forma := forma.(type) { case *format.H265: //nolint:dupl - track := &mcmpegts.Track{Codec: &mcmpegts.CodecH265{}} + track := &mcmpegts.Track{Codec: &tscodecs.H265{}} var dtsExtractor *h265.DTSExtractor @@ -92,7 +93,7 @@ func FromStream( }) case *format.H264: //nolint:dupl - track := &mcmpegts.Track{Codec: &mcmpegts.CodecH264{}} + track := &mcmpegts.Track{Codec: &tscodecs.H264{}} var dtsExtractor *h264.DTSExtractor @@ -133,7 +134,7 @@ func FromStream( }) case *format.MPEG4Video: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecMPEG4Video{}} + track := &mcmpegts.Track{Codec: &tscodecs.MPEG4Video{}} firstReceived := false var lastPTS int64 @@ -166,7 +167,7 @@ func FromStream( }) case *format.MPEG1Video: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecMPEG1Video{}} + track := &mcmpegts.Track{Codec: &tscodecs.MPEG1Video{}} firstReceived := false var lastPTS int64 @@ -199,7 +200,7 @@ func FromStream( }) case *format.Opus: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecOpus{ + track := &mcmpegts.Track{Codec: &tscodecs.Opus{ ChannelCount: forma.ChannelCount, }} @@ -225,7 +226,7 @@ func FromStream( case *format.KLV: track := &mcmpegts.Track{ - Codec: &mcmpegts.CodecKLV{ + Codec: &tscodecs.KLV{ Synchronous: true, }, } @@ -248,7 +249,7 @@ func FromStream( }) case *format.MPEG4Audio: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecMPEG4Audio{ + track := &mcmpegts.Track{Codec: &tscodecs.MPEG4Audio{ Config: *forma.Config, }} @@ -273,7 +274,7 @@ func FromStream( }) case *format.MPEG4AudioLATM: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecMPEG4AudioLATM{}} + track := &mcmpegts.Track{Codec: &tscodecs.MPEG4AudioLATM{}} if !forma.CPresent { addTrack( @@ -336,7 +337,7 @@ func FromStream( } case *format.MPEG1Audio: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecMPEG1Audio{}} + track := &mcmpegts.Track{Codec: &tscodecs.MPEG1Audio{}} addTrack( media, @@ -359,7 +360,7 @@ func FromStream( }) case *format.AC3: - track := &mcmpegts.Track{Codec: &mcmpegts.CodecAC3{}} + track := &mcmpegts.Track{Codec: &tscodecs.AC3{}} addTrack( media, diff --git a/internal/protocols/mpegts/to_stream.go b/internal/protocols/mpegts/to_stream.go index ec9b45df..8ebd3857 100644 --- a/internal/protocols/mpegts/to_stream.go +++ b/internal/protocols/mpegts/to_stream.go @@ -10,6 +10,7 @@ import ( "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/bluenviron/mediamtx/internal/logger" "github.com/bluenviron/mediamtx/internal/stream" @@ -36,7 +37,7 @@ func ToStream( var medi *description.Media switch codec := track.Codec.(type) { - case *mpegts.CodecH265: + case *tscodecs.H265: medi = &description.Media{ Type: description.MediaTypeVideo, Formats: []format.Format{&format.H265{ @@ -54,7 +55,7 @@ func ToStream( return nil }) - case *mpegts.CodecH264: + case *tscodecs.H264: medi = &description.Media{ Type: description.MediaTypeVideo, Formats: []format.Format{&format.H264{ @@ -73,7 +74,7 @@ func ToStream( return nil }) - case *mpegts.CodecMPEG4Video: + case *tscodecs.MPEG4Video: medi = &description.Media{ Type: description.MediaTypeVideo, Formats: []format.Format{&format.MPEG4Video{ @@ -91,7 +92,7 @@ func ToStream( return nil }) - case *mpegts.CodecMPEG1Video: + case *tscodecs.MPEG1Video: medi = &description.Media{ Type: description.MediaTypeVideo, Formats: []format.Format{&format.MPEG1Video{}}, @@ -107,7 +108,7 @@ func ToStream( return nil }) - case *mpegts.CodecOpus: + case *tscodecs.Opus: medi = &description.Media{ Type: description.MediaTypeAudio, Formats: []format.Format{&format.Opus{ @@ -126,7 +127,7 @@ func ToStream( return nil }) - case *mpegts.CodecKLV: + case *tscodecs.KLV: medi = &description.Media{ Type: description.MediaTypeApplication, Formats: []format.Format{&format.KLV{ @@ -143,7 +144,7 @@ func ToStream( return nil }) - case *mpegts.CodecMPEG4Audio: + case *tscodecs.MPEG4Audio: medi = &description.Media{ Type: description.MediaTypeAudio, Formats: []format.Format{&format.MPEG4Audio{ @@ -165,7 +166,7 @@ func ToStream( return nil }) - case *mpegts.CodecMPEG4AudioLATM: + case *tscodecs.MPEG4AudioLATM: // We are dealing with a LATM stream with in-band configuration. // Although in theory this can be streamed with RTSP (RFC6416 with cpresent=1), // in practice there is no player that supports it. @@ -220,7 +221,7 @@ func ToStream( return nil }) - case *mpegts.CodecMPEG1Audio: + case *tscodecs.MPEG1Audio: medi = &description.Media{ Type: description.MediaTypeAudio, Formats: []format.Format{&format.MPEG1Audio{}}, @@ -236,7 +237,7 @@ func ToStream( return nil }) - case *mpegts.CodecAC3: + case *tscodecs.AC3: medi = &description.Media{ Type: description.MediaTypeAudio, Formats: []format.Format{&format.AC3{ diff --git a/internal/recorder/format_fmp4.go b/internal/recorder/format_fmp4.go index b21c5bda..854adbb3 100644 --- a/internal/recorder/format_fmp4.go +++ b/internal/recorder/format_fmp4.go @@ -19,7 +19,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/opus" "github.com/bluenviron/mediacommon/v2/pkg/codecs/vp9" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediamtx/internal/codecprocessor" "github.com/bluenviron/mediamtx/internal/defs" @@ -116,7 +116,7 @@ type formatFMP4 struct { func (f *formatFMP4) initialize() bool { nextID := 1 - addTrack := func(format rtspformat.Format, codec mp4.Codec) *formatFMP4Track { + addTrack := func(format rtspformat.Format, codec mcodecs.Codec) *formatFMP4Track { track := &formatFMP4Track{ f: f, id: nextID, @@ -136,7 +136,7 @@ func (f *formatFMP4) initialize() bool { switch forma := forma.(type) { case *rtspformat.AV1: - codec := &mp4.CodecAV1{ + codec := &mcodecs.AV1{ SequenceHeader: av1DefaultSequenceHeader, } track := addTrack(forma, codec) @@ -191,7 +191,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.VP9: - codec := &mp4.CodecVP9{ + codec := &mcodecs.VP9{ Width: 1280, Height: 720, Profile: 1, @@ -281,7 +281,7 @@ func (f *formatFMP4) initialize() bool { pps = codecprocessor.H265DefaultPPS } - codec := &mp4.CodecH265{ + codec := &mcodecs.H265{ VPS: vps, SPS: sps, PPS: pps, @@ -365,7 +365,7 @@ func (f *formatFMP4) initialize() bool { pps = codecprocessor.H264DefaultPPS } - codec := &mp4.CodecH264{ + codec := &mcodecs.H264{ SPS: sps, PPS: pps, } @@ -441,7 +441,7 @@ func (f *formatFMP4) initialize() bool { config = codecprocessor.MPEG4VideoDefaultConfig } - codec := &mp4.CodecMPEG4Video{ + codec := &mcodecs.MPEG4Video{ Config: config, } track := addTrack(forma, codec) @@ -495,7 +495,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.MPEG1Video: - codec := &mp4.CodecMPEG1Video{ + codec := &mcodecs.MPEG1Video{ Config: codecprocessor.MPEG1VideoDefaultConfig, } track := addTrack(forma, codec) @@ -546,7 +546,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.MJPEG: - codec := &mp4.CodecMJPEG{ + codec := &mcodecs.MJPEG{ Width: 800, Height: 600, } @@ -583,7 +583,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.Opus: - codec := &mp4.CodecOpus{ + codec := &mcodecs.Opus{ ChannelCount: forma.ChannelCount, } track := addTrack(forma, codec) @@ -617,7 +617,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.MPEG4Audio: - codec := &mp4.CodecMPEG4Audio{ + codec := &mcodecs.MPEG4Audio{ Config: *forma.Config, } track := addTrack(forma, codec) @@ -650,7 +650,7 @@ func (f *formatFMP4) initialize() bool { case *rtspformat.MPEG4AudioLATM: if !forma.CPresent { - codec := &mp4.CodecMPEG4Audio{ + codec := &mcodecs.MPEG4Audio{ Config: *forma.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig, } track := addTrack(forma, codec) @@ -681,7 +681,7 @@ func (f *formatFMP4) initialize() bool { } case *rtspformat.MPEG1Audio: - codec := &mp4.CodecMPEG1Audio{ + codec := &mcodecs.MPEG1Audio{ SampleRate: 32000, ChannelCount: 2, } @@ -732,7 +732,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.AC3: - codec := &mp4.CodecAC3{ + codec := &mcodecs.AC3{ SampleRate: forma.SampleRate, ChannelCount: forma.ChannelCount, Fscod: 0, @@ -801,7 +801,7 @@ func (f *formatFMP4) initialize() bool { // TODO case *rtspformat.G711: - codec := &mp4.CodecLPCM{ + codec := &mcodecs.LPCM{ LittleEndian: false, BitDepth: 16, SampleRate: forma.SampleRate, @@ -838,7 +838,7 @@ func (f *formatFMP4) initialize() bool { }) case *rtspformat.LPCM: - codec := &mp4.CodecLPCM{ + codec := &mcodecs.LPCM{ LittleEndian: false, BitDepth: forma.BitDepth, SampleRate: forma.SampleRate, diff --git a/internal/recorder/format_fmp4_segment.go b/internal/recorder/format_fmp4_segment.go index b255f305..807a117a 100644 --- a/internal/recorder/format_fmp4_segment.go +++ b/internal/recorder/format_fmp4_segment.go @@ -9,12 +9,11 @@ import ( "time" amp4 "github.com/abema/go-mp4" - "github.com/google/uuid" - "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4/seekablebuffer" "github.com/bluenviron/mediamtx/internal/logger" "github.com/bluenviron/mediamtx/internal/recordstore" + "github.com/google/uuid" ) func writeInit( diff --git a/internal/recorder/format_fmp4_track.go b/internal/recorder/format_fmp4_track.go index 3100a29f..9c3f867d 100644 --- a/internal/recorder/format_fmp4_track.go +++ b/internal/recorder/format_fmp4_track.go @@ -5,7 +5,7 @@ import ( "time" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/bluenviron/mediamtx/internal/logger" ) @@ -47,7 +47,7 @@ type formatFMP4Track struct { f *formatFMP4 id int clockRate uint32 - codec mp4.Codec + codec mcodecs.Codec initTrack *fmp4.InitTrack nextSample *formatFMP4Sample diff --git a/internal/recorder/format_mpegts.go b/internal/recorder/format_mpegts.go index 12521c4f..512e8b53 100644 --- a/internal/recorder/format_mpegts.go +++ b/internal/recorder/format_mpegts.go @@ -15,6 +15,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4video" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/logger" @@ -66,7 +67,7 @@ type formatMPEGTS struct { func (f *formatMPEGTS) initialize() bool { var tracks []*mpegts.Track - addTrack := func(codec mpegts.Codec) *formatMPEGTSTrack { + addTrack := func(codec tscodecs.Codec) *formatMPEGTSTrack { track := &formatMPEGTSTrack{ f: f, codec: codec, @@ -83,7 +84,7 @@ func (f *formatMPEGTS) initialize() bool { switch forma := forma.(type) { case *rtspformat.H265: //nolint:dupl - track := addTrack(&mpegts.CodecH265{}) + track := addTrack(&tscodecs.H265{}) var dtsExtractor *h265.DTSExtractor @@ -125,7 +126,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.H264: //nolint:dupl - track := addTrack(&mpegts.CodecH264{}) + track := addTrack(&tscodecs.H264{}) var dtsExtractor *h264.DTSExtractor @@ -167,7 +168,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.MPEG4Video: - track := addTrack(&mpegts.CodecMPEG4Video{}) + track := addTrack(&tscodecs.MPEG4Video{}) firstReceived := false var lastPTS int64 @@ -204,7 +205,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.MPEG1Video: - track := addTrack(&mpegts.CodecMPEG1Video{}) + track := addTrack(&tscodecs.MPEG1Video{}) firstReceived := false var lastPTS int64 @@ -240,7 +241,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.Opus: - track := addTrack(&mpegts.CodecOpus{ + track := addTrack(&tscodecs.Opus{ ChannelCount: forma.ChannelCount, }) @@ -266,7 +267,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.KLV: - track := addTrack(&mpegts.CodecKLV{ + track := addTrack(&tscodecs.KLV{ Synchronous: true, }) @@ -292,7 +293,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.MPEG4Audio: - track := addTrack(&mpegts.CodecMPEG4Audio{ + track := addTrack(&tscodecs.MPEG4Audio{ Config: *forma.Config, }) @@ -319,7 +320,7 @@ func (f *formatMPEGTS) initialize() bool { case *rtspformat.MPEG4AudioLATM: if !forma.CPresent { - track := addTrack(&mpegts.CodecMPEG4Audio{ + track := addTrack(&tscodecs.MPEG4Audio{ Config: *forma.StreamMuxConfig.Programs[0].Layers[0].AudioSpecificConfig, }) @@ -353,7 +354,7 @@ func (f *formatMPEGTS) initialize() bool { } case *rtspformat.MPEG1Audio: - track := addTrack(&mpegts.CodecMPEG1Audio{}) + track := addTrack(&tscodecs.MPEG1Audio{}) f.ri.reader.OnData( media, @@ -377,7 +378,7 @@ func (f *formatMPEGTS) initialize() bool { }) case *rtspformat.AC3: - track := addTrack(&mpegts.CodecAC3{}) + track := addTrack(&tscodecs.AC3{}) f.ri.reader.OnData( media, diff --git a/internal/recorder/format_mpegts_track.go b/internal/recorder/format_mpegts_track.go index 641ea3dc..0d5c9e1b 100644 --- a/internal/recorder/format_mpegts_track.go +++ b/internal/recorder/format_mpegts_track.go @@ -5,11 +5,12 @@ import ( "time" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" ) type formatMPEGTSTrack struct { f *formatMPEGTS - codec mpegts.Codec + codec tscodecs.Codec track *mpegts.Track startInitialized bool diff --git a/internal/recorder/recorder_test.go b/internal/recorder/recorder_test.go index 2a278542..de4f8bb1 100644 --- a/internal/recorder/recorder_test.go +++ b/internal/recorder/recorder_test.go @@ -12,7 +12,7 @@ import ( rtspformat "github.com/bluenviron/gortsplib/v5/pkg/format" "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/formats/fmp4" - "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4" + mcodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mp4/codecs" "github.com/stretchr/testify/require" "github.com/bluenviron/mediamtx/internal/conf" @@ -242,7 +242,7 @@ func TestRecorder(t *testing.T) { { ID: 1, TimeScale: 90000, - Codec: &mp4.CodecH264{ + Codec: &mcodecs.H264{ SPS: test.FormatH264.SPS, PPS: test.FormatH264.PPS, }, @@ -250,7 +250,7 @@ func TestRecorder(t *testing.T) { { ID: 2, TimeScale: 90000, - Codec: &mp4.CodecH265{ + Codec: &mcodecs.H265{ VPS: []byte{ 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, @@ -272,7 +272,7 @@ func TestRecorder(t *testing.T) { { ID: 3, TimeScale: 44100, - Codec: &mp4.CodecMPEG4Audio{ + Codec: &mcodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: 2, SampleRate: 44100, @@ -283,7 +283,7 @@ func TestRecorder(t *testing.T) { { ID: 4, TimeScale: 8000, - Codec: &mp4.CodecLPCM{ + Codec: &mcodecs.LPCM{ BitDepth: 16, SampleRate: 8000, ChannelCount: 1, @@ -292,7 +292,7 @@ func TestRecorder(t *testing.T) { { ID: 5, TimeScale: 44100, - Codec: &mp4.CodecLPCM{ + Codec: &mcodecs.LPCM{ BitDepth: 16, SampleRate: 44100, ChannelCount: 2, diff --git a/internal/servers/srt/server_test.go b/internal/servers/srt/server_test.go index 79c083eb..5b669554 100644 --- a/internal/servers/srt/server_test.go +++ b/internal/servers/srt/server_test.go @@ -7,6 +7,7 @@ import ( "github.com/bluenviron/gortsplib/v5/pkg/description" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/bluenviron/mediamtx/internal/conf" "github.com/bluenviron/mediamtx/internal/defs" "github.com/bluenviron/mediamtx/internal/externalcmd" @@ -105,7 +106,7 @@ func TestServerPublish(t *testing.T) { defer publisher.Close() track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } bw := bufio.NewWriter(publisher) @@ -228,7 +229,7 @@ func TestServerRead(t *testing.T) { require.Equal(t, []*mpegts.Track{{ PID: 256, - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, }}, r.Tracks()) received := false diff --git a/internal/staticsources/hls/source_test.go b/internal/staticsources/hls/source_test.go index 6e98a1c6..8d167c88 100644 --- a/internal/staticsources/hls/source_test.go +++ b/internal/staticsources/hls/source_test.go @@ -8,6 +8,7 @@ import ( "github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/stretchr/testify/require" "github.com/bluenviron/mediamtx/internal/conf" @@ -17,11 +18,11 @@ import ( func TestSource(t *testing.T) { track1 := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } track2 := &mpegts.Track{ - Codec: &mpegts.CodecMPEG4Audio{ + Codec: &tscodecs.MPEG4Audio{ Config: mpeg4audio.AudioSpecificConfig{ Type: 2, SampleRate: 44100, diff --git a/internal/staticsources/mpegts/source_test.go b/internal/staticsources/mpegts/source_test.go index 60e10d6b..4cbcee34 100644 --- a/internal/staticsources/mpegts/source_test.go +++ b/internal/staticsources/mpegts/source_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" "github.com/stretchr/testify/require" "github.com/bluenviron/mediamtx/internal/conf" @@ -113,7 +114,7 @@ func TestSourceUDP(t *testing.T) { defer conn.Close() //nolint:errcheck track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}} @@ -185,7 +186,7 @@ func TestSourceUnixSocket(t *testing.T) { require.NoError(t, err) track := &mpegts.Track{ - Codec: &mpegts.CodecH264{}, + Codec: &tscodecs.H264{}, } w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}} diff --git a/internal/staticsources/srt/source_test.go b/internal/staticsources/srt/source_test.go index cc7561fe..7d033c41 100644 --- a/internal/staticsources/srt/source_test.go +++ b/internal/staticsources/srt/source_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts" + tscodecs "github.com/bluenviron/mediacommon/v2/pkg/formats/mpegts/codecs" srt "github.com/datarhei/gosrt" "github.com/stretchr/testify/require" @@ -56,7 +57,7 @@ func TestSource(t *testing.T) { require.NoError(t, err2) defer conn.Close() - track := &mpegts.Track{Codec: &mpegts.CodecH264{}} + track := &mpegts.Track{Codec: &tscodecs.H264{}} w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}} err2 = w.Initialize()