648540858
2020-10-16 4d9a62339d43e163c3615a52b72a3c3f01cc30ab
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
@@ -7,6 +7,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
@@ -69,30 +70,14 @@
               return new ResponseEntity<String>("timeout",HttpStatus.OK);
            }else {
               JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
               Boolean exist = rtpInfo.getBoolean("exist");
               if (rtpInfo == null || !rtpInfo.getBoolean("exist") || streamInfo.getFlv() != null){
               if (rtpInfo == null || !rtpInfo.getBoolean("exist") || storager.queryPlayByDevice(deviceId, channelId).getFlv() == null){
                  Thread.sleep(2000);
                  continue;
               }else {
                  lockFlag = false;
                  streamInfo = storager.queryPlay(streamInfo);
                  // 获取媒体信息
                  JSONObject mediaList = zlmresTfulUtils.getMediaList("rtp", "rtmp");
                  if (mediaList.getInteger("code") == 0) {
                     JSONArray data = mediaList.getJSONArray("data");
                     if (data!= null) {
                        for (Object datum : data) {
                           JSONObject media = (JSONObject)datum;
                           if (streamId.equals(media.getString("stream"))) {
                              streamInfo.setTracks(media.getJSONArray("tracks"));
                              storager.startPlay(streamInfo);
                           }
                        }
                     }
                  }
               };
            }
            Thread.sleep(200);
            streamInfo = storager.queryPlayByDevice(deviceId, channelId);
         } catch (InterruptedException e) {
            e.printStackTrace();
         }