https://github.com/romantomjak/shoutcast
SHOUTcast Go Client
https://github.com/romantomjak/shoutcast
icecast internet-radio radio shoutc shoutcast streaming streaming-audio
Last synced: 6 months ago
JSON representation
SHOUTcast Go Client
- Host: GitHub
- URL: https://github.com/romantomjak/shoutcast
- Owner: romantomjak
- License: mit
- Created: 2019-03-06T23:16:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-09T14:54:07.000Z (about 2 years ago)
- Last Synced: 2025-03-24T18:52:24.978Z (6 months ago)
- Topics: icecast, internet-radio, radio, shoutc, shoutcast, streaming, streaming-audio
- Language: Go
- Size: 22.5 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shoutcast
[](https://travis-ci.org/romantomjak/shoutcast)
Go interface for SHOUTcast streaming protocol.
---
Example SHOUTcast client:
```go
package mainimport (
"io"mp3 "github.com/hajimehoshi/go-mp3"
"github.com/hajimehoshi/oto""github.com/romantomjak/shoutcast"
)func main() {
// open stream
stream, err := shoutcast.Open("http://streamingp.shoutcast.com/TomorrowlandOneWorldRadio")
if err != nil {
panic(err)
}
// optionally register a callback function to be called when song changes
stream.MetadataCallbackFunc = func(m *shoutcast.Metadata) {
println("Now listening to: ", m.StreamTitle)
}// setup mp3 decoder
decoder, err := mp3.NewDecoder(stream)
if err != nil {
panic(err)
}
defer decoder.Close()// initialise audio player
player, err := oto.NewPlayer(decoder.SampleRate(), 2, 2, 8192)
if err != nil {
panic(err)
}
defer player.Close()// enjoy the music
if _, err := io.Copy(player, decoder); err != nil {
panic(err)
}
}
```## SHOUTcast protocol
Very little information is available about how the streaming technology
actually works. Everything in this repo was pieced together from random
sites and [Wayback Machine](https://archive.org/web/) archives.The protocol itself is built on top of HTTP. The client sends information
about itself in the form of HTTP headers, and if it can handle title streaming
it also sends and extra header:```
icy-metadata: 1
```This header signifies that the client has the ability to understand the title
streaming tags coming from the server. When set, the server will embed metadata
about the stream at periodic intervals (once every `icy-metaint` bytes) in the
encoded audio stream itself.The value of `icy-metaint` is decided by the shoutcast server configuration and
is sent to the client as part of the initial reply.The first byte of that metadata block tells you the length of the data.
A length of 0 means there is no updated metadata.- https://www.radiotoolbox.com/community/forums/viewtopic.php?t=74
- https://stackoverflow.com/q/12407248/758384## License
MIT