Add support for signaling v3

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-14 15:17:50 +02:00 committed by Andy Scherzinger
parent c97df9a435
commit de6683815a
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
6 changed files with 39 additions and 25 deletions

View file

@ -1095,7 +1095,7 @@ public class CallController extends BaseController {
}
private void fetchSignalingSettings() {
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, new int[] {2, 1});
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, new int[] {ApiUtils.APIv3, 2, 1});
ncApi.getSignalingSettings(credentials, ApiUtils.getUrlForSignalingSettings(apiVersion, baseUrl))
.subscribeOn(Schedulers.io())
@ -1142,16 +1142,22 @@ public class CallController extends BaseController {
}
}
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
for (int i = 0; i < signalingSettingsOverall.getOcs().getSettings().getStunServers().size();
i++) {
iceServer = signalingSettingsOverall.getOcs().getSettings().getStunServers().get(i);
if (TextUtils.isEmpty(iceServer.getUsername()) || TextUtils.isEmpty(iceServer
.getCredential())) {
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)));
}
}
}
} 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 {
iceServers.add(new PeerConnection.IceServer(iceServer.getUrl(),
iceServer.getUsername(), iceServer.getCredential()));
}
}
}
@ -1161,13 +1167,11 @@ public class CallController extends BaseController {
i++) {
iceServer = signalingSettingsOverall.getOcs().getSettings().getTurnServers().get(i);
for (int j = 0; j < iceServer.getUrls().size(); j++) {
if (TextUtils.isEmpty(iceServer.getUsername()) || TextUtils.isEmpty(iceServer
.getCredential())) {
iceServers.add(new PeerConnection.IceServer(iceServer.getUrls().get(j)));
} else {
iceServers.add(new PeerConnection.IceServer(iceServer.getUrls().get(j),
iceServer.getUsername(), iceServer.getCredential()));
}
iceServers.add(new PeerConnection.IceServer(
iceServer.getUrls().get(j),
iceServer.getUsername(),
iceServer.getCredential()
));
}
}
}
@ -1304,7 +1308,8 @@ public class CallController extends BaseController {
}
if (!hasExternalSignalingServer) {
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, new int[] {2, 1});
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser,
new int[] {ApiUtils.APIv3, 2, 1});
ncApi.pullSignalingMessages(credentials, ApiUtils.getUrlForSignaling(apiVersion,
baseUrl, roomToken))
@ -2000,7 +2005,7 @@ public class CallController extends BaseController {
String stringToSend = stringBuilder.toString();
strings.add(stringToSend);
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, new int[] {2, 1});
int apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, new int[] {ApiUtils.APIv3, 2, 1});
ncApi.sendSignalingMessages(credentials, ApiUtils.getUrlForSignaling(apiVersion, baseUrl, roomToken),
strings.toString())

View file

@ -565,7 +565,7 @@ public class OperationsMenuController extends BaseController {
ApiUtils.getConversationApiVersion(currentUser, new int[] {ApiUtils.APIv4, 1});
ApiUtils.getCallApiVersion(currentUser, new int[] {ApiUtils.APIv4, 1});
ApiUtils.getChatApiVersion(currentUser, new int[] {1});
ApiUtils.getSignalingApiVersion(currentUser, new int[] {2, 1});
ApiUtils.getSignalingApiVersion(currentUser, new int[] {ApiUtils.APIv3, 2, 1});
}
private void inviteUsersToAConversation() {

View file

@ -90,7 +90,7 @@ public class SignalingSettingsWorker extends Worker {
userEntity = userEntityList.get(i);
UserEntity finalUserEntity = userEntity;
int apiVersion = ApiUtils.getSignalingApiVersion(finalUserEntity, new int[] {2, 1});
int apiVersion = ApiUtils.getSignalingApiVersion(finalUserEntity, new int[] {ApiUtils.APIv3, 2, 1});
ncApi.getSignalingSettings(ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()),
ApiUtils.getUrlForSignalingSettings(apiVersion, userEntity.getBaseUrl()))

View file

@ -27,6 +27,7 @@ import java.util.List;
@JsonObject
public class IceServer {
@Deprecated
@JsonField(name = "url")
String url;
@ -39,6 +40,7 @@ public class IceServer {
@JsonField(name = "credential")
String credential;
@Deprecated
public String getUrl() {
return this.url;
}

View file

@ -146,12 +146,19 @@ public class ApiUtils {
public static int getSignalingApiVersion(UserEntity capabilities, int[] versions) throws NoSupportedApiException {
for (int version : versions) {
if (version == 2 && capabilities.hasSpreedFeatureCapability("sip-support")) {
if (capabilities.hasSpreedFeatureCapability("signaling-v" + version)) {
return version;
}
if (version == 1) {
// Has no capability, we just assume it is always there for now.
if (version == 2 &&
capabilities.hasSpreedFeatureCapability("sip-support") &&
!capabilities.hasSpreedFeatureCapability("signaling-v3")) {
return version;
}
if (version == 1 &&
!capabilities.hasSpreedFeatureCapability("signaling-v3")) {
// Has no capability, we just assume it is always there when there is no v3 or later
return version;
}
}

View file

@ -101,7 +101,7 @@ public class WebSocketConnectionHelper {
}
HelloOverallWebSocketMessage getAssembledHelloModel(UserEntity userEntity, String ticket) {
int apiVersion = ApiUtils.getSignalingApiVersion(userEntity, new int[] {2, 1});
int apiVersion = ApiUtils.getSignalingApiVersion(userEntity, new int[] {ApiUtils.APIv3, 2, 1});
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
helloOverallWebSocketMessage.setType("hello");