javaandroidwebrtcpeer

Webrtc: What is the difference between onIceConnectionChange and onConnectionChange


I am develloping an adroid video call app with Webrtc using java. I want to make some stuffs when the connection state of the other peer changes. For example When He's trying to reconnect after loosing connection. I fount some methods in PeerConnection.Observer and I don't know which one should I use and Why. I found :

** onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) ,

** onConnectionChange(PeerConnection.PeerConnectionState newState)

** and onIceConnectionReceivingChange I need your help!


Solution

  • iceConnectionState: represents the state of the network/transport layer connection between the peers. An ICE connection involves checking a bunch of ICE candidate pairs between the two peers in an attempt to find a socket pair the two peers can communicate on. Once the state changes to connected then the peers are able to communicate.

    connectionState: builds on top of the iceConnectionState and represents the application layer connection between the peers. Essentially the connection state is the iceConnection + DTLS. If you don't care about low level details then this is the state to monitor. A connectionState of connected implies an iceConnectionState of connected.

    onIceConnectionReceivingChange: That doesn't seem to be part of the "official" (draft) WebRTC API. It's probably coming from the javascript adapter or library you are using.