package cn.skcks.docking.gb28181.wvp.api.video;

import cn.skcks.docking.gb28181.wvp.service.video.VideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "录像api")
@RequiredArgsConstructor
@RestController
@RequestMapping("/video/record")
public class RecordController {
    private final VideoService videoService;

    @Operation(summary = "返回文件下载 http 头信息",description = "禁止多线程下载, 默认文件名为 record.mp4")
    @RequestMapping(method = {RequestMethod.HEAD,RequestMethod.OPTIONS})
    public void record(HttpServletResponse response){
        videoService.header(response);
    }

    @Operation(summary = "录制flv视频流, 并下载为flv文件")
    @GetMapping
    public void record(HttpServletRequest request, HttpServletResponse response, @RequestParam String url, @RequestParam long time){
        videoService.record(request, response,url,time);
    }
}
