Change summary
src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java | 50
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java | 8
src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java | 4
3 files changed, 38 insertions(+), 24 deletions(-)
Detailed changes
@@ -25,6 +25,7 @@ import org.webrtc.VideoTrack;
import java.lang.ref.WeakReference;
import java.util.Arrays;
+import java.util.List;
import java.util.Set;
import eu.siacs.conversations.Config;
@@ -108,7 +109,13 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
}
private void requestPermissionsAndAcceptCall() {
- if (PermissionUtils.hasPermission(this, ImmutableList.of(Manifest.permission.RECORD_AUDIO), REQUEST_ACCEPT_CALL)) {
+ final List<String> permissions;
+ if (getMedia().contains(Media.VIDEO)) {
+ permissions = ImmutableList.of(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO);
+ } else {
+ permissions = ImmutableList.of(Manifest.permission.RECORD_AUDIO);
+ }
+ if (PermissionUtils.hasPermission(this, permissions, REQUEST_ACCEPT_CALL)) {
//TODO like wise the propose; we might just wait here for the audio manager to come up
putScreenInCallMode();
requireRtpConnection().acceptCall();
@@ -285,6 +292,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
putScreenInCallMode();
}
binding.with.setText(getWith().getDisplayName());
+ updateVideoViews();
updateStateDisplay(currentState);
updateButtonConfiguration(currentState);
}
@@ -300,26 +308,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
setIntent(intent);
}
- private void updateVideoViews() {
- final Optional<VideoTrack> localVideoTrack = requireRtpConnection().geLocalVideoTrack();
- if (localVideoTrack.isPresent()) {
- ensureSurfaceViewRendererIsSetup(binding.localVideo);
- //paint local view over remote view
- binding.localVideo.setZOrderMediaOverlay(true);
- binding.localVideo.setMirror(true);
- localVideoTrack.get().addSink(binding.localVideo);
- } else {
- binding.localVideo.setVisibility(View.GONE);
- }
- final Optional<VideoTrack> remoteVideoTrack = requireRtpConnection().getRemoteVideoTrack();
- if (remoteVideoTrack.isPresent()) {
- ensureSurfaceViewRendererIsSetup(binding.remoteVideo);
- remoteVideoTrack.get().addSink(binding.remoteVideo);
- } else {
- binding.remoteVideo.setVisibility(View.GONE);
- }
- }
-
private void ensureSurfaceViewRendererIsSetup(final SurfaceViewRenderer surfaceViewRenderer) {
surfaceViewRenderer.setVisibility(View.VISIBLE);
try {
@@ -477,6 +465,26 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
this.binding.inCallActionRight.setVisibility(View.VISIBLE);
}
+ private void updateVideoViews() {
+ final Optional<VideoTrack> localVideoTrack = requireRtpConnection().geLocalVideoTrack();
+ if (localVideoTrack.isPresent()) {
+ ensureSurfaceViewRendererIsSetup(binding.localVideo);
+ //paint local view over remote view
+ binding.localVideo.setZOrderMediaOverlay(true);
+ binding.localVideo.setMirror(true);
+ localVideoTrack.get().addSink(binding.localVideo);
+ } else {
+ binding.localVideo.setVisibility(View.GONE);
+ }
+ final Optional<VideoTrack> remoteVideoTrack = requireRtpConnection().getRemoteVideoTrack();
+ if (remoteVideoTrack.isPresent()) {
+ ensureSurfaceViewRendererIsSetup(binding.remoteVideo);
+ remoteVideoTrack.get().addSink(binding.remoteVideo);
+ } else {
+ binding.remoteVideo.setVisibility(View.GONE);
+ }
+ }
+
private void disableMicrophone(View view) {
JingleRtpConnection rtpConnection = requireRtpConnection();
rtpConnection.setMicrophoneEnabled(false);
@@ -820,7 +820,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
private void setupWebRTC(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws WebRTCWrapper.InitializationException {
- this.webRTCWrapper.setup(this.xmppConnectionService);
+ final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference;
+ if (media.contains(Media.VIDEO)) {
+ speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.SPEAKER;
+ } else {
+ speakerPhonePreference = AppRTCAudioManager.SpeakerPhonePreference.EARPIECE;
+ }
+ this.webRTCWrapper.setup(this.xmppConnectionService, speakerPhonePreference);
this.webRTCWrapper.initializePeerConnection(media, iceServers);
}
@@ -145,14 +145,14 @@ public class WebRTCWrapper {
this.eventCallback = eventCallback;
}
- public void setup(final Context context) {
+ public void setup(final Context context, final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference) {
PeerConnectionFactory.initialize(
PeerConnectionFactory.InitializationOptions.builder(context).createInitializationOptions()
);
this.eglBase = EglBase.create();
this.context = context;
mainHandler.post(() -> {
- appRTCAudioManager = AppRTCAudioManager.create(context, AppRTCAudioManager.SpeakerPhonePreference.EARPIECE);
+ appRTCAudioManager = AppRTCAudioManager.create(context, speakerPhonePreference);
appRTCAudioManager.start(audioManagerEvents);
eventCallback.onAudioDeviceChanged(appRTCAudioManager.getSelectedAudioDevice(), appRTCAudioManager.getAudioDevices());
});