AsyncContext 超时调整

This commit is contained in:
shikong 2023-09-07 09:52:11 +08:00
parent 0ece1e2915
commit 310ec451fb

View File

@ -2,7 +2,6 @@ package cn.skcks.docking.gb28181.wvp.service.video;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import cn.skcks.docking.gb28181.wvp.executor.DefaultVideoExecutor;
import jakarta.servlet.AsyncContext;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
@ -11,8 +10,10 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.bytedeco.ffmpeg.global.avcodec;
import org.bytedeco.ffmpeg.global.avutil;
import org.bytedeco.javacv.*;
import org.springframework.scheduling.annotation.Async;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.springframework.stereotype.Service;
import java.io.*;
@ -34,6 +35,7 @@ public class RecordService {
@SneakyThrows
public void record(HttpServletRequest request, HttpServletResponse response, String url, long timeout) {
AsyncContext asyncContext = request.startAsync();
asyncContext.setTimeout(0);
asyncContext.start(() -> {
header(response);
record(asyncContext.getResponse(), url, timeout);