优化分屏监控

pull/1642/head
648540858 2024-09-12 17:49:16 +08:00
parent 525f325d2b
commit 76ef652e7c
17 changed files with 222 additions and 554 deletions

View File

@ -1,17 +1,21 @@
package com.genersoft.iot.vmp.gb28181.controller;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceType;
import com.genersoft.iot.vmp.gb28181.bean.IndustryCodeType;
import com.genersoft.iot.vmp.gb28181.bean.NetworkIdentificationType;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupByGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionByGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionParam;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -22,7 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.message.Response;
import java.util.List;
@ -41,6 +47,12 @@ public class CommonChannelController {
@Autowired
private IMediaServerService mediaServerService;
@Autowired
private IGbChannelPlayService channelPlayService;
@Autowired
private UserSetting userSetting;
@Operation(summary = "查询通道信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "通道的数据库自增Id", required = true)
@ -167,4 +179,38 @@ public class CommonChannelController {
Assert.notEmpty(param.getDeviceIds(),"参数异常");
channelService.deleteChannelToGroupByGbDevice(param.getDeviceIds());
}
@Operation(summary = "播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@GetMapping("/play")
public DeferredResult<WVPResult<StreamContent>> deleteChannelToGroupByGbDevice(Integer channelId){
Assert.notNull(channelId,"参数异常");
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
ErrorCallback<StreamInfo> callback = (code, msg, data) -> {
if (code == InviteErrorCode.SUCCESS.getCode()) {
result.setResult(WVPResult.success(new StreamContent(data)));
}else {
result.setResult(WVPResult.fail(code, msg));
}
};
if (channel.getGbDeviceDbId() != null) {
// 国标通道
channelPlayService.playGbDeviceChannel(channel, callback);
} else if (channel.getStreamProxyId() != null) {
// 拉流代理
channelPlayService.playProxy(channel, callback);
} else if (channel.getStreamPushId() != null) {
// 推流
channelPlayService.playPush(channel, null, null, callback);
} else {
// 通道数据异常
log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
return result;
}
}

View File

@ -9,4 +9,10 @@ import com.genersoft.iot.vmp.service.bean.ErrorCallback;
public interface IGbChannelPlayService {
void start(CommonGBChannel channel, InviteInfo inviteInfo, Platform platform, ErrorCallback<StreamInfo> callback);
void playGbDeviceChannel(CommonGBChannel channel, ErrorCallback<StreamInfo> callback);
void playProxy(CommonGBChannel channel, ErrorCallback<StreamInfo> callback);
void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback<StreamInfo> callback);
}

View File

@ -101,7 +101,8 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
}
}
private void playGbDeviceChannel(CommonGBChannel channel, ErrorCallback<StreamInfo> callback){
@Override
public void playGbDeviceChannel(CommonGBChannel channel, ErrorCallback<StreamInfo> callback){
// 国标通道
try {
deviceChannelPlayService.play(channel, callback);
@ -113,7 +114,8 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
}
}
private void playProxy(CommonGBChannel channel, ErrorCallback<StreamInfo> callback){
@Override
public void playProxy(CommonGBChannel channel, ErrorCallback<StreamInfo> callback){
// 拉流代理通道
try {
StreamInfo streamInfo = streamProxyPlayService.start(channel.getStreamProxyId());
@ -127,7 +129,8 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
}
}
private void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback<StreamInfo> callback){
@Override
public void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback<StreamInfo> callback){
// 推流
try {
streamPushPlayService.start(channel.getStreamPushId(), callback, platformDeviceId, platformName);

View File

@ -675,5 +675,4 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
}
}
}

View File

