Search in sources :

Example 1 with AppRTCAudioManager

use of eu.siacs.conversations.services.AppRTCAudioManager in project Conversations by siacs.

the class WebRTCWrapper method close.

synchronized void close() {
    final PeerConnection peerConnection = this.peerConnection;
    final CapturerChoice capturerChoice = this.capturerChoice;
    final AppRTCAudioManager audioManager = this.appRTCAudioManager;
    final EglBase eglBase = this.eglBase;
    if (peerConnection != null) {
        dispose(peerConnection);
        this.peerConnection = null;
    }
    if (audioManager != null) {
        toneManager.setAppRtcAudioManagerHasControl(false);
        mainHandler.post(audioManager::stop);
    }
    this.localVideoTrack = null;
    this.remoteVideoTrack = null;
    if (capturerChoice != null) {
        try {
            capturerChoice.cameraVideoCapturer.stopCapture();
        } catch (InterruptedException e) {
            Log.e(Config.LOGTAG, "unable to stop capturing");
        }
    }
    if (eglBase != null) {
        eglBase.release();
        this.eglBase = null;
    }
}
Also used : PeerConnection(org.webrtc.PeerConnection) EglBase(org.webrtc.EglBase) AppRTCAudioManager(eu.siacs.conversations.services.AppRTCAudioManager)

Example 2 with AppRTCAudioManager

use of eu.siacs.conversations.services.AppRTCAudioManager 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 AppRTCAudioManager

use of eu.siacs.conversations.services.AppRTCAudioManager 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 4 with AppRTCAudioManager

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

Aggregations

AppRTCAudioManager (eu.siacs.conversations.services.AppRTCAudioManager)4 JingleRtpConnection (eu.siacs.conversations.xmpp.jingle.JingleRtpConnection)2 SuppressLint (android.annotation.SuppressLint)1 RtpEndUserState (eu.siacs.conversations.xmpp.jingle.RtpEndUserState)1 EglBase (org.webrtc.EglBase)1 PeerConnection (org.webrtc.PeerConnection)1