show switch to video only if other party has caps

fixes #4421
This commit is contained in:
Daniel Gultsch 2022-12-12 10:15:10 +01:00
parent 36da1c3a89
commit 4ef4207593
2 changed files with 23 additions and 1 deletions

View file

@ -217,7 +217,7 @@ public class RtpSessionActivity extends XmppActivity
if (connection == null) {
return false;
}
return Media.audioOnly(connection.getMedia()) && STATES_CONSIDERED_CONNECTED.contains(connection.getEndUserState());
return connection.isSwitchToVideoAvailable();
}
private void switchToConversation() {

View file

@ -45,10 +45,13 @@ import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.CryptoFailedException;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Presence;
import eu.siacs.conversations.entities.RtpSessionStatus;
import eu.siacs.conversations.entities.ServiceDiscoveryResult;
import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.utils.IP;
import eu.siacs.conversations.xml.Element;
@ -2763,6 +2766,25 @@ public class JingleRtpConnection extends AbstractJingleConnection
id.account, id.with, id.sessionId, endUserState);
}
public boolean isSwitchToVideoAvailable() {
final boolean prerequisite =
Media.audioOnly(getMedia())
&& Arrays.asList(RtpEndUserState.CONNECTED, RtpEndUserState.RECONNECTING)
.contains(getEndUserState());
return prerequisite && remoteHasVideoFeature();
}
private boolean remoteHasVideoFeature() {
final Contact contact = id.getContact();
final Presence presence =
contact.getPresences().get(Strings.nullToEmpty(id.with.getResource()));
final ServiceDiscoveryResult serviceDiscoveryResult =
presence == null ? null : presence.getServiceDiscoveryResult();
final List<String> features =
serviceDiscoveryResult == null ? null : serviceDiscoveryResult.getFeatures();
return features != null && features.contains(Namespace.JINGLE_FEATURE_VIDEO);
}
private interface OnIceServersDiscovered {
void onIceServersDiscovered(List<PeerConnection.IceServer> iceServers);
}