jitsi/ice4j

factory.createSessionDescription(String sdp) will get NULL Object on Android

shenhuaz opened this issue · 2 comments

I have implementation 'org.jitsi:ice4j:1.0' in my Android code, and compileSDK 27, after I copy remote SDP from another Android device, and use SdpUtils.parseSDP(agent, remoteSdp), it will show error message "get Attempt to invoke interface method 'java.lang.String javax.sdp.SessionDescription.getAttribute(java.lang.String)' on a null object reference", then I found that SessionDescription transform by factory.createSessionDescription(String sdp) will return null.
here are my remote SDP:
v=0
o=ice4j.org 0 0 IN null null
s=-
t=0 0
a=ice-options:trickle
a=ice-ufrag:oune1cn6fbt0i
a=ice-pwd:4t7qqqa5kt85fn2v13krabjug2
m=audio 31750 RTP/AVP 0
c=IN 58.211.241.100 IP4
a=mid:audio
a=candidate:1 1 udp 2130706431 fe80::50c8:e5ff:fe72:2b0d 8888 typ host
a=candidate:2 1 udp 2130706431 192.168.1.114 8888 typ host
a=candidate:3 1 udp 1677724415 58.211.241.100 31750 typ srflx raddr 192.168.1.114 rport 8888

And transform them by SdpUtils.parseSDP :
SdpFactory factory = new NistSdpFactory();
SessionDescription sdess(<-- this will be null) = factory.createSessionDescription(sdp);

I found remove this line "o=ice4j.org 0 0 IN null null", it can be parse success, but I don't know why.

and after that, my app will crash and I catch message as blow:

I/org.ice4j.ice.Component(10051): Add remote candidate for audio.RTP: [fe80::50c8:e5ff:fe72:2b0d]:8888/udp/host
I/org.ice4j.ice.Component(10051): Add remote candidate for audio.RTP: [fe80::52c8:e5ff:fe72:2b0d]:8888/udp/host
I/org.ice4j.ice.Component(10051): Add remote candidate for audio.RTP: 192.168.1.114:8888/udp/host
I/org.ice4j.ice.Component(10051): Add remote candidate for audio.RTP: 58.211.241.100:13655/udp/srflx
I/System.out(10051): [CDS][DNS]Unable to resolve host "IP4": No address associated with hostname
I/Click (10051): connect
I/org.ice4j.ice.Agent(10051): Start ICE connectivity establishment
I/org.ice4j.ice.Agent(10051): Init checklist for stream audio
I/org.ice4j.ice.Agent(10051): ICE state changed from Waiting to Running
W/dalvikvm(10051): threadid=22: thread exiting with uncaught exception (group=0x41821c68)
I/ice (10051): Agent entered the Running state.
I/ConnectivityCheckClient(10051): Start connectivity checks!

it meet uncaught exception and shut down VM, then I found the exception from Agent.initCheckLists(),
and to be continue...

This is a bug in java-sdp-nist-bridge that is fixed in version 1.2. The ice4j version 1.0 on Maven Central is quite old, you'll have better results (and get rid of this bug) when you use a newer version. Either build it yourself or use a snapshot.