获取播放流编码时增加重试之间的延时,避免过度频繁的API查询
parent
f7101f7839
commit
8bb1b2b94f
|
@ -66,19 +66,23 @@ public class PlayController {
|
||||||
try {
|
try {
|
||||||
if (System.currentTimeMillis() - startTime > 30 * 1000) {
|
if (System.currentTimeMillis() - startTime > 30 * 1000) {
|
||||||
storager.stopPlay(streamInfo);
|
storager.stopPlay(streamInfo);
|
||||||
|
logger.info("播放等待超时");
|
||||||
return new ResponseEntity<String>("timeout",HttpStatus.OK);
|
return new ResponseEntity<String>("timeout",HttpStatus.OK);
|
||||||
}else {
|
}else {
|
||||||
streamInfo = storager.queryPlayByDevice(deviceId, channelId);
|
streamInfo = storager.queryPlayByDevice(deviceId, channelId);
|
||||||
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
|
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
|
||||||
if (rtpInfo != null && rtpInfo.getBoolean("exist") && streamInfo.getFlv() != null){
|
if (rtpInfo != null && rtpInfo.getBoolean("exist") && streamInfo.getFlv() != null){
|
||||||
|
logger.info("RTP已推流,查询编码信息:"+streamInfo.getFlv());
|
||||||
|
Thread.sleep(2000);
|
||||||
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId);
|
JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId);
|
||||||
if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
|
if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
|
||||||
lockFlag = false;
|
lockFlag = false;
|
||||||
|
logger.info("媒体编码信息已获取");
|
||||||
JSONArray tracks = mediaInfo.getJSONArray("tracks");
|
JSONArray tracks = mediaInfo.getJSONArray("tracks");
|
||||||
streamInfo.setTracks(tracks);
|
streamInfo.setTracks(tracks);
|
||||||
storager.startPlay(streamInfo);
|
storager.startPlay(streamInfo);
|
||||||
}else {
|
}else {
|
||||||
|
logger.info("媒体编码信息未获取,2秒后重试...");
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
Loading…
Reference in New Issue