修复回看控制失效 #619

This commit is contained in:
648540858
2022-09-30 17:54:58 +08:00
parent 386b48192d
commit a4f48a1522
12 changed files with 185 additions and 35 deletions

View File

@@ -521,10 +521,15 @@ public class ZLMHttpHookListener {
if (sendRtpItem.getApp().equals(app)) {
String platformId = sendRtpItem.getPlatformId();
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
Device device = deviceService.queryDevice(platformId);
try {
commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
} catch (SipException | InvalidArgumentException | ParseException e) {
if (platform != null) {
commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
}else {
cmder.streamByeCmd(device, sendRtpItem.getChannelId(), stream, sendRtpItem.getCallId());
}
} catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) {
logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
}
}
@@ -587,19 +592,24 @@ public class ZLMHttpHookListener {
storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
}else{
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (streamInfoForPlayBackCatch != null) {
Device device = deviceService.queryDevice(streamInfoForPlayCatch.getDeviceID());
if (device != null) {
try {
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
streamInfoForPlayBackCatch.getStream(), null);
} catch (InvalidArgumentException | ParseException | SipException |
SsrcTransactionNotFoundException e) {
logger.error("[无人观看]回放, 发送BYE失败 {}", e.getMessage());
if (streamInfoForPlayBackCatch != null ) {
if (streamInfoForPlayBackCatch.isPause()) {
ret.put("close", false);
}else {
Device device = deviceService.queryDevice(streamInfoForPlayBackCatch.getDeviceID());
if (device != null) {
try {
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
streamInfoForPlayBackCatch.getStream(), null);
} catch (InvalidArgumentException | ParseException | SipException |
SsrcTransactionNotFoundException e) {
logger.error("[无人观看]回放, 发送BYE失败 {}", e.getMessage());
}
}
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
}
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
}else {
StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
// 进行录像下载时无人观看不断流

View File

@@ -23,6 +23,9 @@ public class ZLMRESTfulUtils {
private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class);
public interface RequestCallback{
void run(JSONObject response);
}
@@ -322,10 +325,22 @@ public class ZLMRESTfulUtils {
}
public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
Map<String, Object> param = new HashMap<>();
Map<String, Object> param = new HashMap<>(3);
param.put("url", flvUrl);
param.put("timeout_sec", timeout_sec);
param.put("expire_sec", expire_sec);
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
}
public JSONObject pauseRtpCheck(MediaServerItem mediaServerItem, String streamId) {
Map<String, Object> param = new HashMap<>(1);
param.put("stream_id", streamId);
return sendPost(mediaServerItem, "pauseRtpCheck",param, null);
}
public JSONObject resumeRtpCheck(MediaServerItem mediaServerItem, String streamId) {
Map<String, Object> param = new HashMap<>(1);
param.put("stream_id", streamId);
return sendPost(mediaServerItem, "resumeRtpCheck",param, null);
}
}

View File

@@ -103,7 +103,6 @@ public class ZLMRTPServerFactory {
param.put("stream_id", streamId);
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
if (jsonObject != null ) {
System.out.println(jsonObject);
if (jsonObject.getInteger("code") == 0) {
return createRTPServer(mediaServerItem, streamId, ssrc, port);
}else {
@@ -150,7 +149,6 @@ public class ZLMRTPServerFactory {
param.put("stream_id", streamId);
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param);
if (jsonObject != null ) {
System.out.println(jsonObject);
if (jsonObject.getInteger("code") == 0) {
result = jsonObject.getInteger("hit") == 1;
}else {