1

我正在尝试使用 JAIN SIP 1.2 和 Android 上的 NIST 实现来构建 SIP 应用程序。

我已经从源代码重建了jain-sip-api-1.2.jarand ,并重jain-sip-ri-1.2.1111.jar命名了javax -> jain_javaxand gov.nist.javax -> jain_gov.nist.jain_javax。我在标准 java 上的 textclient 示例上测试了 jar 文件没有问题。但是,当我在 Android 上运行它时,我仍然收到错误:

"The Peer SIP Stack: jain_gov.nist.jain_javax.sip.SipstackImpl could not be instantiated. Ensure the Path Name has been set".

我在这里错过了什么吗?

4

3 回答 3

1

解决了。Jain Sip 使用的 log4i-1.2.x.jar 在 Android 上无法正常工作。互联网上有很多关于如何让 log4j 在 Android 上运行的讨论,但没有一个对我有用。我已经从 Jain Sip 源代码中删除了所有与 log4j 相关的代码,现在 sip 堆栈在 Android 上正常工作。

于 2014-02-22T00:35:25.333 回答
1

重命名包是不够的。JAIN-SIP 通过原始包名“gov.nist”对某些类进行内部引用。您还应该仔细检查所有代码以重命名任何“gov.nist”引用,例如堆栈类的前缀。

Android 内置了旧版本的 JAIN-SIP,它接管了对那些“gov.nist”类的一些现有引用。它不是一个导出的 API,所以不是很明显。这就是为什么它在台式机上的行为可能不同的原因。如果您需要更多帮助,请向您发布代码和完整的错误消息/调试日志。

于 2014-02-13T02:14:07.887 回答
0

我正在使用 JAIN-SIP-1-2-164。这是应用程序代码:

import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.text.ParseException;
import java.util.*;
import android.os.Handler;

import jain_javax.sip.*;
import jain_javax.sip.address.*;
import jain_javax.sip.header.*;
import jain_javax.sip.message.*;

public class SipLayer implements SipListener {

private SipStack sipStack;
private SipFactory sipFactory;
private Properties properties;
private String local_ip;    
int listen_port;            

/** Here we initialize the SIP stack. */
public SipLayer(int listen_port) {
    try {   
    setUsername(username);
    this.local_ip = InetAddress.getLocalHost().getHostAddress();;
    this.listen_port = listen_port;     
    // Create the SIP factory and set the path name.
    this.sipFactory = SipFactory.getInstance();
    this.sipFactory.setPathName("jain_gov.nist");   
    // Create and set the SIP stack properties.
    this.properties = new Properties();
    this.properties.setProperty("jain_javax.sip.STACK_NAME", "stack");
    this.properties.setProperty("jain_javax.sip.IP_ADDRESS", local_ip);
    if(proxy != null) 
        this.properties.setProperty("jain_javax.sip.OUTBOUND_PROXY", proxy + ':' + server_port + '/' + protocol);

    //DEBUGGING: Information will go to files textclient.log and textclientdebug.log
    this.properties.setProperty("jain_gov.nist.javax.sip.TRACE_LEVEL", "32");
    // this.properties.setProperty("jain_gov.nist.javax.sip.SERVER_LOG", "textclient.txt");
    // this.properties.setProperty("jain_gov.nist.javax.sip.DEBUG_LOG", "textclientdebug.log");

    // Create the SIP stack.
    this.sipStack = this.sipFactory.createSipStack(properties);
  }
  catch (Exception e) {       
    msgProc.processError("SipLayer failed: " + e.getMessage() + "\n");
  }
    }
}

相同的代码在 Windows 机器上的 java 上运行正常,但是我得到了上面提到的错误消息的 android 模拟器。

我发现它未能在“SipStack sipStack = (SipStack) sipStackConstructor.newInstance(conArgs);”处遵循 Jain SIP 1.2 例程

private SipStack createStack(Properties properties)
        throws PeerUnavailableException {
    try {
        // create parameters argument to identify constructor
        Class[] paramTypes = new Class[1];
        paramTypes[0] = Class.forName("java.util.Properties");
        // get constructor of SipStack in order to instantiate
        Constructor sipStackConstructor = Class.forName(
                getPathName() + ".jain_javax.sip.SipStackImpl").getConstructor(
                paramTypes);
        // Wrap properties object in order to pass to constructor of
        // SipSatck
        Object[] conArgs = new Object[1];
        conArgs[0] = properties;
        // Creates a new instance of SipStack Class with the supplied
        // properties.
        SipStack  sipStack = (SipStack) sipStackConstructor.newInstance(conArgs);
        sipStackList.add(sipStack);
        String name = properties.getProperty("jain_javax.sip.STACK_NAME");
        this.sipStackByName.put(name, sipStack);
                    return sipStack;
    } catch (Exception e) {
        String errmsg = "The Peer SIP Stack: "
                + getPathName()
                + ".jain_javax.sip.SipStackImpl"
                + " could not be instantiated. Ensure the Path Name has been set.";
        throw new PeerUnavailableException(errmsg, e);
    }
}

任何建议或如何进一步调试?

于 2014-02-13T17:53:47.110 回答