Commit bd2bf01f by gdj

增加直播相机切换live_camera_change。

parent 6f3aa029
package com.dji.sdk.cloudapi.livestream;
import com.dji.sdk.exception.CloudSDKException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
/**
* @author sean
* @version 1.7
* @date 2023/6/25
*/
public enum CameraPositionEnum {
INSIDE(0),
OUTSIDE(1);
private final int type;
CameraPositionEnum(int type) {
this.type = type;
}
@JsonValue
public int getType() {
return type;
}
@JsonCreator
public static CameraPositionEnum find(int videoType) {
return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == videoType).findAny()
.orElseThrow(() -> new CloudSDKException(CameraPositionEnum.class , videoType));
}
}
package com.dji.sdk.cloudapi.livestream;
import com.dji.sdk.cloudapi.device.VideoId;
import com.dji.sdk.common.BaseModel;
import javax.validation.constraints.NotNull;
/**
* @author sean
* @version 1.7
* @date 2023/5/23
*/
public class LiveCameraChangeRequest extends BaseModel {
@NotNull
private CameraPositionEnum cameraPosition;
/**
* The format is #{uav_sn}/#{camera_id}/#{video_index},
* drone serial number/payload and mounted location enumeration value/payload lens numbering
*/
@NotNull
private VideoId videoId;
public LiveCameraChangeRequest() {
}
@Override
public String toString() {
return "LiveLensChangeRequest{" +
"cameraPosition=" + cameraPosition +
", videoId=" + videoId +
'}';
}
public CameraPositionEnum getCameraPosition() {
return cameraPosition;
}
public LiveCameraChangeRequest setCameraPosition(CameraPositionEnum cameraPosition) {
this.cameraPosition = cameraPosition;
return this;
}
public VideoId getVideoId() {
return videoId;
}
public LiveCameraChangeRequest setVideoId(VideoId videoId) {
this.videoId = videoId;
return this;
}
}
......@@ -15,6 +15,8 @@ public enum LiveStreamMethodEnum {
LIVE_SET_QUALITY("live_set_quality"),
LIVE_CAMERA_CHANGE("live_camera_change"),
LIVE_LENS_CHANGE("live_lens_change");
private final String method;
......
......@@ -103,5 +103,18 @@ public abstract class AbstractLivestreamService {
DEFAULT_TIMEOUT);
}
/**
* 直播相机切换
* @param gateway
* @param request data
* @return services_reply
*/
public TopicServicesResponse<ServicesReplyData> liveCameraChange(GatewayManager gateway, LiveCameraChangeRequest request) {
return servicesPublish.publish(
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_CAMERA_CHANGE.getMethod(),
request,
DEFAULT_TIMEOUT);
}
}
......@@ -98,4 +98,9 @@ public class LiveStreamController {
return liveStreamService.liveLensChange(liveParam);
}
@PostMapping("/streams/liveCameraChange")
public HttpResultResponse liveCameraChange(@RequestBody LiveTypeDTO liveParam) {
return liveStreamService.liveCameraChange(liveParam);
}
}
\ No newline at end of file
package com.dji.sample.manage.model.dto;
import com.dji.sdk.cloudapi.device.VideoId;
import com.dji.sdk.cloudapi.livestream.CameraPositionEnum;
import com.dji.sdk.cloudapi.livestream.LensChangeVideoTypeEnum;
import com.dji.sdk.cloudapi.livestream.UrlTypeEnum;
import com.dji.sdk.cloudapi.livestream.VideoQualityEnum;
......@@ -27,4 +28,7 @@ public class LiveTypeDTO {
private LensChangeVideoTypeEnum videoType;
@JsonProperty("camera_position")
private CameraPositionEnum cameraPosition;
}
\ No newline at end of file
......@@ -18,6 +18,8 @@ public enum LiveStreamMethodEnum {
LIVE_LENS_CHANGE("live_lens_change"),
LIVE_CAMERA_CHANGE("live_camera_change"),
UNKNOWN("unknown");
private String method;
......
......@@ -56,4 +56,12 @@ public interface ILiveStreamService {
* @return
*/
HttpResultResponse liveLensChange(LiveTypeDTO liveParam);
/**
* 直播相机切换
* @param liveParam
* @return
*/
HttpResultResponse liveCameraChange(LiveTypeDTO liveParam);
}
......@@ -198,6 +198,24 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
return HttpResultResponse.success();
}
@Override
public HttpResultResponse liveCameraChange(LiveTypeDTO liveParam) {
HttpResultResponse<DeviceDTO> responseResult = this.checkBeforeLive(liveParam.getVideoId());
if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) {
return responseResult;
}
TopicServicesResponse<ServicesReplyData> response = abstractLivestreamService.liveCameraChange(
SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), new LiveCameraChangeRequest()
.setCameraPosition(liveParam.getCameraPosition())
.setVideoId(liveParam.getVideoId()));
if (!response.getData().getResult().isSuccess()) {
return HttpResultResponse.error(response.getData().getResult());
}
return HttpResultResponse.success();
}
/**
* Check if this lens is available live.
* @param videoId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment