| | |
| | | package com.dji.sample.manage.controller; |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.mqtt.model.ChannelName; |
| | | import com.dji.sample.manage.model.dto.CapacityCameraDTO; |
| | | import com.dji.sample.manage.model.dto.CapacityDeviceDTO; |
| | | import com.dji.sample.manage.model.dto.LiveTypeDTO; |
| | | import com.dji.sample.manage.model.receiver.LiveCapacityReceiver; |
| | |
| | | import org.springframework.messaging.MessageHeaders; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import static com.dji.sample.component.AuthInterceptor.TOKEN_CLAIM; |
| | | |
| | | /** |
| | | * @author sean.zhou |
| | |
| | | liveStreamService.saveLiveCapacity(liveCapacity, headers.getTimestamp()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取直播地址 |
| | | * @param workspaceId 项目id |
| | | * @param sn 设备号 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getLiveUrl/{workspace_id}") |
| | | public ResponseResult getLiveUrl(@PathVariable("workspace_id") String workspaceId, String sn) { |
| | | List<CapacityDeviceDTO> liveCapacity = liveStreamService.getLiveCapacity(workspaceId,sn); |
| | | |
| | | if (null == liveCapacity || liveCapacity.isEmpty()) { |
| | | return ResponseResult.error(-1,"暂无直播或者设备未开机"); |
| | | } |
| | | CapacityDeviceDTO deviceDTO = liveCapacity.get(0); |
| | | |
| | | if (null == deviceDTO.getCamerasList() || deviceDTO.getCamerasList().isEmpty()) { |
| | | return ResponseResult.error(-1,"暂无直播地址"); |
| | | } |
| | | |
| | | List<CapacityCameraDTO> camerasList = deviceDTO.getCamerasList(); |
| | | if (null == camerasList || camerasList.isEmpty()) { |
| | | return ResponseResult.error(-1,"获取相机信息失败"); |
| | | } |
| | | |
| | | CapacityCameraDTO cameraDTO = camerasList.get(0); |
| | | |
| | | String videoIndex = cameraDTO.getVideosList().get(0).getIndex(); |
| | | |
| | | LiveTypeDTO liveParam = new LiveTypeDTO(); |
| | | String videoId = deviceDTO.getSn() + "-" + cameraDTO.getIndex() + "-" + videoIndex; |
| | | liveParam.setUrl("rtmp://www.ainfo.top:735/uav/" + videoId); |
| | | liveParam.setUrlType(1); |
| | | liveParam.setVideoId(deviceDTO.getSn() + "/" + cameraDTO.getIndex() + "/" + videoIndex); |
| | | liveParam.setVideoQuality(0); |
| | | return liveStreamService.liveStart(liveParam); |
| | | } |
| | | |
| | | /** |
| | | * Get live capability data of all drones in the current user's workspace from the database. |
| | | * 从数据库中获取当前工作区中所有无人机的实时性能数据。 |
| | |
| | | * @return live capability |
| | | */ |
| | | @GetMapping("/capacity/{workspace_id}") |
| | | public ResponseResult<List<CapacityDeviceDTO>> getLiveCapacity(@PathVariable("workspace_id") String workspaceId) { |
| | | public ResponseResult<List<CapacityDeviceDTO>> getLiveCapacity(@PathVariable("workspace_id") String workspaceId,String sn) { |
| | | // Get information about the current user. 获取当前登录用户的信息 |
| | | // CustomClaim customClaim = (CustomClaim)request.getAttribute(TOKEN_CLAIM); |
| | | |
| | | List<CapacityDeviceDTO> liveCapacity = liveStreamService.getLiveCapacity(workspaceId); |
| | | |
| | | List<CapacityDeviceDTO> liveCapacity = liveStreamService.getLiveCapacity(workspaceId,sn); |
| | | return ResponseResult.success(liveCapacity); |
| | | } |
| | | |
| | |
| | | return liveStreamService.liveStart(liveParam); |
| | | } |
| | | |
| | | @PostMapping("/streams/address") |
| | | public ResponseResult liveAddress(@RequestParam String deviceSn,@RequestParam String deviceName) throws IOException { |
| | | return liveStreamService.liveAddress(deviceSn,deviceName); |
| | | } |
| | | |
| | | /** |
| | | * Stop live streaming according to the parameters passed in from the web side. |
| | | * 根据从web端传入的参数停止直播。 |
| | |
| | | } |
| | | |
| | | /** |
| | | * Set the quality of the live streaming according to the parameters passed in from the web side. |
| | | * @param liveParam Live streaming parameters. |
| | | * 根据从web端传入的参数设置直播的质量。 |
| | | * @param liveParam 直播参数 |
| | | * @return |
| | | */ |
| | | @PostMapping("/streams/update") |