jitsi/ice4j

SdpUtils.parseSDP javax.sdp.SdpParseException

KORuL opened this issue · 0 comments

KORuL commented

Good afternoon! I use the newest 2.0.0 ice4j.jar in android app. I follow this instruction: tutorial part 1
I get SDP using the function SdpUtils.createSDPDescription
Next, I transmit the result encoded in Base64 to the server and get this string from another application instance, decode it from Base64 and the SdpUtils.parseSDP function cannot parse, an exception is thrown - what could be wrong?

my sdp description
v=0 o=mytest 1 1 IN IP4 192.168.111.1 s=- t=0 0 a=ice-options:trickle a=ice-ufrag:b5nch1cp7ippil a=ice-pwd:14m20r27jklhlgjbisil1im2r9 m=data 50455 RTP/AVP 0 c=IN 192.168.111.1 IP4 a=mid:data a=candidate:1 1 udp 2130706431 fe80::ff:fe44:5566 7999 typ host a=candidate:2 1 udp 2130706431 fec0::ff:fe44:5566 7999 typ host a=candidate:3 1 udp 2113939711 fec0::c035:dbe4:581b:4c0f 7999 typ host a=candidate:6 1 udp 2113939711 fec0::9025:74ff:fe1c:6169 7999 typ host a=candidate:7 1 udp 2113939711 fec0::d960:9767:98eb:984f 7999 typ host a=candidate:5 1 udp 2113937151 fe80::9025:74ff:fe1c:6169 7999 typ host a=candidate:4 1 udp 2113932031 192.168.232.2 7999 typ host a=candidate:8 1 udp 2113932031 192.168.200.2 7999 typ host a=candidate:9 1 udp 1677724415 192.168.111.1 50455 typ srflx raddr 192.168.232.2 rport 7999 a=candidate:10 1 udp 1677724415 192.168.111.1 50456 typ srflx raddr 192.168.200.2 rport 7999
Exception
javax.sdp.SdpParseException: o=mytest 1 1 IN IP4 192.168.111.1

part of Util

 // I
    @Throws(Throwable::class)
    fun getNewAgent(Port: Int): Agent {
        val Agent = createAgent(Port)
        Agent.setNominationStrategy(
                NominationStrategy.NOMINATE_HIGHEST_PRIO)

        return Agent
    }

    // II
    @Throws(Throwable::class)
    fun setListenerForAgent(agent: Agent, l: PropertyChangeListener) {
        agent.addStateChangeListener(l)
        //let them fight ... fights forge character.
        agent.isControlling = false
    }

    // III
    @Throws(Throwable::class)
    fun getSDPInfo(agent: Agent): String {
        return SdpUtils.createSDPDescription(agent)
    }


    // IV
    @Throws(Throwable::class)
    fun setSDPToAgent(agent: Agent, SDP: String) {
        SdpUtils.parseSDP(agent, SDP)
    }

    // V
    fun startConnect(agent: Agent) {
        agent.startConnectivityEstablishment()
    }

MainActivity

        val agent = IceInit.createAgent(7999)
        IceInit.setListenerForAgent(agent, IceInit.IceProcessingListener())
        val info = IceInit.getSDPInfo(agent)

        // Sending side
        var data: ByteArray? = null
        try {
            data = info.toByteArray(charset("UTF-8"))
        } catch (e1: UnsupportedEncodingException) {
            e1.printStackTrace()
        }

        val base64 = android.util.Base64.encodeToString(data, android.util.Base64.DEFAULT)

        val listParam: MutableList<String> = arrayListOf()
        listParam.add(uniqueID)
        listParam.add(base64)
        requestInsertClient(listParam.toTypedArray())


        var clientsSDP: MutableList<String>
        while (true) {
            clientsSDP = requestGetClient(uniqueID)
            if(clientsSDP.size > 0)
                break

            Thread.sleep(500)
        }

        if(clientsSDP.size > 0) {
            for (sdp in clientsSDP) {

                val decodeSDPData = android.util.Base64.decode(base64, android.util.Base64.DEFAULT)
                val decodeSDP = String(decodeSDPData, StandardCharsets.UTF_8)

                if (decodeSDP != info)

                    try {
                        IceInit.setSDPToAgent(agent, decodeSDP)
                    }
                    catch (e: SdpParseException) {
                        e.printStackTrace()
                    }
            }

            IceInit.startConnect(agent)
        }
        else {
            error = "error to set SDP"
        }

To work SdpUtils in gradle I specify
// https://mvnrepository.com/artifact/org.opentelecoms.sdp/java-sdp-nist-bridge
implementation group: 'org.opentelecoms.sdp', name: 'java-sdp-nist-bridge', version: '1.2'

Please, help