reverse: webrtc: include oldState in onConnectionChange

turns out we don’t need it and a better way is for RtpConnection to keep track of *all*
states in the current generation
This commit is contained in:
Daniel Gultsch 2021-11-11 17:05:32 +01:00
parent 9c3f55bef2
commit b6dee6da6a
2 changed files with 5 additions and 9 deletions

View file

@ -1338,8 +1338,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
@Override
public void onConnectionChange(final PeerConnection.PeerConnectionState oldState, final PeerConnection.PeerConnectionState newState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed: " + oldState + "->" + newState);
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnectionState changed to" + newState);
this.stateHistory.add(newState);
if (newState == PeerConnection.PeerConnectionState.CONNECTED) {
this.sessionDuration.start();

View file

@ -88,7 +88,6 @@ 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) {
@ -100,9 +99,7 @@ public class WebRTCWrapper {
@Override
public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
final PeerConnection.PeerConnectionState oldState = currentState;
currentState = newState;
eventCallback.onConnectionChange(oldState, newState);
eventCallback.onConnectionChange(newState);
}
@Override
@ -154,6 +151,7 @@ public class WebRTCWrapper {
@Override
public void onRenegotiationNeeded() {
Log.d(EXTENDED_LOGGING_TAG, "onRenegotiationNeeded()");
final PeerConnection.PeerConnectionState currentState = peerConnection == null ? null : peerConnection.connectionState();
if (currentState != null && currentState != PeerConnection.PeerConnectionState.NEW) {
eventCallback.onRenegotiationNeeded();
}
@ -267,8 +265,6 @@ 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()) {
@ -535,7 +531,7 @@ public class WebRTCWrapper {
public interface EventCallback {
void onIceCandidate(IceCandidate iceCandidate);
void onConnectionChange(PeerConnection.PeerConnectionState oldState, PeerConnection.PeerConnectionState newState);
void onConnectionChange(PeerConnection.PeerConnectionState newState);
void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices);