PDA

View Full Version : Remote Streaming - How to write Client code?



AndrewFG
2009-04-16, 10:15
The Help for SqueezeCentre gives the following information: (and indeed it works great with iTunes)


Open the stream called http://localhost:9000/stream.mp3 in your MP3 software player. (Replace "localhost" with the IP address of the remote computer.) This will inform the SqueezeCenter that the software player is ready to receive a stream.

I am developing an own MP3 player, (actually it is a UPnP DLNA Media server that acts as a proxy front end to SC), and so my question is how to convert the words "open the stream called http://localhost:9000/stream.mp3" into actual TCP/IP program code within my player application? e.g. how do I let SC know that I am "ready to receive a stream" without actually receiving one?

I suppose I need to open a TCP socket to the SC URL. But what then?

Shall I do an HTTP GET (or HEAD) on the SC URL? Do I need to set any specific HTTP headers / parameters / encoding (e.g. keep alive / chunked / mime stuff etc.)?

What is the SC response to this HTTP GET? i.e. Assuming that no music is playing at the time, does SC simply not respond to the GET? If so, do I need to worry about socket timeouts? Or does SC send an HTTP response other than "200 OK" to indicate that the client should wait? Or does it "dribble" some bytes to keep the client happy? If so do I need to do any specific handshaking during the period when no music is playing?

And finally, what do I need to do (HTTP handshaking etc.) when the music IS playing?

Thanks in advance...

andyg
2009-04-16, 10:37
On Apr 16, 2009, at 1:15 PM, AndrewFG wrote:

>
> The Help for SqueezeCentre gives the following information: (and
> indeed
> it works great with iTunes)
>
>> Open the stream called http://localhost:9000/stream.mp3 in your MP3
>> software player. (Replace "localhost" with the IP address of the
>> remote
>> computer.) This will inform the SqueezeCenter that the software
>> player
>> is ready to receive a stream.
>
> I am developing an own MP3 player, (actually it is a UPnP DLNA Media
> server that acts as a proxy front end to SC), and so my question is
> how
> to convert the words "open the stream called
> http://localhost:9000/stream.mp3" into actual TCP/IP program code
> within my player application? e.g. how do I let SC know that I am
> "ready to receive a stream" without actually receiving one?

Hang on, you should not be using stream.mp3 for this I think. You
want to send the actual file to the UPnP device right? You will run
into issues with transcoding though, unless you want to handle that
within your server.

AndrewFG
2009-04-16, 12:17
Hang on, you should not be using stream.mp3 for this I think. You
want to send the actual file to the UPnP device right? You will run
into issues with transcoding though, unless you want to handle that
within your server.

Why do you say I should not be using stream.mp3? I don't want to send the actual file. Indeed I DO want to have SC do the transcoding.

As I understand it from Help (and indeed in reality from using this function on iTunes) it is possible for SC to send a transcoded stream to a remote media player.

My intention is as follows:

1) the media renderer calls the media server ContentDirectory::Browse which returns the SC stream URL ( http://localhost:9000/stream.mp3 )

2) the media renderer calls the media server ConnectionManager::PrepareForConnection and it in turns calls SC via the CLI to set up the streaming

<player_ip_address> playlistcontrol cmd:load track_id:NNN

3) the media renderer calls the SC stream URL and downloads the transcoded stream

andyg
2009-04-16, 12:22
On Apr 16, 2009, at 3:17 PM, AndrewFG wrote:

>
> andyg;415936 Wrote:
>> Hang on, you should not be using stream.mp3 for this I think. You
>> want to send the actual file to the UPnP device right? You will run
>> into issues with transcoding though, unless you want to handle that
>> within your server.
>
> Why do you say I should not be using stream.mp3? I don't want to send
> the actual file. Indeed I DO want to have SC do the transcoding.
>
> As I understand it from Help (and indeed in reality from using this
> function on iTunes) it is possible for SC to send a transcoded stream
> to a remote media player.
>
> My intention is as follows:
>
> 1) the media renderer calls the media server ContentDirectory::Browse
> which returns the SC stream URL ( http://localhost:9000/stream.mp3 )
>
> 2) the media renderer calls the media server
> ConnectionManager::PrepareForConnection and it in turns calls SC via
> the CLI to set up the streaming
>
> <player_ip_address> playlistcontrol cmd:load track_id:NNN
>
> 3) the media renderer calls the SC stream URL and downloads the
> transcoded stream

This is an interesting approach, one downside I see is the buffering
delay between when you issue a play/pause/etc command and when the
audio actually changes.

AndrewFG
2009-04-16, 14:15
This is an interesting approach, one downside I see is the buffering
delay between when you issue a play/pause/etc command and when the
audio actually changes.

I tried it between iTunes and SC over my home network, and it works rather well. Actually there is not much delay due to buffering, because the player can start work as soon as the first packets are in.

In the meantime, I (partly) answered my own question by putting a packet sniffer on the traffic. The following are the HTTP request and response headers between iTunes and SC


GET /stream.mp3 HTTP/1.1
Accept: */*
Cache-Control: no-cache
User-Agent: iTunes/8.1.1 (Windows; N)
x-audiocast-udpport: 1211
icy-metadata: 1
Host: 192.168.1.38:9000
Connection: Close

HTTP/1.1 200 OK
Server: SqueezeCenter (7.3.2 - 24695)
Connection: Close
Content-Type: audio/mpeg
icy-metaint: 32768
icy-name: Welcome to SqueezeCenter

The "icy" tags seem to be the give away; it seems to be a very lean and mean version of ShoutCast...