From 3e71e0bdf1e4b2e527d491d426f67e34b7d3c148 Mon Sep 17 00:00:00 2001
From: xiaoQQya <xiaoQQya@126.com>
Date: 星期六, 05 十一月 2022 11:35:01 +0800
Subject: [PATCH] perf(rtcPlayer): 修改控制台 log 级别
---
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 112 +++++++++++++++++++++++++------------------------------
1 files changed, 51 insertions(+), 61 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
index 6d699cf..6798b48 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
@@ -24,6 +25,8 @@
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.utils.DateUtil;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@@ -33,6 +36,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.net.InetAddress;
@@ -93,25 +97,21 @@
@Override
- public WVPResult<StreamInfo> save(StreamProxyItem param) {
+ public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo;
- WVPResult<StreamInfo> wvpResult = new WVPResult<>();
- wvpResult.setCode(0);
- if (param.getMediaServerId() == null || "auto".equals(param.getMediaServerId())){
+ if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
}else {
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
}
if (mediaInfo == null) {
logger.warn("淇濆瓨浠g悊鏈壘鍒板湪绾跨殑ZLM...");
- wvpResult.setMsg("淇濆瓨澶辫触");
- return wvpResult;
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "淇濆瓨浠g悊鏈壘鍒板湪绾跨殑ZLM");
}
-
String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
param.getStream() );
param.setDst_url(dstUrl);
- StringBuffer result = new StringBuffer();
+ StringBuffer resultMsg = new StringBuffer();
boolean streamLive = false;
param.setMediaServerId(mediaInfo.getId());
boolean saveResult;
@@ -121,61 +121,47 @@
}else { // 鏂板
saveResult = addStreamProxy(param);
}
- if (saveResult) {
- result.append("淇濆瓨鎴愬姛");
- if (param.isEnable()) {
- JSONObject jsonObject = addStreamProxyToZlm(param);
- if (jsonObject == null || jsonObject.getInteger("code") != 0) {
- streamLive = false;
- result.append(", 浣嗘槸鍚敤澶辫触锛岃妫�鏌ユ祦鍦板潃鏄惁鍙敤");
- param.setEnable(false);
- // 鐩存帴绉婚櫎
- if (param.isEnable_remove_none_reader()) {
- del(param.getApp(), param.getStream());
- }else {
- updateStreamProxy(param);
- }
-
- }else {
- streamLive = true;
- StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
- mediaInfo, param.getApp(), param.getStream(), null, null);
- wvpResult.setData(streamInfo);
-
- }
- }
- }else {
- result.append("淇濆瓨澶辫触");
+ if (!saveResult) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(),"淇濆瓨澶辫触");
}
- if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) {
+ StreamInfo resultForStreamInfo = null;
+ resultMsg.append("淇濆瓨鎴愬姛");
+ if (param.isEnable()) {
+ JSONObject jsonObject = addStreamProxyToZlm(param);
+ if (jsonObject == null || jsonObject.getInteger("code") != 0) {
+ streamLive = false;
+ resultMsg.append(", 浣嗘槸鍚敤澶辫触锛岃妫�鏌ユ祦鍦板潃鏄惁鍙敤");
+ param.setEnable(false);
+ // 鐩存帴绉婚櫎
+ if (param.isEnable_remove_none_reader()) {
+ del(param.getApp(), param.getStream());
+ }else {
+ updateStreamProxy(param);
+ }
+
+
+ }else {
+ streamLive = true;
+ resultForStreamInfo = mediaService.getStreamInfoByAppAndStream(
+ mediaInfo, param.getApp(), param.getStream(), null, null);
+
+ }
+ }
+ if ( !ObjectUtils.isEmpty(param.getPlatformGbId()) && streamLive) {
List<GbStream> gbStreams = new ArrayList<>();
gbStreams.add(param);
if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){
- result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]鎴愬姛");
+ return resultForStreamInfo;
}else {
- result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触");
+ resultMsg.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触");
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());
+ }
+ }else {
+ if (!streamLive) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());
}
}
- if (!StringUtils.isEmpty(param.getGbId())) {
- // 鏌ユ壘寮�鍚簡鍏ㄩ儴鐩存挱娴佸叡浜殑涓婄骇骞冲彴
- List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
- if (parentPlatforms.size() > 0) {
- for (ParentPlatform parentPlatform : parentPlatforms) {
- param.setPlatformId(parentPlatform.getServerGBId());
- param.setCatalogId(parentPlatform.getCatalogId());
-
- String stream = param.getStream();
- StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
- if (streamProxyItems == null) {
- platformGbStreamMapper.add(param);
- eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD);
- }
- }
- }
- }
-
- wvpResult.setMsg(result.toString());
- return wvpResult;
+ return resultForStreamInfo;
}
/**
@@ -192,7 +178,7 @@
streamProxyItem.setCreateTime(now);
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
- if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
+ if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.add(streamProxyItem) < 0) {
//浜嬪姟鍥炴粴
dataSourceTransactionManager.rollback(transactionStatus);
@@ -227,7 +213,7 @@
streamProxyItem.setStreamType("proxy");
try {
if (streamProxyMapper.update(streamProxyItem) > 0) {
- if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
+ if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
//浜嬪姟鍥炴粴
dataSourceTransactionManager.rollback(transactionStatus);
@@ -311,12 +297,11 @@
public boolean start(String app, String stream) {
boolean result = false;
StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream);
- if (!streamProxy.isEnable() ) {
+ if (streamProxy != null && !streamProxy.isEnable() ) {
JSONObject jsonObject = addStreamProxyToZlm(streamProxy);
if (jsonObject == null) {
return false;
}
- System.out.println(jsonObject);
if (jsonObject.getInteger("code") == 0) {
result = true;
streamProxy.setEnable(true);
@@ -442,7 +427,7 @@
if(data != null && data.size() > 0) {
for (int i = 0; i < data.size(); i++) {
JSONObject streamJSONObj = data.getJSONObject(i);
- if ("rtmp".equals(streamJSONObj.getString("schema"))) {
+ if ("rtsp".equals(streamJSONObj.getString("schema"))) {
StreamInfo streamInfo = new StreamInfo();
String app = streamJSONObj.getString("app");
String stream = streamJSONObj.getString("stream");
@@ -470,4 +455,9 @@
}
}
+
+ @Override
+ public ResourceBaceInfo getOverview() {
+ return streamProxyMapper.getOverview();
+ }
}
--
Gitblit v1.8.0