From e96354497397e58b9b1d049387623c45708a692d Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sat, 1 Feb 2025 13:36:02 +0100 Subject: [PATCH] fix compatibility with AVOID encoders (bluenviron/mediamtx#4183) (#688) --- pkg/format/format_test.go | 40 +++++++++++++++++++++++++++++++++++++++ pkg/format/mpeg4_audio.go | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/pkg/format/format_test.go b/pkg/format/format_test.go index b05dd0f0..f17dd331 100644 --- a/pkg/format/format_test.go +++ b/pkg/format/format_test.go @@ -1194,6 +1194,46 @@ var casesFormat = []struct { "TP-LINK/90000", nil, }, + { + "audio aac from AVOIP (issue mediamtx/4183)", + "v=0\r\n" + + "o=- 1634883673031268 1 IN IP4 127.0.0.1\r\n" + + "s=H265 Video, streamed by the LIVE555 Media Server\r\n" + + "i=test.265\r\n" + + "t=0 0\r\n" + + "a=tool:LIVE555 Streaming Media v2016.10.11\r\n" + + "a=type:broadcast\r\n" + + "a=control:*\r\n" + + "a=range:npt=0-\r\n" + + "a=x-qt-text-nam:H.265 Video, streamed by the LIVE555 Media Server\r\n" + + "a=x-qt-text-inf:test.265\r\n" + + "m=audio 0 RTP/AVP 100\r\n" + + "a=rtpmap:100 mpeg4-generic/48000/2\r\n" + + "a=fmtp:100 streamtype=5; sizeLength=13; indexLength=3; indexDeltaLength=3; mode=AAC_hbr; config=1190\r\n" + + "a=control:track1\r\n", + &MPEG4Audio{ + PayloadTyp: 100, + Config: &mpeg4audio.AudioSpecificConfig{ + Type: 2, + SampleRate: 48000, + ChannelCount: 2, + }, + SizeLength: 13, + IndexLength: 3, + IndexDeltaLength: 3, + }, + 100, + "mpeg4-generic/48000/2", + map[string]string{ + "config": "1190", + "indexdeltalength": "3", + "indexlength": "3", + "mode": "AAC-hbr", + "profile-level-id": "1", + "sizelength": "13", + "streamtype": "5", + }, + }, } func TestUnmarshal(t *testing.T) { diff --git a/pkg/format/mpeg4_audio.go b/pkg/format/mpeg4_audio.go index 629d9312..ff54b79a 100644 --- a/pkg/format/mpeg4_audio.go +++ b/pkg/format/mpeg4_audio.go @@ -51,7 +51,7 @@ func (f *MPEG4Audio) unmarshal(ctx *unmarshalContext) error { } case "mode": - if strings.ToLower(val) != "aac-hbr" { + if strings.ToLower(val) != "aac-hbr" && strings.ToLower(val) != "aac_hbr" { return fmt.Errorf("unsupported AAC mode: %v", val) }