Reading Icecast Audio Stream

Just starting out? Need help? Post your questions and find answers here.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Reading Icecast Audio Stream

Post by chris319 »

I'm trying to write a program to read and play an icecast audio stream and this is as far as I've gotten:

The program appears to make the network connection but it is not reading any data from the stream on port 8000.

Code: Select all

*buffer = AllocateMemory(16384)

connectionID = OpenNetworkConnection("localhost",8000)
If connectionID <> 0: Debug "connected": Else: Debug "no connection" :EndIf

While NetworkClientEvent(connectionID) = 0
Wend

event = NetworkClientEvent(connectionID)
If event <> 0
  Debug "event"
EndIf

result = ReceiveNetworkData(connectionID, *buffer, 16) 
Debug result

FreeMemory (*buffer, 16384)

How to make this work?
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Reading Icecast Audio Stream

Post by infratec »

As far as I know, streams using normally udp and not tcp.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Reading Icecast Audio Stream

Post by chris319 »

According to this it's TCP:

https://stackoverflow.com/questions/246 ... tcp-or-udp
Icecast and SHOUTcast both use TCP for both the source streams and streaming to end clients.
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Reading Icecast Audio Stream

Post by infratec »

Hm ... you are right, but as I read here:

https://www.streamingmediaglobal.com/Ar ... 25665.aspx

a web server listens on 8000.

So you need something to start any action.
You need a http get request to the stream you want to listen to.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Reading Icecast Audio Stream

Post by chris319 »

So you need something to start any action.
You need a http get request to the stream you want to listen to.
See the code I posted. It connects but that's all.
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Reading Icecast Audio Stream

Post by infratec »

I see only that you open a connection, but nothing else.

So what should the server do???
Should he immediately 'stream' every music he has stored?

He thinks: Oh nice, a new connection. I'm waiting now for a message what is expected from me.

You have to start a stream via a http get request.
(As I can read from the link which I wrote above.)
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Reading Icecast Audio Stream

Post by chris319 »

You have to start a stream via a http get request.
How to do this in PB?
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Reading Icecast Audio Stream

Post by infratec »

You should learn the basics of some protocols :wink:

Something like:

Code: Select all

Request$ = "GET /YourMountPointOfTheStreamYouWant HTTP/1.1" + #CRLF$
;Request$ + "Accept: audio/mp3" + #CRLF$
Request$ + "Content-Length: 0" + #CRLF$
Request$ + #CRLF$

SendNetworkString(connectionID, Request$)
Post Reply