Java Pjsip (Pjsua2 api ) 2.10 windows sip语音呼叫教程

1.安装swigwin-4.0.1 下载地址http://www.swig.org/download.html 注意是swigwin

Windows users should download swigwin-4.0.1 which includes a prebuilt executable. 

配置目录到win path

2.下载pjproject-2.10.zip(如果有python错误请安装py2.7 及环境path配置)

使用vs pjproject-vs14.sln 打开 重定向资源方案

>配置jdk的include 目录到swig_java_pjsua2  附件库  添加D:\\java\\jdk1.8\\jdk1.8\\include及D:\\java\\jdk1.8\\jdk1.8\\include\\win32

 >在swig_java_pjsua2项目点击生成  如果遇到错误pj/config_site.h 没找到  双击 用//注释  没用到视频的没用

最后成功后在\pjproject-2.10\pjsip-apps\src\swig\java\output目录有pjsua2.dll 

及org.pjsip.pjsua2 的java 类 及上级目录官方java demo

 

3.创建一个java 工程写入代码

package com.test;
import java.io.IOException;

import org.pjsip.pjsua2.*; //上面目录copy


//Subclass to extend the Account and get notifications etc.
class MyAccount extends Account {
@Override
public void onRegState(OnRegStateParam prm) {
   System.out.println("*** On registration state: " + prm.getCode() + prm.getReason());
}

public class Test {
static {
   System.load("C:/Users/lilin/Desktop/v2.10pjsua2.dll");//上面目录pjsua2.dll
   System.out.println("Library loaded");
}
static Endpoint ep = new Endpoint();
public static void main(String argv[]) {
   try {
       // Create endpoint
       
       ep.libCreate();
       // Initialize endpoint
       EpConfig epConfig = new EpConfig();
       ep.libInit( epConfig );
       // Create SIP transport. Error handling sample is shown
       TransportConfig sipTpConfig = new TransportConfig();
       sipTpConfig.setPort(5060);
       ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);
       // Start the library
       ep.libStart();

       AccountConfig acfg = new AccountConfig();
       acfg.setIdUri("sip:1010@ip:5060");
       acfg.getRegConfig().setRegistrarUri("sip:ip:5060");
       AuthCredInfo cred = new AuthCredInfo("digest", "*", "1010", 0, "h1234");
       acfg.getSipConfig().getAuthCreds().add( cred );
       // Create the account
       MyAccount acc = new MyAccount();
       acc.create(acfg);
       
       System.out.println("=====end====");
       // Here we don't have anything else to do..
       Thread.sleep(2000);
       
       
        
       
       while (true){
           Thread.sleep(1000);
           
           
       }
       
       /* Explicitly delete the account.
        * This is to avoid GC to delete the endpoint first before deleting
        * the account.
        */
       //acc.delete();

       // Explicitly destroy and delete endpoint
     //  ep.libDestroy();
       //ep.delete();

   } catch (Exception e) {
       System.out.println(e);
       return;
   }
}
}

好了   以上就是一个呼叫过程了  成功后就可以和其他的sip 软件呼叫了 也可以去实现视频

如果你觉得麻烦可以去 https://item.taobao.com/item.htm?id=618486196283

sip服务器搭建可参考:https://blog.csdn.net/Java_lilin/article/details/103063930

pjsip qt win32 参考:https://blog.csdn.net/Java_lilin/article/details/103511795

pjsip  c# 参考 https://blog.csdn.net/Java_lilin/article/details/106229860

更多写法可以参考安卓pjsua2代码:https://blog.csdn.net/Java_lilin/article/details/89212406

 

测试交流群:261074724 

 

 

 

 

      

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值