webrtc: include oldState in onConnectionChange

This commit is contained in:
Daniel Gultsch 2021-11-11 11:19:37 +01:00
parent fda45a7c86
commit 4ec0996dff
2 changed files with 10 additions and 6 deletions

View file

@ -1330,8 +1330,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
@Override
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed to " + newState);
public void onConnectionChange(final PeerConnection.PeerConnectionState oldState, final PeerConnection.PeerConnectionState newState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed: "+oldState+"->" + newState);
if (newState == PeerConnection.PeerConnectionState.CONNECTED && this.rtpConnectionStarted == 0) {
this.rtpConnectionStarted = SystemClock.elapsedRealtime();
}

View file

@ -88,6 +88,7 @@ public class WebRTCWrapper {
private final Handler mainHandler = new Handler(Looper.getMainLooper());
private VideoTrack localVideoTrack = null;
private VideoTrack remoteVideoTrack = null;
private PeerConnection.PeerConnectionState currentState;
private final PeerConnection.Observer peerConnectionObserver = new PeerConnection.Observer() {
@Override
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
@ -98,8 +99,9 @@ public class WebRTCWrapper {
}
@Override
public void onConnectionChange(PeerConnection.PeerConnectionState newState) {
eventCallback.onConnectionChange(newState);
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
eventCallback.onConnectionChange(currentState, newState);
currentState = newState;
}
@Override
@ -150,7 +152,7 @@ public class WebRTCWrapper {
@Override
public void onRenegotiationNeeded() {
Log.d(EXTENDED_LOGGING_TAG,"onRenegotiationNeeded - current state: "+currentState);
}
@Override
@ -261,6 +263,8 @@ public class WebRTCWrapper {
throw new InitializationException("Unable to create PeerConnection");
}
this.currentState = peerConnection.connectionState();
final Optional<CapturerChoice> optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent();
if (optionalCapturerChoice.isPresent()) {
@ -531,7 +535,7 @@ public class WebRTCWrapper {
public interface EventCallback {
void onIceCandidate(IceCandidate iceCandidate);
void onConnectionChange(PeerConnection.PeerConnectionState newState);
void onConnectionChange(PeerConnection.PeerConnectionState oldState, PeerConnection.PeerConnectionState newState);
void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices);
}