mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-05 16:18:05 +08:00
开源版本,视频直播功能
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.sip.domain.MediaServer;
|
||||
import com.fastbee.sip.service.IMediaServerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流媒体服务器配置Controller
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2022-11-30
|
||||
*/
|
||||
@Api(tags = "流媒体服务器配置")
|
||||
@RestController
|
||||
@RequestMapping("/sip/mediaserver")
|
||||
public class MediaServerController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
/**
|
||||
* 查询流媒体服务器配置列表
|
||||
*/
|
||||
@ApiOperation("查询流媒体服务器配置列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MediaServer mediaServer)
|
||||
{
|
||||
startPage();
|
||||
List<MediaServer> list = mediaServerService.selectMediaServerList(mediaServer);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出流媒体服务器配置列表
|
||||
*/
|
||||
@ApiOperation("导出流媒体服务器配置列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@Log(title = "流媒体服务器配置", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MediaServer mediaServer)
|
||||
{
|
||||
List<MediaServer> list = mediaServerService.selectMediaServerList(mediaServer);
|
||||
ExcelUtil<MediaServer> util = new ExcelUtil<MediaServer>(MediaServer.class);
|
||||
util.exportExcel(response, list, "流媒体服务器配置数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流媒体服务器配置详细信息,只获取第一条
|
||||
*/
|
||||
@ApiOperation(value = "获取流媒体服务器配置详细信息", notes = "只获取第一条")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:query')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo()
|
||||
{
|
||||
List<MediaServer> list=mediaServerService.selectMediaServer();
|
||||
if(list==null || list.size()==0){
|
||||
MediaServer mediaServer=new MediaServer();
|
||||
// 设置默认值
|
||||
mediaServer.setEnabled(1);
|
||||
mediaServer.setDomain("");
|
||||
mediaServer.setIp("");
|
||||
mediaServer.setPortHttp(8082L);
|
||||
mediaServer.setPortHttps(8443L);
|
||||
mediaServer.setPortRtmp(1935L);
|
||||
mediaServer.setPortRtsp(554L);
|
||||
mediaServer.setProtocol("HTTP");
|
||||
mediaServer.setSecret("035c73f7-bb6b-4889-a715-d9eb2d192xxx");
|
||||
mediaServer.setRtpPortRange("30000,30500");
|
||||
list=new ArrayList<>();
|
||||
list.add(mediaServer);
|
||||
}
|
||||
return AjaxResult.success(list.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流媒体服务器配置
|
||||
*/
|
||||
@ApiOperation("新增流媒体服务器配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:add')")
|
||||
@Log(title = "流媒体服务器配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MediaServer mediaServer)
|
||||
{
|
||||
return toAjax(mediaServerService.insertMediaServer(mediaServer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流媒体服务器配置
|
||||
*/
|
||||
@ApiOperation("修改流媒体服务器配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:edit')")
|
||||
@Log(title = "流媒体服务器配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MediaServer mediaServer)
|
||||
{
|
||||
return toAjax(mediaServerService.updateMediaServer(mediaServer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流媒体服务器配置
|
||||
*/
|
||||
@ApiOperation("删除流媒体服务器配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "流媒体服务器配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(mediaServerService.deleteMediaServerByIds(ids));
|
||||
}
|
||||
|
||||
@ApiOperation("获取流媒体服务器视频流信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/mediaList/{schema}/{stream}")
|
||||
public AjaxResult getMediaList(@PathVariable String schema,
|
||||
@PathVariable String stream)
|
||||
{
|
||||
return AjaxResult.success("success!", mediaServerService.getMediaList(schema,stream));
|
||||
}
|
||||
|
||||
@ApiOperation("获取rtp推流端口列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/listRtpServer")
|
||||
public AjaxResult listRtpServer()
|
||||
{
|
||||
return AjaxResult.success("success!", mediaServerService.listRtpServer());
|
||||
}
|
||||
|
||||
@ApiOperation("检验流媒体服务")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping(value = "/check")
|
||||
public AjaxResult checkMediaServer(@RequestParam String ip, @RequestParam Long port, @RequestParam String secret) {
|
||||
return AjaxResult.success("success!", mediaServerService.checkMediaServer(ip, port, secret));
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.sip.service.IPlayService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sip/player")
|
||||
public class PlayerController extends BaseController {
|
||||
@Autowired
|
||||
private IPlayService playService;
|
||||
|
||||
@GetMapping("/getBigScreenUrl/{deviceId}/{channelId}")
|
||||
public AjaxResult getBigScreenUrl(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
return AjaxResult.success("success!", playService.play(deviceId, channelId,false).getHttps_fmp4());
|
||||
}
|
||||
|
||||
@ApiOperation("直播播放")
|
||||
@GetMapping("/play/{deviceId}/{channelId}")
|
||||
public AjaxResult play(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
return AjaxResult.success("success!", playService.play(deviceId, channelId,false));
|
||||
}
|
||||
@ApiOperation("回放播放")
|
||||
@GetMapping("/playback/{deviceId}/{channelId}")
|
||||
public AjaxResult playback(@PathVariable String deviceId,
|
||||
@PathVariable String channelId, String start, String end) {
|
||||
return AjaxResult.success("success!", playService.playback(deviceId, channelId, start, end));
|
||||
}
|
||||
@ApiOperation("停止推流")
|
||||
@GetMapping("/closeStream/{deviceId}/{channelId}/{streamId}")
|
||||
public AjaxResult closeStream(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String streamId) {
|
||||
return AjaxResult.success("success!", playService.closeStream(deviceId, channelId, streamId));
|
||||
}
|
||||
@ApiOperation("回放暂停")
|
||||
@GetMapping("/playbackPause/{deviceId}/{channelId}/{streamId}")
|
||||
public AjaxResult playbackPause(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String streamId) {
|
||||
return AjaxResult.success("success!", playService.playbackPause(deviceId, channelId, streamId));
|
||||
}
|
||||
@ApiOperation("回放恢复")
|
||||
@GetMapping("/playbackReplay/{deviceId}/{channelId}/{streamId}")
|
||||
public AjaxResult playbackReplay(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String streamId) {
|
||||
return AjaxResult.success("success!", playService.playbackReplay(deviceId, channelId, streamId));
|
||||
}
|
||||
@ApiOperation("录像回放定位")
|
||||
@GetMapping("/playbackSeek/{deviceId}/{channelId}/{streamId}")
|
||||
public AjaxResult playbackSeek(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String streamId, long seek) {
|
||||
return AjaxResult.success("success!", playService.playbackSeek(deviceId, channelId, streamId, seek));
|
||||
}
|
||||
@ApiOperation("录像倍速播放")
|
||||
@GetMapping("/playbackSpeed/{deviceId}/{channelId}/{streamId}")
|
||||
public AjaxResult playbackSpeed(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String streamId, Integer speed) {
|
||||
return AjaxResult.success("success!", playService.playbackSpeed(deviceId, channelId, streamId, speed));
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.sip.enums.Direct;
|
||||
import com.fastbee.sip.model.PtzDirectionInput;
|
||||
import com.fastbee.sip.model.PtzscaleInput;
|
||||
import com.fastbee.sip.service.IPtzCmdService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sip/ptz")
|
||||
public class PtzController {
|
||||
@Autowired
|
||||
private IPtzCmdService ptzCmdService;
|
||||
@ApiOperation("云台方向控制")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@PostMapping("/direction/{deviceId}/{channelId}")
|
||||
public AjaxResult direction(@PathVariable String deviceId, @PathVariable String channelId, @RequestBody PtzDirectionInput ptzDirectionInput) {
|
||||
Direct direct = null;
|
||||
int leftRight = ptzDirectionInput.getLeftRight();
|
||||
int upDown = ptzDirectionInput.getUpDown();
|
||||
if (leftRight == 1) {
|
||||
direct = Direct.RIGHT;
|
||||
} else if (leftRight == 2) {
|
||||
direct = Direct.LEFT;
|
||||
} else if (upDown == 1) {
|
||||
direct = Direct.UP;
|
||||
} else if (upDown == 2) {
|
||||
direct = Direct.DOWN;
|
||||
} else {
|
||||
direct = Direct.STOP;
|
||||
}
|
||||
Integer speed = ptzDirectionInput.getMoveSpeed();
|
||||
return AjaxResult.success("success!", ptzCmdService.directPtzCmd(deviceId, channelId, direct, speed));
|
||||
}
|
||||
@ApiOperation("云台缩放控制")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@PostMapping("/scale/{deviceId}/{channelId}")
|
||||
public AjaxResult scale(@PathVariable String deviceId, @PathVariable String channelId, @RequestBody PtzscaleInput ptzscaleInput) {
|
||||
Direct direct = null;
|
||||
if (ptzscaleInput.getInOut() == 1) {
|
||||
direct = Direct.ZOOM_IN;
|
||||
} else if (ptzscaleInput.getInOut() == 2) {
|
||||
direct = Direct.ZOOM_OUT;
|
||||
} else {
|
||||
direct = Direct.STOP;
|
||||
}
|
||||
Integer speed = ptzscaleInput.getScaleSpeed();
|
||||
return AjaxResult.success("success!", ptzCmdService.directPtzCmd(deviceId, channelId, direct, speed));
|
||||
}
|
||||
@ApiOperation("云台ptz控制")
|
||||
@PostMapping("/ptz/{deviceId}/{channelId}/{direct}/{speed}")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
public AjaxResult ptzControl(@PathVariable String deviceId,
|
||||
@PathVariable String channelId,
|
||||
@PathVariable Direct direct,
|
||||
@PathVariable Integer speed) {
|
||||
return AjaxResult.success("success!", ptzCmdService.directPtzCmd(deviceId, channelId, direct, speed));
|
||||
}
|
||||
@ApiOperation("云台停止控制")
|
||||
@PostMapping("/ptz/{deviceId}/{channelId}/STOP")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
public AjaxResult ptzControlStop(@PathVariable String deviceId,
|
||||
@PathVariable String channelId) {
|
||||
return AjaxResult.success("success!", ptzCmdService.directPtzCmd(deviceId, channelId, Direct.STOP, 0));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.sip.model.RecordList;
|
||||
import com.fastbee.sip.service.IRecordService;
|
||||
import com.fastbee.sip.util.WebAsyncUtil;
|
||||
import com.fastbee.sip.util.result.BaseResult;
|
||||
import com.fastbee.sip.util.result.CodeEnum;
|
||||
import com.fastbee.sip.util.result.DataResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.WebAsyncTask;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sip/record")
|
||||
public class RecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IRecordService recordService;
|
||||
|
||||
@Qualifier("taskExecutor")
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor taskExecutor;
|
||||
@ApiOperation("设备录像查询")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/devquery/{deviceId}/{channelId}")
|
||||
public WebAsyncTask<Object> devquery(@PathVariable String deviceId,
|
||||
@PathVariable String channelId, String start, String end) {
|
||||
return WebAsyncUtil.init(taskExecutor, () -> {
|
||||
try {
|
||||
RecordList result = recordService.listDevRecord(deviceId, channelId, start, end);
|
||||
return DataResult.out(CodeEnum.SUCCESS, result);
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
return BaseResult.out(CodeEnum.FAIL, e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ApiOperation("设备录像缓存查询")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/query/{channelId}/{sn}")
|
||||
public AjaxResult list(@PathVariable String channelId,
|
||||
@PathVariable String sn) {
|
||||
return AjaxResult.success("success!", recordService.listRecord(channelId, sn));
|
||||
}
|
||||
|
||||
@ApiOperation("指定流ID开始录像")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/start/{stream}")
|
||||
public AjaxResult startRecord(@PathVariable String stream) {
|
||||
boolean result = recordService.startRecord(stream);
|
||||
if (result) {
|
||||
return AjaxResult.success("success!");
|
||||
} else {
|
||||
return AjaxResult.error("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("指定流ID停止录像")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/stop/{stream}")
|
||||
public AjaxResult stopRecord(@PathVariable String stream) {
|
||||
boolean result = recordService.stopRecord(stream);
|
||||
if (result) {
|
||||
return AjaxResult.success("success!");
|
||||
} else {
|
||||
return AjaxResult.error("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取流对应的录像文件列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/file/{stream}/{period}")
|
||||
public AjaxResult getMp4RecordFile(@PathVariable String stream,
|
||||
@PathVariable String period) {
|
||||
return AjaxResult.success("success!", recordService.getMp4RecordFile(stream, period));
|
||||
}
|
||||
|
||||
@ApiOperation("直播录像")
|
||||
@GetMapping("/play/{deviceId}/{channelId}")
|
||||
public AjaxResult playRecord(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
logger.debug(String.format("直播录像 API调用,deviceId:%s,channelId:%s", deviceId, channelId));
|
||||
return AjaxResult.success("success!", recordService.playRecord(deviceId, channelId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:download')")
|
||||
@ApiOperation("设备录像下载")
|
||||
@GetMapping("/download/{deviceId}/{channelId}")
|
||||
public AjaxResult download(@PathVariable String deviceId, @PathVariable String channelId,
|
||||
String startTime, String endTime, String speed) {
|
||||
logger.debug(String.format("设备录像下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, speed));
|
||||
return AjaxResult.success("success!", recordService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(speed)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/list")
|
||||
public AjaxResult listServerRecord(@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize, @RequestParam String recordApi) {
|
||||
try{
|
||||
Object data = recordService.listServerRecord(recordApi, pageNum, pageSize);
|
||||
return AjaxResult.success("success!", data);
|
||||
}catch(Exception e){
|
||||
return AjaxResult.error("连接超时或发生错误,未获取到数据!");
|
||||
}
|
||||
}
|
||||
@ApiOperation("通过日期查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/date/list")
|
||||
public AjaxResult listServerRecordByDate(@RequestParam(required = false) Integer year,
|
||||
@RequestParam(required = false) Integer month, @RequestParam String app, @RequestParam String stream, @RequestParam String recordApi) {
|
||||
return AjaxResult.success("success!", recordService.listServerRecordByDate(recordApi, year, month, app, stream));
|
||||
}
|
||||
@ApiOperation("通过流ID查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/stream/list")
|
||||
public AjaxResult listServerRecordByStream(@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize, @RequestParam String app, @RequestParam String recordApi) {
|
||||
return AjaxResult.success("success!", recordService.listServerRecordByStream(recordApi, pageNum, pageSize, app));
|
||||
}
|
||||
@ApiOperation("通过应用名查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/app/list")
|
||||
public AjaxResult listServerRecordByApp(@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize, @RequestParam String recordApi) {
|
||||
return AjaxResult.success("success!", recordService.listServerRecordByApp(recordApi, pageNum, pageSize));
|
||||
}
|
||||
@ApiOperation("通过文件名查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/file/list")
|
||||
public AjaxResult listServerRecordByFile(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
|
||||
@RequestParam String app, @RequestParam String stream,
|
||||
@RequestParam String startTime, @RequestParam String endTime, @RequestParam String recordApi) {
|
||||
return AjaxResult.success("success!", recordService.listServerRecordByFile(recordApi, pageNum, pageSize, app, stream, startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("通过设备信息查询服务端录像列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:sip:record:list')")
|
||||
@GetMapping("/serverRecord/device/list")
|
||||
public AjaxResult getServerRecordByDevice(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
|
||||
@RequestParam String deviceId, @RequestParam String channelId,
|
||||
@RequestParam String startTime, @RequestParam String endTime) {
|
||||
return AjaxResult.success("success!", recordService.listServerRecordByDevice(pageNum, pageSize, deviceId, channelId, startTime, endTime));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.sip.domain.SipConfig;
|
||||
import com.fastbee.sip.service.ISipConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* sip系统配置Controller
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2022-11-30
|
||||
*/
|
||||
@Api(tags = "sip系统配置")
|
||||
@RestController
|
||||
@RequestMapping("/sip/sipconfig")
|
||||
public class SipConfigController extends BaseController {
|
||||
@Autowired
|
||||
private ISipConfigService sipConfigService;
|
||||
|
||||
/**
|
||||
* 获取产品下第一条sip系统配置详细信息
|
||||
*/
|
||||
@ApiOperation("获取产品下sip系统配置信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:query')")
|
||||
@GetMapping(value = "/{productId}/{isDefault}")
|
||||
public AjaxResult getInfo(@PathVariable("productId") Long productId, @PathVariable("isDefault") Boolean isDefault) {
|
||||
SipConfig sipConfig = isDefault ? sipConfigService.GetDefaultSipConfig() : sipConfigService.selectSipConfigByProductId(productId);
|
||||
return AjaxResult.success(sipConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增sip系统配置
|
||||
*/
|
||||
@ApiOperation("新增sip系统配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:add')")
|
||||
@Log(title = "sip系统配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SipConfig sipConfig) {
|
||||
return AjaxResult.success(sipConfigService.insertSipConfig(sipConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改sip系统配置
|
||||
*/
|
||||
@ApiOperation("修改sip系统配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:edit')")
|
||||
@Log(title = "sip系统配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SipConfig sipConfig) {
|
||||
return toAjax(sipConfigService.updateSipConfig(sipConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除sip系统配置
|
||||
*/
|
||||
@ApiOperation("删除sip系统配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "sip系统配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(sipConfigService.deleteSipConfigByIds(ids));
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除sip系统配置")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "sip系统配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/product/{productIds}")
|
||||
public AjaxResult removeByProductId(@PathVariable Long[] productIds) {
|
||||
// 设备可能不存在通道,可以返回0
|
||||
int result = sipConfigService.deleteSipConfigByProductIds(productIds);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.sip.domain.SipDeviceChannel;
|
||||
import com.fastbee.sip.service.ISipDeviceChannelService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控设备通道信息Controller
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2022-10-07
|
||||
*/
|
||||
@Api(tags = "监控设备通道信息")
|
||||
@RestController
|
||||
@RequestMapping("/sip/channel")
|
||||
public class SipDeviceChannelController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISipDeviceChannelService sipDeviceChannelService;
|
||||
|
||||
/**
|
||||
* 查询监控设备通道信息列表
|
||||
*/
|
||||
@ApiOperation("查询监控设备通道信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SipDeviceChannel sipDeviceChannel)
|
||||
{
|
||||
startPage();
|
||||
List<SipDeviceChannel> list = sipDeviceChannelService.selectSipDeviceChannelList(sipDeviceChannel);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出监控设备通道信息列表
|
||||
*/
|
||||
@ApiOperation("导出监控设备通道信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@Log(title = "监控设备通道信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SipDeviceChannel sipDeviceChannel)
|
||||
{
|
||||
List<SipDeviceChannel> list = sipDeviceChannelService.selectSipDeviceChannelList(sipDeviceChannel);
|
||||
ExcelUtil<SipDeviceChannel> util = new ExcelUtil<SipDeviceChannel>(SipDeviceChannel.class);
|
||||
util.exportExcel(response, list, "监控设备通道信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取监控设备通道信息详细信息
|
||||
*/
|
||||
@ApiOperation("获取监控设备通道信息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:query')")
|
||||
@GetMapping(value = "/{channelId}")
|
||||
public AjaxResult getInfo(@PathVariable("channelId") Long channelId)
|
||||
{
|
||||
return AjaxResult.success(sipDeviceChannelService.selectSipDeviceChannelByChannelId(channelId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增监控设备通道信息
|
||||
*/
|
||||
@ApiOperation("新增监控设备通道信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:add')")
|
||||
@Log(title = "监控设备通道信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping(value = "/{createNum}")
|
||||
public AjaxResult add(@PathVariable("createNum") Long createNum, @RequestBody SipDeviceChannel sipDeviceChannel) {
|
||||
return AjaxResult.success("操作成功", sipDeviceChannelService.insertSipDeviceChannelGen(createNum, sipDeviceChannel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改监控设备通道信息
|
||||
*/
|
||||
@ApiOperation("修改监控设备通道信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:edit')")
|
||||
@Log(title = "监控设备通道信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SipDeviceChannel sipDeviceChannel)
|
||||
{
|
||||
return toAjax(sipDeviceChannelService.updateSipDeviceChannel(sipDeviceChannel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监控设备通道信息
|
||||
*/
|
||||
@ApiOperation("删除监控设备通道信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "监控设备通道信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{channelIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] channelIds)
|
||||
{
|
||||
return toAjax(sipDeviceChannelService.deleteSipDeviceChannelByChannelIds(channelIds));
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.common.utils.file.FileUploadUtils;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.sip.domain.SipDevice;
|
||||
import com.fastbee.sip.service.ISipDeviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控设备Controller
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2022-10-07
|
||||
*/
|
||||
@Api(tags = "监控设备")
|
||||
@RestController
|
||||
@RequestMapping("/sip/device")
|
||||
public class SipDeviceController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISipDeviceService sipDeviceService;
|
||||
|
||||
/**
|
||||
* 查询监控设备列表
|
||||
*/
|
||||
@ApiOperation("查询监控设备列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SipDevice sipDevice)
|
||||
{
|
||||
startPage();
|
||||
List<SipDevice> list = sipDeviceService.selectSipDeviceList(sipDevice);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation("查询监控设备树结构")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@GetMapping("/listchannel/{deviceId}")
|
||||
public AjaxResult listchannel(@PathVariable("deviceId") String deviceId)
|
||||
{
|
||||
return AjaxResult.success(sipDeviceService.selectSipDeviceChannelList(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出监控设备列表
|
||||
*/
|
||||
@ApiOperation("导出监控设备列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:list')")
|
||||
@Log(title = "监控设备", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SipDevice sipDevice)
|
||||
{
|
||||
List<SipDevice> list = sipDeviceService.selectSipDeviceList(sipDevice);
|
||||
ExcelUtil<SipDevice> util = new ExcelUtil<SipDevice>(SipDevice.class);
|
||||
util.exportExcel(response, list, "监控设备数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取监控设备详细信息
|
||||
*/
|
||||
@ApiOperation("获取监控设备详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") String deviceId)
|
||||
{
|
||||
return AjaxResult.success(sipDeviceService.selectSipDeviceBySipId(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增监控设备
|
||||
*/
|
||||
@ApiOperation("新增监控设备")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:add')")
|
||||
@Log(title = "监控设备", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SipDevice sipDevice)
|
||||
{
|
||||
return toAjax(sipDeviceService.insertSipDevice(sipDevice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改监控设备
|
||||
*/
|
||||
@ApiOperation("修改监控设备")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:edit')")
|
||||
@Log(title = "监控设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SipDevice sipDevice)
|
||||
{
|
||||
return toAjax(sipDeviceService.updateSipDevice(sipDevice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监控设备
|
||||
*/
|
||||
@ApiOperation("根据设备id批量删除监控设备")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "监控设备", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceIds)
|
||||
{
|
||||
return toAjax(sipDeviceService.deleteSipDeviceByDeviceIds(deviceIds));
|
||||
}
|
||||
|
||||
@ApiOperation("根据sipId删除")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:remove')")
|
||||
@Log(title = "监控设备", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/sipid/{sipId}")
|
||||
public AjaxResult remove(@PathVariable String sipId)
|
||||
{
|
||||
return toAjax(sipDeviceService.deleteSipDeviceBySipId(sipId));
|
||||
}
|
||||
|
||||
@ApiOperation("根据设备id捕捉")
|
||||
@PreAuthorize("@ss.hasPermi('iot:video:query')")
|
||||
@GetMapping("/snap/{deviceId}/{channelId}")
|
||||
public void getSnap(HttpServletResponse resp, @PathVariable String deviceId, @PathVariable String channelId) {
|
||||
try {
|
||||
final InputStream in = Files.newInputStream(new File(FileUploadUtils.getDefaultBaseDir() + File.separator + "snap" + File.separator + deviceId + "_" + channelId + ".jpg").toPath());
|
||||
resp.setContentType(MediaType.IMAGE_PNG_VALUE);
|
||||
IOUtils.copy(in, resp.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
package com.fastbee.data.controller.media;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fastbee.sip.service.IZmlHookService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/zlmhook")
|
||||
public class ZmlHookController
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private IZmlHookService zmlHookService;
|
||||
@ApiOperation("访问流媒体服务器上的文件时触发回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onHttpAccess(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onHttpAccess(json).toString(), HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("播放器鉴权事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onPlay(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onPlay(json).toString(), HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("rtsp/rtmp/rtp推流鉴权事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onPublish(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onPublish(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("流无人观看时事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onStreamNoneReader(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("流未找到事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onStreamNotFound(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onStreamNotFound(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("流注册或注销时触发此事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onStreamChanged(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onStreamChanged(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("流量统计事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onFlowReport(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onFlowReport(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("rtp服务器长时间未收到数据超时回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onRtpServerTimeout(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onRtpServerTimeout(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("rtp发送停止回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_send_rtp_stopped", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onSendRtpStopped(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onSendRtpStopped(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("录制mp4完成后通知事件回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onRecordMp4(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onRecordMp4(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("流媒体服务器启动回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onServerStarted(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onServerStarted(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("流媒体服务器心跳回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onServerKeepalive(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onServerKeepalive(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("流媒体服务器存活回调")
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_server_exited", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onServerExited(@RequestBody JSONObject json){
|
||||
return new ResponseEntity<String>(zmlHookService.onServerExited(json).toString(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user