|
|
@ -9,6 +9,10 @@ import com.inspect.base.core.web.domain.AjaxResult; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.patrol.contants.AccessApiConstant; |
|
|
import com.inspect.patrol.contants.AccessApiConstant; |
|
|
import com.inspect.patrol.linkage.util.JsonUtil; |
|
|
import com.inspect.patrol.linkage.util.JsonUtil; |
|
|
|
|
|
import com.inspect.patrol.model.HlsControlModel; |
|
|
|
|
|
import com.inspect.patrol.model.HlsSessionModel; |
|
|
|
|
|
import com.inspect.patrol.model.HlsUiControlModel; |
|
|
|
|
|
import com.inspect.patrol.model.HlsUiSessionModel; |
|
|
import com.inspect.patrol.model.PtzFiModel; |
|
|
import com.inspect.patrol.model.PtzFiModel; |
|
|
import com.inspect.patrol.model.PtzModel; |
|
|
import com.inspect.patrol.model.PtzModel; |
|
|
import com.inspect.patrol.model.RecordListModel; |
|
|
import com.inspect.patrol.model.RecordListModel; |
|
|
@ -28,7 +32,11 @@ import javax.servlet.http.HttpServletRequest; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
@ -154,6 +162,71 @@ public class PatrolVideotapeController extends BaseController { |
|
|
return AjaxResult.success(JSONObject.parseObject(result)); |
|
|
return AjaxResult.success(JSONObject.parseObject(result)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"/hls/session/create"}) |
|
|
|
|
|
public AjaxResult hlsCreateSession(@RequestBody HlsSessionModel hlsSessionModel) throws Exception { |
|
|
|
|
|
log.info("hls session create param: {}", JSONObject.toJSONString(hlsSessionModel)); |
|
|
|
|
|
String params = JSONObject.toJSONString(hlsSessionModel); |
|
|
|
|
|
String result = HttpClientUtils.postJson(this.deviceUrl + AccessApiConstant.HLS_SESSION_CREATE, params, ""); |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping({"/hls/session/delete/{sessionId}"}) |
|
|
|
|
|
public AjaxResult hlsDeleteSession(@PathVariable String sessionId) throws Exception { |
|
|
|
|
|
log.info("hls session delete sessionId: {}", sessionId); |
|
|
|
|
|
String result = HttpClientUtils.delete(this.deviceUrl + String.format(AccessApiConstant.HLS_SESSION_DELETE, sessionId)); |
|
|
|
|
|
if (result == null || result.trim().isEmpty()) { |
|
|
|
|
|
return AjaxResult.success(); |
|
|
|
|
|
} |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"/hls/session/query/{sessionId}"}) |
|
|
|
|
|
public AjaxResult hlsGetSession(@PathVariable String sessionId) throws Exception { |
|
|
|
|
|
log.info("hls session query sessionId: {}", sessionId); |
|
|
|
|
|
String result = HttpClientUtils.get(this.deviceUrl + String.format(AccessApiConstant.HLS_SESSION_QUERY, sessionId)); |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"/hls/session/control/{sessionId}"}) |
|
|
|
|
|
public AjaxResult hlsControlSession(@PathVariable String sessionId, @RequestBody HlsControlModel hlsControlModel) throws Exception { |
|
|
|
|
|
log.info("hls session control sessionId: {}, param: {}", sessionId, JSONObject.toJSONString(hlsControlModel)); |
|
|
|
|
|
String params = JSONObject.toJSONString(hlsControlModel); |
|
|
|
|
|
String result = HttpClientUtils.postJson(this.deviceUrl + String.format(AccessApiConstant.HLS_SESSION_CONTROL, sessionId), params, ""); |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"/hls/ui/session/create"}) |
|
|
|
|
|
public AjaxResult hlsCreateUiSession(@RequestBody HlsUiSessionModel hlsUiSessionModel) throws Exception { |
|
|
|
|
|
log.info("hls ui session create param: {}", JSONObject.toJSONString(hlsUiSessionModel)); |
|
|
|
|
|
String params = JSONObject.toJSONString(hlsUiSessionModel); |
|
|
|
|
|
String result = HttpClientUtils.postJson(this.deviceUrl + AccessApiConstant.HLS_UI_SESSION_CREATE, params, ""); |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"/hls/ui/session/control/{sessionId}"}) |
|
|
|
|
|
public AjaxResult hlsControlUiSession(@PathVariable String sessionId, @RequestBody HlsUiControlModel hlsUiControlModel) throws Exception { |
|
|
|
|
|
log.info("hls ui session control sessionId: {}, param: {}", sessionId, JSONObject.toJSONString(hlsUiControlModel)); |
|
|
|
|
|
String params = JSONObject.toJSONString(hlsUiControlModel); |
|
|
|
|
|
String result = HttpClientUtils.postJson(this.deviceUrl + String.format(AccessApiConstant.HLS_UI_SESSION_CONTROL, sessionId), params, ""); |
|
|
|
|
|
return parseHlsResult(result); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AjaxResult parseHlsResult(String result) { |
|
|
|
|
|
if (result == null || result.trim().isEmpty()) { |
|
|
|
|
|
return AjaxResult.error("接入层返回异常"); |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result); |
|
|
|
|
|
if (jsonObject.containsKey("code") && !Constants.SUCCESS.equals(jsonObject.getInteger("code"))) { |
|
|
|
|
|
return AjaxResult.error(jsonObject.getString("message")); |
|
|
|
|
|
} |
|
|
|
|
|
return AjaxResult.success(jsonObject); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("hls response parse error, result: {}", result, e); |
|
|
|
|
|
return AjaxResult.error("接入层返回异常"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
String str = "{\"msg\":\"操作成功\",\"code\":200,\"data\":{\"SnapURL\":\"\",\"RTMP\":\"rtmp://10.10.18.201:11935/hls/010010000103010001_010010000103010001_1010000002\",\"SourceVideoFrameRate\":0,\"RTPLostCount\":0,\"PlaybackDuration\":26638,\"CDN\":\"\",\"HLS\":\"http://10.10.18.201:20000/sms/34020000002020000001/hls/010010000103010001_010010000103010001_1010000002/010010000103010001_010010000103010001_1010000002_live.m3u8\",\"InBytes\":0,\"FLV\":\"http://10.10.18.201:20000/sms/34020000002020000001/flv/hls/010010000103010001_010010000103010001_1010000002.flv\",\"ChannelCustomName\":\"\",\"SourceAudioSampleRate\":0,\"SourceVideoHeight\":0,\"SourceVideoWidth\":0,\"Ondemand\":true,\"VideoFrameCount\":0,\"NumOutputs\":0,\"InBitRate\":0,\"WS_FLV\":\"ws://10.10.18.201:20000/sms/34020000002020000001/ws-flv/hls/010010000103010001_010010000103010001_1010000002.flv\",\"AudioEnable\":false,\"OutBytes\":0,\"SMSID\":\"34020000002020000001\",\"Progress\":0,\"RTPLostRate\":0,\"StreamID\":\"playback:010010000103010001:010010000103010001:1010000002\",\"DeviceID\":\"010010000103010001\",\"SourceVideoCodecName\":\"\",\"Duration\":0,\"SourceAudioCodecName\":\"\",\"TimestampSec\":0,\"ChannelID\":\"010010000103010001\",\"WEBRTC\":\"\",\"CascadeSize\":0,\"PlaybackFileURL\":\"\",\"RecordStartAt\":\"\",\"RTPCount\":0,\"ChannelName\":\"Camera 01\",\"StartAt\":\"2022-05-06 08:32:49\",\"RTSP\":\"\",\"Transport\":\"UDP\"}}"; |
|
|
String str = "{\"msg\":\"操作成功\",\"code\":200,\"data\":{\"SnapURL\":\"\",\"RTMP\":\"rtmp://10.10.18.201:11935/hls/010010000103010001_010010000103010001_1010000002\",\"SourceVideoFrameRate\":0,\"RTPLostCount\":0,\"PlaybackDuration\":26638,\"CDN\":\"\",\"HLS\":\"http://10.10.18.201:20000/sms/34020000002020000001/hls/010010000103010001_010010000103010001_1010000002/010010000103010001_010010000103010001_1010000002_live.m3u8\",\"InBytes\":0,\"FLV\":\"http://10.10.18.201:20000/sms/34020000002020000001/flv/hls/010010000103010001_010010000103010001_1010000002.flv\",\"ChannelCustomName\":\"\",\"SourceAudioSampleRate\":0,\"SourceVideoHeight\":0,\"SourceVideoWidth\":0,\"Ondemand\":true,\"VideoFrameCount\":0,\"NumOutputs\":0,\"InBitRate\":0,\"WS_FLV\":\"ws://10.10.18.201:20000/sms/34020000002020000001/ws-flv/hls/010010000103010001_010010000103010001_1010000002.flv\",\"AudioEnable\":false,\"OutBytes\":0,\"SMSID\":\"34020000002020000001\",\"Progress\":0,\"RTPLostRate\":0,\"StreamID\":\"playback:010010000103010001:010010000103010001:1010000002\",\"DeviceID\":\"010010000103010001\",\"SourceVideoCodecName\":\"\",\"Duration\":0,\"SourceAudioCodecName\":\"\",\"TimestampSec\":0,\"ChannelID\":\"010010000103010001\",\"WEBRTC\":\"\",\"CascadeSize\":0,\"PlaybackFileURL\":\"\",\"RecordStartAt\":\"\",\"RTPCount\":0,\"ChannelName\":\"Camera 01\",\"StartAt\":\"2022-05-06 08:32:49\",\"RTSP\":\"\",\"Transport\":\"UDP\"}}"; |
|
|
JSONObject jsonObject = JSONObject.parseObject(str); |
|
|
JSONObject jsonObject = JSONObject.parseObject(str); |
|
|
|