ICE, SDP Parse exception

583 views Asked by At

I am trying to implement Ice4J into my Android application, but I am stuck at following piece of code:

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();
}

This is how Agent is inited:

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);
}

So that code is fairly simple, and all I do is I create session description and then recreate it from string, that shouldn't make any problems, right? Sadly, here we go:

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

This is first Log.e, and after doing .parse():

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)

Any help? I am struggling over this for hours already and find no solution...

EDIT: After long time finding out why, seems error is in LexerCore.java from gov.nist.javax.sdp.parser, Map<Token> currentLexer is never allocated as OriginParseField.java calls wrong constructor, which leaves currentLexer as null, so question is, how can I patch file like this?

0

There are 0 answers