Rename localMediaStream to localStream

Align naming to the names used in WebRTC example code and documentation.

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-02-21 16:04:42 +01:00
parent 86f20dcfd3
commit 5b95b5675d
No known key found for this signature in database
GPG key ID: FECE3A7222C52A4E
2 changed files with 27 additions and 27 deletions

View file

@ -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<MagicPeerConnectionWrapper> magicPeerConnectionWrapperList = new ArrayList<>();
private Map<String, Participant> 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);

View file

@ -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<PeerConnection.IceServer> 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<String> localMediaStreamIds = Collections.singletonList(localMediaStream.getId());
for(AudioTrack track : localMediaStream.audioTracks) {
peerConnection.addTrack(track, localMediaStreamIds);
if (this.localStream != null) {
List<String> 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"));