648540858
2020-10-26 9361943e47a09ea46f76adf06fa0d24a07ac711d
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
@@ -58,24 +58,31 @@
      }
      String streamId = String.format("%08x", Integer.parseInt(streamInfo.getSsrc())).toUpperCase();
      // 等待推流, TODO 默认超时15s
      // 等待推流, TODO 默认超时30s
      boolean lockFlag = true;
      long startTime = System.currentTimeMillis();
      while (lockFlag) {
         try {
            if (System.currentTimeMillis() - startTime > 15 * 1000) {
            if (System.currentTimeMillis() - startTime > 30 * 1000) {
               storager.stopPlay(streamInfo);
               return new ResponseEntity<String>("timeout",HttpStatus.OK);
            }else {
               streamInfo = storager.queryPlayByDevice(deviceId, channelId);
               JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
               if (rtpInfo == null || !rtpInfo.getBoolean("exist") || storager.queryPlayByDevice(deviceId, channelId).getFlv() == null){
               if (rtpInfo != null && rtpInfo.getBoolean("exist") && streamInfo != null && streamInfo.getFlv() != null){
                  JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo("rtp", "rtmp", streamId);
                  if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
                     lockFlag = false;
                     JSONArray tracks = mediaInfo.getJSONArray("tracks");
                     streamInfo.setTracks(tracks);
                     storager.startPlay(streamInfo);
                  }else {
                  }
               }else {
                  Thread.sleep(2000);
                  continue;
               }else {
                  lockFlag = false;
                  streamInfo = storager.queryPlay(streamInfo);
               };
            }
         } catch (InterruptedException e) {