17

I'm trying to build a program in C# that will allow me to stream audio and video from one computer, over the network, to another computer, which is hooked up to a bunch of video/audio equipment (projector, speakers, etc). Ideally, I'd like to be able to capture this data directly from the "presenter" computer without it having to plug into anything.

The video, streaming, and re-displaying on the "output" computer is all working well, but I can't seem to find a good way to capture audio output without the need for a cable plugged in to the headphone jack and wired to the other computer. The whole point of this program is to allow this to be done wirelessly, so this is kind of a problem. To sum up, I'm looking for some sort of C# interface that will allow me to capture the sound output on a windows machine, as though I had plugged something into the headphone jack.

Thanks in advance for any help.

Sean James
  • 320
  • 1
  • 2
  • 7
  • Can you point me to a good reference about video streaming? I'm interested how you did the video streaming and the "capture" thing.. – Svetlozar Angelov Aug 18 '09 at 06:20
  • 1
    I used the C# screen shot API (http://www.developerfusion.com/code/4630/capture-a-screen-shot/) and compressed the images to PNG, then simply sent the raw data across the network. On the other end they're reconstructed and drawn in a full screen picturebox. It seems like it would be pretty slow but we're using a network that is dedicated solely to this purpose and the computers on either end are fairly beefy. – Sean James Aug 18 '09 at 06:26
  • This is the right link, sorry: http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.html – Sean James Aug 18 '09 at 06:34
  • **Working** example here: http://stackoverflow.com/questions/18812224/c-sharp-recording-audio-from-soundcard – Florian Apr 05 '14 at 09:33

3 Answers3

4

In Windows, the audio card manufacturers could choose to supply a "what you hear" input stream in order for you to capture the output. If your sound card/driver doesn't have this feature, you could try to use the Virtual Audio Cable to perform the same thing.

In Windows 7, there's a new functionality that allows you to listen to / capture any input stream directly.

Magnus Johansson
  • 28,010
  • 19
  • 106
  • 164
  • 4
    Can you provide some details about the windows 7 functionality. – kay.one Oct 27 '13 at 21:30
  • @Keivan , I was probably thinking of WASAPI, more specifically [Loopback Recording](http://msdn.microsoft.com/en-us/library/dd316551%28v=vs.85%29.aspx), [Sample in C++](http://msdn.microsoft.com/en-us/library/windows/desktop/dd370800(v=vs.85).aspx). In C#, I think [NAudio](http://naudio.codeplex.com/) provides this. – Magnus Johansson Oct 27 '13 at 21:50
4

If you already have the Video side figured out; NAudio is a good way to handle the Audio component.

Assuming we break the task in to the recording and then the receiving and playing components then the following should help you with each side;

The recording: http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html

The receiving and playing: Play audio from a stream using C#

The method of transport in between is up to you but if you already have a way of sending a stream between two computers you should be able to reuse that. Just make sure your buffer is big enough that there is always data to play back on the receiving computer.

Community
  • 1
  • 1
Sebastian Gray
  • 2,590
  • 3
  • 26
  • 36
1

Have a look at the code in this article , it needs to be modified quite a bit to be able to stream the output over the network , but that should not be hard enough. http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=19102

RC1140
  • 8,423
  • 14
  • 48
  • 71