views:

2216

answers:

5

I was wondering if there was a way to stream sound over a LAN. Can I have a client app connect to a server app and then receive a stream of sound from it. I'm sure it can be done, just not sure where to even start. Any suggestions? I was looking to do this with c#.

I am not asking anyone to write it for me, just some on ideas or tricks that you may know, of just references or suggestions you may have.

A: 

You probably want to implement RTSP, the standard "Real Time Streaming Protocol". According to MSDN, Silverlight kind-of-supports it (and several Windows Media Audio formats). However, the best-known open source libraries for RTSP are C++ -- maybe you can call them from your C# code?

Alex Martelli
+1  A: 

I believe you could use Windows media player on the client.

We use winmm.dll to play some music in one of our applications. And since the media player supports streaming you could probably solve your problem with a bit of fiddling.

Nifle
+3  A: 

Another option could be to have your own Shoutcast server and play that audio on the client after capturing it with a ShoutcastStream Class

Nifle
+1 This seems like the best option so far, I am headed in this direction for now.
gmcalab
A: 

This is not a c# solution but may help with making a decision on what to use. http://pulseaudio.org/ is used in a few linux distros now and you can install it on windows as well.

From http://pulseaudio.org/wiki/WikiStart#Whatisit

PulseAudio is a sound server for POSIX and Win32 systems. A sound server is basically a proxy for your sound applications. It allows you to do advanced operations on your sound data as it passes between your application and your hardware. Things like transferring the audio to a different machine, changing the sample format or channel count and mixing several sounds into one are easily achieved using a sound server.

PulseAudio has been tested on Linux, Solaris, FreeBSD, NetBSD, Windows 2000 and Windows XP. It should also run on all other POSIX and Windows systems, but may require new backends to handle their sound systems.

Might be a good option depending on your scenario...

Derek Ekins
+1  A: 

Though not C#, would this be an option? Netcat, mpg123, and rawplay create a solution. The author of this article serves audio from one machine to another.

$(audioclient1):~$ nc -l -p 2345 | rawplay
$(audioserver):~$ mpg123 -s *.mp3 | nc (audioclient1) 2345 

Later in the article, he shows how to use named pipes, serving audio to 6 machines on his LAN.

"use and abuse of pipes with audio data" http://www.debian-administration.org/articles/145

Dan