mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
Use temporary SignalingMessageReceiver implementation in CallActivity
Eventually all signaling related code should be moved to a Signaling class that abstracts the differences between the internal and external signaling servers, including how messages are sent and listened to. In the meantime a temporary SignalingMessageReceiver implementation is added to CallActivity to be able to start using it. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
45787caf0a
commit
476fb59a08
@ -78,7 +78,6 @@ import com.nextcloud.talk.models.json.participants.Participant;
|
|||||||
import com.nextcloud.talk.models.json.participants.ParticipantsOverall;
|
import com.nextcloud.talk.models.json.participants.ParticipantsOverall;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
|
||||||
import com.nextcloud.talk.models.json.signaling.NCMessagePayload;
|
import com.nextcloud.talk.models.json.signaling.NCMessagePayload;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||||
@ -86,6 +85,7 @@ import com.nextcloud.talk.models.json.signaling.Signaling;
|
|||||||
import com.nextcloud.talk.models.json.signaling.SignalingOverall;
|
import com.nextcloud.talk.models.json.signaling.SignalingOverall;
|
||||||
import com.nextcloud.talk.models.json.signaling.settings.IceServer;
|
import com.nextcloud.talk.models.json.signaling.settings.IceServer;
|
||||||
import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
|
import com.nextcloud.talk.models.json.signaling.settings.SignalingSettingsOverall;
|
||||||
|
import com.nextcloud.talk.signaling.SignalingMessageReceiver;
|
||||||
import com.nextcloud.talk.ui.dialog.AudioOutputDialog;
|
import com.nextcloud.talk.ui.dialog.AudioOutputDialog;
|
||||||
import com.nextcloud.talk.users.UserManager;
|
import com.nextcloud.talk.users.UserManager;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
@ -264,6 +264,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
private SpotlightView spotlightView;
|
private SpotlightView spotlightView;
|
||||||
|
|
||||||
|
private CallActivitySignalingMessageReceiver signalingMessageReceiver = new CallActivitySignalingMessageReceiver();
|
||||||
|
|
||||||
private ExternalSignalingServer externalSignalingServer;
|
private ExternalSignalingServer externalSignalingServer;
|
||||||
private MagicWebSocketInstance webSocketClient;
|
private MagicWebSocketInstance webSocketClient;
|
||||||
private WebSocketConnectionHelper webSocketConnectionHelper;
|
private WebSocketConnectionHelper webSocketConnectionHelper;
|
||||||
@ -1670,44 +1672,12 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerConnectionWrapper peerConnectionWrapper = null;
|
|
||||||
|
|
||||||
if ("offer".equals(type)) {
|
if ("offer".equals(type)) {
|
||||||
peerConnectionWrapper =
|
|
||||||
getOrCreatePeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
|
getOrCreatePeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
|
||||||
ncSignalingMessage.getRoomType(), false);
|
ncSignalingMessage.getRoomType(), false);
|
||||||
} else {
|
|
||||||
peerConnectionWrapper =
|
|
||||||
getPeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
|
|
||||||
ncSignalingMessage.getRoomType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peerConnectionWrapper == null) {
|
signalingMessageReceiver.process(ncSignalingMessage);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sdp = ncSignalingMessage.getPayload().getSdp();
|
|
||||||
String nick = ncSignalingMessage.getPayload().getNick();
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case "offer":
|
|
||||||
peerConnectionWrapper.getWebRtcMessageListener().onOffer(sdp, nick);
|
|
||||||
break;
|
|
||||||
case "answer":
|
|
||||||
peerConnectionWrapper.getWebRtcMessageListener().onAnswer(sdp, nick);
|
|
||||||
break;
|
|
||||||
case "candidate":
|
|
||||||
NCIceCandidate ncIceCandidate = ncSignalingMessage.getPayload().getIceCandidate();
|
|
||||||
peerConnectionWrapper.getWebRtcMessageListener().onCandidate(ncIceCandidate.getSdpMid(),
|
|
||||||
ncIceCandidate.getSdpMLineIndex(),
|
|
||||||
ncIceCandidate.getCandidate());
|
|
||||||
break;
|
|
||||||
case "endOfCandidates":
|
|
||||||
peerConnectionWrapper.getWebRtcMessageListener().onEndOfCandidates();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "unexpected RoomType while processing NCSignalingMessage");
|
Log.e(TAG, "unexpected RoomType while processing NCSignalingMessage");
|
||||||
}
|
}
|
||||||
@ -2010,7 +1980,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
localStream,
|
localStream,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
type);
|
type,
|
||||||
|
signalingMessageReceiver);
|
||||||
|
|
||||||
} else if (hasMCU) {
|
} else if (hasMCU) {
|
||||||
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
||||||
@ -2021,7 +1992,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
type);
|
type,
|
||||||
|
signalingMessageReceiver);
|
||||||
} else {
|
} else {
|
||||||
if (!"screen".equals(type)) {
|
if (!"screen".equals(type)) {
|
||||||
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
||||||
@ -2032,7 +2004,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
localStream,
|
localStream,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
type);
|
type,
|
||||||
|
signalingMessageReceiver);
|
||||||
} else {
|
} else {
|
||||||
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
peerConnectionWrapper = new PeerConnectionWrapper(peerConnectionFactory,
|
||||||
iceServers,
|
iceServers,
|
||||||
@ -2042,7 +2015,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
type);
|
type,
|
||||||
|
signalingMessageReceiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2653,6 +2627,15 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary implementation of SignalingMessageReceiver until signaling related code is extracted from CallActivity.
|
||||||
|
*/
|
||||||
|
private static class CallActivitySignalingMessageReceiver extends SignalingMessageReceiver {
|
||||||
|
public void process(NCSignalingMessage message) {
|
||||||
|
processSignalingMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MicrophoneButtonTouchListener implements View.OnTouchListener {
|
private class MicrophoneButtonTouchListener implements View.OnTouchListener {
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
@ -37,6 +37,7 @@ import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
|||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||||
|
import com.nextcloud.talk.signaling.SignalingMessageReceiver;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.webrtc.AudioTrack;
|
import org.webrtc.AudioTrack;
|
||||||
@ -74,6 +75,7 @@ public class PeerConnectionWrapper {
|
|||||||
|
|
||||||
private static final String TAG = PeerConnectionWrapper.class.getCanonicalName();
|
private static final String TAG = PeerConnectionWrapper.class.getCanonicalName();
|
||||||
|
|
||||||
|
private final SignalingMessageReceiver signalingMessageReceiver;
|
||||||
private final WebRtcMessageListener webRtcMessageListener = new WebRtcMessageListener();
|
private final WebRtcMessageListener webRtcMessageListener = new WebRtcMessageListener();
|
||||||
|
|
||||||
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||||
@ -98,7 +100,8 @@ public class PeerConnectionWrapper {
|
|||||||
List<PeerConnection.IceServer> iceServerList,
|
List<PeerConnection.IceServer> iceServerList,
|
||||||
MediaConstraints mediaConstraints,
|
MediaConstraints mediaConstraints,
|
||||||
String sessionId, String localSession, @Nullable MediaStream localStream,
|
String sessionId, String localSession, @Nullable MediaStream localStream,
|
||||||
boolean isMCUPublisher, boolean hasMCU, String videoStreamType) {
|
boolean isMCUPublisher, boolean hasMCU, String videoStreamType,
|
||||||
|
SignalingMessageReceiver signalingMessageReceiver) {
|
||||||
|
|
||||||
Objects.requireNonNull(NextcloudTalkApplication.Companion.getSharedApplication()).getComponentApplication().inject(this);
|
Objects.requireNonNull(NextcloudTalkApplication.Companion.getSharedApplication()).getComponentApplication().inject(this);
|
||||||
|
|
||||||
@ -116,6 +119,9 @@ public class PeerConnectionWrapper {
|
|||||||
configuration.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
configuration.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
||||||
peerConnection = peerConnectionFactory.createPeerConnection(configuration, new MagicPeerConnectionObserver());
|
peerConnection = peerConnectionFactory.createPeerConnection(configuration, new MagicPeerConnectionObserver());
|
||||||
|
|
||||||
|
this.signalingMessageReceiver = signalingMessageReceiver;
|
||||||
|
this.signalingMessageReceiver.addListener(webRtcMessageListener, sessionId, videoStreamType);
|
||||||
|
|
||||||
if (peerConnection != null) {
|
if (peerConnection != null) {
|
||||||
if (this.localStream != null) {
|
if (this.localStream != null) {
|
||||||
List<String> localStreamIds = Collections.singletonList(this.localStream.getId());
|
List<String> localStreamIds = Collections.singletonList(this.localStream.getId());
|
||||||
@ -152,6 +158,8 @@ public class PeerConnectionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removePeerConnection() {
|
public void removePeerConnection() {
|
||||||
|
signalingMessageReceiver.removeListener(webRtcMessageListener);
|
||||||
|
|
||||||
if (dataChannel != null) {
|
if (dataChannel != null) {
|
||||||
dataChannel.dispose();
|
dataChannel.dispose();
|
||||||
dataChannel = null;
|
dataChannel = null;
|
||||||
@ -261,11 +269,7 @@ public class PeerConnectionWrapper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebRtcMessageListener getWebRtcMessageListener() {
|
private class WebRtcMessageListener implements SignalingMessageReceiver.WebRtcMessageListener {
|
||||||
return webRtcMessageListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WebRtcMessageListener {
|
|
||||||
|
|
||||||
public void onOffer(String sdp, String nick) {
|
public void onOffer(String sdp, String nick) {
|
||||||
onOfferOrAnswer("offer", sdp, nick);
|
onOfferOrAnswer("offer", sdp, nick);
|
||||||
|
Loading…
Reference in New Issue
Block a user