Compare commits

..

No commits in common. "994c0995e0d59d114e5b947c4a8458c1761df19d" and "0d8ecc64adbeb7a487fdec577d0fe46cda26bbb1" have entirely different histories.

6 changed files with 5 additions and 49 deletions

View File

@ -13,7 +13,7 @@ import (
func Test_Demux(t *testing.T) {
Convey("Demuxer", t, func() {
Convey("audio-only", func() {
reader, _ := os.Open("testassets/mpthreetest.mp3")
reader, _ := os.Open("mpthreetest.mp3")
defer reader.Close()
demuxer := Demux(reader)
@ -43,7 +43,7 @@ func Test_Demux(t *testing.T) {
})
Convey("video and audio", func() {
reader, _ := os.Open("testassets/small.ogv")
reader, _ := os.Open("small.ogv")
defer reader.Close()
demuxer := Demux(reader)

View File

@ -12,7 +12,7 @@ import (
func Test_Muxer(t *testing.T) {
Convey("Muxer", t, func() {
Convey("audio-only", func() {
reader, _ := os.Open("testassets/mpthreetest.mp3")
reader, _ := os.Open("mpthreetest.mp3")
defer reader.Close()
demuxer := Demux(reader)

View File

@ -4,7 +4,6 @@ import (
"log"
"git.icedream.tech/icedream/uplink/app"
"git.icedream.tech/icedream/uplink/plugins/icecast/input"
"git.icedream.tech/icedream/uplink/plugins/icecast/output"
"git.icedream.tech/icedream/uplink/plugins/test/sine"
)
@ -17,7 +16,7 @@ func main() {
func run() (err error) {
backend := app.New()
backend.UsePlugin(icecast_input.Plugin)
// backend.UsePlugin(icecast_input.Plugin)
backend.UsePlugin(icecast_output.Plugin)
backend.UsePlugin(sine.Plugin)
backend.Init()

View File

@ -2,24 +2,13 @@ package icecast_input
import (
"io"
"strconv"
"git.icedream.tech/icedream/uplink/app/authentication"
"git.icedream.tech/icedream/uplink/app/channels"
"git.icedream.tech/icedream/uplink/app/servers/http"
"git.icedream.tech/icedream/uplink/app/streams"
"github.com/gin-gonic/gin"
)
var allowedCopyHeaders = []string{
"icy-br",
"icy-name",
"icy-description",
"icy-pub",
"icy-url",
"icy-genre",
}
type pluginInstance struct {
server *httpserver.Server
authenticator authentication.Authenticator
@ -36,9 +25,7 @@ func (instance *pluginInstance) SetChannelManager(channelManager *channels.Chann
func (instance *pluginInstance) SetServer(server *httpserver.Server) {
instance.server = server
}
func (instance *pluginInstance) Init() {
router := instance.server.Router
router.PUT("/:channel", func(ctx *gin.Context) {
@ -56,36 +43,6 @@ func (instance *pluginInstance) Init() {
ctx.Status(401)
return
}
var sr io.Reader = ctx.Request.Body
defer ctx.Request.Body.Close()
if ctx.GetHeader("icy-metadata") == "1" {
metaInt64, err := strconv.ParseInt(ctx.GetHeader("icy-metaint"), 10, 32)
if err != nil {
ctx.Status(400)
return
}
metaInt := int(metaInt64)
// Client is sending metadata!
mr := streams.NewMetadataExtractor(sr, metaInt)
sr = mr
metadataChan := channel.Metadata()
defer func() { metadataChan <- nil }()
go func() {
for metadata := range metadataChan {
metadataToWrite := streams.Metadata{}
if value, ok := metadata["StreamTitle"]; ok {
metadataToWrite["StreamTitle"] = value
}
channel.SetMetadata(metadataToWrite)
}
}()
}
input := channel.AddInputStream("icecast")
io.Copy(input, sr)
io.Copy(channel.InputStream, ctx.Request.Body)
})
}