Add android bindings for PeerConnectionState.

This change makes it possible for android apps to use the new standards-compliant PeerConnectionState.

Bug: webrtc:9977
Change-Id: Iad19c38e664a59e86879715ec7a04a59a9894bee
Reviewed-on: https://webrtc-review.googlesource.com/c/109883
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25652}
This commit is contained in:
Jonas Olsson
2018-11-08 15:19:04 +01:00
committed by Commit Bot
parent 586725dc9a
commit f01d8c8d92
7 changed files with 149 additions and 10 deletions

View File

@ -52,6 +52,7 @@ import org.webrtc.MediaStreamTrack;
import org.webrtc.MediaStreamTrack.MediaType;
import org.webrtc.PeerConnection;
import org.webrtc.PeerConnection.IceConnectionState;
import org.webrtc.PeerConnection.PeerConnectionState;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.RtpParameters;
import org.webrtc.RtpReceiver;
@ -293,11 +294,23 @@ public class PeerConnectionClient {
void onIceConnected();
/**
* Callback fired once connection is closed (IceConnectionState is
* Callback fired once connection is disconnected (IceConnectionState is
* DISCONNECTED).
*/
void onIceDisconnected();
/**
* Callback fired once DTLS connection is established (PeerConnectionState
* is CONNECTED).
*/
void onConnected();
/**
* Callback fired once DTLS connection is disconnected (PeerConnectionState
* is DISCONNECTED).
*/
void onDisconnected();
/**
* Callback fired once peer connection is closed.
*/
@ -1263,6 +1276,20 @@ public class PeerConnectionClient {
});
}
@Override
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
executor.execute(() -> {
Log.d(TAG, "PeerConnectionState: " + newState);
if (newState == PeerConnectionState.CONNECTED) {
events.onConnected();
} else if (newState == PeerConnectionState.DISCONNECTED) {
events.onDisconnected();
} else if (newState == PeerConnectionState.FAILED) {
reportError("DTLS connection failed.");
}
});
}
@Override
public void onIceGatheringChange(PeerConnection.IceGatheringState newState) {
Log.d(TAG, "IceGatheringState: " + newState);