smackx jingle语音通话实例

关于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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值