更换播放器, 修正和优化sql脚本,
This commit is contained in:
@@ -5,9 +5,11 @@ import java.util.logging.LogManager;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@EnableOpenApi
|
||||
public class VManageBootstrap extends LogManager {
|
||||
private static String[] args;
|
||||
|
||||
@@ -8,6 +8,8 @@ package com.genersoft.iot.vmp.common;
|
||||
*/
|
||||
public class VideoManagerConstants {
|
||||
|
||||
public static final String WVP_SERVER_PREFIX = "VMP_wvp_server";
|
||||
|
||||
public static final String MEDIA_SERVER_PREFIX = "VMP_media_server";
|
||||
|
||||
public static final String MEDIA_STREAM_PREFIX = "VMP_media_stream";
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MediaConfig {
|
||||
@Value("${media.rtp.port-range}")
|
||||
private String rtpPortRange;
|
||||
|
||||
@Value("${media.record-assist-port}")
|
||||
@Value("${media.record-assist-port:0}")
|
||||
private Integer recordAssistPort;
|
||||
|
||||
public String getIp() {
|
||||
|
||||
@@ -48,4 +48,16 @@ public class VideoStreamSessionManager {
|
||||
ssrcMap.remove(deviceId + "_" + channelId);
|
||||
streamIdMap.remove(deviceId + "_" + channelId);
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, ClientTransaction> getSessionMap() {
|
||||
return sessionMap;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, String> getSsrcMap() {
|
||||
return ssrcMap;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<String, String> getStreamIdMap() {
|
||||
return streamIdMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,13 @@ public class ZLMRTPServerFactory {
|
||||
if (currentStreams == null) {
|
||||
currentStreams = new HashMap<>();
|
||||
JSONObject jsonObject = zlmresTfulUtils.listRtpServer();
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
if (data != null) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject dataItem = data.getJSONObject(i);
|
||||
currentStreams.put(dataItem.getString("stream_id"), dataItem.getInteger("port"));
|
||||
if (jsonObject != null) {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
if (data != null) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject dataItem = data.getJSONObject(i);
|
||||
currentStreams.put(dataItem.getString("stream_id"), dataItem.getInteger("port"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,12 +75,12 @@ public class ZLMRTPServerFactory {
|
||||
result= createRTPServer(streamId);
|
||||
break;
|
||||
default:
|
||||
logger.error("创建RTP Server 失败: " + jsonObject.getString("msg"));
|
||||
logger.error("创建RTP Server 失败 {}: " + jsonObject.getString("msg"), newPort);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
// 检查ZLM状态
|
||||
logger.error("创建RTP Server 失败: 请检查ZLM服务");
|
||||
logger.error("创建RTP Server 失败 {}: 请检查ZLM服务", newPort);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ZLMRunner implements CommandLineRunner {
|
||||
if (responseJSON != null && responseJSON.getInteger("code") == 0) {
|
||||
logger.info("设置zlm成功");
|
||||
}else {
|
||||
logger.info("设置zlm失败: " + responseJSON.getString("msg"));
|
||||
logger.info("设置zlm失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,9 @@ public class ZLMRunner implements CommandLineRunner {
|
||||
// 设置为未启用
|
||||
logger.info("恢复流代理失败,请检查流地址后重新启用" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream());
|
||||
streamProxyService.stop(streamProxyDto.getApp(), streamProxyDto.getStream());
|
||||
}else if (jsonObject.getInteger("code") != 0){ // TODO 将错误信息存入数据库, 前端展示
|
||||
logger.info("恢复流代理失败:" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream() + "[ " + JSONObject.toJSONString(jsonObject) + " ]");
|
||||
streamProxyService.stop(streamProxyDto.getApp(), streamProxyDto.getStream());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||
zlmresTfulUtils.getSnap(streamUrl, 15, 1, path, fileName);
|
||||
}
|
||||
}
|
||||
System.out.println(path);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
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.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.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
@@ -31,6 +34,8 @@ 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.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.sip.message.Response;
|
||||
@@ -46,6 +51,9 @@ public class PlayController {
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager streamSession;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
|
||||
@@ -227,6 +235,20 @@ public class PlayController {
|
||||
logger.debug("语音广播API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
|
||||
if (device == null) {
|
||||
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId, result);
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("DeviceID", deviceId);
|
||||
json.put("CmdType", "Broadcast");
|
||||
json.put("Result", "Failed");
|
||||
json.put("Description", "Device 不存在");
|
||||
msg.setData(json);
|
||||
resultHolder.invokeResult(msg);
|
||||
return result;
|
||||
}
|
||||
cmder.audioBroadcastCmd(device, event -> {
|
||||
Response response = event.getResponse();
|
||||
RequestMessage msg = new RequestMessage();
|
||||
@@ -239,7 +261,7 @@ public class PlayController {
|
||||
msg.setData(json);
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
|
||||
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("语音广播操作超时, 设备未返回应答指令"));
|
||||
RequestMessage msg = new RequestMessage();
|
||||
@@ -256,5 +278,32 @@ public class PlayController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有的ssrc")
|
||||
@GetMapping("/ssrc")
|
||||
public WVPResult<JSONObject> getSSRC() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
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());
|
||||
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()));
|
||||
objects.add(jsonObject);
|
||||
}
|
||||
WVPResult<JSONObject> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data", objects);
|
||||
jsonObject.put("count", objects.size());
|
||||
result.setData(jsonObject);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user