when local RTCDatachannel connected to remote RTCDatachannel, I wanna to konw the connection type: host/srflx/prflx/relay..
I try to parse the following string, but it's not the current one which is connected
RTCPeerConnection.localDescription.sdp
RTCPeerConnection.remoteDescription.sdp
RTCPeerConnection.currentLocalDescription.sdp
RTCPeerConnection.currentRemoteDescription.sdp
I can use chrome://webrtc-internals/ to see the connected candidate type
The getStats() API provides that information. In essence, you search for the
transportstats, traverse to its selected candidate pair usingselectedCandidatePairIdand then can access the local and remote candidates and their respective types.In practice it is a bit more complicated, in particular if you want to support Firefox as well. The code around https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/constraints/js/main.js#L229 provides a full sample.