1078-增加结束点播
This commit is contained in:
@@ -22,6 +22,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
@@ -51,21 +52,26 @@ public class JT1078Controller {
|
||||
@Autowired
|
||||
UserSetting userSetting;
|
||||
|
||||
/**
|
||||
* jt1078Template 调用示例
|
||||
*/
|
||||
@GetMapping("/start/live/{deviceId}/{channelId}")
|
||||
public DeferredResult<WVPResult<StreamContent>> startLive(HttpServletRequest request, @PathVariable String deviceId, @PathVariable String channelId) {
|
||||
@Operation(summary = "1078-开始点播", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||
@GetMapping("/live/start")
|
||||
public DeferredResult<WVPResult<StreamContent>> startLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String deviceId,
|
||||
@Parameter(required = false) String channelId) {
|
||||
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
String finalChannelId = channelId;
|
||||
result.onTimeout(()->{
|
||||
logger.info("[1078-点播等待超时] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
logger.info("[1078-点播等待超时] deviceId:{}, channelId:{}, ", deviceId, finalChannelId);
|
||||
// 释放rtpserver
|
||||
WVPResult<StreamContent> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
||||
wvpResult.setMsg("点播超时");
|
||||
result.setResult(wvpResult);
|
||||
service.stopPlay(deviceId, channelId);
|
||||
service.stopPlay(deviceId, finalChannelId);
|
||||
});
|
||||
|
||||
service.play(deviceId, channelId, (code, msg, streamInfo) -> {
|
||||
@@ -101,6 +107,19 @@ public class JT1078Controller {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-结束点播", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||
@GetMapping("/live/stop")
|
||||
public void stopLive(HttpServletRequest request,
|
||||
@Parameter(required = true) String deviceId,
|
||||
@Parameter(required = false) String channelId) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId = "1";
|
||||
}
|
||||
service.stopPlay(deviceId, channelId);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询部标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
|
||||
import com.genersoft.iot.vmp.jt1078.config.JT1078Controller;
|
||||
import com.genersoft.iot.vmp.jt1078.dao.JTDeviceMapper;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.J9101;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.J9102;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
@@ -194,6 +195,27 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
|
||||
@Override
|
||||
public void stopPlay(String deviceId, String channelId) {
|
||||
|
||||
String playKey = VideoManagerConstants.INVITE_INFO_1078 + deviceId + ":" + channelId;
|
||||
dynamicTask.stop(playKey);
|
||||
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
|
||||
// 发送停止命令
|
||||
J9102 j9102 = new J9102();
|
||||
j9102.setChannel(Integer.valueOf(channelId));
|
||||
j9102.setCommand(0);
|
||||
j9102.setCloseType(0);
|
||||
j9102.setStreamType(1);
|
||||
jt1078Template.stopLive(deviceId, j9102, 6);
|
||||
// 删除缓存数据
|
||||
if (streamInfo != null) {
|
||||
// 关闭rtpServer
|
||||
mediaServerService.closeRTPServer(streamInfo.getMediaServerId(), streamInfo.getStream());
|
||||
}
|
||||
// 清理回调
|
||||
List<GeneralCallback<StreamInfo>> generalCallbacks = inviteErrorCallbackMap.get(playKey);
|
||||
if (!generalCallbacks.isEmpty()) {
|
||||
for (GeneralCallback<StreamInfo> callback : generalCallbacks) {
|
||||
callback.run(InviteErrorCode.ERROR_FOR_FINISH.getCode(), InviteErrorCode.ERROR_FOR_FINISH.getMsg(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ public enum InviteErrorCode {
|
||||
ERROR_FOR_RESET_SSRC(-9, "重新设置收流信息失败"),
|
||||
ERROR_FOR_SIP_SENDING_FAILED(-10, "命令发送失败"),
|
||||
ERROR_FOR_ASSIST_NOT_READY(-11, "没有可用的assist服务"),
|
||||
ERROR_FOR_PARAMETER_ERROR(-13, "参数异常");
|
||||
ERROR_FOR_PARAMETER_ERROR(-13, "参数异常"),
|
||||
ERROR_FOR_FINISH(-14, "已结束"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
Reference in New Issue
Block a user