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