smackx jingle语音通话实例

本文探讨了Jingle通信技术的使用及其在实际应用中遇到的问题,特别是服务端返回501异常的情况。通过引用IgniteRealtime社区的一篇示例文章,详细解释了如何设置和实现Jingle通信,包括用户连接、创建Jingle会话等关键步骤。重点介绍了JMFMediaManager的使用,以及在不同操作系统下可能需要添加的依赖库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关于jingle ,资料网上少之又少,官方提供的Demo无法运行(原因:问声明客户端支持Jingle,所以服务端返回501异常)。

这个问题困然我几天,然后在Ignite Realtime看到一篇可以很好工作的JIngle示例:

public static void main(String[] args) throws Exception {
 // enable Jingle service
 JingleManager.setJingleServiceEnabled();

 // user1 connect to a XMPP Server
 XMPPConnection x1 = new XMPPConnection("localhost");
 x1.connect();
 x1.login("user1", "user1");

 // Create a JingleManager using a BasicTransportManager
 List<JingleMediaManager> mediaManagers1 = new ArrayList<JingleMediaManager>();
 mediaManagers1.add(new JmfMediaManager(new BasicTransportManager()));
 final JingleManager jm1 = new JingleManager(x1, mediaManagers1);

 // Listen for incoming calls
 jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
 public void sessionRequested(JingleSessionRequest request) {

 try {
 // Accept the call
 JingleSession session = request.accept();

 // Start the call
 session.startIncoming();
 }
 catch (XMPPException e) {
 e.printStackTrace();
 }

 }
 });

 // user2 connect to a XMPP Server
 XMPPConnection x0 = new XMPPConnection("localhost");
 x0.connect();
 x0.login("user2", "user2");

 // Create a JingleManager using a BasicTransportManager
 List<JingleMediaManager> mediaManagers0 = new ArrayList<JingleMediaManager>();
 mediaManagers0.add(new JmfMediaManager(new BasicTransportManager()));
 final JingleManager jm0 = new JingleManager(x0, mediaManagers0);

 // Create a new Jingle Call with a full JID
 JingleSession js0 = jm0
 .createOutgoingJingleSession("user1@localhost/Smack");

 // Start the call
 js0.startOutgoing();

 Thread.sleep(30000);
 js0.terminate();

 Thread.sleep(3000);

}
For the JMFMediaManager to work you have to add the jmf.jar and maybe some OS dependent libraries to the classpath. These can be found in the svn repository /smack/jingle/extensions/build/lib

转自:http://community.igniterealtime.org/thread/37786


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值