mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
Migrate WebRTC from plan b to unified plan
The in 'MagicPeerConnectionWrapper#removePeerConnection' used method 'PeerConnection#removeStream' was not longer available in the unified plan. So to make sure that the local stream is disposed, it will now be done in 'CallActivity#hangup'. Resolves: #1773 See: [1] [1] https://webrtc.org/getting-started/unified-plan-transition-guide Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
bad5b5f9bc
commit
86f20dcfd3
2 changed files with 29 additions and 12 deletions
|
@ -1608,7 +1608,13 @@ public class CallActivity extends CallBaseActivity {
|
|||
peerConnectionFactory = null;
|
||||
}
|
||||
|
||||
if(localMediaStream != null) {
|
||||
localMediaStream.dispose();
|
||||
localMediaStream = null;
|
||||
Log.d(TAG, "Disposed localMediaStream");
|
||||
} else {
|
||||
Log.d(TAG, "localMediaStream is null");
|
||||
}
|
||||
localAudioTrack = null;
|
||||
localVideoTrack = null;
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Tim Krüger
|
||||
* Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
|
||||
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -37,6 +39,7 @@ import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
|||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.webrtc.AudioTrack;
|
||||
import org.webrtc.DataChannel;
|
||||
import org.webrtc.IceCandidate;
|
||||
import org.webrtc.MediaConstraints;
|
||||
|
@ -46,10 +49,12 @@ import org.webrtc.PeerConnectionFactory;
|
|||
import org.webrtc.RtpReceiver;
|
||||
import org.webrtc.SdpObserver;
|
||||
import org.webrtc.SessionDescription;
|
||||
import org.webrtc.VideoTrack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -60,7 +65,7 @@ import autodagger.AutoInjector;
|
|||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class MagicPeerConnectionWrapper {
|
||||
private static final String TAG = "MagicPeerConWrapper";
|
||||
private static final String TAG = MagicPeerConnectionWrapper.class.getCanonicalName();
|
||||
|
||||
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||
private PeerConnection peerConnection;
|
||||
|
@ -107,14 +112,18 @@ public class MagicPeerConnectionWrapper {
|
|||
this.isMCUPublisher = isMCUPublisher;
|
||||
|
||||
PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServerList);
|
||||
configuration.sdpSemantics = PeerConnection.SdpSemantics.PLAN_B;
|
||||
|
||||
peerConnection = peerConnectionFactory.createPeerConnection(configuration, sdpConstraints,
|
||||
new MagicPeerConnectionObserver());
|
||||
configuration.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
||||
peerConnection = peerConnectionFactory.createPeerConnection(configuration, new MagicPeerConnectionObserver());
|
||||
|
||||
if (peerConnection != null) {
|
||||
if (localMediaStream != null) {
|
||||
peerConnection.addStream(localMediaStream);
|
||||
if (localStream != null) {
|
||||
List<String> localMediaStreamIds = Collections.singletonList(localMediaStream.getId());
|
||||
for(AudioTrack track : localMediaStream.audioTracks) {
|
||||
peerConnection.addTrack(track, localMediaStreamIds);
|
||||
}
|
||||
for(VideoTrack track : localStream.videoTracks) {
|
||||
peerConnection.addTrack(track, localMediaStreamIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMCU || hasInitiated) {
|
||||
|
@ -145,15 +154,17 @@ public class MagicPeerConnectionWrapper {
|
|||
if (magicDataChannel != null) {
|
||||
magicDataChannel.dispose();
|
||||
magicDataChannel = null;
|
||||
Log.d(TAG, "Disposed DataChannel");
|
||||
} else {
|
||||
Log.d(TAG, "DataChannel is null.");
|
||||
}
|
||||
|
||||
if (peerConnection != null) {
|
||||
if (localMediaStream != null) {
|
||||
peerConnection.removeStream(localMediaStream);
|
||||
}
|
||||
|
||||
peerConnection.close();
|
||||
peerConnection = null;
|
||||
Log.d(TAG, "Disposed PeerConnection");
|
||||
} else {
|
||||
Log.d(TAG, "PeerConnection is null.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue