临时提交
This commit is contained in:
@@ -7,10 +7,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 语音广播消息管理类
|
||||
@@ -23,81 +24,42 @@ public class AudioBroadcastManager {
|
||||
@Autowired
|
||||
private SipConfig config;
|
||||
|
||||
public static Map<String, AudioBroadcastCatch> data = new ConcurrentHashMap<>();
|
||||
public static Map<Integer, AudioBroadcastCatch> data = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void update(AudioBroadcastCatch audioBroadcastCatch) {
|
||||
if (SipUtils.isFrontEnd(audioBroadcastCatch.getDeviceId())) {
|
||||
audioBroadcastCatch.setChannelId(audioBroadcastCatch.getDeviceId());
|
||||
data.put(audioBroadcastCatch.getDeviceId(), audioBroadcastCatch);
|
||||
}else {
|
||||
data.put(audioBroadcastCatch.getDeviceId() + audioBroadcastCatch.getChannelId(), audioBroadcastCatch);
|
||||
}
|
||||
data.put(audioBroadcastCatch.getChannelId(), audioBroadcastCatch);
|
||||
}
|
||||
|
||||
public void del(String deviceId, String channelId) {
|
||||
if (SipUtils.isFrontEnd(deviceId)) {
|
||||
data.remove(deviceId);
|
||||
}else {
|
||||
data.remove(deviceId + channelId);
|
||||
}
|
||||
public void del(Integer channelId) {
|
||||
data.remove(channelId);
|
||||
|
||||
}
|
||||
|
||||
public void delByDeviceId(String deviceId) {
|
||||
for (String key : data.keySet()) {
|
||||
if (key.startsWith(deviceId)) {
|
||||
data.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<AudioBroadcastCatch> getAll(){
|
||||
Collection<AudioBroadcastCatch> values = data.values();
|
||||
return new ArrayList<>(values);
|
||||
}
|
||||
|
||||
|
||||
public boolean exit(String deviceId, String channelId) {
|
||||
for (String key : data.keySet()) {
|
||||
if (SipUtils.isFrontEnd(deviceId)) {
|
||||
return key.equals(deviceId);
|
||||
}else {
|
||||
return key.equals(deviceId + channelId);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean exit(Integer channelId) {
|
||||
return data.containsKey(channelId);
|
||||
}
|
||||
|
||||
public AudioBroadcastCatch get(String deviceId, String channelId) {
|
||||
AudioBroadcastCatch audioBroadcastCatch;
|
||||
if (SipUtils.isFrontEnd(deviceId)) {
|
||||
audioBroadcastCatch = data.get(deviceId);
|
||||
}else {
|
||||
audioBroadcastCatch = data.get(deviceId + channelId);
|
||||
}
|
||||
if (audioBroadcastCatch == null) {
|
||||
Stream<AudioBroadcastCatch> allAudioBroadcastCatchStreamForDevice = data.values().stream().filter(
|
||||
audioBroadcastCatchItem -> Objects.equals(audioBroadcastCatchItem.getDeviceId(), deviceId));
|
||||
List<AudioBroadcastCatch> audioBroadcastCatchList = allAudioBroadcastCatchStreamForDevice.collect(Collectors.toList());
|
||||
if (audioBroadcastCatchList.size() == 1 && Objects.equals(config.getId(), channelId)) {
|
||||
audioBroadcastCatch = audioBroadcastCatchList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return audioBroadcastCatch;
|
||||
public AudioBroadcastCatch get(Integer channelId) {
|
||||
return data.get(channelId);
|
||||
}
|
||||
|
||||
public List<AudioBroadcastCatch> get(String deviceId) {
|
||||
public List<AudioBroadcastCatch> getByDeviceId(String deviceId) {
|
||||
List<AudioBroadcastCatch> audioBroadcastCatchList= new ArrayList<>();
|
||||
if (SipUtils.isFrontEnd(deviceId)) {
|
||||
if (data.get(deviceId) != null) {
|
||||
audioBroadcastCatchList.add(data.get(deviceId));
|
||||
}
|
||||
}else {
|
||||
for (String key : data.keySet()) {
|
||||
if (key.startsWith(deviceId)) {
|
||||
audioBroadcastCatchList.add(data.get(key));
|
||||
for (AudioBroadcastCatch broadcastCatch : data.values()) {
|
||||
if (broadcastCatch.getDeviceId().equals(deviceId)) {
|
||||
audioBroadcastCatchList.add(broadcastCatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class VideoStreamSessionManager {
|
||||
* @param mediaServerId 所使用的流媒体ID
|
||||
* @param response 回复
|
||||
*/
|
||||
public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){
|
||||
public void put(String deviceId, Integer channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){
|
||||
SsrcTransaction ssrcTransaction = new SsrcTransaction();
|
||||
ssrcTransaction.setDeviceId(deviceId);
|
||||
ssrcTransaction.setChannelId(channelId);
|
||||
|
||||
Reference in New Issue
Block a user