@ -247,347 +247,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
log.error("[命令发送失败] invite 点播失败: {}", sendException.getMessage());
}
}
// // Invite Request消息实现此消息一般为级联消息上级给下级发送请求视频指令
// try {
//
//
//
//
//
//
//
// // 查询请求是否来自上级平台\设备
// Platform platform = platformService.queryPlatformByServerGBId(requesterId);
//
// if (platform == null) {
// inviteFromDeviceHandle(request, requesterId, channelId);
//
// } else {
// // 查询平台下是否有该通道
// CommonGBChannel channel= channelService.queryOneWithPlatform(platform.getId(), channelId);
// MediaServer mediaServerItem = null;
// StreamPush streamPushItem = null;
// StreamProxy proxyByAppAndStream = null;
// if (channel == null) {
// log.info("[上级INVITE] 通道不存在返回404: {}", channelId);
// try {
// // 通道不存在发404资源不存在
// responseAck(request, Response.NOT_FOUND);
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite 通道不存在: {}", e.getMessage());
// }
// return;
// }
// // 通道存在发100TRYING
// try {
// responseAck(request, Response.TRYING);
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite TRYING: {}", e.getMessage());
// }
//
//
//
// Device device = null;
// // 通过 channel 和 gbStream 是否为null 值判断来源是直播流合适国标
// if (channel != null) {
// device = storager.queryVideoDeviceByPlatformIdAndChannelId(requesterId, channelId);
// if (device == null) {
// log.warn("点播平台{}的通道{}时未找到设备信息", requesterId, channel);
// try {
// responseAck(request, Response.SERVER_INTERNAL_ERROR);
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite 未找到设备信息: {}", e.getMessage());
// }
// return;
// }
// mediaServerItem = playService.getNewMediaServerItem(device);
// if (mediaServerItem == null) {
// log.warn("未找到可用的zlm");
// try {
// responseAck(request, Response.BUSY_HERE);
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite BUSY_HERE: {}", e.getMessage());
// }
// return;
// }
//
// String ssrc;
// if (userSetting.getUseCustomSsrcForParentInvite() || gb28181Sdp.getSsrc() == null) {
// // 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式
// ssrc = "Play".equalsIgnoreCase(sessionName) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId());
// }else {
// ssrc = gb28181Sdp.getSsrc();
// }
// String streamTypeStr = null;
// if (mediaTransmissionTCP) {
// if (tcpActive) {
// streamTypeStr = "TCP-ACTIVE";
// } else {
// streamTypeStr = "TCP-PASSIVE";
// }
// } else {
// streamTypeStr = "UDP";
// }
//
// SendRtpItem sendRtpItem = mediaServerService.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
// device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp());
//
// if (tcpActive != null) {
// sendRtpItem.setTcpActive(tcpActive);
// }
// if (sendRtpItem == null) {
// log.warn("服务器端口资源不足");
// try {
// responseAck(request, Response.BUSY_HERE);
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage());
// }
// return;
// }
// sendRtpItem.setCallId(callIdHeader.getCallId());
// sendRtpItem.setPlayType("Play".equalsIgnoreCase(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK);
//
// Long finalStartTime = startTime;
// Long finalStopTime = stopTime;
// ErrorCallback<Object> hookEvent = (code, msg, data) -> {
// StreamInfo streamInfo = (StreamInfo)data;
// MediaServer mediaServerItemInUSe = mediaServerService.getOne(streamInfo.getMediaServerId());
// log.info("[上级Invite]下级已经开始推流。 回复200OK(SDP) {}/{}", streamInfo.getApp(), streamInfo.getStream());
// // * 0 等待设备推流上来
// // * 1 下级已经推流等待上级平台回复ack
// // * 2 推流中
// sendRtpItem.setStatus(1);
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// String sdpIp = mediaServerItemInUSe.getSdpIp();
// if (!ObjectUtils.isEmpty(platform.getSendStreamIp())) {
// sdpIp = platform.getSendStreamIp();
// }
// StringBuffer content = new StringBuffer(200);
// content.append("v=0\r\n");
// content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n");
// content.append("s=" + sessionName + "\r\n");
// content.append("c=IN IP4 " + sdpIp + "\r\n");
// if ("Playback".equalsIgnoreCase(sessionName)) {
// content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n");
// } else {
// content.append("t=0 0\r\n");
// }
// int localPort = sendRtpItem.getLocalPort();
// if (localPort == 0) {
// // 非严格模式端口不统一, 增加兼容性修改为一个不为0的端口
// localPort = new Random().nextInt(65535) + 1;
// }
// if (sendRtpItem.isTcp()) {
// content.append("m=video " + localPort + " TCP/RTP/AVP 96\r\n");
// if (!sendRtpItem.isTcpActive()) {
// content.append("a=setup:active\r\n");
// } else {
// content.append("a=setup:passive\r\n");
// }
// }else {
// content.append("m=video " + localPort + " RTP/AVP 96\r\n");
// }
// content.append("a=sendonly\r\n");
// content.append("a=rtpmap:96 PS/90000\r\n");
// content.append("y=" + sendRtpItem.getSsrc() + "\r\n");
// content.append("f=\r\n");
//
//
// try {
// // 超时未收到Ack应该回复bye,当前等待时间为10秒
// dynamicTask.startDelay(callIdHeader.getCallId(), () -> {
// log.info("Ack 等待超时");
// mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), sendRtpItem.getSsrc());
// // 回复bye
// try {
// cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId());
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
// }
// }, 60 * 1000);
// responseSdpAck(request, content.toString(), platform);
// // tcp主动模式回复sdp后开启监听
// if (sendRtpItem.isTcpActive()) {
// MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId());
// try {
// mediaServerService.startSendRtpPassive(mediaServer, sendRtpItem, 5);
// redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, platform);
// }catch (ControllerException e) {}
// }
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] 国标级联 回复SdpAck", e);
// }
// };
// ErrorCallback<Object> errorEvent = ((statusCode, msg, data) -> {
// log.info("[上级Invite] {}, 失败, 平台:{} 通道:{}, code {} msg{}", sessionName, username, channelId, statusCode, msg);
// // 未知错误。直接转发设备点播的错误
// try {
// Response response = getMessageFactory().createResponse(statusCode, evt.getRequest());
// sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
// } catch (ParseException | SipException e) {
// log.error("未处理的异常 ", e);
// }
// });
// sendRtpItem.setApp("rtp");
// if ("Playback".equalsIgnoreCase(sessionName)) {
// sendRtpItem.setPlayType(InviteStreamType.PLAYBACK);
// String startTimeStr = DateUtil.urlFormatter.format(start);
// String endTimeStr = DateUtil.urlFormatter.format(end);
// String stream = device.getDeviceId() + "_" + channelId + "_" + startTimeStr + "_" + endTimeStr;
// int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
// SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null,
// device.isSsrcCheck(), true, 0,false,!channel.isHasAudio(), false, tcpMode);
// sendRtpItem.setStream(stream);
// // 写入redis 超时时回复
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// playService.playBack(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start),
// DateUtil.formatter.format(end),
// (code, msg, data) -> {
// if (code == InviteErrorCode.SUCCESS.getCode()) {
// hookEvent.run(code, msg, data);
// } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
// log.info("[录像回放]超时, 用户:{} 通道:{}", username, channelId);
// redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
// errorEvent.run(code, msg, data);
// } else {
// errorEvent.run(code, msg, data);
// }
// });
// } else if ("Download".equalsIgnoreCase(sessionName)) {
// // 获取指定的下载速度
// Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true);
// MediaDescription mediaDescription = null;
// String downloadSpeed = "1";
// if (sdpMediaDescriptions.size() > 0) {
// mediaDescription = (MediaDescription) sdpMediaDescriptions.get(0);
// }
// if (mediaDescription != null) {
// downloadSpeed = mediaDescription.getAttribute("downloadspeed");
// }
//
// sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD);
// int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
// SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null,
// device.isSsrcCheck(), true, 0, false,!channel.isHasAudio(), false, tcpMode);
// sendRtpItem.setStream(ssrcInfo.getStream());
// // 写入redis 超时时回复
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start),
// DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed),
// (code, msg, data) -> {
// if (code == InviteErrorCode.SUCCESS.getCode()) {
// hookEvent.run(code, msg, data);
// } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
// log.info("[录像下载]超时, 用户:{} 通道:{}", username, channelId);
// redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
// errorEvent.run(code, msg, data);
// } else {
// errorEvent.run(code, msg, data);
// }
// });
// } else {
// sendRtpItem.setPlayType(InviteStreamType.PLAY);
// String streamId = String.format("%s_%s", device.getDeviceId(), channelId);
// sendRtpItem.setStream(streamId);
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> {
// if (code == InviteErrorCode.SUCCESS.getCode()) {
// hookEvent.run(code, msg, data);
// } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
// log.info("[上级点播]超时, 用户:{} 通道:{}", username, channelId);
// redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
// errorEvent.run(code, msg, data);
// } else {
// errorEvent.run(code, msg, data);
// }
// }));
// sendRtpItem.setSsrc(ssrcInfo.getSsrc());
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
//
// }
// } else if (gbStream != null) {
// SendRtpItem sendRtpItem = new SendRtpItem();
// if (!userSetting.getUseCustomSsrcForParentInvite() && gb28181Sdp.getSsrc() != null) {
// sendRtpItem.setSsrc(gb28181Sdp.getSsrc());
// }
//
// if (tcpActive != null) {
// sendRtpItem.setTcpActive(tcpActive);
// }
// sendRtpItem.setTcp(mediaTransmissionTCP);
// sendRtpItem.setRtcp(platform.isRtcp());
// sendRtpItem.setPlatformName(platform.getName());
// sendRtpItem.setPlatformId(platform.getServerGBId());
// sendRtpItem.setMediaServerId(mediaServerItem.getId());
// sendRtpItem.setChannelId(channelId);
// sendRtpItem.setIp(addressStr);
// sendRtpItem.setPort(port);
// sendRtpItem.setUsePs(true);
// sendRtpItem.setApp(gbStream.getApp());
// sendRtpItem.setStream(gbStream.getStream());
// sendRtpItem.setCallId(callIdHeader.getCallId());
// sendRtpItem.setFromTag(request.getFromTag());
// sendRtpItem.setOnlyAudio(false);
// sendRtpItem.setStatus(0);
// sendRtpItem.setSessionName(sessionName);
// // 清理可能存在的缓存避免用到旧的数据
// List<SendRtpItem> sendRtpItemList = redisCatchStorage.querySendRTPServer(platform.getServerGBId(), channelId, gbStream.getStream());
// if (!sendRtpItemList.isEmpty()) {
// for (SendRtpItem rtpItem : sendRtpItemList) {
// redisCatchStorage.deleteSendRTPServer(rtpItem);
// }
// }
// if ("push".equals(gbStream.getStreamType())) {
// sendRtpItem.setPlayType(InviteStreamType.PUSH);
// if (streamPushItem != null) {
// // 从redis查询是否正在接收这个推流
// MediaInfo mediaInfo = redisCatchStorage.getPushListItem(gbStream.getApp(), gbStream.getStream());
// if (mediaInfo != null) {
// sendRtpItem.setServerId(mediaInfo.getServerId());
// sendRtpItem.setMediaServerId(mediaInfo.getMediaServer().getId());
//
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// // 开始推流
// sendPushStream(sendRtpItem, mediaServerItem, platform, request);
// }else {
// if (!platform.isStartOfflinePush()) {
// // 平台设置中关闭了拉起离线的推流则直接回复
// try {
// log.info("[上级点播] 失败推流设备未推流channel: {}, app: {}, stream: {}", sendRtpItem.getChannelId(), sendRtpItem.getApp(), sendRtpItem.getStream());
// responseAck(request, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing");
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite 通道未推流: {}", e.getMessage());
// }
// return;
// }
// notifyPushStreamOnline(sendRtpItem, mediaServerItem, platform, request);
// }
// }
// } else if ("proxy".equals(gbStream.getStreamType())) {
// if (null != proxyByAppAndStream) {
// sendRtpItem.setServerId(userSetting.getServerId());
// if (sendRtpItem.getSsrc() == null) {
// // 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式
// String ssrc = "Play".equalsIgnoreCase(sessionName) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId());
// sendRtpItem.setSsrc(ssrc);
// }
// MediaInfo mediaInfo = redisCatchStorage.getProxyStream(gbStream.getApp(), gbStream.getStream());
// if (mediaInfo != null) {
// sendProxyStream(sendRtpItem, mediaServerItem, platform, request);
// } else {
// //开启代理拉流
// notifyProxyStreamOnline(sendRtpItem, mediaServerItem, platform, request);
// }
// }
// }
// }
// }
// } catch (SdpParseException e) {
// log.error("sdp解析错误", e);
// } catch (SdpException e) {
// log.error("未处理的异常 ", e);
// }
}
private InviteInfo decode(RequestEvent evt) throws SdpException {

View File

@ -84,4 +84,10 @@ public interface StreamProxyMapper {
@SelectProvider(type = StreamProxyProvider.class, method = "select")
StreamProxy select(@Param("id") int id);
@Update("UPDATE wvp_stream_proxy " +
"SET pulling=false, " +
"stream_key = null " +
"WHERE id=#{id}")
void removeStream(@Param("id")int id);
}

View File

@ -91,7 +91,7 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService {
streamProxy.setMediaServerId(mediaServer.getId());
streamProxy.setStreamKey(null);
streamProxy.setPulling(false);
streamProxyMapper.update(streamProxy);
streamProxyMapper.removeStream(streamProxy.getId());
}
}

