| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.Response4Http; |
| | | import com.whyc.service.VideoService; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 摄像头的存储逻辑分为如下步骤: |
| | | * 1.程序启动时,获取所有的视频流id,并openRtpServer来开启流,执行startRecord来启动录制,自动1个小时保存一次录像. |
| | | * 2.录像的保存路径映射到http url中,可通过http获取mp4 |
| | | * 3.每秒钟检测所有的视频流 是否 开启状态是否异常,如果异常,重新开启流 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("video") |
| | | @Api(tags = "摄像头视频") |
| | |
| | | @Autowired |
| | | private VideoService service; |
| | | |
| | | @RequestMapping("getVideoStreamIds") |
| | | public Response<List> getVideoStreamIds() { |
| | | List<String> videoStreamIds = service.getVideoStreamIds(); |
| | | return new Response<List>().set(1, videoStreamIds, "获取摄像头视频流成功"); |
| | | @GetMapping("getVideoStreamIds") |
| | | public Response4Http getVideoStreamIds() { |
| | | return service.getVideoStreamIds(); |
| | | } |
| | | |
| | | @RequestMapping("startRecord") |
| | | public Response<String> startRecord(String streamId) { |
| | | service.startRecord(streamId); |
| | | return new Response<String>().set(1, "开始录制视频流成功"); |
| | | @GetMapping("startRecord") |
| | | public Response4Http startRecord(String streamId) { |
| | | return service.startRecord(streamId); |
| | | } |
| | | |
| | | @RequestMapping("stopRecord") |
| | | public Response<String> stopRecord(String streamId) { |
| | | service.stopRecord(streamId); |
| | | return new Response<String>().set(1, "停止录制视频流成功"); |
| | | @GetMapping("stopRecord") |
| | | public Response4Http<String> stopRecord(String streamId) { |
| | | return service.stopRecord(streamId); |
| | | } |
| | | |
| | | @GetMapping("getMp4RecordFile") |
| | | public Response4Http<String> getMp4RecordFile(String streamId,String period){ |
| | | return service.getMp4RecordFile(streamId,period); |
| | | } |
| | | |
| | | } |