Merge remote-tracking branch 'origin/wvp-28181-2.0' into liujie-20220712

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
#	src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
This commit is contained in:
648540858
2022-07-12 16:28:51 +08:00
66 changed files with 1614 additions and 665 deletions

View File

@@ -63,12 +63,13 @@ public class MobilePositionController {
@ApiOperation("查询历史轨迹")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "start", value = "开始时间", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "通道ID", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "start", value = "开始时间", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "结束时间", required = false, dataTypeClass = String.class),
})
@GetMapping("/history/{deviceId}/{channelId}")
@GetMapping("/history/{deviceId}")
public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId,
@PathVariable String channelId,
@RequestParam(required = false) String channelId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
// if (logger.isDebugEnabled()) {

View File

@@ -1,9 +1,14 @@
package com.genersoft.iot.vmp.vmanager.gb28181.media;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.annotations.Api;
@@ -16,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@Api(tags = "媒体流相关")
@Controller
@@ -26,17 +33,11 @@ public class MediaController {
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IStreamPushService streamPushService;
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IMediaService mediaService;
@Autowired
private IMediaServerService mediaServerService;
/**
* 根据应用名和流id获取播放地址
@@ -52,13 +53,47 @@ public class MediaController {
})
@GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam(required = false) String mediaServerId){
StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId,
@RequestParam(required = false) String callId,
@RequestParam(required = false) Boolean useSourceIpAsStreamIp){
boolean authority = false;
if (callId != null) {
// 权限校验
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
if (streamAuthorityInfo.getCallId().equals(callId)) {
authority = true;
}else {
WVPResult<StreamInfo> result = new WVPResult<>();
result.setCode(401);
result.setMsg("fail");
return result;
}
}else {
// 是否登陆用户, 登陆用户返回完整信息
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo!= null) {
authority = true;
}
}
StreamInfo streamInfo;
if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) {
String host = request.getHeader("Host");
String localAddr = host.split(":")[0];
logger.info("使用{}作为返回流的ip", localAddr);
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
}else {
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfoByAppAndStreamWithCheck != null){
if (streamInfo != null){
result.setCode(0);
result.setMsg("scccess");
result.setData(streamInfoByAppAndStreamWithCheck);
result.setData(streamInfo);
}else {
result.setCode(-1);
result.setMsg("fail");

View File

@@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
@@ -169,6 +170,8 @@ public class PlatformController {
wvpResult.setMsg("平台 " + parentPlatform.getServerGBId() + " 已存在");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
parentPlatform.setCreateTime(DateUtil.getNow());
parentPlatform.setUpdateTime(DateUtil.getNow());
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {
@@ -232,7 +235,7 @@ public class PlatformController {
}
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
parentPlatform.setUpdateTime(DateUtil.getNow());
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {

View File

@@ -197,7 +197,7 @@ public class PlayController {
JSONObject data = jsonObject.getJSONObject("data");
if (data != null) {
result.put("key", data.getString("key"));
StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId());
StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false);
result.put("data", streamInfoResult);
}
}else {

View File

@@ -131,6 +131,9 @@ public class StreamProxyController {
public Object start(String app, String stream){
logger.info("启用代理: " + app + "/" + stream);
boolean result = streamProxyService.start(app, stream);
if (!result) {
logger.info("启用代理失败: " + app + "/" + stream);
}
return result?"success":"fail";
}

View File

@@ -3,11 +3,16 @@ package com.genersoft.iot.vmp.vmanager.streamPush;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam;
@@ -30,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -54,6 +60,9 @@ public class StreamPushController {
@Autowired
private DeferredResultHolder resultHolder;
@Autowired
private IMediaService mediaService;
@ApiOperation("推流列表查询")
@ApiImplicitParams({
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@@ -237,5 +246,43 @@ public class StreamPushController {
return result;
}
/**
* 获取推流播放地址
* @param app 应用名
* @param stream 流id
* @return
*/
@ApiOperation("获取推流播放地址")
@ApiImplicitParams({
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class),
@ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class, required = false),
})
@GetMapping(value = "/getPlayUrl")
@ResponseBody
public WVPResult<StreamInfo> getPlayUrl(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId){
boolean authority = false;
// 是否登陆用户, 登陆用户返回完整信息
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo!= null) {
authority = true;
}
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfo != null){
result.setCode(0);
result.setMsg("scccess");
result.setData(streamInfo);
}else {
result.setCode(-1);
result.setMsg("fail");
}
return result;
}
}