View File

@ -209,7 +209,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
if (streamProxyInDb == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "代理不存在");
}
if (streamProxyMapper.update(streamProxy) > 0 && !ObjectUtils.isEmpty(streamProxy.getGbDeviceId())) {
int updateResult = streamProxyMapper.update(streamProxy);
if (updateResult > 0 && !ObjectUtils.isEmpty(streamProxy.getGbDeviceId())) {
if (streamProxy.getGbId() > 0) {
gbChannelService.update(streamProxy.buildCommonGBChannel());
}else {

View File

@ -1,32 +1,24 @@
<template>
<div id="DeviceTree" style="width: 100%;height: 100%; background-color: #FFFFFF; overflow: auto">
<el-container>
<el-header>设备列表</el-header>
<el-main style="background-color: #ffffff;">
<div class="device-tree-main-box">
<el-tree ref="gdTree" :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" node-key="id" style="min-width: 100%; display:inline-block !important;">
<span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%">
<span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span>
<span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span>
<span v-if="node.data.type === 2 && node.data.online" title="目录" class="device-online iconfont icon-jiedianleilianjipingtai"></span>
<span v-if="node.data.type === 2 && !node.data.online" title="目录" class="device-offline iconfont icon-jiedianleilianjipingtai"></span>
<span v-if="node.data.type === 3 && node.data.online " title="在线通道" class="device-online iconfont icon-shebeileijiankongdian"></span>
<span v-if="node.data.type === 3 && !node.data.online" title="在线通道" class="device-offline iconfont icon-shebeileijiankongdian"></span>
<span v-if="node.data.type === 4 && node.data.online " title="在线通道-球机" class="device-online iconfont icon-shebeileiqiuji"></span>
<span v-if="node.data.type === 4 && !node.data.online" title="在线通道-球机" class="device-offline iconfont icon-shebeileiqiuji"></span>
<span v-if="node.data.type === 5 && node.data.online " title="在线通道-半球" class="device-online iconfont icon-shebeileibanqiu"></span>
<span v-if="node.data.type === 5 && !node.data.online" title="在线通道-半球" class="device-offline iconfont icon-shebeileibanqiu"></span>
<span v-if="node.data.type === 6 && node.data.online " title="在线通道-枪机" class="device-online iconfont icon-shebeileiqiangjitongdao"></span>
<span v-if="node.data.type === 6 && !node.data.online" title="在线通道-枪机" class="device-offline iconfont icon-shebeileiqiangjitongdao"></span>
<span v-if="node.data.online" style="padding-left: 1px" class="device-online">{{ node.label }}</span>
<span v-if="!node.data.online" style="padding-left: 1px" class="device-offline">{{ node.label }}</span>
<span>
<i v-if="node.data.hasGPS && node.data.online" style="color: #9d9d9d" class="device-online iconfont icon-dizhi"></i>
<i v-if="node.data.hasGPS && !node.data.online" style="color: #9d9d9d" class="device-offline iconfont icon-dizhi"></i>
</span>
</span>
</el-tree>
<el-header>
<div style="display: grid; grid-template-columns: auto auto">
<div >通道列表</div>
<div >
<el-switch
v-model="showRegion"
active-color="#13ce66"
inactive-color="rgb(64, 158, 255)"
active-text="行政区划"
inactive-text="业务分组">
</el-switch>
</div>
</div>
</el-header>
<el-main style="background-color: #ffffff;">
<RegionTree v-if="showRegion" ref="regionTree" :edit="false" :showHeader="false" :clickEvent="treeNodeClickEvent" ></RegionTree>
<GroupTree v-if="!showRegion" ref="groupTree" :edit="false" :showHeader="false" :clickEvent="treeNodeClickEvent" ></GroupTree>
</el-main>
</el-container>
</div>
@ -34,11 +26,15 @@
<script>
import DeviceService from "../service/DeviceService.js";
import RegionTree from "./RegionTree.vue";
import GroupTree from "./GroupTree.vue";
export default {
name: 'DeviceTree',
components: {GroupTree, RegionTree},
data() {
return {
showRegion: true,
deviceService: new DeviceService(),
defaultProps: {
children: 'children',
@ -49,120 +45,17 @@ export default {
},
props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'],
methods: {
handleNodeClick(data,node,element) {
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if(typeof (this.clickEvent) == "function") {
this.clickEvent(deviceNode.data.userData, data.userData, data.type === 2)
}
handleClick: function (tab, event){
},
handleContextMenu(event,data,node,element) {
console.log("右键点击事件")
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if(typeof (this.contextMenuEvent) == "function") {
this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
}
},
loadNode: function(node, resolve){
console.log(this.device)
if (node.level === 0) {
if (this.device) {
let node = {
name: this.device.name || this.device.deviceId,
isLeaf: false,
id: this.device.deviceId,
type: this.device.online,
online: this.device.online === 1,
userData: this.device
}
resolve([node])
}else {
this.deviceService.getAllDeviceList((data)=>{
console.log(data)
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
console.log(data[i].name)
let node = {
name: data[i].name || data[i].deviceId,
isLeaf: false,
id: data[i].deviceId,
type: data[i].online,
online: data[i].online === 1,
userData: data[i]
}
nodeList.push(node);
}
resolve(nodeList)
}else {
resolve([])
}
}, (list)=>{
console.log("设备加载完成")
}, (error)=>{
treeNodeClickEvent: function (data){
})
if (data.leaf) {
console.log(23111)
console.log(data)
if (this.clickEvent){
this.clickEvent(data.id)
}
}else {
let channelArray = []
this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{
console.log(catalogData)
channelArray = channelArray.concat(catalogData)
this.channelDataHandler(channelArray, resolve)
},(endCatalogData) => {
})
}
},
channelDataHandler: function (data, resolve) {
if (data.length > 0) {
let nodeList = []
for (let i = 0; i <data.length; i++) {
let item = data[i];
let type = 3;
if (item.id.length <= 10) {
type = 2;
}else {
if (item.id.length > 14) {
let channelType = item.id.substring(10, 13)
console.log("channelType: " + channelType)
if (channelType === '215' || channelType === '216') {
type = 2;
}
console.log(type)
if (item.basicData.ptzType === 1 ) { // 1-;2-;3-;4-
type = 4;
}else if (item.basicData.ptzType === 2) {
type = 5;
}else if (item.basicData.ptzType === 3 || item.basicData.ptzType === 4) {
type = 6;
}
}else {
if (item.basicData.subCount > 0 || item.basicData.parental === 1) {
type = 2;
}
}
}
let node = {
name: item.name || item.basicData.channelId,
isLeaf: type !== 2,
id: item.id,
deviceId: item.deviceId,
type: type,
online: item.basicData.status === 1,
hasGPS: item.basicData.longitude*item.basicData.latitude !== 0,
userData: item.basicData
}
nodeList.push(node);
}
resolve(nodeList)
}else {
resolve([])
}
},
reset: function (){
this.$forceUpdate();
}
},
destroyed() {

View File

@ -1,6 +1,6 @@
<template>
<div id="DeviceTree">
<div class="page-header" style="margin-bottom: 1rem;">
<div v-if="showHeader" class="page-header" style="margin-bottom: 1rem;">
<div class="page-title">业务分组</div>
<div class="page-header-btn">
<div style="display: inline;">
@ -11,6 +11,7 @@
</div>
</div>
</div>
<div v-if="showHeader" style="height: 2rem; background-color: #FFFFFF" ></div>
<div>
<vue-easy-tree
class="flow-tree"
@ -18,7 +19,7 @@
node-key="deviceId"
height="78vh"
lazy
style="padding: 2rem 0 2rem 0.5rem"
style="padding: 0 0 2rem 0.5rem"
:load="loadNode"
:data="treeData"
:props="props"
@ -27,8 +28,8 @@
@node-click="nodeClickHandler"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span @click.stop >
<el-radio v-if="node.data.type === 0 && node.level > 2 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.deviceId, node.data.businessGroup)" :label="node.data.deviceId">{{''}}</el-radio>
<span @click.stop v-if="edit">
<el-radio v-if="node.data.type === 0 && node.level > 2" style="margin-right: 0" v-model="chooseId" @input="chooseIdChange(node.data.deviceId, node.data.businessGroup)" :label="node.data.deviceId">{{''}}</el-radio>
</span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
@ -63,7 +64,7 @@ export default {
treeData: [],
}
},
props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange'],
props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange', 'showHeader'],
created() {
},
methods: {
@ -100,7 +101,9 @@ export default {
this.$forceUpdate();
},
contextmenuEventHandler: function (event, data, node, element) {
if (!this.edit) {
return;
}
console.log(node.level)
if (node.data.type === 1) {
data.parentId = node.parent.data.id;
@ -356,11 +359,9 @@ export default {
}, id);
},
nodeClickHandler: function (data, node, tree) {
console.log(data)
console.log(node)
// this.chooseId = data.id;
// this.chooseName = data.name;
// if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName);
if (this.clickEvent) {
this.clickEvent(data)
}
}
},
destroyed() {

View File

@ -1,6 +1,6 @@
<template>
<div id="DeviceTree">
<div class="page-header" style="margin-bottom: 1rem;">
<div class="page-header" style="margin-bottom: 1rem;" v-if="showHeader">
<div class="page-title">行政区划</div>
<div class="page-header-btn">
<div style="display: inline;">
@ -11,14 +11,15 @@
</div>
</div>
</div>
<div>
<div v-if="showHeader" style="height: 2rem; background-color: #FFFFFF" ></div>
<div >
<vue-easy-tree
class="flow-tree"
ref="veTree"
node-key="deviceId"
height="78vh"
lazy
style="padding: 2rem 0 2rem 0.5rem"
style="padding: 0 0 2rem 0.5rem"
:load="loadNode"
:data="treeData"
:props="props"
@ -27,7 +28,7 @@
@node-click="nodeClickHandler"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span @click.stop >
<span @click.stop v-if="edit">
<el-radio v-if="node.data.type === 0 && node.level !== 1 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange" :label="node.data.deviceId">{{''}}</el-radio>
</span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
@ -63,7 +64,7 @@ export default {
treeData: [],
}
},
props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange'],
props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange', 'showHeader'],
created() {
},
methods: {
@ -102,7 +103,9 @@ export default {
this.$forceUpdate();
},
contextmenuEventHandler: function (event, data, node, element) {
if (!this.edit) {
return
}
console.log(node.level)
if (node.data.type === 1) {
data.parentId = node.parent.data.id;
@ -356,6 +359,9 @@ export default {
nodeClickHandler: function (data, node, tree) {
console.log(data)
console.log(node)
if (this.clickEvent) {
this.clickEvent(data)
}
// this.chooseId = data.id;
// this.chooseName = data.name;
// if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName);

View File

@ -2,7 +2,7 @@
<div id="region" style="width: 100%">
<el-container v-loading="loading" >
<el-aside width="400px" >
<GroupTree ref="groupTree" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange" :onChannelChange="getChannelList"></GroupTree>
<GroupTree ref="groupTree" :show-header="true" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange" :onChannelChange="getChannelList"></GroupTree>
</el-aside>
<el-main style="padding: 5px;">
<div class="page-header">

View File

@ -1,22 +1,23 @@
<template>
<div id="devicePosition" style="width:100vw; height: 91vh">
<el-container v-loading="loading" style="height: 91vh;" element-loading-text="拼命加载中">
<el-aside width="300px" style="background-color: #ffffff">
<el-aside width="400px" style="background-color: #ffffff">
<DeviceTree :clickEvent="clickEvent" :contextMenuEvent="contextMenuEvent"></DeviceTree>
</el-aside>
<el-container>
<el-header height="5vh" style="text-align: left;font-size: 17px;line-height:5vh">
分屏:
<i class="el-icon-full-screen btn" :class="{active:spilt==1}" @click="spilt=1"/>
<i class="el-icon-menu btn" :class="{active:spilt==4}" @click="spilt=4"/>
<i class="el-icon-s-grid btn" :class="{active:spilt==9}" @click="spilt=9"/>
<i class="iconfont icon-a-mti-1fenpingshi btn" :class="{active:spiltIndex === 0}" @click="spiltIndex=0"/>
<i class="iconfont icon-a-mti-4fenpingshi btn" :class="{active: spiltIndex === 1}" @click="spiltIndex=1"/>
<i class="iconfont icon-a-mti-6fenpingshi btn" :class="{active: spiltIndex === 2}" @click="spiltIndex=2"/>
<i class="iconfont icon-a-mti-9fenpingshi btn" :class="{active: spiltIndex === 3}" @click="spiltIndex=3"/>
</el-header>
<el-main style="padding: 0;">
<div style="width: 99%;height: 85vh;display: flex;flex-wrap: wrap;background-color: #000;">
<div v-for="i in spilt" :key="i" class="play-box"
:style="liveStyle" :class="{redborder:playerIdx == (i-1)}"
<el-main style="padding: 0; margin: 0 auto; background-color: #a9a8a8" >
<div :style="{width: '151vh', height: '85vh', display: 'grid', gridTemplateColumns: layout[spiltIndex].columns,
gridTemplateRows: layout[spiltIndex].rows, gap: '4px', backgroundColor: '#a9a8a8'}">
<div v-for="i in layout[spiltIndex].spilt" :key="i" class="play-box" :class="getPlayerClass(spiltIndex, i)"
@click="playerIdx = (i-1)">
<div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{ i }}</div>
<div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 15px;font-weight: bold;"></div>
<player ref="player" v-else :videoUrl="videoUrl[i-1]" fluent autoplay @screenshot="shot"
@destroy="destroy"/>
</div>
@ -26,8 +27,8 @@
</el-container>
</div>
</template>
<script>
import uiHeader from "../layout/UiHeader.vue";
import player from './common/jessibuca.vue'
import DeviceTree from './common/DeviceTree.vue'
@ -37,10 +38,11 @@ export default {
components: {
uiHeader, player, DeviceTree
},
data() {
return {
videoUrl: [''],
spilt: 1,//
spiltIndex: 2,//
playerIdx: 0,//
updateLooper: 0, //
@ -48,7 +50,42 @@ export default {
total: 0,
//channel
loading: false
loading: false,
layout: [
{
spilt: 1,
columns: "1fr",
rows: "1fr",
style: function (){}
},
{
spilt: 4,
columns: "1fr 1fr",
rows: "1fr 1fr",
style: function (){}
},
{
spilt: 6,
columns: "1fr 1fr 1fr",
rows: "1fr 1fr 1fr",
style: function (index){
console.log(index)
if (index === 0) {
return {
gridColumn: ' 1 / span 2',
gridRow: ' 1 / span 2',
}
}
}
},
{
spilt: 9,
columns: "1fr 1fr 1fr",
rows: "1fr 1fr 1fr",
style: function (){}
},
]
};
},
mounted() {
@ -107,39 +144,31 @@ export default {
console.log(idx);
this.clear(idx.substring(idx.length - 1))
},
clickEvent: function (device, data, isCatalog) {
if (data.channelId && !isCatalog) {
if (device.online === 0) {
this.$message.error({
showClose: true,
message: "设备离线!不允许点播"
})
}else {
this.sendDevicePush(data)
}
clickEvent: function (channelId) {
this.sendDevicePush(channelId)
},
getPlayerClass: function (splitIndex, i) {
let classStr = "play-box-" + splitIndex + "-" +i
if (this.playerIdx === (i-1)) {
classStr += " redborder"
}
return classStr
},
contextMenuEvent: function (device, event, data, isCatalog) {
},
//
sendDevicePush: function (itemData) {
// if (itemData.status === 0) {
// this.$message.error('线!');
// return
// }
this.save(itemData)
let deviceId = itemData.deviceId;
// this.isLoging = true;
let channelId = itemData.channelId;
console.log("通知设备推流1" + deviceId + " : " + channelId);
sendDevicePush: function (channelId) {
this.save(channelId)
let idxTmp = this.playerIdx
let that = this;
this.loading = true
this.$axios({
method: 'get',
url: '/api/play/start/' + deviceId + '/' + channelId
}).then(function (res) {
url: '/api/common/channel/play',
params: {
channelId: channelId
}
}).then((res)=> {
if (res.data.code === 0 && res.data.data) {
let videoUrl;
if (location.protocol === "https:") {
@ -147,14 +176,13 @@ export default {
} else {
videoUrl = res.data.data.ws_flv;
}
itemData.playUrl = videoUrl;
that.setPlayUrl(videoUrl, idxTmp);
this.setPlayUrl(videoUrl, idxTmp);
} else {
that.$message.error(res.data.msg);
this.$message.error(res.data.msg);
}
}).catch(function (e) {
}).finally(() => {
that.loading = false
this.loading = false
});
},
setPlayUrl(url, idx) {
@ -166,9 +194,9 @@ export default {
},
checkPlayByParam() {
let {deviceId, channelId} = this.$route.query
if (deviceId && channelId) {
this.sendDevicePush({deviceId, channelId})
let channelId = this.$route.query
if (channelId) {
this.sendDevicePush(channelId)
}
},
shot(e) {
@ -227,16 +255,20 @@ export default {
}
.redborder {
border: 2px solid red !important;
border: 2px solid rgb(64, 158, 255) !important;
}
.play-box {
background-color: #000000;
border: 2px solid #505050;
//border: 2px solid #505050;
display: flex;
align-items: center;
justify-content: center;
}
.play-box-2-1 {
grid-column: 1 / span 2;
grid-row: 1 / span 2;
}
</style>
<style>
.videoList {

View File

@ -2,7 +2,7 @@
<div id="region" style="width: 100%">
<el-container v-loading="loading" >
<el-aside width="400px" >
<RegionTree ref="regionTree" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange" :onChannelChange="getChannelList"></RegionTree>
<RegionTree ref="regionTree" :showHeader=true :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange" :onChannelChange="getChannelList"></RegionTree>
</el-aside>
<el-main style="padding: 5px;">
<div class="page-header">

View File

@ -6,8 +6,8 @@
<el-menu-item index="/console">控制台</el-menu-item>
<el-menu-item index="/live">分屏监控</el-menu-item>
<el-menu-item index="/deviceList">国标设备</el-menu-item>
<el-menu-item index="/map">电子地图</el-menu-item>
<el-menu-item index="/deviceList">国标设备</el-menu-item>
<el-menu-item index="/streamPushList">推流列表</el-menu-item>
<el-menu-item index="/streamProxyList">拉流代理</el-menu-item>
<el-submenu index="/channel">

View File

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 1291092 */
src: url('iconfont.woff2?t=1722327493746') format('woff2'),
url('iconfont.woff?t=1722327493746') format('woff'),
url('iconfont.ttf?t=1722327493746') format('truetype');
src: url('iconfont.woff2?t=1726109971995') format('woff2'),
url('iconfont.woff?t=1726109971995') format('woff'),
url('iconfont.ttf?t=1726109971995') format('truetype');
}
.iconfont {
@ -13,6 +13,22 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-a-mti-1fenpingshi:before {
content: "\e7e5";
}
.icon-a-mti-4fenpingshi:before {
content: "\e7e6";
}
.icon-a-mti-6fenpingshi:before {
content: "\e7e7";
}
.icon-a-mti-9fenpingshi:before {
content: "\e7e8";
}
.icon-shexiangtou01:before {
content: "\e7e1";
}

Binary file not shown.