diff --git a/pkg/playlist/multivariant.go b/pkg/playlist/multivariant.go index 3352474..b234cff 100644 --- a/pkg/playlist/multivariant.go +++ b/pkg/playlist/multivariant.go @@ -121,12 +121,6 @@ func (m Multivariant) Marshal() ([]byte, error) { ret += m.Start.marshal() } - ret += "\n" - - for _, v := range m.Variants { - ret += v.marshal() - } - if len(m.Renditions) != 0 { ret += "\n" @@ -135,5 +129,11 @@ func (m Multivariant) Marshal() ([]byte, error) { } } + ret += "\n" + + for _, v := range m.Variants { + ret += v.marshal() + } + return []byte(ret), nil } diff --git a/pkg/playlist/multivariant_test.go b/pkg/playlist/multivariant_test.go index 4f63a51..3061ba9 100644 --- a/pkg/playlist/multivariant_test.go +++ b/pkg/playlist/multivariant_test.go @@ -61,17 +61,17 @@ var casesMultivariant = []struct { "#EXT-X-INDEPENDENT-SEGMENTS\n" + "#EXT-X-START:TIME-OFFSET=15.00000\n" + "\n" + + "#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" + + ",DEFAULT=YES,AUTOSELECT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" + + "#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" + + ",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI=\"sub.m3u8\"\n" + + "\n" + "#EXT-X-STREAM-INF:BANDWIDTH=155000,AVERAGE-BANDWIDTH=120000,CODECS=\"avc1.42c028,mp4a.40.2\"" + ",RESOLUTION=1280x720,FRAME-RATE=24.000,AUDIO=\"aud1\",SUBTITLES=\"sub1\"\n" + "stream1.m3u8\n" + "#EXT-X-STREAM-INF:BANDWIDTH=55000,AVERAGE-BANDWIDTH=20000,CODECS=\"avc1.42c028,mp4a.40.2\"" + ",RESOLUTION=1280x720,FRAME-RATE=24.000\n" + - "stream2.m3u8\n" + - "\n" + - "#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" + - ",DEFAULT=YES,AUTOSELECT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" + - "#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" + - ",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI=\"sub.m3u8\"\n", + "stream2.m3u8\n", Multivariant{ Version: 9, IndependentSegments: true, @@ -204,6 +204,12 @@ v2/prog_index.m3u8 #EXT-X-VERSION:6 #EXT-X-INDEPENDENT-SEGMENTS +#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="a1/prog_index.m3u8" +#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a2/prog_index.m3u8" +#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a3/prog_index.m3u8" +#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES +#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI="s1/en/prog_index.m3u8" + #EXT-X-STREAM-INF:BANDWIDTH=2177116,AVERAGE-BANDWIDTH=2168183,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=60.000,AUDIO="aud1",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1" v5/prog_index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=8001098,AVERAGE-BANDWIDTH=7968416,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,AUDIO="aud1",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1" @@ -252,12 +258,6 @@ v4/prog_index.m3u8 v3/prog_index.m3u8 #EXT-X-STREAM-INF:BANDWIDTH=571555,AVERAGE-BANDWIDTH=561224,CODECS="avc1.640015,ec-3",RESOLUTION=480x270,FRAME-RATE=30.000,AUDIO="aud3",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1" v2/prog_index.m3u8 - -#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="a1/prog_index.m3u8" -#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a2/prog_index.m3u8" -#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a3/prog_index.m3u8" -#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES -#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI="s1/en/prog_index.m3u8" `, Multivariant{ Version: 6, @@ -687,6 +687,9 @@ QualityLevels(5977913)/Manifest(video,format=m3u8-aapl) `#EXTM3U #EXT-X-VERSION:4 +#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="QualityLevels(125615)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)" +#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_56kbps",DEFAULT=YES,URI="QualityLevels(53620)/Manifest(AAC_und_ch2_56kbps,format=m3u8-aapl)" + #EXT-X-STREAM-INF:BANDWIDTH=546902,CODECS="avc1.64000d,mp4a.40.2",RESOLUTION=320x180,AUDIO="audio" QualityLevels(393546)/Manifest(video,format=m3u8-aapl) #EXT-X-STREAM-INF:BANDWIDTH=801672,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio" @@ -703,9 +706,6 @@ QualityLevels(3385171)/Manifest(video,format=m3u8-aapl) QualityLevels(4681440)/Manifest(video,format=m3u8-aapl) #EXT-X-STREAM-INF:BANDWIDTH=6254125,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1920x1080,AUDIO="audio" QualityLevels(5977913)/Manifest(video,format=m3u8-aapl) - -#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="QualityLevels(125615)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)" -#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_56kbps",DEFAULT=YES,URI="QualityLevels(53620)/Manifest(AAC_und_ch2_56kbps,format=m3u8-aapl)" `, Multivariant{ Version: 4,