|
|
@ -1,11 +1,13 @@ |
|
|
package com.inspect.ivs.controller; |
|
|
package com.inspect.ivs.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.inspect.base.core.domain.Response; |
|
|
import com.inspect.base.core.domain.Response; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
import com.inspect.base.core.utils.uuid.UUID; |
|
|
import com.inspect.base.core.utils.uuid.UUID; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.ivs.constant.IvsConst; |
|
|
import com.inspect.ivs.constant.IvsConst; |
|
|
import com.inspect.ivs.enums.RtspType; |
|
|
import com.inspect.ivs.enums.RtspType; |
|
|
|
|
|
import com.inspect.ivs.service.HlsPlaybackComponent; |
|
|
import com.inspect.ivs.service.IvsCommonService; |
|
|
import com.inspect.ivs.service.IvsCommonService; |
|
|
import com.inspect.ivs.service.XinTongComponent; |
|
|
import com.inspect.ivs.service.XinTongComponent; |
|
|
import com.inspect.ivs.service.ZlMediaComponent; |
|
|
import com.inspect.ivs.service.ZlMediaComponent; |
|
|
@ -16,12 +18,16 @@ import com.inspect.ivs.vo.IvsVideoRtspVo; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
|
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.RequestParam; |
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping({"/api/v1/stream"}) |
|
|
@RequestMapping({"/api/v1/stream"}) |
|
|
@ -30,6 +36,7 @@ public class IvsStreamController { |
|
|
private final IvsCommonService ivsCommonService; |
|
|
private final IvsCommonService ivsCommonService; |
|
|
private final ZlMediaComponent zlMediaComponent; |
|
|
private final ZlMediaComponent zlMediaComponent; |
|
|
private final XinTongComponent xinTongComponent; |
|
|
private final XinTongComponent xinTongComponent; |
|
|
|
|
|
private final HlsPlaybackComponent hlsPlaybackComponent; |
|
|
@Value("${ivs.test:false}") |
|
|
@Value("${ivs.test:false}") |
|
|
private Boolean bIvsTestMode; |
|
|
private Boolean bIvsTestMode; |
|
|
@Value("${rtsp.type:xintong}") |
|
|
@Value("${rtsp.type:xintong}") |
|
|
@ -37,10 +44,11 @@ public class IvsStreamController { |
|
|
@Resource |
|
|
@Resource |
|
|
private RedisService redisService; |
|
|
private RedisService redisService; |
|
|
|
|
|
|
|
|
public IvsStreamController(IvsCommonService ivsCommonService, ZlMediaComponent zlMediaComponent, XinTongComponent xinTongComponent) { |
|
|
|
|
|
|
|
|
public IvsStreamController(IvsCommonService ivsCommonService, ZlMediaComponent zlMediaComponent, XinTongComponent xinTongComponent, HlsPlaybackComponent hlsPlaybackComponent) { |
|
|
this.ivsCommonService = ivsCommonService; |
|
|
this.ivsCommonService = ivsCommonService; |
|
|
this.zlMediaComponent = zlMediaComponent; |
|
|
this.zlMediaComponent = zlMediaComponent; |
|
|
this.xinTongComponent = xinTongComponent; |
|
|
this.xinTongComponent = xinTongComponent; |
|
|
|
|
|
this.hlsPlaybackComponent = hlsPlaybackComponent; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@GetMapping({"start"}) |
|
|
@GetMapping({"start"}) |
|
|
@ -122,4 +130,23 @@ public class IvsStreamController { |
|
|
|
|
|
|
|
|
return ivsVideoRtspView; |
|
|
return ivsVideoRtspView; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"live/start"}) |
|
|
|
|
|
public ResponseEntity<JSONObject> liveStart(@RequestBody JSONObject request) { |
|
|
|
|
|
log.debug("[STREAM] live start param:{}", request); |
|
|
|
|
|
return this.hlsPlaybackComponent.post(IvsConst.URI_LIVE_START, request); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping({"live/stop"}) |
|
|
|
|
|
public ResponseEntity<JSONObject> liveStop(@RequestBody JSONObject request) { |
|
|
|
|
|
log.debug("[STREAM] live stop param:{}", request); |
|
|
|
|
|
return this.hlsPlaybackComponent.post(IvsConst.URI_LIVE_STOP, request); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping({"live/status"}) |
|
|
|
|
|
public ResponseEntity<JSONObject> liveStatus(@RequestParam("cameraCode") String cameraCode) throws Exception { |
|
|
|
|
|
log.debug("[STREAM] live status cameraCode:{}", cameraCode); |
|
|
|
|
|
String uri = IvsConst.URI_LIVE_STATUS + "?cameraCode=" + URLEncoder.encode(cameraCode, "UTF-8"); |
|
|
|
|
|
return this.hlsPlaybackComponent.get(uri); |
|
|
|
|
|
} |
|
|
} |
|
|
} |