Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ and voIP using P2P [closed]

I am currently planning my final year project were I wish to create a application which supports voice over IP and text based chat (though not the "next skype"). I just really want a easy to use lightweight way to get the voIP part done with and it does not need extended amount of features, at least not to begin with.

One of the features I wanted is that it doesn't go by a server, but that is because I do not want to maintain a server after the release of the application. So if it is possible to just give your IP to someone and they join using it would be preferable.

I'm planning to use the Qt framework for GUI, though it can be changed and so can the language (C++), so nothing is written in stone. The software will run on windows.

I have looked at H.323, sip and some other open source, but it seems just so difficult to get into and I cannot figure out whether they do what I need them to do.

Any open source libraries I should look into that does partly the thing I want? Any sources I have missed? I'm completely new to the voIP world and could use a push in the right direction. Again if there is a language that does this in a simple fashion I can just switch since I am currently in a planning phase. Thanks for any help I get.

like image 877
John Mikael Gundersen Avatar asked Oct 23 '12 21:10

John Mikael Gundersen


2 Answers

Firstly I implemented something similar for my company a few months back.

Lessons learnt:

1. you can't just pass IPs around and expect the users to like that over skype.
   Solution:
      a. You will need your own server with the necessary ports forwarded. You will have to use some sort of firewall hole punching algorithm(take a look at UDP hole punching).

2. Using existing VoIP library is always better. Downside? You can't write proprietary code using opensource library. Hence you will need to learn H.323 and RTCP/RTP protocol.

3. You will need to write echo reduction algorithms for voice.

4. COMPRESS your audio data before sending it to another computer. PCM data can and will clog your network, delaying sound and fuzzing up everything in the process.
Use aLaw and uLaw compression schemes.

5. Make sure you take care of all the error conditions. Multimedia over network can be tricky if not really hard to implement. 

6. DONT USE QT. Use a platform specific framework like .NET and libraries that deal with sound (NAudio). 

I think this will sum up the problems you will need to solve first, before delving into the art of VoIP programming.

For your question, your problem is much smaller.

1. You don't need echo reduction algorithms IF you use headsets.
2. You don't need to write hole punching algorithms if you're OK with passing IPs around. Take a look at NAT traversal(UPnP?) if the data is suppose to go on a network and to a computer that isn't on your LAN.

FLOW:
COMPUTER1->DATABUFFER->COMPRESSuLaw/aLaw->NETWORK->DECOMPRESSuLaw/aLaw->OTHERCOMPUTER
and vice versa.

Good luck :)

like image 83
Aniket Inge Avatar answered Nov 07 '22 18:11

Aniket Inge


I would recommend PJSIP. http://www.pjsip.org/

PJSIP will handle the SIP and the audio for you. (It has STUN too!)

I will have to disagree with the other answer, DO use QT. There is no reason to go "native" here. Not only can PJSIP handle the audio for you, but there are plenty of other cross-platform audio libraries.

In regards to passing around IPs... if you intend to use this on the LAN I would recommend using a UDP broadcast to discover other users (and have a place in the UI to define your username so end users can identify eachother). This is very easy to accomplish in QT.

like image 2
Daniel Placek Avatar answered Nov 07 '22 19:11

Daniel Placek