Search in sources :

Example 1 with Media

use of eu.siacs.conversations.xmpp.jingle.Media in project Conversations by siacs.

the class RtpSessionActivity method retry.

private void retry(View view) {
    final Intent intent = getIntent();
    final Account account = extractAccount(intent);
    final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH));
    final String lastAction = intent.getStringExtra(EXTRA_LAST_ACTION);
    final String action = intent.getAction();
    final Set<Media> media = actionToMedia(lastAction == null ? action : lastAction);
    this.rtpConnectionReference = null;
    Log.d(Config.LOGTAG, "attempting retry with " + with.toEscapedString());
    proposeJingleRtpSession(account, with, media);
}
Also used : Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.Jid) Media(eu.siacs.conversations.xmpp.jingle.Media) Intent(android.content.Intent)

Example 2 with Media

use of eu.siacs.conversations.xmpp.jingle.Media 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 3 with Media

use of eu.siacs.conversations.xmpp.jingle.Media in project Conversations by siacs.

the class MessageGenerator method sessionProposal.

public MessagePacket sessionProposal(final JingleConnectionManager.RtpSessionProposal proposal) {
    final MessagePacket packet = new MessagePacket();
    // we want to carbon copy those
    packet.setType(MessagePacket.TYPE_CHAT);
    packet.setTo(proposal.with);
    packet.setId(JingleRtpConnection.JINGLE_MESSAGE_PROPOSE_ID_PREFIX + proposal.sessionId);
    final Element propose = packet.addChild("propose", Namespace.JINGLE_MESSAGE);
    propose.setAttribute("id", proposal.sessionId);
    for (final Media media : proposal.media) {
        propose.addChild("description", Namespace.JINGLE_APPS_RTP).setAttribute("media", media.toString());
    }
    packet.addChild("request", "urn:xmpp:receipts");
    packet.addChild("store", "urn:xmpp:hints");
    return packet;
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Element(eu.siacs.conversations.xml.Element) Media(eu.siacs.conversations.xmpp.jingle.Media)

Example 4 with Media

use of eu.siacs.conversations.xmpp.jingle.Media 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

Media (eu.siacs.conversations.xmpp.jingle.Media)4 JingleRtpConnection (eu.siacs.conversations.xmpp.jingle.JingleRtpConnection)2 Intent (android.content.Intent)1 Account (eu.siacs.conversations.entities.Account)1 Contact (eu.siacs.conversations.entities.Contact)1 Element (eu.siacs.conversations.xml.Element)1 Jid (eu.siacs.conversations.xmpp.Jid)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 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)1