|
@@ -445,12 +445,12 @@ public class CallController extends BaseController {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new Observer<RoomsOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(RoomsOverall roomsOverall) {
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull RoomsOverall roomsOverall) {
|
|
|
for (Conversation conversation : roomsOverall.getOcs().getData()) {
|
|
|
if (roomId.equals(conversation.getRoomId())) {
|
|
|
roomToken = conversation.getToken();
|
|
@@ -462,13 +462,13 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -500,7 +500,6 @@ public class CallController extends BaseController {
|
|
|
pipVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
|
|
|
|
|
pipVideoView.setOnTouchListener(new SelfVideoTouchListener());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
gridView.setOnTouchListener(new View.OnTouchListener() {
|
|
@@ -942,17 +941,16 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isConnectionEstablished()) {
|
|
|
+ if (isConnectionEstablished() && magicPeerConnectionWrapperList != null) {
|
|
|
if (!hasMCU) {
|
|
|
- for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) {
|
|
|
- magicPeerConnectionWrapperList.get(i).sendChannelData(new DataChannelMessage(message));
|
|
|
+ for (MagicPeerConnectionWrapper magicPeerConnectionWrapper : magicPeerConnectionWrapperList) {
|
|
|
+ magicPeerConnectionWrapper.sendChannelData(new DataChannelMessage(message));
|
|
|
}
|
|
|
} else {
|
|
|
- for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) {
|
|
|
- if (magicPeerConnectionWrapperList.get(i).getSessionId().equals(webSocketClient.getSessionId())) {
|
|
|
- magicPeerConnectionWrapperList.get(i).sendChannelData(new DataChannelMessage(message));
|
|
|
+ for (MagicPeerConnectionWrapper magicPeerConnectionWrapper : magicPeerConnectionWrapperList) {
|
|
|
+ if (magicPeerConnectionWrapper.getSessionId().equals(webSocketClient.getSessionId())) {
|
|
|
+ magicPeerConnectionWrapper.sendChannelData(new DataChannelMessage(message));
|
|
|
break;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1103,13 +1101,12 @@ public class CallController extends BaseController {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new Observer<SignalingSettingsOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(SignalingSettingsOverall signalingSettingsOverall) {
|
|
|
- IceServer iceServer;
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull SignalingSettingsOverall signalingSettingsOverall) {
|
|
|
if (signalingSettingsOverall != null && signalingSettingsOverall.getOcs() != null &&
|
|
|
signalingSettingsOverall.getOcs().getSettings() != null) {
|
|
|
|
|
@@ -1142,36 +1139,38 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (apiVersion == ApiUtils.APIv3) {
|
|
|
- if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
|
|
- for (int i = 0; i < signalingSettingsOverall.getOcs().getSettings().getStunServers().size();
|
|
|
- i++) {
|
|
|
- iceServer = signalingSettingsOverall.getOcs().getSettings().getStunServers().get(i);
|
|
|
- for (int j = 0; j < iceServer.getUrls().size(); j++) {
|
|
|
- iceServers.add(new PeerConnection.IceServer(iceServer.getUrls().get(j)));
|
|
|
+ if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
|
|
+ List<IceServer> stunServers =
|
|
|
+ signalingSettingsOverall.getOcs().getSettings().getStunServers();
|
|
|
+ if (apiVersion == ApiUtils.APIv3) {
|
|
|
+ if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
|
|
+ for (IceServer stunServer : stunServers) {
|
|
|
+ if (stunServer.getUrls() != null) {
|
|
|
+ for (String url : stunServer.getUrls()) {
|
|
|
+ iceServers.add(new PeerConnection.IceServer(url));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
|
|
- for (int i = 0; i < signalingSettingsOverall.getOcs().getSettings().getStunServers().size();
|
|
|
- i++) {
|
|
|
- iceServer = signalingSettingsOverall.getOcs().getSettings().getStunServers().get(i);
|
|
|
- iceServers.add(new PeerConnection.IceServer(iceServer.getUrl()));
|
|
|
+ } else {
|
|
|
+ if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
|
|
+ for (IceServer stunServer : stunServers) {
|
|
|
+ iceServers.add(new PeerConnection.IceServer(stunServer.getUrl()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (signalingSettingsOverall.getOcs().getSettings().getTurnServers() != null) {
|
|
|
- for (int i = 0; i < signalingSettingsOverall.getOcs().getSettings().getTurnServers().size();
|
|
|
- i++) {
|
|
|
- iceServer = signalingSettingsOverall.getOcs().getSettings().getTurnServers().get(i);
|
|
|
- for (int j = 0; j < iceServer.getUrls().size(); j++) {
|
|
|
- iceServers.add(new PeerConnection.IceServer(
|
|
|
- iceServer.getUrls().get(j),
|
|
|
- iceServer.getUsername(),
|
|
|
- iceServer.getCredential()
|
|
|
- ));
|
|
|
+ List<IceServer> turnServers =
|
|
|
+ signalingSettingsOverall.getOcs().getSettings().getTurnServers();
|
|
|
+ for (IceServer turnServer : turnServers) {
|
|
|
+ if (turnServer.getUrls() != null) {
|
|
|
+ for (String url : turnServer.getUrls()) {
|
|
|
+ iceServers.add(new PeerConnection.IceServer(
|
|
|
+ url, turnServer.getUsername(), turnServer.getCredential()
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1181,13 +1180,13 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
Log.e(TAG, e.getMessage(), e);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1199,12 +1198,12 @@ public class CallController extends BaseController {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new Observer<CapabilitiesOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(CapabilitiesOverall capabilitiesOverall) {
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull CapabilitiesOverall capabilitiesOverall) {
|
|
|
// FIXME check for compatible Call API version
|
|
|
if (hasExternalSignalingServer) {
|
|
|
setupAndInitiateWebSocketsConnection();
|
|
@@ -1214,13 +1213,13 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1238,12 +1237,12 @@ public class CallController extends BaseController {
|
|
|
.retry(3)
|
|
|
.subscribe(new Observer<RoomOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(RoomOverall roomOverall) {
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull RoomOverall roomOverall) {
|
|
|
callSession = roomOverall.getOcs().getData().getSessionId();
|
|
|
ApplicationWideCurrentRoomHolder.getInstance().setSession(callSession);
|
|
|
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
|
|
@@ -1253,13 +1252,13 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
-
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
@@ -1292,27 +1291,31 @@ public class CallController extends BaseController {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new Observer<GenericOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(GenericOverall genericOverall) {
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
|
|
|
if (!currentCallStatus.equals(CallStatus.LEAVING)) {
|
|
|
setCallState(CallStatus.JOINED);
|
|
|
|
|
|
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
|
|
|
|
|
|
if (!TextUtils.isEmpty(roomToken)) {
|
|
|
- NotificationUtils.INSTANCE.cancelExistingNotificationsForRoom(getApplicationContext(), conversationUser, roomToken);
|
|
|
+ NotificationUtils.INSTANCE.cancelExistingNotificationsForRoom(getApplicationContext(),
|
|
|
+ conversationUser,
|
|
|
+ roomToken);
|
|
|
}
|
|
|
|
|
|
if (!hasExternalSignalingServer) {
|
|
|
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser,
|
|
|
new int[] {ApiUtils.APIv3, 2, 1});
|
|
|
|
|
|
- ncApi.pullSignalingMessages(credentials, ApiUtils.getUrlForSignaling(apiVersion,
|
|
|
- baseUrl, roomToken))
|
|
|
+ ncApi.pullSignalingMessages(credentials,
|
|
|
+ ApiUtils.getUrlForSignaling(apiVersion,
|
|
|
+ baseUrl,
|
|
|
+ roomToken))
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.repeatWhen(observable -> observable)
|
|
@@ -1320,26 +1323,19 @@ public class CallController extends BaseController {
|
|
|
.retry(3, observable -> isConnectionEstablished())
|
|
|
.subscribe(new Observer<SignalingOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
signalingDisposable = d;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(SignalingOverall signalingOverall) {
|
|
|
- if (signalingOverall.getOcs().getSignalings() != null) {
|
|
|
- for (int i = 0; i < signalingOverall.getOcs().getSignalings().size(); i++) {
|
|
|
- try {
|
|
|
- receivedSignalingMessage(signalingOverall.getOcs().getSignalings().get(i));
|
|
|
- } catch (IOException e) {
|
|
|
- Log.e(TAG, "Failed to process received signaling" +
|
|
|
- " message");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ public void onNext(
|
|
|
+ @io.reactivex.annotations.NonNull
|
|
|
+ SignalingOverall signalingOverall) {
|
|
|
+ receivedSignalingMessages(signalingOverall.getOcs().getSignalings());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
dispose(signalingDisposable);
|
|
|
}
|
|
|
|
|
@@ -1348,19 +1344,18 @@ public class CallController extends BaseController {
|
|
|
dispose(signalingDisposable);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1402,7 +1397,6 @@ public class CallController extends BaseController {
|
|
|
} else {
|
|
|
initiateCall();
|
|
|
}
|
|
|
- } else {
|
|
|
}
|
|
|
break;
|
|
|
case "roomJoined":
|
|
@@ -1414,14 +1408,19 @@ public class CallController extends BaseController {
|
|
|
break;
|
|
|
case "participantsUpdate":
|
|
|
if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) {
|
|
|
- processUsersInRoom((List<HashMap<String, Object>>) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
|
|
+ processUsersInRoom(
|
|
|
+ (List<HashMap<String, Object>>) webSocketClient
|
|
|
+ .getJobWithId(
|
|
|
+ Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
|
|
}
|
|
|
break;
|
|
|
case "signalingMessage":
|
|
|
- processMessage((NCSignalingMessage) webSocketClient.getJobWithId(Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
|
|
+ processMessage((NCSignalingMessage) webSocketClient.getJobWithId(
|
|
|
+ Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
|
|
break;
|
|
|
case "peerReadyForRequestingOffer":
|
|
|
- webSocketClient.requestOfferForSessionIdWithType(webSocketCommunicationEvent.getHashMap().get("sessionId"), "video");
|
|
|
+ webSocketClient.requestOfferForSessionIdWithType(
|
|
|
+ webSocketCommunicationEvent.getHashMap().get("sessionId"), "video");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1442,6 +1441,18 @@ public class CallController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void receivedSignalingMessages(@Nullable List<Signaling> signalingList) {
|
|
|
+ if (signalingList != null) {
|
|
|
+ for (Signaling signaling : signalingList) {
|
|
|
+ try {
|
|
|
+ receivedSignalingMessage(signaling);
|
|
|
+ } catch (IOException e) {
|
|
|
+ Log.e(TAG, "Failed to process received signaling message", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void receivedSignalingMessage(Signaling signaling) throws IOException {
|
|
|
String messageType = signaling.getType();
|
|
|
|
|
@@ -2013,31 +2024,23 @@ public class CallController extends BaseController {
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.subscribe(new Observer<SignalingOverall>() {
|
|
|
@Override
|
|
|
- public void onSubscribe(Disposable d) {
|
|
|
-
|
|
|
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
|
|
+ // unused atm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onNext(SignalingOverall signalingOverall) {
|
|
|
- if (signalingOverall.getOcs().getSignalings() != null) {
|
|
|
- for (int i = 0; i < signalingOverall.getOcs().getSignalings().size(); i++) {
|
|
|
- try {
|
|
|
- receivedSignalingMessage(signalingOverall.getOcs().getSignalings().get(i));
|
|
|
- } catch (IOException e) {
|
|
|
- Log.e(TAG, "", e);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ public void onNext(@io.reactivex.annotations.NonNull SignalingOverall signalingOverall) {
|
|
|
+ receivedSignalingMessages(signalingOverall.getOcs().getSignalings());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(Throwable e) {
|
|
|
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
|
|
Log.e(TAG, "", e);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete() {
|
|
|
-
|
|
|
+ // unused atm
|
|
|
}
|
|
|
});
|
|
|
} else {
|