use of eu.siacs.conversations.xmpp.jingle.JingleRtpConnection in project Conversations by siacs.
the class RtpSessionActivity method onJingleRtpConnectionUpdate.
@Override
public void onJingleRtpConnectionUpdate(Account account, Jid with, final String sessionId, RtpEndUserState state) {
Log.d(Config.LOGTAG, "onJingleRtpConnectionUpdate(" + state + ")");
if (END_CARD.contains(state)) {
Log.d(Config.LOGTAG, "end card reached");
releaseProximityWakeLock();
runOnUiThread(() -> getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
}
if (with.isBareJid()) {
updateRtpSessionProposalState(account, with, state);
return;
}
if (emptyReference(this.rtpConnectionReference)) {
if (END_CARD.contains(state)) {
Log.d(Config.LOGTAG, "not reinitializing session");
return;
}
// this happens when going from proposed session to actual session
reInitializeActivityWithRunningRtpSession(account, with, sessionId);
return;
}
final AbstractJingleConnection.Id id = requireRtpConnection().getId();
final boolean verified = requireRtpConnection().isVerified();
final Set<Media> media = getMedia();
final Contact contact = getWith();
if (account == id.account && id.with.equals(with) && id.sessionId.equals(sessionId)) {
if (state == RtpEndUserState.ENDED) {
finish();
return;
}
runOnUiThread(() -> {
updateStateDisplay(state, media);
updateVerifiedShield(verified && STATES_SHOWING_SWITCH_TO_CHAT.contains(state));
updateButtonConfiguration(state, media);
updateVideoViews(state);
updateProfilePicture(state, contact);
invalidateOptionsMenu();
});
if (END_CARD.contains(state)) {
final JingleRtpConnection rtpConnection = requireRtpConnection();
resetIntent(account, with, state, rtpConnection.getMedia());
releaseVideoTracks(rtpConnection);
this.rtpConnectionReference = null;
}
} else {
Log.d(Config.LOGTAG, "received update for other rtp session");
}
}
use of eu.siacs.conversations.xmpp.jingle.JingleRtpConnection in project Conversations by siacs.
the class RtpSessionActivity method updateInCallButtonConfiguration.
@SuppressLint("RestrictedApi")
private void updateInCallButtonConfiguration(final RtpEndUserState state, final Set<Media> media) {
if (STATES_CONSIDERED_CONNECTED.contains(state) && !isPictureInPicture()) {
Preconditions.checkArgument(media.size() > 0, "Media must not be empty");
if (media.contains(Media.VIDEO)) {
final JingleRtpConnection rtpConnection = requireRtpConnection();
updateInCallButtonConfigurationVideo(rtpConnection.isVideoEnabled(), rtpConnection.isCameraSwitchable());
} else {
final AppRTCAudioManager audioManager = requireRtpConnection().getAudioManager();
updateInCallButtonConfigurationSpeaker(audioManager.getSelectedAudioDevice(), audioManager.getAudioDevices().size());
this.binding.inCallActionFarRight.setVisibility(View.GONE);
}
if (media.contains(Media.AUDIO)) {
updateInCallButtonConfigurationMicrophone(requireRtpConnection().isMicrophoneEnabled());
} else {
this.binding.inCallActionLeft.setVisibility(View.GONE);
}
} else {
this.binding.inCallActionLeft.setVisibility(View.GONE);
this.binding.inCallActionRight.setVisibility(View.GONE);
this.binding.inCallActionFarRight.setVisibility(View.GONE);
}
}
use of eu.siacs.conversations.xmpp.jingle.JingleRtpConnection in project Conversations by siacs.
the class RtpSessionActivity method updateCallDuration.
private void updateCallDuration() {
final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null;
if (connection == null || connection.getMedia().contains(Media.VIDEO)) {
this.binding.duration.setVisibility(View.GONE);
return;
}
if (connection.zeroDuration()) {
this.binding.duration.setVisibility(View.GONE);
} else {
this.binding.duration.setText(TimeFrameUtils.formatElapsedTime(connection.getCallDuration(), false));
this.binding.duration.setVisibility(View.VISIBLE);
}
}
use of eu.siacs.conversations.xmpp.jingle.JingleRtpConnection in project Conversations by siacs.
the class RtpSessionActivity method putScreenInCallMode.
private void putScreenInCallMode(final Set<Media> media) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (!media.contains(Media.VIDEO)) {
final JingleRtpConnection rtpConnection = rtpConnectionReference != null ? rtpConnectionReference.get() : null;
final AppRTCAudioManager audioManager = rtpConnection == null ? null : rtpConnection.getAudioManager();
if (audioManager == null || audioManager.getSelectedAudioDevice() == AppRTCAudioManager.AudioDevice.EARPIECE) {
acquireProximityWakeLock();
}
}
}
use of eu.siacs.conversations.xmpp.jingle.JingleRtpConnection in project Conversations by siacs.
the class RtpSessionActivity method initializeActivityWithRunningRtpSession.
private boolean initializeActivityWithRunningRtpSession(final Account account, Jid with, String sessionId) {
final WeakReference<JingleRtpConnection> reference = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
if (reference == null || reference.get() == null) {
final JingleConnectionManager.TerminatedRtpSession terminatedRtpSession = xmppConnectionService.getJingleConnectionManager().getTerminalSessionState(with, sessionId);
if (terminatedRtpSession == null) {
throw new IllegalStateException("failed to initialize activity with running rtp session. session not found");
}
initializeWithTerminatedSessionState(account, with, terminatedRtpSession);
return true;
}
this.rtpConnectionReference = reference;
final RtpEndUserState currentState = requireRtpConnection().getEndUserState();
final boolean verified = requireRtpConnection().isVerified();
if (currentState == RtpEndUserState.ENDED) {
reference.get().throwStateTransitionException();
finish();
return true;
}
final Set<Media> media = getMedia();
if (currentState == RtpEndUserState.INCOMING_CALL) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
if (JingleRtpConnection.STATES_SHOWING_ONGOING_CALL.contains(requireRtpConnection().getState())) {
putScreenInCallMode();
}
binding.with.setText(getWith().getDisplayName());
updateVideoViews(currentState);
updateStateDisplay(currentState, media);
updateVerifiedShield(verified && STATES_SHOWING_SWITCH_TO_CHAT.contains(currentState));
updateButtonConfiguration(currentState, media);
updateProfilePicture(currentState);
invalidateOptionsMenu();
return false;
}
Aggregations