通用通道支持停止实时流
This commit is contained in:
@@ -150,6 +150,9 @@ public class CommonGBChannel {
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@Schema(description = "流唯一编号,存在表示正在直播")
|
||||
private String streamId;
|
||||
|
||||
public String encode(String serverDeviceId) {
|
||||
return encode(null, serverDeviceId);
|
||||
}
|
||||
|
||||
@@ -179,9 +179,6 @@ public class DeviceChannel extends CommonGBChannel {
|
||||
@Schema(description = "子设备数")
|
||||
private int subCount;
|
||||
|
||||
@Schema(description = "流唯一编号,存在表示正在直播")
|
||||
private String streamId;
|
||||
|
||||
@Schema(description = "是否含有音频")
|
||||
private boolean hasAudio;
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ public class ChannelController {
|
||||
|
||||
@Operation(summary = "播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@GetMapping("/play")
|
||||
public DeferredResult<WVPResult<StreamContent>> deleteChannelToGroupByGbDevice(HttpServletRequest request, Integer channelId){
|
||||
public DeferredResult<WVPResult<StreamContent>> play(HttpServletRequest request, Integer channelId){
|
||||
Assert.notNull(channelId,"参数异常");
|
||||
CommonGBChannel channel = channelService.getOne(channelId);
|
||||
Assert.notNull(channel, "通道不存在");
|
||||
@@ -316,4 +316,13 @@ public class ChannelController {
|
||||
channelPlayService.play(channel, null, userSetting.getRecordSip(), callback);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "停止播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@GetMapping("/play/stop")
|
||||
public void stopPlay(Integer channelId){
|
||||
Assert.notNull(channelId,"参数异常");
|
||||
CommonGBChannel channel = channelService.getOne(channelId);
|
||||
Assert.notNull(channel, "通道不存在");
|
||||
channelPlayService.stopPlay(channel, channel.getStreamId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,4 +580,7 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryOnlineListsByGbDeviceId")
|
||||
List<CommonGBChannel> queryOnlineListsByGbDeviceId(@Param("deviceId") int deviceId);
|
||||
|
||||
@Update("UPDATE wvp_device_channel SET stream_id = #{stream} where id = #{gbId}")
|
||||
void updateStream(int gbId, String stream);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ChannelProvider {
|
||||
" data_device_id,\n" +
|
||||
" create_time,\n" +
|
||||
" update_time,\n" +
|
||||
" stream_id,\n" +
|
||||
" record_plan_id,\n" +
|
||||
" coalesce(gb_device_id, device_id) as gb_device_id,\n" +
|
||||
" coalesce(gb_name, name) as gb_name,\n" +
|
||||
@@ -60,6 +61,7 @@ public class ChannelProvider {
|
||||
" wdc.data_device_id,\n" +
|
||||
" wdc.create_time,\n" +
|
||||
" wdc.update_time,\n" +
|
||||
" wdc.stream_id,\n" +
|
||||
" wdc.record_plan_id,\n" +
|
||||
" coalesce(wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
|
||||
" coalesce(wdc.gb_name, wdc.name) as gb_name,\n" +
|
||||
|
||||
@@ -8,8 +8,10 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlayException;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -24,6 +26,9 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private CommonGBChannelMapper channelMapper;
|
||||
|
||||
@Autowired
|
||||
private Map<String, ISourcePlayService> sourcePlayServiceMap;
|
||||
|
||||
@@ -86,7 +91,15 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService {
|
||||
log.error("[点播通用通道] 类型编号: {} 不支持实时流预览", dataType);
|
||||
throw new PlayException(Response.BUSY_HERE, "channel not support");
|
||||
}
|
||||
sourceChannelPlayService.play(channel, platform, record, callback);
|
||||
sourceChannelPlayService.play(channel, platform, record, (code, msg, data) -> {
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
// 将流ID记录到数据库
|
||||
if (channel.getDataType() != ChannelDataType.GB28181) {
|
||||
channelMapper.updateStream(channel.getGbId(), data.getStream());
|
||||
}
|
||||
}
|
||||
callback.run(code, msg, data);
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback<StreamInfo> callback) {
|
||||
|
||||
Reference in New Issue
Block a user