Code Repo    |     RSS
MD's Technical Sharing



Monday, September 22, 2008

P2P audio Streaming between computer & device

This project attempts to develop a simple program, which can run on the Pocket PC device as well as the personal computers with Windows installed, that allows 2 people to talk to each other via a simple P2P streaming system.

The software runs on Pocket devices with Windows Mobile 5.0 and 6.0 having .NET Compact Framework 2.0 installed. Interestingly, since the .NET Compact Framework is compatible with the .NET framework which can run on Windows XP, our program can also run on the personal computer with Windows XP installed without any major code changes.

Regardless of the platform on which the program is running, the user needs to configure the address of the destination which he intends to talk to. This consists of the IP address of the target device/computer as well as the port to which the outgoing audio data (recorded from the microphone, referred to as outgoing audio) is sent to. He also needs to configure the port on which the program receives audio data (which will be played back, referred to as incoming audio). On both ends, the settings of IP address and ports must match in order for the program to work:
  • Local IP: the IP address and the port at which the program receives audio data for playback. The local IP field is read-only; user can select one of the listed values.
  • Remote IP: the IP address and the port to which the recorded audio data is sent.
Given this information, it is obvious that user should swap the values of Remote IP and Local IP on both ends for the program to work. This would mean, the values for Local IP on one end should be used as Remote IP on the other end, and vice versa.

Technical details

As mentioned, the program is written using .NET Compact Framework 2.0, with the help of Visual Studio 2005. Two important features are demonstrated in the program

1. Audio capturing and playing back. This is done via the Waveform Application Programming Interface (API), which comes with the SDK. This allows the programmer to capture real-time audio data from the microphone and transmit to the remote destination, as well as to receive audio data from the remote destination and play back locally. This creates an effect of real-time voice conversation.

2. Socket programming. Audio is transmitted and received via UDP (User Datagram Protocol) socket, which is handy as the .NET compact framework has built-in support for UDP. Since UDP requires that data must be sent via a single data port, this explains why the port must be specified in the user interface. Obviously, further development can automatically guess the port in the background and there would be no need for the user to manually specify the port.

Download 

Source Code
Binary (Windows Mobile and PC) 

References

1. The Waveform API

Useful information about how to record and play back audio on a Pocket PC is found on this website

2. Full-duplex audio player in .NET

This is an example of how to use the Waveform API. It records audio and playback locally.

3. Sockets Programming in .NET

This gives information about how to transmit and receive data via UDP sockets

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.