2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.stores;
|
|
|
|
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
|
|
import com.discord.api.voice.state.VoiceState;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
/* compiled from: StoreRtcConnection.kt */
|
|
|
|
public final class VoicePropsTracker {
|
|
|
|
private final Set<Long> allListenerUsers = new LinkedHashSet();
|
|
|
|
private final Set<Long> allSpeakerUsers = new LinkedHashSet();
|
|
|
|
private final Set<Long> allVoiceStateUsers = new LinkedHashSet();
|
|
|
|
private final long channelId;
|
|
|
|
private final Set<Long> currentPotentialListeners = new LinkedHashSet();
|
|
|
|
private final Set<Long> currentSpeakerUsers = new LinkedHashSet();
|
|
|
|
private final Set<Long> currentVoiceStateUsers = new LinkedHashSet();
|
|
|
|
private final long guildId;
|
|
|
|
private final long localUserId;
|
|
|
|
private boolean localUserSpeaking;
|
|
|
|
private int maxListenerCount;
|
|
|
|
private int maxSpeakerCount;
|
|
|
|
private int maxVoiceStateCount;
|
|
|
|
|
|
|
|
public VoicePropsTracker(long j, long j2, long j3, Map<Long, VoiceState> map) {
|
|
|
|
this.guildId = j;
|
|
|
|
this.channelId = j2;
|
|
|
|
this.localUserId = j3;
|
|
|
|
if (map != null) {
|
|
|
|
for (Map.Entry<Long, VoiceState> entry : map.entrySet()) {
|
|
|
|
long longValue = entry.getKey().longValue();
|
|
|
|
VoiceState value = entry.getValue();
|
|
|
|
Long a = value.a();
|
|
|
|
long j4 = this.channelId;
|
|
|
|
if (a != null && a.longValue() == j4) {
|
|
|
|
this.currentVoiceStateUsers.add(Long.valueOf(longValue));
|
|
|
|
if (!value.b() && !value.g()) {
|
|
|
|
this.currentPotentialListeners.add(Long.valueOf(longValue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void getProps(Map<String, Object> map) {
|
|
|
|
m.checkNotNullParameter(map, "properties");
|
|
|
|
map.put("max_voice_state_count", Integer.valueOf(this.maxVoiceStateCount));
|
|
|
|
map.put("total_voice_state_count", Integer.valueOf(this.allVoiceStateUsers.size()));
|
|
|
|
map.put("max_listener_count", Integer.valueOf(this.maxListenerCount));
|
|
|
|
map.put("total_listener_count", Integer.valueOf(this.allListenerUsers.size()));
|
|
|
|
map.put("max_speaker_count", Integer.valueOf(this.maxSpeakerCount));
|
|
|
|
map.put("total_speaker_count", Integer.valueOf(this.allSpeakerUsers.size()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void handleOnSpeaking(long j, boolean z2) {
|
|
|
|
if (z2) {
|
|
|
|
this.allSpeakerUsers.add(Long.valueOf(j));
|
|
|
|
this.currentSpeakerUsers.add(Long.valueOf(j));
|
|
|
|
this.maxSpeakerCount = Math.max(this.maxSpeakerCount, this.currentSpeakerUsers.size());
|
|
|
|
} else {
|
|
|
|
this.currentSpeakerUsers.remove(Long.valueOf(j));
|
|
|
|
}
|
|
|
|
if (j == this.localUserId && this.localUserSpeaking != z2) {
|
|
|
|
this.localUserSpeaking = z2;
|
|
|
|
if (z2) {
|
|
|
|
this.allListenerUsers.addAll(this.currentPotentialListeners);
|
|
|
|
this.maxListenerCount = Math.max(this.maxListenerCount, this.currentPotentialListeners.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void handleVoiceStateUpdate(VoiceState voiceState) {
|
|
|
|
m.checkNotNullParameter(voiceState, "voiceState");
|
|
|
|
if (voiceState.c() != this.guildId) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-03 23:36:06 +00:00
|
|
|
if (AnimatableValueParser.u1(voiceState)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.currentVoiceStateUsers.remove(Long.valueOf(voiceState.m()));
|
|
|
|
this.currentPotentialListeners.remove(Long.valueOf(voiceState.m()));
|
|
|
|
this.currentSpeakerUsers.remove(Long.valueOf(voiceState.m()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Long a = voiceState.a();
|
|
|
|
long j = this.channelId;
|
|
|
|
if (a != null && a.longValue() == j) {
|
|
|
|
this.currentVoiceStateUsers.add(Long.valueOf(voiceState.m()));
|
|
|
|
this.allVoiceStateUsers.add(Long.valueOf(voiceState.m()));
|
|
|
|
this.maxVoiceStateCount = Math.max(this.maxVoiceStateCount, this.currentVoiceStateUsers.size());
|
|
|
|
if (voiceState.b() || voiceState.g()) {
|
|
|
|
this.currentPotentialListeners.remove(Long.valueOf(voiceState.m()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.currentPotentialListeners.add(Long.valueOf(voiceState.m()));
|
|
|
|
if (this.localUserSpeaking) {
|
|
|
|
this.allListenerUsers.add(Long.valueOf(voiceState.m()));
|
|
|
|
this.maxListenerCount = Math.max(this.maxListenerCount, this.currentPotentialListeners.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|