| | |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult; |
| | | import com.genersoft.iot.vmp.vmanager.service.IMediaService; |
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @CrossOrigin |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | @RequestMapping("/api/play") |
| | | public class PlayController { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(PlayController.class); |
| | |
| | | @Autowired |
| | | private IMediaService mediaService; |
| | | |
| | | @GetMapping("/play/{deviceId}/{channelId}") |
| | | @GetMapping("/start/{deviceId}/{channelId}") |
| | | public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, |
| | | @PathVariable String channelId) { |
| | | |
| | |
| | | return playResult.getResult(); |
| | | } |
| | | |
| | | @PostMapping("/play/{streamId}/stop") |
| | | @PostMapping("/stop/{streamId}") |
| | | public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String streamId) { |
| | | |
| | | logger.debug(String.format("设备预览/回放停止API调用,streamId:%s", streamId)); |
| | |
| | | * @param streamId 流ID |
| | | * @return |
| | | */ |
| | | @PostMapping("/play/{streamId}/convert") |
| | | @PostMapping("/convert/{streamId}") |
| | | public ResponseEntity<String> playConvert(@PathVariable String streamId) { |
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); |
| | | if (streamInfo == null) { |
| | |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | result.put("key", data.getString("key")); |
| | | // StreamInfo streamInfoResult = new StreamInfo(); |
| | | // streamInfoResult.setRtmp(dstUrl); |
| | | // streamInfoResult.setRtsp(String.format("rtsp://%s:%s/convert/%s", mediaInfo.getWanIp(), mediaInfo.getRtspPort(), streamId)); |
| | | // streamInfoResult.setStreamId(streamId); |
| | | // streamInfoResult.setFlv(String.format("http://%s:%s/convert/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setWs_flv(String.format("ws://%s:%s/convert/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setHls(String.format("http://%s:%s/convert/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setWs_hls(String.format("ws://%s:%s/convert/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setFmp4(String.format("http://%s:%s/convert/%s.live.mp4", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/convert/%s.live.mp4", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setTs(String.format("http://%s:%s/convert/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | // streamInfoResult.setWs_ts(String.format("ws://%s:%s/convert/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId)); |
| | | StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStream("convert", streamId); |
| | | streamInfoResult.setStreamId(streamId); |
| | | result.put("data", streamInfoResult); |
| | | } |
| | | }else { |
| | |
| | | * @param key |
| | | * @return |
| | | */ |
| | | @PostMapping("/play/convert/stop/{key}") |
| | | @PostMapping("/convertStop/{key}") |
| | | public ResponseEntity<String> playConvertStop(@PathVariable String key) { |
| | | |
| | | JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(key); |