From 341a25a6ea324646600b1dc693ec1d5016fc2961 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sat, 5 Mar 2022 11:12:44 +0100 Subject: [PATCH] Added support for FLAC inside Ogg, and Vorbis --- README.md | 2 +- go.mod | 6 ++++-- go.sum | 12 ++++++++---- queue.go | 14 +++++++++++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 33abc3e..40e8629 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Radio streamer ([kawa](https://github.com/Luminarys/kawa) drop-in compatible). # Improvements / differences from Kawa * Does not use libav ([see supported formats/codecs on Kirika](https://git.gammaspectra.live/S.O.N.G/Kirika#codecs-supported)) -* No Vorbis support. +* No Vorbis encoding support. * Supports HTTP clients that have more than 16 HTTP request headers or longer than 64 bytes per header. * Does not restart stream per-track, instead being a continuous stream without parameter changes. * Normalized channels / sample rates for mounts. diff --git a/go.mod b/go.mod index 219f24a..a931161 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.gammaspectra.live/S.O.N.G/MeteorLight go 1.18 require ( - git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220304112513-f1e808b8f144 + git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220305100924-d8fbe580cedf github.com/BurntSushi/toml v1.0.0 github.com/enriquebris/goconcurrentqueue v0.6.3 ) @@ -12,10 +12,12 @@ require ( git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220228131722-e9cb84c52f48 // indirect git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba // indirect git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 // indirect - git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220223152921-827e6c3f729f // indirect + git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220305093419-2fd5e3285566 // indirect github.com/dh1tw/gosamplerate v0.1.2 // indirect github.com/edgeware/mp4ff v0.26.1 // indirect github.com/icza/bitio v1.0.0 // indirect + github.com/jfreymuth/oggvorbis v1.0.3 // indirect + github.com/jfreymuth/vorbis v1.0.2 // indirect github.com/klauspost/cpuid v1.3.1 // indirect github.com/kvark128/minimp3 v0.0.0-20211109174940-101188771a65 // indirect github.com/mewkiz/flac v1.0.7 // indirect diff --git a/go.sum b/go.sum index b11cf8c..3b88fb4 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,13 @@ -git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220304112513-f1e808b8f144 h1:2bJiVqiDQw36CKp6taE9MIl9tJ0j0E7Hp9n/QNgTdLo= -git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220304112513-f1e808b8f144/go.mod h1:NYC/3wOINygtTYvAqEtMfgWBeJ/9Gfv0NvDxnWmg+yA= +git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220305100924-d8fbe580cedf h1:kfTzYFPk9v/03NO6fpTLyhYGNkerggOJiMfOcNS49n8= +git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220305100924-d8fbe580cedf/go.mod h1:slLvZqRcR9yMu3Ety7AKzyxu87tHfUKR49ae83sCAM8= git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220228131722-e9cb84c52f48 h1:MaKiBfXQl0keyfdCi1PxGOKRTiWhIs8PqCal5GhKDi0= git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220228131722-e9cb84c52f48/go.mod h1:pkWt//S9hLVEQaJDPu/cHHPk8vPpo/0+zHy0me4LIP4= git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba h1:JEaxCVgdr3XXAuDCPAx7ttLFZaaHzTEzG+oRnVUtUKU= git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba/go.mod h1:vkoHSHVM9p6vAUmXAik0gvaLcIfiQYrD6bQqVpOulUk= git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 h1:ITVVisbHPnUclp3PBkCbXFeBhOCBcOjPdgjJ9wRH3TI= git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6/go.mod h1:cobkT8u8vq/+ngLy+feKS2M2ZT2HoCec5riA/0Cex3Q= -git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220223152921-827e6c3f729f h1:4Dkx1l5Ex7pG/Xbs57L4IQd7mBgd6TO5rhP0BKP9PiI= -git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220223152921-827e6c3f729f/go.mod h1:/po1QgOh3xynbvi4sxdY6Iw8m5WPJfGGmry2boZD8fs= +git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220305093419-2fd5e3285566 h1:nhnwjyaAydpSU3UADA9BRJmwpmJ8UlffxvBDuHC1T+8= +git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220305093419-2fd5e3285566/go.mod h1:/po1QgOh3xynbvi4sxdY6Iw8m5WPJfGGmry2boZD8fs= github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64 h1:LjPYdzoFSAJ5Tr/ElL8kzTJghXgpnOjJVbgd1UvZB1o= @@ -28,6 +28,10 @@ github.com/icza/bitio v1.0.0 h1:squ/m1SHyFeCA6+6Gyol1AxV9nmPPlJFT8c2vKdj3U8= github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A= github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k= github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA= +github.com/jfreymuth/oggvorbis v1.0.3 h1:MLNGGyhOMiVcvea9Dp5+gbs2SAwqwQbtrWnonYa0M0Y= +github.com/jfreymuth/oggvorbis v1.0.3/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII= +github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE= +github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ= github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s= github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4= github.com/kvark128/minimp3 v0.0.0-20211109174940-101188771a65 h1:8qfVQv7MSACDXadEwl1yjUKJ68yC9B7nR4cioEoCfH0= diff --git a/queue.go b/queue.go index 9e68f10..e079731 100644 --- a/queue.go +++ b/queue.go @@ -8,6 +8,7 @@ import ( "git.gammaspectra.live/S.O.N.G/Kirika/audio/format/mp3" "git.gammaspectra.live/S.O.N.G/Kirika/audio/format/opus" "git.gammaspectra.live/S.O.N.G/Kirika/audio/format/tta" + "git.gammaspectra.live/S.O.N.G/Kirika/audio/format/vorbis" "git.gammaspectra.live/S.O.N.G/Kirika/audio/packetizer" "log" "net/http" @@ -105,6 +106,7 @@ var flacFormat = flac.NewFormat() var ttaFormat = tta.NewFormat() var mp3Format = mp3.NewFormat() var opusFormat = opus.NewFormat() +var vorbisFormat = vorbis.NewFormat() func (q *Queue) AddTrack(entry *QueueTrackEntry, tail bool) error { @@ -120,8 +122,18 @@ func (q *Queue) AddTrack(entry *QueueTrackEntry, tail bool) error { source, err = ttaFormat.Open(f) case ".mp3": source, err = mp3Format.Open(f) - case ".ogg", ".opus": + case ".ogg": + if source, err = opusFormat.Open(f); err != nil { + //try flac + if source, err = flacFormat.Open(f); err != nil { + //try vorbis + source, err = vorbisFormat.Open(f) + } + } + case ".opus": source, err = opusFormat.Open(f) + case ".vorbis": + source, err = vorbisFormat.Open(f) } if err != nil {