use of eu.siacs.conversations.xmpp.jingle.RtpEndUserState in project Conversations by siacs.
the class RtpSessionActivity method initializeWithTerminatedSessionState.
private void initializeWithTerminatedSessionState(final Account account, final Jid with, final JingleConnectionManager.TerminatedRtpSession terminatedRtpSession) {
Log.d(Config.LOGTAG, "initializeWithTerminatedSessionState()");
if (terminatedRtpSession.state == RtpEndUserState.ENDED) {
finish();
return;
}
RtpEndUserState state = terminatedRtpSession.state;
resetIntent(account, with, terminatedRtpSession.state, terminatedRtpSession.media);
updateButtonConfiguration(state);
updateStateDisplay(state);
updateProfilePicture(state);
updateCallDuration();
updateVerifiedShield(false);
invalidateOptionsMenu();
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
}
use of eu.siacs.conversations.xmpp.jingle.RtpEndUserState in project Conversations by siacs.
the class RtpSessionActivity method onBackendConnected.
@Override
void onBackendConnected() {
final Intent intent = getIntent();
final String action = intent.getAction();
final Account account = extractAccount(intent);
final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH));
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
if (sessionId != null) {
if (initializeActivityWithRunningRtpSession(account, with, sessionId)) {
return;
}
if (ACTION_ACCEPT_CALL.equals(intent.getAction())) {
Log.d(Config.LOGTAG, "intent action was accept");
requestPermissionsAndAcceptCall();
resetIntent(intent.getExtras());
}
} else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(action)) {
proposeJingleRtpSession(account, with, actionToMedia(action));
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
} else if (Intent.ACTION_VIEW.equals(action)) {
final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
final RtpEndUserState state = extraLastState == null ? null : RtpEndUserState.valueOf(extraLastState);
if (state != null) {
Log.d(Config.LOGTAG, "restored last state from intent extra");
updateButtonConfiguration(state);
updateVerifiedShield(false);
updateStateDisplay(state);
updateProfilePicture(state);
invalidateOptionsMenu();
}
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
if (xmppConnectionService.getJingleConnectionManager().fireJingleRtpConnectionStateUpdates()) {
return;
}
if (END_CARD.contains(state) || xmppConnectionService.getJingleConnectionManager().hasMatchingProposal(account, with)) {
return;
}
Log.d(Config.LOGTAG, "restored state (" + state + ") was not an end card. finishing");
finish();
}
}
use of eu.siacs.conversations.xmpp.jingle.RtpEndUserState in project Conversations by siacs.
the class RtpSessionActivity method onAudioDeviceChanged.
@Override
public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
Log.d(Config.LOGTAG, "onAudioDeviceChanged in activity: selected:" + selectedAudioDevice + ", available:" + availableAudioDevices);
try {
if (getMedia().contains(Media.VIDEO)) {
Log.d(Config.LOGTAG, "nothing to do; in video mode");
return;
}
final RtpEndUserState endUserState = requireRtpConnection().getEndUserState();
if (endUserState == RtpEndUserState.CONNECTED) {
final AppRTCAudioManager audioManager = requireRtpConnection().getAudioManager();
updateInCallButtonConfigurationSpeaker(audioManager.getSelectedAudioDevice(), audioManager.getAudioDevices().size());
} else if (END_CARD.contains(endUserState)) {
Log.d(Config.LOGTAG, "onAudioDeviceChanged() nothing to do because end card has been reached");
} else {
putProximityWakeLockInProperState(selectedAudioDevice);
}
} catch (IllegalStateException e) {
Log.d(Config.LOGTAG, "RTP connection was not available when audio device changed");
}
}
use of eu.siacs.conversations.xmpp.jingle.RtpEndUserState 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