|
@@ -120,48 +120,53 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
String channelId,int isUsePs,
|
|
|
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
|
|
Runnable timeoutCallback) {
|
|
|
- if (mediaServerItem == null) {
|
|
|
- logger.info("无法找到zlm服务");
|
|
|
- throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
|
|
|
- }
|
|
|
- String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
|
|
|
|
|
+ String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
|
|
+ WVPResult wvpResult = new WVPResult();
|
|
|
RequestMessage msg = new RequestMessage();
|
|
|
- msg.setKey(key);
|
|
|
-
|
|
|
Device device = redisCatchStorage.getDevice(deviceId);
|
|
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
|
|
|
|
|
|
+ msg.setKey(key);
|
|
|
+
|
|
|
+ if (mediaServerItem == null) {
|
|
|
+ logger.info("无法找到zlm服务");
|
|
|
+ // 释放异步请求
|
|
|
+ wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
+ wvpResult.setMsg("点播失败, 无法找到zlm服务");
|
|
|
+ msg.setData(wvpResult);
|
|
|
+ resultHolder.invokeAllResult(msg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (streamInfo != null) {
|
|
|
logger.info("可以找到对应的stream");
|
|
|
String streamId = streamInfo.getStream();
|
|
|
+
|
|
|
if (streamId == null) {
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
wvpResult.setMsg("点播失败, redis缓存streamId等于null");
|
|
|
msg.setData(wvpResult);
|
|
|
resultHolder.invokeAllResult(msg);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
String mediaServerId = streamInfo.getMediaServerId();
|
|
|
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
-
|
|
|
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
|
|
|
+
|
|
|
if (rtpInfo.getInteger("code") == 0) {
|
|
|
if (rtpInfo.getBoolean("exist")) {
|
|
|
int localPort = rtpInfo.getInteger("local_port");
|
|
|
if (localPort == 0) {
|
|
|
logger.warn("[点播],点播时发现rtpServerC存在,但是尚未开始推流");
|
|
|
// 此时说明rtpServer已经创建但是流还没有推上来
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
wvpResult.setMsg("点播已经在进行中,请稍候重试");
|
|
|
msg.setData(wvpResult);
|
|
|
-
|
|
|
resultHolder.invokeAllResult(msg);
|
|
|
return;
|
|
|
} else {
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
|
|
|
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
|
|
|
wvpResult.setData(streamInfo);
|
|
@@ -171,7 +176,6 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
hookEvent.response(mediaServerItem, JSON.parseObject(JSON.toJSONString(streamInfo)));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
redisCatchStorage.stopPlay(streamInfo);
|
|
|
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
|
@@ -190,17 +194,14 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
if (mediaServerItem.isRtpEnable()) {
|
|
|
logger.info("test ----- {}",device.getDeviceId());
|
|
|
logger.info("test ----- {}",channelId);
|
|
|
-
|
|
|
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
|
|
|
}
|
|
|
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
|
|
|
logger.info(JSONObject.toJSONString(ssrcInfo));
|
|
|
if (ssrcInfo == null) {
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
wvpResult.setMsg("开启收流失败");
|
|
|
msg.setData(wvpResult);
|
|
|
-
|
|
|
resultHolder.invokeAllResult(msg);
|
|
|
return;
|
|
|
}
|
|
@@ -213,7 +214,6 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
}, event -> {
|
|
|
// sip error错误
|
|
|
logger.warn("sip 错误,点播失败");
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
|
|
|
msg.setData(wvpResult);
|
|
@@ -224,7 +224,6 @@ public class PlayServiceImpl implements IPlayService {
|
|
|
}, (code, msgStr) -> {
|
|
|
// invite点播超时
|
|
|
logger.warn("sip 点播超时");
|
|
|
- WVPResult wvpResult = new WVPResult();
|
|
|
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
|
|
if (code == 0) {
|
|
|
wvpResult.setMsg("点播超时,请稍候重试");
|