| | |
| | | */ |
| | | public enum LiveErrorEnum implements IErrorInfo { |
| | | |
| | | NO_AIRCRAFT(613001, "No aircraft."), |
| | | NO_AIRCRAFT(613001, "没有找到飞行器。"), |
| | | |
| | | NO_CAMERA(613002, "No camera."), |
| | | NO_CAMERA(613002, "没有找到相机。"), |
| | | |
| | | LIVE_STREAM_ALREADY_STARTED(613003, "The camera has started live streaming."), |
| | | LIVE_STREAM_ALREADY_STARTED(613003, "摄像机已经开始直播了。"), |
| | | |
| | | FUNCTION_NOT_SUPPORT(613004, "The function is not supported."), |
| | | FUNCTION_NOT_SUPPORT(613004, "不支持该功能。"), |
| | | |
| | | STRATEGY_NOT_SUPPORT(613005, "The strategy is not supported."), |
| | | STRATEGY_NOT_SUPPORT(613005, "不支持该策略。"), |
| | | |
| | | NOT_IN_CAMERA_INTERFACE(613006, "The current app is not in the camera interface."), |
| | | NOT_IN_CAMERA_INTERFACE(613006, "当前的应用程序不在摄像头界面中。"), |
| | | |
| | | NO_FLIGHT_CONTROL(613007, "The remote control has no flight control rights and cannot respond to control commands"), |
| | | NO_FLIGHT_CONTROL(613007, "遥控器没有飞行控制权限,无法响应控制命令。"), |
| | | |
| | | NO_STREAM_DATA(613008, "The current app has no stream data."), |
| | | NO_STREAM_DATA(613008, "当前应用程序没有流数据。"), |
| | | |
| | | TOO_FREQUENT(613009, "The operation is too frequent."), |
| | | TOO_FREQUENT(613009, "操作太频繁了。"), |
| | | |
| | | ENABLE_FAILED(613010, "Please check whether the live stream service is normal."), |
| | | ENABLE_FAILED(613010, "请检查直播服务是否正常。"), |
| | | |
| | | NO_LIVE_STREAM(613011, "There are no live stream currently."), |
| | | NO_LIVE_STREAM(613011, "目前没有直播。"), |
| | | |
| | | SWITCH_NOT_SUPPORT(613012, "There is already another camera in the live stream. It's not support to switch the stream directly."), |
| | | SWITCH_NOT_SUPPORT(613012, "直播流中已经有另一个摄像头了。不支持直接切换流。"), |
| | | |
| | | URL_TYPE_NOT_SUPPORTED(613013, "This url type is not supported."), |
| | | URL_TYPE_NOT_SUPPORTED(613013, "不支持此url类型。"), |
| | | |
| | | ERROR_PARAMETERS(613014, "The live stream parameters are abnormal or incomplete."), |
| | | ERROR_PARAMETERS(613014, "直播参数异常或不完整。"), |
| | | |
| | | NO_REPLY(613098, "No live reply received."), |
| | | NO_REPLY(613098, "没有收到即时回复。"), |
| | | |
| | | UNKNOWN(613099, "UNKNOWN"); |
| | | UNKNOWN(613099, "未知消息"); |
| | | |
| | | |
| | | private String msg; |
| | |
| | | if (dockOpt.isPresent() && (DockModeCodeEnum.IDLE == dockMode || DockModeCodeEnum.WORKING == dockMode)) { |
| | | Optional<OsdSubDeviceReceiver> deviceOsd = deviceRedisService.getDeviceOsd(dockOpt.get().getChildDeviceSn(), OsdSubDeviceReceiver.class); |
| | | if (deviceOsd.isEmpty() || deviceOsd.get().getElevation() <= 0) { |
| | | throw new RuntimeException("The drone is not in the sky and cannot enter command flight mode."); |
| | | throw new RuntimeException("无人机不在空中,不能进入指挥飞行模式。"); |
| | | } |
| | | } else { |
| | | throw new RuntimeException("The current state of the dock does not support entering command flight mode."); |
| | | throw new RuntimeException("当前状态不支持进入命令飞行模式。"); |
| | | } |
| | | |
| | | ResponseResult result = controlService.seizeAuthority(dockSn, DroneAuthorityEnum.FLIGHT, null); |
| | |
| | | package com.dji.sample.manage.controller; |
| | | |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.manage.model.dto.UserListDTO; |
| | | import com.dji.sample.manage.model.dto.WorkspaceDTO; |
| | | import com.dji.sample.manage.service.IWorkspaceService; |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Optional; |
| | |
| | | |
| | | return workspaceOpt.isEmpty() ? ResponseResult.error() : ResponseResult.success(workspaceOpt.get()); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseResult findCurrentWorkspace(@RequestParam(defaultValue = "1") Long page, |
| | | @RequestParam(value = "page_size", defaultValue = "50") Long pageSize) { |
| | | PaginationData<WorkspaceDTO> paginationData = workspaceService.selectWorkspace(page, pageSize); |
| | | return ResponseResult.success(paginationData); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseResult add(@RequestBody WorkspaceDTO dto) { |
| | | return workspaceService.createWorkspace(dto)?ResponseResult.success():ResponseResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/delete") |
| | | public ResponseResult delete(@RequestParam(value = "id") Integer id) { |
| | | return workspaceService.deleteWorkspaceById(id)?ResponseResult.success():ResponseResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | public ResponseResult update(@RequestBody WorkspaceDTO dto) { |
| | | return workspaceService.updateWorkspaceById(dto)?ResponseResult.success():ResponseResult.error(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private Integer id; |
| | | |
| | | private String workspaceId; |
| | | private String workspaceId;//项目id |
| | | |
| | | private String workspaceName; |
| | | private String workspaceName;//项目名称 |
| | | |
| | | private String workspaceDesc; |
| | | private String workspaceDesc;//项目描述 |
| | | |
| | | private String platformName; |
| | | private String platformName;//平台名称 |
| | | |
| | | private String bindCode; |
| | | private String bindCode;//绑定码 |
| | | } |
| | |
| | | package com.dji.sample.manage.model.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @TableName(value = "manage_workspace") |
| | | @Data |
| | | @Builder |
| | | public class WorkspaceEntity implements Serializable { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | |
| | | package com.dji.sample.manage.service; |
| | | |
| | | |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.mqtt.model.CommonTopicReceiver; |
| | | import com.dji.sample.manage.model.dto.WorkspaceDTO; |
| | | import org.springframework.messaging.MessageHeaders; |
| | |
| | | |
| | | public interface IWorkspaceService { |
| | | |
| | | PaginationData<WorkspaceDTO> selectWorkspace(long page, long pageSize); |
| | | |
| | | Boolean createWorkspace(WorkspaceDTO dto); |
| | | |
| | | Boolean deleteWorkspaceById(Integer id); |
| | | |
| | | Boolean updateWorkspaceById(WorkspaceDTO dto); |
| | | |
| | | /** |
| | | * Query the information of a workspace based on its workspace id. |
| | | * @param workspaceId |
| | |
| | | |
| | | @Override |
| | | public ResponseResult liveStart(LiveTypeDTO liveParam) { |
| | | |
| | | // String streamId_2 = liveParam.getVideoId().replace("/","_"); |
| | | // String streamId_1 = liveParam.getVideoId().replace("_","/"); |
| | | // liveParam.setVideoId(streamId_2); |
| | | |
| | | // Check if this lens is available live. |
| | | ResponseResult responseResult = this.checkBeforeLive(liveParam.getVideoId()); |
| | | if (ResponseResult.CODE_SUCCESS != responseResult.getCode()) { |
| | |
| | | // target topic |
| | | String respTopic = THING_MODEL_PRE + PRODUCT + |
| | | data.getDeviceSn() + SERVICES_SUF; |
| | | |
| | | ServiceReply receiveReply = this.publishLiveStart(respTopic, liveParam); |
| | | |
| | | if(receiveReply.getResult() == 513003) { |
| | | LiveDTO live = new LiveDTO(); |
| | | live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv"); |
| | | return ResponseResult.success(live); |
| | | } |
| | | |
| | | if (ResponseResult.CODE_SUCCESS != receiveReply.getResult()) { |
| | | return ResponseResult.error(LiveErrorEnum.find(receiveReply.getResult())); |
| | |
| | | |
| | | switch (urlType) { |
| | | case RTMP: |
| | | live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc")); |
| | | // live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc")); |
| | | live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv"); |
| | | break; |
| | | case GB28181: |
| | | LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl()); |
| | |
| | | |
| | | String respTopic = THING_MODEL_PRE + PRODUCT + responseResult.getData().getDeviceSn() + SERVICES_SUF; |
| | | |
| | | videoId = videoId.replace("_","/"); |
| | | |
| | | ServiceReply receiveReply = this.publishLiveStop(respTopic, videoId); |
| | | if (receiveReply.getResult() != 0) { |
| | | return ResponseResult.error(LiveErrorEnum.find(receiveReply.getResult())); |
| | |
| | | package com.dji.sample.manage.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dji.sample.common.error.CommonErrorEnum; |
| | | import com.dji.sample.common.model.Pagination; |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.component.mqtt.model.*; |
| | | import com.dji.sample.component.mqtt.service.IMessageSenderService; |
| | | import com.dji.sample.manage.dao.IWorkspaceMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Transactional |
| | |
| | | |
| | | @Autowired |
| | | private IMessageSenderService messageSenderService; |
| | | |
| | | @Override |
| | | public PaginationData<WorkspaceDTO> selectWorkspace(long page, long pageSize) { |
| | | Page<WorkspaceEntity> entityPage = mapper.selectPage( |
| | | new Page<>(page, pageSize), |
| | | new QueryWrapper<>()); |
| | | |
| | | List<WorkspaceDTO> list = entityPage.getRecords() |
| | | .stream() |
| | | .map(this::entityConvertToDto) |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<>(list, new Pagination(entityPage)); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean createWorkspace(WorkspaceDTO dto) { |
| | | dto.setWorkspaceId(UUID.randomUUID().toString()); |
| | | return mapper.insert(dtoConvertToEntity(dto)) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteWorkspaceById(Integer id) { |
| | | return mapper.deleteById(id) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateWorkspaceById(WorkspaceDTO dto) { |
| | | return mapper.updateById(dtoConvertToEntity(dto)) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Optional<WorkspaceDTO> getWorkspaceByWorkspaceId(String workspaceId) { |
| | |
| | | .bindCode(entity.getBindCode()) |
| | | .build(); |
| | | } |
| | | |
| | | private WorkspaceEntity dtoConvertToEntity(WorkspaceDTO dto) { |
| | | if (dto == null) { |
| | | return null; |
| | | } |
| | | return WorkspaceEntity.builder() |
| | | .id(dto.getId()) |
| | | .workspaceId(dto.getWorkspaceId()) |
| | | .platformName(dto.getPlatformName()) |
| | | .workspaceDesc(dto.getWorkspaceDesc()) |
| | | .workspaceName(dto.getWorkspaceName()) |
| | | .bindCode(dto.getBindCode()) |
| | | .build(); |
| | | } |
| | | } |
| | |
| | | druid: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://cloud_api_sample_mysql:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true |
| | | url: jdbc:mysql://172.16.13.129:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true |
| | | username: root |
| | | password: root |
| | | password: 123456 |
| | | initial-size: 10 |
| | | min-idle: 10 |
| | | max-active: 20 |
| | | max-wait: 60000 |
| | | |
| | | redis: |
| | | host: cloud_api_sample_redis |
| | | host: 127.0.0.1 |
| | | port: 6379 |
| | | database: 0 |
| | | username: # if you enable |
| | |
| | | # BASIC parameters are required. |
| | | BASIC: |
| | | protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum |
| | | host: Please enter your ip. |
| | | port: 1883 |
| | | username: JavaServer |
| | | password: 123456 |
| | | client-id: 123456 |
| | | host: 182.106.212.58 |
| | | port: 31883 |
| | | username: root |
| | | password: root |
| | | # host: 127.0.0.1 |
| | | # port: 1883 |
| | | # username: guest |
| | | # password: guest |
| | | client-id: aix123456 |
| | | # If the protocol is ws/wss, this value is required. |
| | | path: |
| | | # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",". |
| | | inbound-topic: sys/product/+/status,thing/product/+/requests |
| | | # inbound-topic: sys/product/+/status,thing/product/+/requests |
| | | inbound-topic: sys/product/+/+,thing/product/+/+ |
| | | DRC: |
| | | protocol: WS # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum |
| | | host: Please enter your ip. |
| | | port: 8083 |
| | | path: /mqtt |
| | | host: 182.106.212.58 |
| | | port: 15675 |
| | | path: /ws |
| | | |
| | | url: |
| | | manage: |
| | |
| | | version: /api/v1 |
| | | |
| | | # Tutorial: https://www.alibabacloud.com/help/en/object-storage-service/latest/use-a-temporary-credential-provided-by-sts-to-access-oss |
| | | oss: |
| | | enable: false |
| | | provider: ali # @see com.dji.sample.component.OssConfiguration.model.enums.OssTypeEnum |
| | | endpoint: https://oss-cn-hangzhou.aliyuncs.com |
| | | access-key: Please enter your access key. |
| | | secret-key: Please enter your secret key. |
| | | expire: 3600 |
| | | region: Please enter your oss region. # cn-hangzhou |
| | | role-session-name: cloudApi |
| | | role-arn: Please enter your role arn. # acs:ram::123456789:role/stsrole |
| | | bucket: Please enter your bucket name. |
| | | object-dir-prefix: Please enter a folder name. |
| | | #oss: |
| | | # enable: false |
| | | # provider: ali # @see com.dji.sample.component.OssConfiguration.model.enums.OssTypeEnum |
| | | # endpoint: https://oss-cn-hangzhou.aliyuncs.com |
| | | # access-key: Please enter your access key. |
| | | # secret-key: Please enter your secret key. |
| | | # expire: 3600 |
| | | # region: Please enter your oss region. # cn-hangzhou |
| | | # role-session-name: cloudApi |
| | | # role-arn: Please enter your role arn. # acs:ram::123456789:role/stsrole |
| | | # bucket: Please enter your bucket name. |
| | | # object-dir-prefix: Please enter a folder name. |
| | | |
| | | #oss: |
| | | # enable: true |
| | |
| | | # bucket: cloudapi-bucket |
| | | # object-dir-prefix: wayline |
| | | |
| | | #oss: |
| | | # enable: true |
| | | # provider: minio |
| | | # endpoint: http://192.168.1.1:9000 |
| | | # access-key: minioadmin |
| | | # secret-key: minioadmin |
| | | # bucket: cloud-bucket |
| | | # expire: 3600 |
| | | # region: us-east-1 |
| | | # object-dir-prefix: wayline |
| | | oss: |
| | | enable: true |
| | | provider: minio |
| | | # endpoint: http://172.16.13.129:9000 |
| | | # access-key: admin |
| | | # secret-key: 12345678 |
| | | endpoint: http://dev.jxpskj.com:9000 |
| | | access-key: pskj |
| | | secret-key: pskj@2021 |
| | | bucket: cloud-bucket |
| | | expire: 3600 |
| | | region: us-east-1 |
| | | object-dir-prefix: wayline |
| | | |
| | | logging: |
| | | level: |
| | |
| | | # To create a license for an application: https://developer.dji.com/user/apps/#all |
| | | cloud-api: |
| | | app: |
| | | id: Please enter the app id. |
| | | key: Please enter the app key. |
| | | license: Please enter the app license. |
| | | id: 136971 |
| | | key: 3e56cb20958060caeb1071cdb32400e |
| | | license: eS2rczbPpEUZZkOuek7hB1fugv3TE0RdKyEU319A2cxmVKs7Bc11RadcPcHnQJjBq/Peja5R6bp2IILCypa2lskCUGXkXHmqxdPIVTyMQpkZtjM+eXLut/VHPdXVZOvYxKFMVel6jfEyd4rWL9jBI1N34rCvwSgad6T49mRC8R0= |