|  |  |  | 
|---|
|  |  |  | package com.genersoft.iot.vmp.vmanager.gb28181.play; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.genersoft.iot.vmp.common.StreamInfo; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.conf.MediaServerConfig; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.bean.Device; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 
|---|
|  |  |  | 
|---|
|  |  |  | StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); | 
|---|
|  |  |  | if (streamInfo == null) { | 
|---|
|  |  |  | RequestMessage msg = new RequestMessage(); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid); | 
|---|
|  |  |  | msg.setData("streamId not found"); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); | 
|---|
|  |  |  | msg.setData("点播未找到"); | 
|---|
|  |  |  | resultHolder.invokeResult(msg); | 
|---|
|  |  |  | storager.stopPlay(deviceId, channelId); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | redisCatchStorage.stopPlay(streamInfo); | 
|---|
|  |  |  | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping("/convert/{streamId}") | 
|---|
|  |  |  | public ResponseEntity<String> playConvert(@PathVariable String streamId) { | 
|---|
|  |  |  | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); | 
|---|
|  |  |  | StreamInfo streamInfo = streamId.startsWith("gb_play_") ? redisCatchStorage.queryPlayByStreamId(streamId) : redisCatchStorage.queryPlaybackByStreamId(streamId); | 
|---|
|  |  |  | if (streamInfo == null) { | 
|---|
|  |  |  | logger.warn("视频转码API调用失败!, 视频流已经停止!"); | 
|---|
|  |  |  | return new ResponseEntity<String>("未找到视频流信息, 视频流可能已经停止", HttpStatus.OK); | 
|---|
|  |  |  | 
|---|
|  |  |  | logger.warn("视频转码API调用失败!, 视频流已停止推流!"); | 
|---|
|  |  |  | return new ResponseEntity<String>("推流信息在流媒体中不存在, 视频流可能已停止推流", HttpStatus.OK); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 
|---|
|  |  |  | ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 
|---|
|  |  |  | String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), | 
|---|
|  |  |  | streamId ); | 
|---|
|  |  |  | String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); | 
|---|
|  |  |  | JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000"); | 
|---|
|  |  |  | System.out.println(jsonObject); | 
|---|
|  |  |  | JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000", true, false, null); | 
|---|
|  |  |  | logger.info(jsonObject.toJSONString()); | 
|---|
|  |  |  | JSONObject result = new JSONObject(); | 
|---|
|  |  |  | if (jsonObject != null && jsonObject.getInteger("code") == 0) { | 
|---|
|  |  |  | result.put("code", 0); | 
|---|
|  |  |  | 
|---|
|  |  |  | public ResponseEntity<String> playConvertStop(@PathVariable String key) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(key); | 
|---|
|  |  |  | System.out.println(jsonObject); | 
|---|
|  |  |  | logger.info(jsonObject.toJSONString()); | 
|---|
|  |  |  | JSONObject result = new JSONObject(); | 
|---|
|  |  |  | if (jsonObject != null && jsonObject.getInteger("code") == 0) { | 
|---|
|  |  |  | result.put("code", 0); | 
|---|