C++和VoIP使用P2P

5
我目前正在计划我的毕业项目,我希望创建一个支持语音和文本聊天的应用程序(不是“下一个Skype”)。我只是想要一个易于使用且轻量级的方法来完成VoIP部分,并且它不需要大量的功能,至少在开始阶段不需要。
我想要的其中一个功能是它不依赖服务器,但这是因为我不想在发布应用程序后维护服务器。因此,如果可能的话,只需向某人提供您的IP地址,他们就可以加入使用它,这将更可取。
我打算使用Qt框架进行GUI,尽管它可以更改以及语言(C ++),因此没有什么是一成不变的。该软件将在Windows上运行。
我已经看过H.323、SIP和其他一些开源项目,但似乎很难入手,而且我无法弄清楚它们是否能够满足我的需求。
有没有任何开源库可以部分地实现我想要的功能?有没有我错过的资源?我完全是VoIP世界的新手,可以向正确方向推进。再次感谢任何帮助。

这个问题涉及SIP,我认为它是VoIP最普遍的协议。我不知道P2P与服务器之间的关注点是什么。P2P只是客户端/服务器的一个特殊情况。 - paddy
你想要什么质量水平?(良好的VoIP基本上需要QoS标记)。你想支持跨越NAT设备的机器吗?(如果是这样,你需要研究TURN和STUN)。你可能还想看一下XMPP。哦,几乎忘了:要配置NAT路由器以支持TURN/STUN,通常使用UPnP。 - Jerry Coffin
我不需要最好的,只要质量足以听清人们在说什么即可。基本上只需要完成任务即可。说实话,我甚至还没有考虑过NAT...我需要再多了解一些 :) - John Mikael Gundersen
它将需要支持一次2-8人的对话... - John Mikael Gundersen
你应该看一下 Mumble。幸运的是,它也使用 Qt 来构建其 GUI。它使用服务器来连接客户端(更像是 Ventrilo 或 TeamSpeak 而不是 Skype),但如果你对如何编码语音并通过网络发送感兴趣,这并不重要。它还有聊天功能。它是开源的,你可以在这里找到它:http://mumble.sourceforge.net。 - Nikos C.
显示剩余2条评论
2个回答

3

首先,几个月前我为我的公司实现了类似的东西。

经验教训:

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). 

在深入了解VoIP编程之前,我认为您需要先解决以下问题。

就您的问题而言,它相对较小。

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.

祝你好运 :)


1
请不要使用aLaw/uLaw编码。请使用Opus!http://www.opus-codec.org/downloads/ - Johan Kotlinski

2
我建议使用PJSIP。http://www.pjsip.org/ PJSIP可以为您处理SIP和音频。(它也有STUN!)
我不同意其他答案,一定要使用QT。这里没有理由去“本地化”。不仅PJSIP可以为您处理音频,还有许多其他跨平台音频库。
关于传输IP地址…如果您打算在局域网上使用,我建议使用UDP广播来发现其他用户(并在UI中定义您的用户名,以便最终用户可以互相识别)。在QT中实现这一点非常容易。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接