Commit 8bb1b2b94f07c2f9ebc4b2a63e9ace14765e3d8b

Authored by Lawrence
1 parent f7101f78

获取播放流编码时增加重试之间的延时,避免过度频繁的API查询

src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
... ... @@ -66,19 +66,23 @@ public class PlayController {
66 66 try {
67 67 if (System.currentTimeMillis() - startTime > 30 * 1000) {
68 68 storager.stopPlay(streamInfo);
  69 + logger.info("播放等待超时");
69 70 return new ResponseEntity<String>("timeout",HttpStatus.OK);
70 71 }else {
71 72 streamInfo = storager.queryPlayByDevice(deviceId, channelId);
72 73 JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
73 74 if (rtpInfo != null && rtpInfo.getBoolean("exist") && streamInfo.getFlv() != null){
  75 + logger.info("RTP已推流,查询编码信息:"+streamInfo.getFlv());
  76 + Thread.sleep(2000);
74 77 JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId);
75 78 if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
76 79 lockFlag = false;
  80 + logger.info("媒体编码信息已获取");
77 81 JSONArray tracks = mediaInfo.getJSONArray("tracks");
78 82 streamInfo.setTracks(tracks);
79 83 storager.startPlay(streamInfo);
80 84 }else {
81   -
  85 + logger.info("媒体编码信息未获取,2秒后重试...");
82 86 }
83 87 }else {
84 88 Thread.sleep(2000);
... ...