forked from mirror/monocles_chat
Do not use JMI if any rtp capable device does not support it
This commit is contained in:
parent
92a05fd309
commit
7860fb3d55
4 changed files with 18 additions and 19 deletions
|
@ -153,20 +153,6 @@ public class Presences {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean anySupport(final String namespace) {
|
||||
synchronized (this.presences) {
|
||||
if (this.presences.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
for (Presence presence : this.presences.values()) {
|
||||
ServiceDiscoveryResult disco = presence.getServiceDiscoveryResult();
|
||||
if (disco != null && disco.getFeatures().contains(namespace)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String firstWhichSupport(final String namespace) {
|
||||
for (Map.Entry<String, Presence> entry : this.presences.entrySet()) {
|
||||
|
|
|
@ -2419,7 +2419,7 @@ public class ConversationFragment extends XmppFragment
|
|||
return;
|
||||
}
|
||||
final Contact contact = conversation.getContact();
|
||||
if (contact.getPresences().anySupport(Namespace.JINGLE_MESSAGE)) {
|
||||
if (RtpCapability.jmiSupport(contact)) {
|
||||
triggerRtpSession(contact.getAccount(), contact.getJid().asBareJid(), action);
|
||||
} else {
|
||||
final RtpCapability.Capability capability;
|
||||
|
|
|
@ -72,6 +72,7 @@ import eu.siacs.conversations.xmpp.jingle.ContentAddition;
|
|||
import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager;
|
||||
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
|
||||
import eu.siacs.conversations.xmpp.jingle.Media;
|
||||
import eu.siacs.conversations.xmpp.jingle.RtpCapability;
|
||||
import eu.siacs.conversations.xmpp.jingle.RtpEndUserState;
|
||||
|
||||
import static eu.siacs.conversations.utils.PermissionUtils.getFirstDenied;
|
||||
|
@ -1530,10 +1531,8 @@ public class RtpSessionActivity extends XmppActivity
|
|||
final Account account, Jid with, final RtpEndUserState state, final Set<Media> media) {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.putExtra(EXTRA_ACCOUNT, account.getJid().toEscapedString());
|
||||
if (account.getRoster()
|
||||
.getContact(with)
|
||||
.getPresences()
|
||||
.anySupport(Namespace.JINGLE_MESSAGE)) {
|
||||
if (RtpCapability.jmiSupport(account.getRoster()
|
||||
.getContact(with))) {
|
||||
intent.putExtra(EXTRA_WITH, with.asBareJid().toEscapedString());
|
||||
} else {
|
||||
intent.putExtra(EXTRA_WITH, with.toEscapedString());
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package eu.siacs.conversations.xmpp.jingle;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Collections2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -85,6 +87,18 @@ public class RtpCapability {
|
|||
return result;
|
||||
}
|
||||
|
||||
// do all devices that support Rtp Call also support JMI?
|
||||
public static boolean jmiSupport(final Contact contact) {
|
||||
return !Collections2.transform(
|
||||
Collections2.filter(
|
||||
contact.getPresences().getPresences(),
|
||||
p -> RtpCapability.check(p) != RtpCapability.Capability.NONE),
|
||||
p -> {
|
||||
ServiceDiscoveryResult disco = p.getServiceDiscoveryResult();
|
||||
return disco != null && disco.getFeatures().contains(Namespace.JINGLE_MESSAGE);
|
||||
}).contains(false);
|
||||
}
|
||||
|
||||
public enum Capability {
|
||||
NONE, AUDIO, VIDEO;
|
||||
|
||||
|
|
Loading…
Reference in a new issue