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 @Override
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) { public void onConnectionChange(final PeerConnection.PeerConnectionState oldState, final PeerConnection.PeerConnectionState newState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed to " + newState); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed: "+oldState+"->" + newState);
if (newState == PeerConnection.PeerConnectionState.CONNECTED && this.rtpConnectionStarted == 0) { if (newState == PeerConnection.PeerConnectionState.CONNECTED && this.rtpConnectionStarted == 0) {
this.rtpConnectionStarted = SystemClock.elapsedRealtime(); this.rtpConnectionStarted = SystemClock.elapsedRealtime();
} }

View file

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