~singpolyma/cheogram-android

d5208a6b1c272a5f84c91a3d746b26843226f1a0 — Daniel Gultsch 1 year, 7 months ago e3eb486
show switch to video only if other party has caps

fixes #4421
M src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java => src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +1 -1
@@ 239,7 239,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() {

M src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java => src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +22 -0
@@ 49,10 49,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;


@@ 2777,6 2780,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);
    }