Search in sources :

Example 1 with JingleRtpConnection

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");
    }
}
Also used : AbstractJingleConnection(eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection) Media(eu.siacs.conversations.xmpp.jingle.Media) JingleRtpConnection(eu.siacs.conversations.xmpp.jingle.JingleRtpConnection) Contact(eu.siacs.conversations.entities.Contact)

Example 2 with JingleRtpConnection

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);
    }
}
Also used : JingleRtpConnection(eu.siacs.conversations.xmpp.jingle.JingleRtpConnection) AppRTCAudioManager(eu.siacs.conversations.services.AppRTCAudioManager) SuppressLint(android.annotation.SuppressLint)

Example 3 with JingleRtpConnection

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);
    }
}
Also used : JingleRtpConnection(eu.siacs.conversations.xmpp.jingle.JingleRtpConnection)

Example 4 with JingleRtpConnection

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();
        }
    }
}
Also used : JingleRtpConnection(eu.siacs.conversations.xmpp.jingle.JingleRtpConnection) AppRTCAudioManager(eu.siacs.conversations.services.AppRTCAudioManager)

Example 5 with JingleRtpConnection

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;
}
Also used : Media(eu.siacs.conversations.xmpp.jingle.Media) JingleRtpConnection(eu.siacs.conversations.xmpp.jingle.JingleRtpConnection) JingleConnectionManager(eu.siacs.conversations.xmpp.jingle.JingleConnectionManager) RtpEndUserState(eu.siacs.conversations.xmpp.jingle.RtpEndUserState)

Aggregations

JingleRtpConnection (eu.siacs.conversations.xmpp.jingle.JingleRtpConnection)6 AppRTCAudioManager (eu.siacs.conversations.services.AppRTCAudioManager)2 Media (eu.siacs.conversations.xmpp.jingle.Media)2 SuppressLint (android.annotation.SuppressLint)1 Contact (eu.siacs.conversations.entities.Contact)1 AbstractJingleConnection (eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection)1 JingleConnectionManager (eu.siacs.conversations.xmpp.jingle.JingleConnectionManager)1 RtpEndUserState (eu.siacs.conversations.xmpp.jingle.RtpEndUserState)1