优化媒体节点服务的代码结构
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.Track;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class StreamContent {
|
||||
private String mediaServerId;
|
||||
|
||||
@Schema(description = "流编码信息")
|
||||
private Track track;
|
||||
private MediaInfo mediaInfo;
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
private String startTime;
|
||||
@@ -171,7 +171,7 @@ public class StreamContent {
|
||||
}
|
||||
|
||||
this.mediaServerId = streamInfo.getMediaServerId();
|
||||
this.track = streamInfo.getTrack();
|
||||
this.mediaInfo = streamInfo.getMediaInfo();
|
||||
this.startTime = streamInfo.getStartTime();
|
||||
this.endTime = streamInfo.getEndTime();
|
||||
this.progress = streamInfo.getProgress();
|
||||
@@ -389,12 +389,12 @@ public class StreamContent {
|
||||
this.mediaServerId = mediaServerId;
|
||||
}
|
||||
|
||||
public Track getTrack() {
|
||||
return track;
|
||||
public MediaInfo getMediaInfo() {
|
||||
return mediaInfo;
|
||||
}
|
||||
|
||||
public void setTrack(Track track) {
|
||||
this.track = track;
|
||||
public void setMediaInfo(MediaInfo mediaInfo) {
|
||||
this.mediaInfo = mediaInfo;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.vmanager.cloudRecord;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
||||
@@ -67,10 +67,10 @@ public class CloudRecordController {
|
||||
if (ObjectUtils.isEmpty(month)) {
|
||||
month = calendar.get(Calendar.MONTH) + 1;
|
||||
}
|
||||
List<MediaServerItem> mediaServerItems;
|
||||
List<MediaServer> mediaServerItems;
|
||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||
mediaServerItems = new ArrayList<>();
|
||||
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
MediaServer mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServerItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId);
|
||||
}
|
||||
@@ -110,10 +110,10 @@ public class CloudRecordController {
|
||||
logger.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}",
|
||||
app, stream, mediaServerId, page, count, startTime, endTime);
|
||||
|
||||
List<MediaServerItem> mediaServerItems;
|
||||
List<MediaServer> mediaServerItems;
|
||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||
mediaServerItems = new ArrayList<>();
|
||||
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
MediaServer mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServerItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) String remoteHost
|
||||
){
|
||||
MediaServerItem mediaServerItem;
|
||||
MediaServer mediaServerItem;
|
||||
if (mediaServerId == null) {
|
||||
mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
}else {
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
@@ -104,7 +104,7 @@ public class PlayController {
|
||||
logger.info("[开始点播] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
// 获取可用的zlm
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
MediaServer newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
|
||||
RequestMessage requestMessage = new RequestMessage();
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
||||
@@ -218,7 +218,7 @@ public class PlayController {
|
||||
logger.warn("视频转码API调用失败!, 视频流已经停止!");
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到视频流信息, 视频流可能已经停止");
|
||||
}
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId());
|
||||
MediaServer mediaInfo = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId());
|
||||
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
|
||||
if (!rtpInfo.getBoolean("exist")) {
|
||||
logger.warn("视频转码API调用失败!, 视频流已停止推流!");
|
||||
@@ -257,7 +257,7 @@ public class PlayController {
|
||||
if (mediaServerId == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "流媒体:" + mediaServerId + "不存在" );
|
||||
}
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||
MediaServer mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaInfo == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "使用的流媒体已经停止运行" );
|
||||
}else {
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRtpServerTimeoutHookParam;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
@@ -83,7 +83,7 @@ public class PsController {
|
||||
logger.info("[第三方PS服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack);
|
||||
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
if (mediaServerItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(),"没有可用的MediaServer");
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class PsController {
|
||||
@Parameter(name = "stream", description = "流的ID", required = true)
|
||||
public void closeRtpServer(String stream) {
|
||||
logger.info("[第三方PS服务对接->关闭收流] stream->{}", stream);
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
zlmServerFactory.closeRtpServer(mediaServerItem,stream);
|
||||
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_*_" + stream;
|
||||
List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey);
|
||||
@@ -201,7 +201,7 @@ public class PsController {
|
||||
app,
|
||||
stream,
|
||||
callId);
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId;
|
||||
OtherPsSendInfo sendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(key);
|
||||
if (sendInfo == null) {
|
||||
@@ -290,7 +290,7 @@ public class PsController {
|
||||
param.put("app",sendInfo.getPushApp());
|
||||
param.put("stream",sendInfo.getPushStream());
|
||||
param.put("ssrc",sendInfo.getPushSSRC());
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
Boolean result = zlmServerFactory.stopSendRtpStream(mediaServerItem, param);
|
||||
if (!result) {
|
||||
logger.info("[第三方PS服务对接->关闭发送流] 失败 callId->{}", callId);
|
||||
@@ -305,7 +305,7 @@ public class PsController {
|
||||
@GetMapping(value = "/getTestPort")
|
||||
@ResponseBody
|
||||
public int getTestPort() {
|
||||
MediaServerItem defaultMediaServer = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer defaultMediaServer = mediaServerService.getDefaultMediaServer();
|
||||
|
||||
// for (int i = 0; i <300; i++) {
|
||||
// new Thread(() -> {
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRtpServerTimeoutHookParam;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
@@ -83,7 +83,7 @@ public class RtpController {
|
||||
logger.info("[第三方服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack);
|
||||
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
if (mediaServerItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(),"没有可用的MediaServer");
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class RtpController {
|
||||
@Parameter(name = "stream", description = "流的ID", required = true)
|
||||
public void closeRtpServer(String stream) {
|
||||
logger.info("[第三方服务对接->关闭收流] stream->{}", stream);
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
zlmServerFactory.closeRtpServer(mediaServerItem,stream);
|
||||
zlmServerFactory.closeRtpServer(mediaServerItem,stream + "_a");
|
||||
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_*_" + stream;
|
||||
@@ -225,7 +225,7 @@ public class RtpController {
|
||||
if (!((dstPortForAudio > 0 && !ObjectUtils.isEmpty(dstPortForAudio) || (dstPortForVideo > 0 && !ObjectUtils.isEmpty(dstIpForVideo))))) {
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "至少应该存在一组音频或视频发送参数");
|
||||
}
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
String key = VideoManagerConstants.WVP_OTHER_SEND_RTP_INFO + userSetting.getServerId() + "_" + callId;
|
||||
OtherRtpSendInfo sendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(key);
|
||||
if (sendInfo == null) {
|
||||
@@ -367,7 +367,7 @@ public class RtpController {
|
||||
param.put("app",sendInfo.getPushApp());
|
||||
param.put("stream",sendInfo.getPushStream());
|
||||
param.put("ssrc",sendInfo.getPushSSRC());
|
||||
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
Boolean result = zlmServerFactory.stopSendRtpStream(mediaServerItem, param);
|
||||
if (!result) {
|
||||
logger.info("[第三方服务对接->关闭发送流] 失败 callId->{}", callId);
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
@@ -83,14 +83,14 @@ public class ServerController {
|
||||
@GetMapping(value = "/media_server/list")
|
||||
@ResponseBody
|
||||
@Operation(summary = "流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public List<MediaServerItem> getMediaServerList() {
|
||||
public List<MediaServer> getMediaServerList() {
|
||||
return mediaServerService.getAll();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/media_server/online/list")
|
||||
@ResponseBody
|
||||
@Operation(summary = "在线流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public List<MediaServerItem> getOnlineMediaServerList() {
|
||||
public List<MediaServer> getOnlineMediaServerList() {
|
||||
return mediaServerService.getAllOnline();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ServerController {
|
||||
@ResponseBody
|
||||
@Operation(summary = "停止视频回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "id", description = "流媒体服务ID", required = true)
|
||||
public MediaServerItem getMediaServer(@PathVariable String id) {
|
||||
public MediaServer getMediaServer(@PathVariable String id) {
|
||||
return mediaServerService.getOne(id);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ServerController {
|
||||
@Parameter(name = "secret", description = "流媒体服务secret", required = true)
|
||||
@GetMapping(value = "/media_server/check")
|
||||
@ResponseBody
|
||||
public MediaServerItem checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret, @RequestParam String type) {
|
||||
public MediaServer checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret, @RequestParam String type) {
|
||||
return mediaServerService.checkMediaServer(ip, port, secret, type);
|
||||
}
|
||||
|
||||
@@ -128,8 +128,8 @@ public class ServerController {
|
||||
@Parameter(name = "mediaServerItem", description = "流媒体信息", required = true)
|
||||
@PostMapping(value = "/media_server/save")
|
||||
@ResponseBody
|
||||
public void saveMediaServer(@RequestBody MediaServerItem mediaServerItem) {
|
||||
MediaServerItem mediaServerItemInDatabase = mediaServerService.getOneFromDatabase(mediaServerItem.getId());
|
||||
public void saveMediaServer(@RequestBody MediaServer mediaServerItem) {
|
||||
MediaServer mediaServerItemInDatabase = mediaServerService.getOneFromDatabase(mediaServerItem.getId());
|
||||
|
||||
if (mediaServerItemInDatabase != null) {
|
||||
mediaServerService.update(mediaServerItem);
|
||||
@@ -238,11 +238,11 @@ public class ServerController {
|
||||
@Operation(summary = "获取负载信息")
|
||||
public List<MediaServerLoad> getMediaLoad() {
|
||||
List<MediaServerLoad> result = new ArrayList<>();
|
||||
List<MediaServerItem> allOnline = mediaServerService.getAllOnline();
|
||||
List<MediaServer> allOnline = mediaServerService.getAllOnline();
|
||||
if (allOnline.size() == 0) {
|
||||
return result;
|
||||
}else {
|
||||
for (MediaServerItem mediaServerItem : allOnline) {
|
||||
for (MediaServer mediaServerItem : allOnline) {
|
||||
result.add(mediaServerService.getLoad(mediaServerItem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
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.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||
@@ -138,7 +138,7 @@ public class StreamProxyController {
|
||||
public JSONObject getFFmpegCMDs(@RequestParam String mediaServerId){
|
||||
logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId );
|
||||
|
||||
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
MediaServer mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServerItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "流媒体: " + mediaServerId + "未找到");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user