guoshilong
2023-09-22 b1c1ec2cf0880227ff354f5766e9a7af6011f9ad
注释添加
9 files modified
42 ■■■■ changed files
src/main/java/com/dji/sample/common/error/LiveErrorEnum.java 17 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/component/mqtt/service/IMessageSenderService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/controller/LiveStreamController.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/IDeviceService.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/ILiveStreamService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/common/error/LiveErrorEnum.java
@@ -14,23 +14,23 @@
    NO_CAMERA(613002, "没有找到相机。"),
    LIVE_STREAM_ALREADY_STARTED(613003, "摄像机已经开始直播了。"),
    FUNCTION_NOT_SUPPORT(613004, "不支持该功能。"),
    STRATEGY_NOT_SUPPORT(613005, "不支持该策略。"),
    NOT_IN_CAMERA_INTERFACE(613006, "当前的应用程序不在摄像头界面中。"),
    NO_FLIGHT_CONTROL(613007, "遥控器没有飞行控制权限,无法响应控制命令。"),
    NO_STREAM_DATA(613008, "当前应用程序没有流数据。"),
    TOO_FREQUENT(613009, "操作太频繁了。"),
    ENABLE_FAILED(613010, "请检查直播服务是否正常。"),
    NO_LIVE_STREAM(613011, "目前没有直播。"),
    SWITCH_NOT_SUPPORT(613012, "直播流中已经有另一个摄像头了。不支持直接切换流。"),
    URL_TYPE_NOT_SUPPORTED(613013, "不支持此url类型。"),
@@ -63,6 +63,7 @@
    /**
     * Get the corresponding enumeration object based on the error code.
     * 根据错误代码获取相应的枚举对象。
     * @param code error code
     * @return enumeration object
     */
src/main/java/com/dji/sample/component/mqtt/service/IMessageSenderService.java
@@ -28,6 +28,7 @@
    /**
     * Send message and receive a response at the same time.
     * 发送消息并同时接收响应。
     * @param clazz
     * @param topic
     * @param response  notification of whether the start is successful.
src/main/java/com/dji/sample/manage/controller/LiveStreamController.java
@@ -64,6 +64,7 @@
    /**
     * Live streaming according to the parameters passed in from the web side.
     * 根据从web端传入的参数进行直播。
     * @param liveParam Live streaming parameters.
     * @return
     */
@@ -74,6 +75,7 @@
    /**
     * Stop live streaming according to the parameters passed in from the web side.
     * 根据从web端传入的参数停止直播。
     * @param liveParam Live streaming parameters.
     * @return
     */
src/main/java/com/dji/sample/manage/service/ICapacityCameraService.java
@@ -14,6 +14,7 @@
    /**
     * Query all camera data that can be live streamed from this device based on the device sn.
     * 根据设备序列号查询该设备可直播的所有摄像头数据。
     * @param deviceSn
     * @return
     */
src/main/java/com/dji/sample/manage/service/IDeviceRedisService.java
@@ -17,6 +17,7 @@
    /**
     * Determine if the device is online.
     * 判断设备是否在线
     * @param sn
     * @return
     */
src/main/java/com/dji/sample/manage/service/IDeviceService.java
@@ -69,6 +69,7 @@
    /**
     * Obtain device data according to different query conditions.
     * 根据不同的查询条件获取设备数据。
     * @param param query parameters
     * @return
     */
@@ -171,6 +172,7 @@
    /**
     * Get device information based on device's sn.
     * 根据设备码获取设备信息
     * @param sn device's sn
     * @return device
     */
@@ -229,4 +231,4 @@
     */
    Boolean checkAuthorityFlight(String gatewaySn);
}
}
src/main/java/com/dji/sample/manage/service/ILiveStreamService.java
@@ -31,6 +31,7 @@
    /**
     * Initiate a live streaming by publishing mqtt message.
     * 通过发布mqtt消息启动实时流。
     * @param liveParam Parameters needed for on-demand.
     * @return
     */
@@ -38,6 +39,7 @@
    /**
     * Stop the live streaming by publishing mqtt message.
     * 通过发布mqtt消息来停止实时流。
     * @param videoId
     * @return
     */
src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
@@ -279,10 +279,13 @@
    public List<DeviceDTO> getDevicesByParams(DeviceQueryParam param) {
        return mapper.selectList(
                new LambdaQueryWrapper<DeviceEntity>()
                        //设备编码
                        .eq(StringUtils.hasText(param.getDeviceSn()),
                                DeviceEntity::getDeviceSn, param.getDeviceSn())
                        //设备类型
                        .eq(param.getDeviceType() != null,
                                DeviceEntity::getDeviceType, param.getDeviceType())
                        //负载类型
                        .eq(param.getSubType() != null,
                                DeviceEntity::getSubType, param.getSubType())
                        .eq(StringUtils.hasText(param.getChildSn()),
@@ -1194,4 +1197,4 @@
        }
        return deviceBasic.getPayloads();
    }
}
}
src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java
@@ -65,6 +65,7 @@
        // Query the live capability of each drone.
        return devicesList.stream()
                //过滤出在线设备
                .filter(device -> deviceRedisService.checkDeviceOnline(device.getDeviceSn()))
                .map(device -> CapacityDeviceDTO.builder()
                        .name(Objects.requireNonNullElse(device.getNickname(), device.getDeviceName()))
@@ -97,6 +98,7 @@
//        liveParam.setVideoId(streamId_2);
        // Check if this lens is available live.
        //检查镜头是否可用
        ResponseResult responseResult = this.checkBeforeLive(liveParam.getVideoId());
        if (ResponseResult.CODE_SUCCESS != responseResult.getCode()) {
            return responseResult;
@@ -104,11 +106,14 @@
        DeviceDTO data = (DeviceDTO)responseResult.getData();
        // target topic
        //thing/product/{gateway_sn}/services   云平台向设备发送的服务
        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");
@@ -122,6 +127,7 @@
        LiveUrlTypeEnum urlType = LiveUrlTypeEnum.find(liveParam.getUrlType());
        LiveDTO live = new LiveDTO();
        //对不同的协议类型做处理
        switch (urlType) {
            case RTMP:
//                live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc"));
@@ -156,6 +162,7 @@
            return responseResult;
        }
        //thing/product/{gateway_sn}/services
        String respTopic = THING_MODEL_PRE + PRODUCT + responseResult.getData().getDeviceSn() + SERVICES_SUF;
        videoId = videoId.replace("_","/");
@@ -228,6 +235,7 @@
    /**
     * Check if this lens is available live.
     * 检查镜头是否可用
     * @param videoId
     * @return
     */
@@ -309,6 +317,7 @@
    /**
     * Send a message to the pilot via mqtt to start the live streaming.
     *通过mqtt向飞行员发送消息以启动直播。
     * @param topic
     * @param liveParam
     * @return