1078-切换码流类型

This commit is contained in:
648540858
2024-05-29 18:36:19 +08:00
parent 84ef932964
commit 2b1645729b
3 changed files with 41 additions and 24 deletions

View File

@@ -64,24 +64,20 @@ public class JT1078Controller {
@GetMapping("/live/start")
public DeferredResult<WVPResult<StreamContent>> startLive(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = false) String channelId,
@Parameter(required = true) String channelId,
@Parameter(required = false) Integer type) {
if (type == null || (type != 0 && type != 1 && type != 3)) {
type = 0;
}
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, finalChannelId);
logger.info("[1078-点播等待超时] deviceId{}, channelId{}, ", deviceId, channelId);
// 释放rtpserver
WVPResult<StreamContent> wvpResult = new WVPResult<>();
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("超时");
result.setResult(wvpResult);
service.stopPlay(deviceId, finalChannelId);
service.stopPlay(deviceId, channelId);
});
service.play(deviceId, channelId, type, (code, msg, streamInfo) -> {
@@ -123,10 +119,7 @@ public class JT1078Controller {
@GetMapping("/live/stop")
public void stopLive(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = false) String channelId) {
if (ObjectUtils.isEmpty(channelId)) {
channelId = "1";
}
@Parameter(required = true) String channelId) {
service.stopPlay(deviceId, channelId);
}
@@ -199,10 +192,7 @@ public class JT1078Controller {
@GetMapping("/talk/stop")
public void stopTalk(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = false) String channelId) {
if (ObjectUtils.isEmpty(channelId)) {
channelId = "1";
}
@Parameter(required = true) String channelId) {
service.stopTalk(deviceId, channelId);
}
@@ -213,10 +203,7 @@ public class JT1078Controller {
@GetMapping("/live/pause")
public void pauseLive(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = false) String channelId) {
if (ObjectUtils.isEmpty(channelId)) {
channelId = "1";
}
@Parameter(required = true) String channelId) {
service.pausePlay(deviceId, channelId);
}
@@ -226,13 +213,23 @@ public class JT1078Controller {
@GetMapping("/live/continue")
public void continueLive(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = false) String channelId) {
if (ObjectUtils.isEmpty(channelId)) {
channelId = "1";
}
@Parameter(required = true) String channelId) {
service.continueLivePlay(deviceId, channelId);
}
@Operation(summary = "1078-切换码流类型", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
@Parameter(name = "streamType", description = "0:主码流; 1:子码流", required = true)
@GetMapping("/live/continue")
public void changeStreamType(HttpServletRequest request,
@Parameter(required = true) String deviceId,
@Parameter(required = true) String channelId,
@Parameter(required = true) Integer streamType) {
service.changeStreamType(deviceId, channelId, streamType);
}
@Operation(summary = "1078-录像-查询资源列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)

View File

@@ -110,4 +110,6 @@ public interface Ijt1078Service {
void startTalk(String deviceId, String channelId, String app, String stream, String mediaServerId, Boolean onlySend, GeneralCallback<StreamInfo> callback);
void stopTalk(String deviceId, String channelId);
void changeStreamType(String deviceId, String channelId, Integer streamType);
}

View File

@@ -895,7 +895,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
// 发送停止命令
J9102 j9102 = new J9102();
j9102.setChannel(Integer.valueOf(channelId));
j9102.setCommand(0);
j9102.setCommand(4);
j9102.setCloseType(0);
j9102.setStreamType(1);
jt1078Template.stopLive(deviceId, j9102, 6);
@@ -914,4 +914,22 @@ public class jt1078ServiceImpl implements Ijt1078Service {
}
}
}
@Override
public void changeStreamType(String deviceId, String channelId, Integer streamType) {
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + deviceId + ":" + channelId;
dynamicTask.stop(playKey);
StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey);
if (streamInfo == null) {
logger.info("[1078-切换码流类型] 未找到点播信息 deviceId {} channelId {}, streamType: {}", deviceId, channelId, streamType);
}
logger.info("[1078-切换码流类型] deviceId {} channelId {}, streamType: {}", deviceId, channelId, streamType);
// 发送暂停命令
J9102 j9102 = new J9102();
j9102.setChannel(Integer.valueOf(channelId));
j9102.setCommand(1);
j9102.setCloseType(0);
j9102.setStreamType(streamType);
jt1078Template.stopLive(deviceId, j9102, 6);
}
}