Moved Stream logic to engine layer
This commit is contained in:
+5
-4
@@ -1,13 +1,14 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/deluan/gosonic/api/responses"
|
"github.com/deluan/gosonic/api/responses"
|
||||||
"github.com/deluan/gosonic/domain"
|
"github.com/deluan/gosonic/domain"
|
||||||
"github.com/deluan/gosonic/stream"
|
"github.com/deluan/gosonic/engine"
|
||||||
"github.com/deluan/gosonic/utils"
|
"github.com/deluan/gosonic/utils"
|
||||||
"github.com/karlkfi/inject"
|
"github.com/karlkfi/inject"
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StreamController struct {
|
type StreamController struct {
|
||||||
@@ -55,7 +56,7 @@ func (c *StreamController) Stream() {
|
|||||||
c.Ctx.Output.Header("Cache-Control", "must-revalidate")
|
c.Ctx.Output.Header("Cache-Control", "must-revalidate")
|
||||||
c.Ctx.Output.Header("Pragma", "public")
|
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 {
|
if err != nil {
|
||||||
beego.Error("Error streaming file", c.id, ":", err)
|
beego.Error("Error streaming file", c.id, ":", err)
|
||||||
}
|
}
|
||||||
@@ -66,7 +67,7 @@ func (c *StreamController) Stream() {
|
|||||||
func (c *StreamController) Download() {
|
func (c *StreamController) Download() {
|
||||||
beego.Debug("Sending file", c.mf.Path)
|
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)
|
beego.Debug("Finished sending", c.mf.Path)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package stream
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO Encapsulate as a io.Reader
|
// TODO Encapsulate as a io.Reader
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package stream
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
. "github.com/deluan/gosonic/tests"
|
. "github.com/deluan/gosonic/tests"
|
||||||
. "github.com/smartystreets/goconvey/convey"
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDownsampling(t *testing.T) {
|
func TestDownsampling(t *testing.T) {
|
||||||
Reference in New Issue
Block a user