Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

systemfreund/go-libshout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

go-libshout

(Incomplete but working) Go binding for libshout 2.x

Example

package main

import (
	"flag"
	"github.com/systemfreund/go-libshout"
	"os"
	"io"
)

// Setup some command line flags
var (
	hostname = flag.String("host", "localhost", "shoutcast server name")
	port = flag.Uint("port", 8000, "shoutcast server source port")
	user = flag.String("user", "source", "source user name")
	password = flag.String("password", "", "source password")
	mount = flag.String("mountpoint", "/stream.mp3", "mountpoint")
	filename = flag.String("file", "", "file to send to shoutcast")
) 

func main() {
	flag.Parse()

	// Setup libshout parameters
	s := shout.Shout{
		Host:     *hostname,
		Port:     *port,
		User:     *user,
		Password: *password,
		Mount:    *mount,
		Format:   shout.FORMAT_MP3,
		Protocol: shout.PROTOCOL_HTTP,
	}

	// Open the file
	//
	file, err := os.Open(*filename)
	if err != nil {
		panic(err)
	}

	// Create a channel where we can send the data
	//
	stream, err := s.Open()
	if err != nil {
		panic(err)
	}

	defer s.Close()

	buffer := make([]byte, shout.BUFFER_SIZE)
	for {
		// Read from file
		n, err := file.Read(buffer)
		if err != nil && err != io.EOF { panic(err)	}
		if n == 0 { break }

		// Send to shoutcast server
		stream <- buffer
	}

	// done
}

About

Go binding for libshout 2.x

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages