Moved Stream logic to engine layer

This commit is contained in:
Deluan 2016-03-09 09:12:26 -05:00
parent 6d64d35564
commit 4d1a4613d9
3 changed files with 11 additions and 8 deletions

View File

@ -1,13 +1,14 @@
package api
import (
"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)
}

View File

@ -1,12 +1,13 @@
package stream
package engine
import (
"github.com/astaxie/beego"
"io"
"os"
"os/exec"
"strconv"
"strings"
"github.com/astaxie/beego"
)
// TODO Encapsulate as a io.Reader

View File

@ -1,9 +1,10 @@
package stream
package engine
import (
"testing"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestDownsampling(t *testing.T) {