Runime
Runime

Reputation: 1

webRtc android, SessionDescription alwais null,

I'm making a video call using WebRTC for Android, and the problem is that in this line of code:

val sdp = SessionDescription(SessionDescription.Type.OFFER, message.message)

I get the SDP, and in the logs:

Log.d("WebRtcActivityCandidate", "SessionDescription - ${sdp.description}")
Log.d("WebRtcActivityCandidate", "SessionDescription - ${sdp}")

I see that the SDP is not empty, but then when using the following code:

peerConnection?.setRemoteDescription(object : SdpObserver {
override fun onCreateSuccess(p0: SessionDescription?) {}
override fun onSetSuccess() {
Log.d("WebRtcActivityCandidate", "Remote SDP set successfully after delay")
}
override fun onCreateFailure(p0: String?) {
Log.e("WebRtcActivityCandidate", "Failed to create SDP: $p0")
}
override fun onSetFailure(p0: String?) {
Log.e("WebRtcActivityCandidate", "Failed : $p0, SDP:    ${sdp.description}")
Log.e("WebRtcActivityCandidate", "Failed to set remote SDP after delay: $p0")
}
}, sdp)

The logs stubbornly say that "Failed to set remote SDP after delay: SessionDescription is NULL."

No matter what I do, there are no changes; it consistently writes: "Failed to set remote SDP after delay: SessionDescription is NULL."

The code for obtaining it looks like this:

if (message?.type == "video_call_process_offer_dsgdlkhjerogjdslghk" && openType == "incoming") {
Log.d("WebRtcActivityCandidate", "Original message: ${message.message}")
val sdpReplace = message.message.replace("\\s+".toRegex(), " ").trim()
Log.d("WebRtcActivityCandidate", "SDP Length: ${sdpReplace.length}")
Log.d("WebRtcActivityCandidate", "SDP Content after trim: $sdpReplace")
val sdp = SessionDescription(SessionDescription.Type.OFFER, message.message)
Log.d("WebRtcActivityCandidate", "SessionDescription - ${sdp.description}")
Log.d("WebRtcActivityCandidate", "SessionDescription - ${sdp}")
if (sdp.description.isEmpty()) {
    Log.e("WebRtcActivityCandidate", "SDP Description is empty")
}
if (peerConnection == null) {
    Log.e("WebRtcActivityCandidate", "PeerConnection is null!")
} else {
    Log.d("WebRtcActivityCandidate", "PeerConnection is ready to set remote SDP")
}
val sdpM = sdp

peerConnection?.setRemoteDescription(object : SdpObserver {
    override fun onCreateSuccess(p0: SessionDescription?) {}
    override fun onSetSuccess() {
        Log.d("WebRtcActivityCandidate", "Remote SDP set successfully after delay")
    }
    override fun onCreateFailure(p0: String?) {
        Log.e("WebRtcActivityCandidate", "Failed to create SDP: $p0")
    }
    override fun onSetFailure(p0: String?) {
        Log.e("WebRtcActivityCandidate", "Failed to set remote SDP after delay: $p0, SDP: ${sdp.description}")
        Log.e("WebRtcActivityCandidate", "Failed to set remote SDP after delay: $p0")
    }
}, sdpM)
}

The logs look like this:

SessionDescription - org.webrtc.SessionDescription@9b95f43
12:17:50.737 17462-17462 WebRtcActivityCandidate ru....r.it.service.afreeapplication D  PeerConnection is ready to set remote SDP
12:17:50.776 17462-18956 WebRtcActivityCandidate ru....r.it.service.afreeapplication E Failed to set remote SDP after delay: SessionDescription is NULL., SDP: v=0
o=- 5772125125799692495 2 IN IP4 127.0.0.1
s=-
t=0 0
...
Failed to set remote SDP after delay: SessionDescription is NULL.

I tried changing it on the server and formatting the string, but nothing changes. THANKS!

Upvotes: 0

Views: 36

Answers (0)

Related Questions