From 5b95b5675d89b2731643d7748a083a34cf878ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Kr=C3=BCger?= Date: Mon, 21 Feb 2022 16:04:42 +0100 Subject: [PATCH] Rename localMediaStream to localStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align naming to the names used in WebRTC example code and documentation. Signed-off-by: Tim Krüger --- .../talk/activities/CallActivity.java | 30 +++++++++---------- .../webrtc/MagicPeerConnectionWrapper.java | 24 +++++++-------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index f203896f4..07ad7da1e 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -213,7 +213,7 @@ public class CallActivity extends CallBaseActivity { private UserEntity conversationUser; private String conversationName; private String callSession; - private MediaStream localMediaStream; + private MediaStream localStream; private String credentials; private List magicPeerConnectionWrapperList = new ArrayList<>(); private Map participantMap = new HashMap<>(); @@ -408,7 +408,7 @@ public class CallActivity extends CallBaseActivity { audioConstraints = new MediaConstraints(); videoConstraints = new MediaConstraints(); - localMediaStream = peerConnectionFactory.createLocalMediaStream("NCMS"); + localStream = peerConnectionFactory.createLocalMediaStream("NCMS"); // Create and audio manager that will take care of audio routing, // audio modes, audio device enumeration etc. @@ -781,7 +781,7 @@ public class CallActivity extends CallBaseActivity { videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver()); } localVideoTrack = peerConnectionFactory.createVideoTrack("NCv0", videoSource); - localMediaStream.addTrack(localVideoTrack); + localStream.addTrack(localVideoTrack); localVideoTrack.setEnabled(false); localVideoTrack.addSink(binding.selfVideoRenderer); } @@ -791,7 +791,7 @@ public class CallActivity extends CallBaseActivity { audioSource = peerConnectionFactory.createAudioSource(audioConstraints); localAudioTrack = peerConnectionFactory.createAudioTrack("NCa0", audioSource); localAudioTrack.setEnabled(false); - localMediaStream.addTrack(localAudioTrack); + localStream.addTrack(localAudioTrack); } private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) { @@ -963,8 +963,8 @@ public class CallActivity extends CallBaseActivity { } } - if (localMediaStream != null && localMediaStream.videoTracks.size() > 0) { - localMediaStream.videoTracks.get(0).setEnabled(enable); + if (localStream != null && localStream.videoTracks.size() > 0) { + localStream.videoTracks.get(0).setEnabled(enable); } if (enable) { binding.selfVideoRenderer.setVisibility(View.VISIBLE); @@ -980,8 +980,8 @@ public class CallActivity extends CallBaseActivity { binding.microphoneButton.setAlpha(0.7f); } - if (localMediaStream != null && localMediaStream.audioTracks.size() > 0) { - localMediaStream.audioTracks.get(0).setEnabled(enable); + if (localStream != null && localStream.audioTracks.size() > 0) { + localStream.audioTracks.get(0).setEnabled(enable); } } @@ -1608,12 +1608,12 @@ public class CallActivity extends CallBaseActivity { peerConnectionFactory = null; } - if(localMediaStream != null) { - localMediaStream.dispose(); - localMediaStream = null; - Log.d(TAG, "Disposed localMediaStream"); + if(localStream != null) { + localStream.dispose(); + localStream = null; + Log.d(TAG, "Disposed localStream"); } else { - Log.d(TAG, "localMediaStream is null"); + Log.d(TAG, "localStream is null"); } localAudioTrack = null; localVideoTrack = null; @@ -1807,7 +1807,7 @@ public class CallActivity extends CallBaseActivity { sdpConstraintsForMCU, sessionId, callSession, - localMediaStream, + localStream, true, true, type); @@ -1829,7 +1829,7 @@ public class CallActivity extends CallBaseActivity { sdpConstraints, sessionId, callSession, - localMediaStream, + localStream, false, false, type); diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java index d8d2f7826..013cefded 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java @@ -81,7 +81,7 @@ public class MagicPeerConnectionWrapper { private boolean hasInitiated; - private MediaStream localMediaStream; + private MediaStream localStream; private boolean isMCUPublisher; private boolean hasMCU; private String videoStreamType; @@ -95,12 +95,12 @@ public class MagicPeerConnectionWrapper { public MagicPeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory, List iceServerList, MediaConstraints sdpConstraints, - String sessionId, String localSession, @Nullable MediaStream mediaStream, + String sessionId, String localSession, @Nullable MediaStream localStream, boolean isMCUPublisher, boolean hasMCU, String videoStreamType) { NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); - this.localMediaStream = mediaStream; + this.localStream = localStream; this.videoStreamType = videoStreamType; this.hasMCU = hasMCU; @@ -116,13 +116,13 @@ public class MagicPeerConnectionWrapper { peerConnection = peerConnectionFactory.createPeerConnection(configuration, new MagicPeerConnectionObserver()); if (peerConnection != null) { - if (localStream != null) { - List localMediaStreamIds = Collections.singletonList(localMediaStream.getId()); - for(AudioTrack track : localMediaStream.audioTracks) { - peerConnection.addTrack(track, localMediaStreamIds); + if (this.localStream != null) { + List localStreamIds = Collections.singletonList(this.localStream.getId()); + for(AudioTrack track : this.localStream.audioTracks) { + peerConnection.addTrack(track, localStreamIds); } - for(VideoTrack track : localStream.videoTracks) { - peerConnection.addTrack(track, localMediaStreamIds); + for(VideoTrack track : this.localStream.videoTracks) { + peerConnection.addTrack(track, localStreamIds); } } @@ -240,14 +240,14 @@ public class MagicPeerConnectionWrapper { } private void sendInitialMediaStatus() { - if (localMediaStream != null) { - if (localMediaStream.videoTracks.size() == 1 && localMediaStream.videoTracks.get(0).enabled()) { + if (localStream != null) { + if (localStream.videoTracks.size() == 1 && localStream.videoTracks.get(0).enabled()) { sendChannelData(new DataChannelMessage("videoOn")); } else { sendChannelData(new DataChannelMessage("videoOff")); } - if (localMediaStream.audioTracks.size() == 1 && localMediaStream.audioTracks.get(0).enabled()) { + if (localStream.audioTracks.size() == 1 && localStream.audioTracks.get(0).enabled()) { sendChannelData(new DataChannelMessage("audioOn")); } else { sendChannelData(new DataChannelMessage("audioOff"));