优化集群方案, 每个zlm一套ssrc;
优化集群下的docker接入逻辑; 更正sql脚本; 支持重启不设置设备离线。重启SIP事务不丢失
This commit is contained in:
@@ -2,13 +2,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.play;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
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.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
@@ -37,7 +36,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -89,7 +88,7 @@ public class PlayController {
|
||||
|
||||
// 获取可用的zlm
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
IMediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null);
|
||||
|
||||
return playResult.getResult();
|
||||
@@ -174,7 +173,7 @@ public class PlayController {
|
||||
logger.warn("视频转码API调用失败!, 视频流已经停止!");
|
||||
return new ResponseEntity<String>("未找到视频流信息, 视频流可能已经停止", HttpStatus.OK);
|
||||
}
|
||||
IMediaServerItem mediaInfo = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
|
||||
if (!rtpInfo.getBoolean("exist")) {
|
||||
logger.warn("视频转码API调用失败!, 视频流已停止推流!");
|
||||
@@ -219,7 +218,7 @@ public class PlayController {
|
||||
result.put("msg", "mediaServerId is null");
|
||||
return new ResponseEntity<String>( result.toJSONString(), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
IMediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaInfo == null) {
|
||||
result.put("code", 0);
|
||||
result.put("msg", "使用的流媒体已经停止运行");
|
||||
@@ -307,16 +306,16 @@ public class PlayController {
|
||||
logger.debug("获取所有的ssrc");
|
||||
}
|
||||
JSONArray objects = new JSONArray();
|
||||
for(Map.Entry<String, String> entry: streamSession.getSsrcMap().entrySet()) {
|
||||
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
|
||||
List<SsrcTransaction> allSsrc = streamSession.getAllSsrc();
|
||||
for (SsrcTransaction transaction : allSsrc) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String[] keyArray = entry.getKey().split("_");
|
||||
jsonObject.put("deviceId", keyArray[0]);
|
||||
jsonObject.put("channelId", keyArray[1]);
|
||||
jsonObject.put("ssrc", entry.getValue());
|
||||
jsonObject.put("streamId", streamSession.getStreamIdMap().get(entry.getKey()));
|
||||
jsonObject.put("deviceId", transaction.getDeviceId());
|
||||
jsonObject.put("channelId", transaction.getChannelId());
|
||||
jsonObject.put("ssrc", transaction.getSsrc());
|
||||
jsonObject.put("streamId", transaction.getStreamId());
|
||||
objects.add(jsonObject);
|
||||
}
|
||||
|
||||
WVPResult<JSONObject> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
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.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -58,6 +58,9 @@ public class DownloadController {
|
||||
@Autowired
|
||||
private DeferredResultHolder resultHolder;
|
||||
|
||||
@Autowired
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
@ApiOperation("开始历史媒体下载")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
|
||||
@@ -90,7 +93,7 @@ public class DownloadController {
|
||||
cmder.streamByeCmd(deviceId, channelId);
|
||||
}
|
||||
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result);
|
||||
IMediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
if (newMediaServerItem == null) {
|
||||
logger.warn(String.format("设备下载响应超时,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||
RequestMessage msg = new RequestMessage();
|
||||
@@ -99,7 +102,10 @@ public class DownloadController {
|
||||
resultHolder.invokeResult(msg);
|
||||
return result;
|
||||
}
|
||||
cmder.downloadStreamCmd(newMediaServerItem, device, channelId, startTime, endTime, downloadSpeed, (IMediaServerItem mediaServerItem, JSONObject response) -> {
|
||||
|
||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null);
|
||||
|
||||
cmder.downloadStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, (MediaServerItem mediaServerItem, JSONObject response) -> {
|
||||
logger.info("收到订阅消息: " + response.toJSONString());
|
||||
playService.onPublishHandlerForPlayBack(mediaServerItem, response, deviceId, channelId, uuid.toString());
|
||||
}, event -> {
|
||||
|
||||
@@ -4,8 +4,9 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
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.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -58,6 +59,9 @@ public class PlaybackController {
|
||||
@Autowired
|
||||
private DeferredResultHolder resultHolder;
|
||||
|
||||
@Autowired
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
@ApiOperation("开始视频回放")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
|
||||
@@ -74,6 +78,15 @@ public class PlaybackController {
|
||||
}
|
||||
UUID uuid = UUID.randomUUID();
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(30000L);
|
||||
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
if (device == null) {
|
||||
result.setResult(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
|
||||
return result;
|
||||
}
|
||||
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null);
|
||||
|
||||
// 超时处理
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||
@@ -82,14 +95,14 @@ public class PlaybackController {
|
||||
msg.setData("Timeout");
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
|
||||
StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, channelId);
|
||||
if (streamInfo != null) {
|
||||
// 停止之前的回放
|
||||
cmder.streamByeCmd(deviceId, channelId);
|
||||
}
|
||||
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result);
|
||||
IMediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
|
||||
if (newMediaServerItem == null) {
|
||||
logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||
RequestMessage msg = new RequestMessage();
|
||||
@@ -98,7 +111,8 @@ public class PlaybackController {
|
||||
resultHolder.invokeResult(msg);
|
||||
return result;
|
||||
}
|
||||
cmder.playbackStreamCmd(newMediaServerItem, device, channelId, startTime, endTime, (IMediaServerItem mediaServerItem, JSONObject response) -> {
|
||||
|
||||
cmder.playbackStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, (MediaServerItem mediaServerItem, JSONObject response) -> {
|
||||
logger.info("收到订阅消息: " + response.toJSONString());
|
||||
playService.onPublishHandlerForPlayBack(mediaServerItem, response, deviceId, channelId, uuid.toString());
|
||||
}, event -> {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.session;
|
||||
|
||||
public enum PlayTypeEnum {
|
||||
|
||||
PLAY("0", "直播"),
|
||||
PLAY_BACK("1", "回放");
|
||||
|
||||
private String value;
|
||||
private String name;
|
||||
|
||||
PlayTypeEnum(String value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.genersoft.iot.vmp.vmanager.server;
|
||||
|
||||
import com.genersoft.iot.vmp.VManageBootstrap;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
@@ -17,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.sip.ListeningPoint;
|
||||
import javax.sip.ObjectInUseException;
|
||||
import javax.sip.SipProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,19 +35,30 @@ public class ServerController {
|
||||
@ApiOperation("流媒体服务列表")
|
||||
@GetMapping(value = "/media_server/list")
|
||||
@ResponseBody
|
||||
public WVPResult<List<IMediaServerItem>> getMediaServerList(){
|
||||
WVPResult<List<IMediaServerItem>> result = new WVPResult<>();
|
||||
public WVPResult<List<MediaServerItem>> getMediaServerList(){
|
||||
WVPResult<List<MediaServerItem>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
result.setData(mediaServerService.getAll());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("在线流媒体服务列表")
|
||||
@GetMapping(value = "/media_server/online/list")
|
||||
@ResponseBody
|
||||
public WVPResult<List<MediaServerItem>> getOnlineMediaServerList(){
|
||||
WVPResult<List<MediaServerItem>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
result.setData(mediaServerService.getAllOnline());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("获取流媒体服务")
|
||||
@GetMapping(value = "/media_server/one/{id}")
|
||||
@ResponseBody
|
||||
public WVPResult<IMediaServerItem> getMediaServer(@PathVariable String id){
|
||||
WVPResult<IMediaServerItem> result = new WVPResult<>();
|
||||
public WVPResult<MediaServerItem> getMediaServer(@PathVariable String id){
|
||||
WVPResult<MediaServerItem> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
result.setData(mediaServerService.getOne(id));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.genersoft.iot.vmp.vmanager.streamProxy;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
@@ -9,7 +8,6 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@@ -86,7 +84,7 @@ public class StreamProxyController {
|
||||
public WVPResult getFFmpegCMDs(@RequestParam String mediaServerId){
|
||||
logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId );
|
||||
|
||||
IMediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
JSONObject data = streamProxyService.getFFmpegCMDs(mediaServerItem);
|
||||
WVPResult<JSONObject> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
|
||||
Reference in New Issue
Block a user