Senthil Kumar V
Senthil Kumar V

Reputation: 33

Android (Kotlin) WebRTC - "Failed to parse: "". Reason: Invalid SDP line"

I'm working on integration of WebRTC into a project and using "implementation 'org.webrtc:google-webrtc:1.0.30039'". When I just use the example project from Google source https://webrtc.googlesource.com/src/, it works fine without any issue. However when converted all the Java files to Kotlin and run, it always throw the below error (Invalid SDP line). I did verify that the SDP is similar between Java and Kotlin project. Also I tried adding new line at the end of SDP as recommended in some forum, didn't help either.

Below is the error that I see in the Logcat when tried creating offer:

E/webrtc_sdp.cc: (line 402): Failed to parse: "". Reason: Invalid SDP line.
E/PCRTCClient: Peerconnection error: setSDP error: SessionDescription is NULL.

Following is the SDP:

    v=0
    o=- 3703865506153758141 2 IN IP4 127.0.0.1
    s=-
    t=0 0
    a=group:BUNDLE 0 1
    a=msid-semantic: WMS ARDAMS
    m=video 9 RTP/SAVPF 96 97 98 99 100 101 127 124 125
    c=IN IP4 0.0.0.0
    a=rtcp:9 IN IP4 0.0.0.0
    a=ice-ufrag:WMCz
    a=ice-pwd:7U8pMIKV8KizMp6zeYgpnD6X
    a=ice-options:trickle renomination
    a=mid:0
    a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
    a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
    a=extmap:13 urn:3gpp:video-orientation
    a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
    a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
    a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
    a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
    a=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07
    a=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space
    a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
    a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
    a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
    a=sendrecv
    a=msid:ARDAMS ARDAMSv0
    a=rtcp-mux
    a=rtcp-rsize
    a=crypto:0 AES_CM_128_HMAC_SHA1_80 inline:xpIiJ7ZL8lDPOZbcBrMV8Q0kH/7K2bwborNljNEq
    a=rtpmap:96 VP8/90000
    a=rtcp-fb:96 goog-remb
    a=rtcp-fb:96 transport-cc
    a=rtcp-fb:96 ccm fir
    a=rtcp-fb:96 nack
    a=rtcp-fb:96 nack pli
    a=rtpmap:97 rtx/90000
    a=fmtp:97 apt=96
    a=rtpmap:98 VP9/90000
    a=rtcp-fb:98 goog-remb
    a=rtcp-fb:98 transport-cc
    a=rtcp-fb:98 ccm fir
    a=rtcp-fb:98 nack
    a=rtcp-fb:98 nack pli
    a=rtpmap:99 rtx/90000
    a=fmtp:99 apt=98
    a=rtpmap:100 H264/90000
    a=rtcp-fb:100 goog-remb
    a=rtcp-fb:100 transport-cc
    a=rtcp-fb:100 ccm fir
    a=rtcp-fb:100 nack
    a=rtcp-fb:100 nack pli
    a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
    a=rtpmap:101 rtx/90000
    a=fmtp:101 apt=100
    a=rtpmap:127 red/90000
    a=rtpmap:124 rtx/90000
    a=fmtp:124 apt=127
    a=rtpmap:125 ulpfec/90000
    a=ssrc-group:FID 3892029952 1800496854
    a=ssrc:3892029952 cname:1P/brKdD8UOBMgTV
    a=ssrc:3892029952 msid:ARDAMS ARDAMSv0
    a=ssrc:3892029952 mslabel:ARDAMS
    a=ssrc:3892029952 label:ARDAMSv0
    a=ssrc:1800496854 cname:1P/brKdD8UOBMgTV
    a=ssrc:1800496854 msid:ARDAMS ARDAMSv0
    a=ssrc:1800496854 mslabel:ARDAMS
    a=ssrc:1800496854 label:ARDAMSv0
    m=audio 9 RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126
    c=IN IP4 0.0.0.0
    a=rtcp:9 IN IP4 0.0.0.0
    a=ice-ufrag:WMCz
    a=ice-pwd:7U8pMIKV8KizMp6zeYgpnD6X
    a=ice-options:trickle renomination
    a=mid:1
    a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
    a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
    a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
    a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
    a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
    a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
    a=sendrecv
    a=msid:ARDAMS ARDAMSa0
    a=rtcp-mux
    a=crypto:0 AES_CM_128_HMAC_SHA1_80 inline:xpIiJ7ZL8lDPOZbcBrMV8Q0kH/7K2bwborNljNEq
    a=rtpmap:111 opus/48000/2
    a=rtcp-fb:111 transport-cc
    a=fmtp:111 minptime=10;useinbandfec=1
    a=rtpmap:103 ISAC/16000
    a=rtpmap:104 ISAC/32000
    a=rtpmap:9 G722/8000
    a=rtpmap:102 ILBC/8000
    a=rtpmap:0 PCMU/8000
    a=rtpmap:8 PCMA/8000
    a=rtpmap:106 CN/32000
    a=rtpmap:105 CN/16000
    a=rtpmap:13 CN/8000
    a=rtpmap:110 telephone-event/48000
    a=rtpmap:112 telephone-event/32000
    a=rtpmap:113 telephone-event/16000
    a=rtpmap:126 telephone-event/8000
    a=ssrc:167068800 cname:1P/brKdD8UOBMgTV
    a=ssrc:167068800 msid:ARDAMS ARDAMSa0
    a=ssrc:167068800 mslabel:ARDAMS
    a=ssrc:167068800 label:ARDAMSa0 

Anyone seen similar issue when using WebRTC lib in Kotlin based android app ?

Upvotes: 2

Views: 1722

Answers (1)

Felipe Lima
Felipe Lima

Reputation: 10740

I just ran into the same issue. The problem is, according to this discuss-webrtc mailing list thread, \r\n is required at the end of the session description. You can fix this by simply appending \r\n at the end of the description string when constructing your SessionDescription object, eg.:

val sdp = SessionDescription(origSdp.type, "${sdpDescription.trim()}\r\n")

There is also a bug tracking this cryptic error message.

Upvotes: 2

Related Questions