Skip to content

Commit

Permalink
Merge pull request #2 from stunndard/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
stunndard authored Jul 11, 2016
2 parents 7583030 + 31c5366 commit 5d8b4c7
Show file tree
Hide file tree
Showing 10 changed files with 699 additions and 68 deletions.
17 changes: 8 additions & 9 deletions aac/aac.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,22 @@ func isValidFrameHeader(header []byte) (int, bool) {
return frame_length, true
}

func GetSPF(header []byte) int {
return 1024
}

func SeekTo1StFrame(f os.File) int {
var (
buf []byte
aac_header []byte
j int64
)

buf = make([]byte, 5000)
buf := make([]byte, 5000)
f.ReadAt(buf, 0)

j = -1
j := int64(-1)
for i := 0; i < len(buf); i++ {
if (buf[i] == 0xFF) && ((buf[i+1] & 0xF0) == 0xF0) {
if len(buf)-i < 10 {
break
}
aac_header = buf[i : i+7]
aac_header := buf[i : i+7]

if n, ok := isValidFrameHeader(aac_header); ok {
if i+n+7 >= len(buf) {
Expand Down Expand Up @@ -229,7 +228,7 @@ func GetFileInfo(filename string, br *float64, spf, sr, frames, ch *int) error {
16000, 12000, 11025, 8000,
7350, 0, 0, 0}

if !util.FileExists(filename) {
if ok := util.FileExists(filename); !ok {
err := new(util.FileError)
err.Msg = "File doesn't exist"
return err
Expand Down
6 changes: 0 additions & 6 deletions aac/aacx.go

This file was deleted.

2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Config struct {
FFMPEGPath string
}

const Version = "0.2"
const Version = "0.3"

var Cfg Config

Expand Down
8 changes: 4 additions & 4 deletions goicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
}
inifile := string(os.Args[1])

//inifile := "d:\\work\\src\\Go\\src\\goicy\\tests\\hz.ini"
//inifile := "d:\\work\\src\\Go\\src\\github.com\\stunndard\\goicy\\tests\\goicy.ini"

logger.TermLn("Loading config...", logger.LOG_DEBUG)
err := config.LoadConfig(inifile)
Expand Down Expand Up @@ -88,13 +88,13 @@ func main() {
}

retries := 0
filename := playlist.Next()
filename := playlist.First()
for {
var err error
if config.Cfg.StreamType == "file" {
err = stream.StreamAACFile(filename)
err = stream.StreamFile(filename)
} else {
err = stream.StreamAACFFMPEG(filename)
err = stream.StreamFFMPEG(filename)
}

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions goicy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ samplerate = 44100
; 1 = mono, 2 stereo
channels = 2

; ffmpeg settings for aac
; ffmpeg bitrate for MPEG or AAC
bitrate = 192000

; aac profile
; AAC profile
; must be 'lc', 'he', 'hev2'
; valid only for stream format AAC
aacprofile = lc

;------
Expand Down
8 changes: 3 additions & 5 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ func SendMetadata(metadata string) error {

headers := ""
if config.Cfg.ServerType == "shoutcast" {
headers = "GET /admin.cgi?pass=" + url.QueryEscape("changeme") +
//base64.RawURLEncoding.EncodeToString([]byte("changeme")) +
headers = "GET /admin.cgi?pass=" + url.QueryEscape(config.Cfg.Password) +
"&mode=updinfo&song=" + strings.Replace(url.QueryEscape(metadata), "+", "%20", -1) + " HTTP/1.0\r\n" +
"User-Agent: (Mozilla Compatible)\r\n\r\n"
} else {
headers = "GET /admin/metadata?mode=updinfo&mount=/" + config.Cfg.Mount +
"&song=" + strings.Replace(url.QueryEscape(metadata), "+", "%20", -1) + " HTTP/1.0\r\n" +
"User-Agent: goicy/" + config.Version + "\r\n" + //version + crlf +
"Authorization: Basic " + base64.StdEncoding.EncodeToString([]byte("source:"+config.Cfg.Password)) + "\r\n" +
"\r\n"
"User-Agent: goicy/" + config.Version + "\r\n" +
"Authorization: Basic " + base64.StdEncoding.EncodeToString([]byte("source:"+config.Cfg.Password)) + "\r\n\r\n"
}
if err := network.Send(sock, []byte(headers)); err != nil {
return err
Expand Down
Loading

0 comments on commit 5d8b4c7

Please sign in to comment.