合并主线

This commit is contained in:
648540858
2022-08-23 11:48:31 +08:00
parent 020f9ea8a0
commit 8f7e8efc98
11 changed files with 149 additions and 195 deletions

View File

@@ -10,6 +10,7 @@ import gov.nist.javax.sip.message.SIPRequest;
import gov.nist.javax.sip.stack.SIPDialog;
import javax.sip.Dialog;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
@@ -127,7 +128,7 @@ public interface ISIPCommander {
*/
void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent);
void streamByeCmd(String deviceId, String channelId, String stream, String callId);
void streamByeCmd(SIPDialog dialog, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException;
void streamByeCmd(SIPDialog dialog, String channelId, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException, InvalidArgumentException;
/**
* 回放暂停

View File

@@ -676,6 +676,46 @@ public class SIPCommander implements ISIPCommander {
streamByeCmd(deviceId, channelId, stream, callId, null);
}
@Override
public void streamByeCmd(SIPDialog dialog, String channelId, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException, InvalidArgumentException {
Request byeRequest = dialog.createRequest(Request.BYE);
SipURI byeURI = (SipURI) byeRequest.getRequestURI();
byeURI.setHost(request.getRemoteAddress().getHostAddress());
byeURI.setPort(request.getRemotePort());
byeURI.setUser(channelId);
ViaHeader viaHeader = (ViaHeader) byeRequest.getHeader(ViaHeader.NAME);
String protocol = viaHeader.getTransport().toUpperCase();
viaHeader.setRPort();
// 增加Contact header
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
byeRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
List<String> agentParam = new ArrayList<>();
agentParam.add("wvp-pro");
// TODO 添加版本信息以及日期
UserAgentHeader userAgentHeader = null;
try {
userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
} catch (ParseException e) {
throw new RuntimeException(e);
}
byeRequest.addHeader(userAgentHeader);
ClientTransaction clientTransaction = null;
if("TCP".equals(protocol)) {
clientTransaction = tcpSipProvider.getNewClientTransaction(byeRequest);
} else if("UDP".equals(protocol)) {
clientTransaction = udpSipProvider.getNewClientTransaction(byeRequest);
}
CallIdHeader callIdHeader = (CallIdHeader) byeRequest.getHeader(CallIdHeader.NAME);
if (okEvent != null) {
sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent);
}
CSeqHeader cSeqHeader = (CSeqHeader)byeRequest.getHeader(CSeqHeader.NAME);
cSeqHeader.setSeqNumber(redisCatchStorage.getCSEQ());
dialog.sendRequest(clientTransaction);
}
/**
* 视频流停止
*/

View File

@@ -26,10 +26,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.sip.Dialog;
import javax.sip.DialogState;
import javax.sip.RequestEvent;
import javax.sip.SipException;
import javax.sip.*;
import javax.sip.address.SipURI;
import javax.sip.header.CallIdHeader;
import javax.sip.header.FromHeader;
@@ -151,11 +148,13 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
if (sendRtpItem.isOnlyAudio()) {
// 语音对讲
try {
cmder.streamByeCmd((SIPDialog) evt.getDialog(), (SIPRequest) evt.getRequest(), null);
cmder.streamByeCmd((SIPDialog) evt.getDialog(), sendRtpItem.getChannelId(), (SIPRequest) evt.getRequest(), null);
} catch (SipException e) {
throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
} catch (InvalidArgumentException e) {
throw new RuntimeException(e);
}
} else {
// 向上级平台

View File

@@ -89,12 +89,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
private ZLMRTPServerFactory zlmrtpServerFactory;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IStreamProxyService streamProxyService;
@Autowired
private EventPublisher publisher;
@@ -288,6 +282,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
return (MediaServerItem)RedisUtil.get(key);
}
@Override
public MediaServerItem getDefaultMediaServer() {

View File

@@ -24,13 +24,9 @@ public class MediaServiceImpl implements IMediaService {
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IMediaServerService mediaServerService;
@Autowired
private MediaConfig mediaConfig;

View File

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import javax.sip.InvalidArgumentException;
import javax.sip.ResponseEvent;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -745,7 +746,7 @@ public class PlayServiceImpl implements IPlayService {
zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
}
if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null);
cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getChannelId(), audioBroadcastCatch.getRequest(), null);
}
audioBroadcastManager.del(deviceId, channelId);
@@ -753,6 +754,8 @@ public class PlayServiceImpl implements IPlayService {
throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
} catch (InvalidArgumentException e) {
throw new RuntimeException(e);
}
}

View File

@@ -76,12 +76,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Autowired
private PlatformGbStreamMapper platformGbStreamMapper;
@Autowired
private EventPublisher eventPublisher;
@Autowired
private ParentPlatformMapper parentPlatformMapper;
@Autowired
private IGbStreamService gbStreamService;

View File

@@ -197,9 +197,11 @@ public class PlayController {
@Operation(summary = "语音广播命令")
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/broadcast/{deviceId}")
@PostMapping("/broadcast/{deviceId}")
public DeferredResult<WVPResult<AudioBroadcastResult>> broadcastApi(@PathVariable String deviceId) {
@Parameter(name = "deviceId", description = "通道国标编号", required = true)
@Parameter(name = "timeout", description = "推流超时时间(秒)", required = true)
@GetMapping("/broadcast/{deviceId}/{channelId}")
@PostMapping("/broadcast/{deviceId}/{channelId}")
public DeferredResult<WVPResult<AudioBroadcastResult>> broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) {
if (logger.isDebugEnabled()) {
logger.debug("语音广播API调用");
}
@@ -258,13 +260,10 @@ public class PlayController {
return result;
}
@Operation(summary = "获取所有的ssrc")
@ApiOperation("停止语音广播")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备Id", dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "通道Id", dataTypeClass = String.class),
})
@Operation(summary = "停止语音广播")
@Parameter(name = "deviceId", description = "设备Id", required = true)
@Parameter(name = "channelId", description = "通道Id", required = true)
@GetMapping("/broadcast/stop/{deviceId}/{channelId}")
@PostMapping("/broadcast/stop/{deviceId}/{channelId}")
public WVPResult<String> stopBroadcastA(@PathVariable String deviceId, @PathVariable String channelId) {

View File

@@ -199,4 +199,15 @@ public class UserController {
}
}
}
@PostMapping("/userInfo")
@Operation(summary = "管理员修改普通用户密码")
public LoginUser getUserInfo() {
// 获取当前登录用户id
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo == null) {
throw new ControllerException(ErrorCode.ERROR100);
}
return userInfo;
}
}