🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Moved Stream logic to engine layer
Deluan4d1a4613d903
diff --git a/api/stream.go b/api/stream.goindex 7be7be97e..e7bbafd38 100644--- a/api/stream.go+++ b/api/stream.go@@ -1,13 +1,14 @@package apiimport (+ "strconv"+"github.com/astaxie/beego""github.com/deluan/gosonic/api/responses""github.com/deluan/gosonic/domain"- "github.com/deluan/gosonic/stream"+ "github.com/deluan/gosonic/engine""github.com/deluan/gosonic/utils""github.com/karlkfi/inject"- "strconv")type StreamController struct {@@ -55,7 +56,7 @@ func (c *StreamController) Stream() {c.Ctx.Output.Header("Cache-Control", "must-revalidate")c.Ctx.Output.Header("Pragma", "public")- err := stream.Stream(c.mf.Path, c.mf.BitRate, maxBitRate, c.Ctx.ResponseWriter)+ err := engine.Stream(c.mf.Path, c.mf.BitRate, maxBitRate, c.Ctx.ResponseWriter)if err != nil {beego.Error("Error streaming file", c.id, ":", err)}@@ -66,7 +67,7 @@ func (c *StreamController) Stream() {func (c *StreamController) Download() {beego.Debug("Sending file", c.mf.Path)- stream.Stream(c.mf.Path, 0, 0, c.Ctx.ResponseWriter)+ engine.Stream(c.mf.Path, 0, 0, c.Ctx.ResponseWriter)beego.Debug("Finished sending", c.mf.Path)}diff --git a/stream/downsampling.go b/engine/stream.gosimilarity index 98%rename from stream/downsampling.gorename to engine/stream.goindex a4f1cbeb7..3efd6908d 100644--- a/stream/downsampling.go+++ b/engine/stream.go@@ -1,12 +1,13 @@-package stream+package engineimport (- "github.com/astaxie/beego""io""os""os/exec""strconv""strings"++ "github.com/astaxie/beego")// TODO Encapsulate as a io.Readerdiff --git a/stream/downsampling_test.go b/engine/stream_test.gosimilarity index 97%rename from stream/downsampling_test.gorename to engine/stream_test.goindex 9dc5103bf..ee03bf596 100644--- a/stream/downsampling_test.go+++ b/engine/stream_test.go@@ -1,9 +1,10 @@-package stream+package engineimport (+ "testing"+. "github.com/deluan/gosonic/tests". "github.com/smartystreets/goconvey/convey"- "testing")func TestDownsampling(t *testing.T) {