mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
parent
589f7f934f
commit
0bb65795ad
@ -1263,7 +1263,7 @@ public class CallController extends BaseController {
|
|||||||
magicPeerConnectionWrapper.setNick(ncSignalingMessage.getPayload().getNick());
|
magicPeerConnectionWrapper.setNick(ncSignalingMessage.getPayload().getNick());
|
||||||
String sessionDescriptionStringWithPreferredCodec = MagicWebRTCUtils.preferCodec
|
String sessionDescriptionStringWithPreferredCodec = MagicWebRTCUtils.preferCodec
|
||||||
(ncSignalingMessage.getPayload().getSdp(),
|
(ncSignalingMessage.getPayload().getSdp(),
|
||||||
"H264", false);
|
"VP8", false);
|
||||||
|
|
||||||
SessionDescription sessionDescriptionWithPreferredCodec = new SessionDescription(
|
SessionDescription sessionDescriptionWithPreferredCodec = new SessionDescription(
|
||||||
SessionDescription.Type.fromCanonicalForm(type),
|
SessionDescription.Type.fromCanonicalForm(type),
|
||||||
|
31
app/src/main/java/com/nextcloud/talk/utils/MagicMap.java
Normal file
31
app/src/main/java/com/nextcloud/talk/utils/MagicMap.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.utils;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class MagicMap extends ConcurrentHashMap<Integer, Object> {
|
||||||
|
public int add(Object element) {
|
||||||
|
int key = System.identityHashCode(element);
|
||||||
|
super.put(key, element);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
@ -340,7 +340,7 @@ public class MagicPeerConnectionWrapper {
|
|||||||
public void onCreateSuccess(SessionDescription sessionDescription) {
|
public void onCreateSuccess(SessionDescription sessionDescription) {
|
||||||
String sessionDescriptionStringWithPreferredCodec = MagicWebRTCUtils.preferCodec
|
String sessionDescriptionStringWithPreferredCodec = MagicWebRTCUtils.preferCodec
|
||||||
(sessionDescription.description,
|
(sessionDescription.description,
|
||||||
"H264", false);
|
"VP8", false);
|
||||||
|
|
||||||
SessionDescription sessionDescriptionWithPreferredCodec = new SessionDescription(
|
SessionDescription sessionDescriptionWithPreferredCodec = new SessionDescription(
|
||||||
sessionDescription.type,
|
sessionDescription.type,
|
||||||
|
@ -33,6 +33,7 @@ import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage;
|
|||||||
import com.nextcloud.talk.models.json.websocket.ErrorOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.ErrorOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
||||||
|
import com.nextcloud.talk.utils.MagicMap;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
private boolean connected;
|
private boolean connected;
|
||||||
private WebSocketConnectionHelper webSocketConnectionHelper;
|
private WebSocketConnectionHelper webSocketConnectionHelper;
|
||||||
private WebSocket webSocket;
|
private WebSocket webSocket;
|
||||||
private ConcurrentHashMap<Integer, Object> concurrentHashMapQueue;
|
private MagicMap<Integer, Object> magicMap;
|
||||||
|
|
||||||
MagicWebSocketInstance(UserEntity conversationUser, String connectionUrl, String webSocketTicket) {
|
MagicWebSocketInstance(UserEntity conversationUser, String connectionUrl, String webSocketTicket) {
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
@ -82,7 +84,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
this.webSocketTicket = webSocketTicket;
|
this.webSocketTicket = webSocketTicket;
|
||||||
this.webSocketConnectionHelper = new WebSocketConnectionHelper();
|
this.webSocketConnectionHelper = new WebSocketConnectionHelper();
|
||||||
|
|
||||||
concurrentHashMapQueue = new ConcurrentHashMap<>();
|
magicMap = new MagicMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -150,37 +152,18 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
Map<String, Object> participantsUpdateMap = eventOverallWebSocketMessage.getEventMap();
|
Map<String, Object> participantsUpdateMap = eventOverallWebSocketMessage.getEventMap();
|
||||||
HashMap<String, String> refreshChatHashMap = new HashMap<>();
|
HashMap<String, String> refreshChatHashMap = new HashMap<>();
|
||||||
refreshChatHashMap.put("roomToken", (String) eventOverallWebSocketMessage.getEventMap().get("roomid"));
|
refreshChatHashMap.put("roomToken", (String) eventOverallWebSocketMessage.getEventMap().get("roomid"));
|
||||||
int newId;
|
refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(participantsUpdateMap.get("users"))));
|
||||||
do {
|
|
||||||
Random rand = new Random();
|
|
||||||
newId = rand.nextInt(1000);
|
|
||||||
if (!concurrentHashMapQueue.contains(newId)) {
|
|
||||||
concurrentHashMapQueue.put(newId, participantsUpdateMap.get("users"));
|
|
||||||
refreshChatHashMap.put("roomToken", (String) eventOverallWebSocketMessage.getEventMap().get("roomid"));
|
|
||||||
refreshChatHashMap.put("jobId", Integer.toString(newId));
|
|
||||||
eventBus.post(new WebSocketCommunicationEvent("participantsUpdate", refreshChatHashMap));
|
eventBus.post(new WebSocketCommunicationEvent("participantsUpdate", refreshChatHashMap));
|
||||||
}
|
}
|
||||||
} while (!concurrentHashMapQueue.contains(newId));
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "message":
|
case "message":
|
||||||
CallOverallWebSocketMessage callOverallWebSocketMessage = LoganSquare.parse(text, CallOverallWebSocketMessage.class);
|
CallOverallWebSocketMessage callOverallWebSocketMessage = LoganSquare.parse(text, CallOverallWebSocketMessage.class);
|
||||||
int newId;
|
|
||||||
do {
|
|
||||||
HashMap<String, String> messageHashMap = new HashMap<>();
|
HashMap<String, String> messageHashMap = new HashMap<>();
|
||||||
Random rand = new Random();
|
messageHashMap.put("jobId", Integer.toString(magicMap.add(callOverallWebSocketMessage.getCallWebSocketMessage().getNcSignalingMessage())));
|
||||||
newId = rand.nextInt(1000);
|
|
||||||
if (!concurrentHashMapQueue.contains(newId)) {
|
|
||||||
concurrentHashMapQueue.put(newId, callOverallWebSocketMessage.getCallWebSocketMessage().getNcSignalingMessage());
|
|
||||||
messageHashMap.put("jobId", Integer.toString(newId));
|
|
||||||
eventBus.post(new WebSocketCommunicationEvent("signalingMessage", messageHashMap));
|
eventBus.post(new WebSocketCommunicationEvent("signalingMessage", messageHashMap));
|
||||||
}
|
|
||||||
} while (!concurrentHashMapQueue.contains(newId));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user