Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ICE,SDP解析异常_Java_Android_Sdp_Ice4j - Fatal编程技术网

Java ICE,SDP解析异常

Java ICE,SDP解析异常,java,android,sdp,ice4j,Java,Android,Sdp,Ice4j,我正试图在我的Android应用程序中实现Ice4J,但我被以下代码卡住了: NistSdpFactory factory = new NistSdpFactory(); SessionDescription sd = null; try { sd=factory.createSessionDescription(); /* put some random longs here as seen in examples */ /* leaving next line wo

我正试图在我的Android应用程序中实现Ice4J,但我被以下代码卡住了:

NistSdpFactory factory = new NistSdpFactory();
SessionDescription sd = null;

try {
    sd=factory.createSessionDescription();
    /* put some random longs here as seen in examples */
    /* leaving next line would result in o=ice4j.org 0 0 IN null null */
    sd.setOrigin(factory.createOrigin("phone",1235435654721342455L,3521512531241L,"IN","IP4",null));
    IceSdpUtils.initSessionDescription(sd, agent);
    Log.e("ICE","SDP: "+sd.toString()); //this actually works
    /* so far no problems */
    SessionDescription reversed=new SDPAnnounceParser(sd.toString()).parse(); //and this suddenly throws an exception!!!
    Log.e("ICE","Reversed... "+reversed.toString());
} catch (Exception ex){
     Log.e("ICE","Failed to init session description", ex);
     ex.printStackTrace();
}
代理是这样初始化的:

Agent agent=new Agent();
String[] hostnames = new String[] {"jitsi.org","numb.viagenie.ca","stun.ekiga.net"};
for(String hostname: hostnames){
    try {
        TransportAddress ta = new TransportAddress(InetAddress.getByName(hostname), 3478, Transport.UDP);
        agent.addCandidateHarvester(new StunCandidateHarvester(ta));
    } catch (Exception e) { Log.e("ICE","Failed to add candidate", e); }
}


try {
    IceMediaStream stream = agent.createMediaStream("audio");
    IceMediaStream streamVideo = agent.createMediaStream("video");
    int port = 5000;
    agent.createComponent(stream, Transport.UDP, port, port, port + 100);
    agent.createComponent(streamVideo, Transport.UDP, port+100, port+100, port + 200);
} catch (Exception ex){
    Log.e("ICE","Failed to create component",ex);
}
所以代码相当简单,我所做的就是创建会话描述,然后从字符串重新创建它,这应该不会产生任何问题,对吗?可悲的是,我们走了:

SDP: v=0
o=phone 1235435654721342455 3521512531241 IN IP4 123.45.67.89
s=-
t=0 0
a=ice-options:trickle
a=ice-ufrag:datbs1al0pu6l0
a=ice-pwd:74gk6of5iedc4h5uug7nvmrdis
m=audio 30783 RTP/AVP 0
c=IN 123.45.67.89 IP4
a=mid:audio
a=candidate:1 1 udp 2130706431 fe80::4adb:50ff:fe47:f8ab 5000 typ host
a=candidate:2 1 udp 2130706431 192.168.1.104 5000 typ host
a=candidate:3 1 udp 1677724415 123.45.67.89 30783 typ srflx raddr 192.168.1.104 rport 5000
m=video 30784 RTP/AVP 0
c=IN 123.45.67.89 IP4
a=mid:video
a=candidate:1 1 udp 2130706431 fe80::4adb:50ff:fe47:f8ab 5100 typ host
a=candidate:2 1 udp 2130706431 192.168.1.104 5100 typ host
a=candidate:3 1 udp 1677724415 123.45.67.89 30784 typ srflx raddr 192.168.1.104 rport 5100
这是第一个Log.e,在执行.parse()之后:

有什么帮助吗?我已经为此挣扎了好几个小时,却找不到解决办法


编辑:在长时间找出原因后,似乎错误出现在
gov.nist.javax.sdp.parser
LexerCore.java
中,
Map currentLexer
从未分配为
OriginParseField。java
调用了错误的构造函数,将
currentLexer
保留为
null
,所以问题是,我怎样才能这样修补文件?

Hello@jakubinf,你找到解决方案了吗。我也面临着这种错误。
Failed to init session description
    java.text.ParseException: o=phone 1235435654721342455 3521512531241 IN IP4 123.45.67.89 (at offset 7)
            at gov.nist.javax.sdp.parser.OriginFieldParser.originField(OriginFieldParser.java:103)
            at gov.nist.javax.sdp.parser.OriginFieldParser.parse(OriginFieldParser.java:108)
            at gov.nist.javax.sdp.parser.SDPAnnounceParser.parse(SDPAnnounceParser.java:113)
            at com.example.app.CallActivity$1.run(CallActivity.java:105)
            at java.lang.Thread.run(Thread.java:831)
java.text.ParseException: o=phone 1235435654721342455 3521512531241 IN IP4 123.45.67.89 (at offset 7)
  at gov.nist.javax.sdp.parser.OriginFieldParser.originField(OriginFieldParser.java:103)
  at gov.nist.javax.sdp.parser.OriginFieldParser.parse(OriginFieldParser.java:108)
  at gov.nist.javax.sdp.parser.SDPAnnounceParser.parse(SDPAnnounceParser.java:113)
  at com.example.app.CallActivity$1.run(CallActivity.java:105)
  at java.lang.Thread.run(Thread.java:831)