14 changed files with 299 additions and 5 deletions
@ -0,0 +1,39 @@ |
|||
package org.dromara.common.sdk.cloudapi.device; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonValue; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import org.dromara.common.sdk.exception.CloudSDKException; |
|||
|
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* @author sean |
|||
* @version 1.7 |
|||
* @date 2023/5/26 |
|||
*/ |
|||
@Schema(description = "DeviceTypeVideoEnum", enumAsRef = true) |
|||
public enum DeviceTypeVideoEnum { |
|||
|
|||
ZERO(0), |
|||
SEVEN(7); |
|||
|
|||
; |
|||
|
|||
private final int videoType; |
|||
|
|||
DeviceTypeVideoEnum(int videoType) { |
|||
this.videoType = videoType; |
|||
} |
|||
|
|||
@JsonValue |
|||
public int getVideoType() { |
|||
return videoType; |
|||
} |
|||
|
|||
@JsonCreator |
|||
public static DeviceTypeVideoEnum find(int videoType) { |
|||
return Arrays.stream(values()).filter(typeEnum -> typeEnum.videoType == videoType).findAny() |
|||
.orElseThrow(() -> new CloudSDKException(DeviceTypeVideoEnum.class, videoType)); |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
package org.dromara.common.sdk.cloudapi.device; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonValue; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.sdk.exception.CloudSDKException; |
|||
|
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* @author sean |
|||
* @version 1.7 |
|||
* @date 2023/5/19 |
|||
*/ |
|||
@Schema(description = "device model key.", format = "domain-type-subType", enumAsRef = true, example = "0-89-0") |
|||
public enum DeviceVideoEnum { |
|||
|
|||
|
|||
DOCK(DeviceTypeEnum.DOCK_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.SEVEN), |
|||
|
|||
DJIDock2(DeviceTypeEnum.DOCK_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.SEVEN), |
|||
|
|||
DOCK3(DeviceTypeEnum.DOCK_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.SEVEN), |
|||
Matrice30(DeviceTypeEnum.M30_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
|
|||
Matrice30T(DeviceTypeEnum.M30T_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
M3D(DeviceTypeEnum.M3D_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
|
|||
M3TD(DeviceTypeEnum.M3TD_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
|
|||
M4D(DeviceTypeEnum.M4D_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
|
|||
M4TD(DeviceTypeEnum.M4TD_CAMERA, DeviceSubTypeEnum.ZERO, DeviceTypeVideoEnum.ZERO), |
|||
|
|||
; |
|||
|
|||
|
|||
@Schema(enumAsRef = true) |
|||
private final DeviceTypeEnum type; |
|||
|
|||
@Schema(enumAsRef = true) |
|||
private final DeviceSubTypeEnum subType; |
|||
|
|||
@Schema(enumAsRef = true) |
|||
private final DeviceTypeVideoEnum videoType; |
|||
|
|||
DeviceVideoEnum(DeviceTypeEnum type, DeviceSubTypeEnum subType, DeviceTypeVideoEnum videoType) { |
|||
this.type = type; |
|||
this.subType = subType; |
|||
this.videoType = videoType; |
|||
} |
|||
|
|||
public DeviceTypeEnum getType() { |
|||
return type; |
|||
} |
|||
|
|||
public DeviceSubTypeEnum getSubType() { |
|||
return subType; |
|||
} |
|||
|
|||
public DeviceTypeVideoEnum getVideoType() { |
|||
return videoType; |
|||
} |
|||
|
|||
@JsonValue |
|||
public String getDevice() { |
|||
return String.format("%s-%s-%s", type.getType(), subType.getSubType(),videoType.getVideoType()); |
|||
} |
|||
|
|||
|
|||
@JsonCreator |
|||
public static DeviceVideoEnum find(String key) { |
|||
String finalKey = key.replaceAll(" ",""); |
|||
return Arrays.stream(values()).filter(device -> device.toString().equals(finalKey)) |
|||
.findAny().orElseThrow(() -> new CloudSDKException(DeviceEnum.class, finalKey)); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,46 @@ |
|||
package org.dromara.sample.rocketmq; |
|||
|
|||
import org.apache.rocketmq.common.message.MessageExt; |
|||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|||
import org.dromara.common.sdk.cloudapi.device.VideoId; |
|||
import org.dromara.common.sdk.cloudapi.livestream.LensChangeVideoTypeEnum; |
|||
import org.dromara.common.sdk.cloudapi.livestream.UrlTypeEnum; |
|||
import org.dromara.common.sdk.cloudapi.livestream.VideoQualityEnum; |
|||
import org.dromara.sample.manage.model.dto.LiveTypeDTO; |
|||
import org.dromara.sample.manage.service.ILiveStreamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.ObjectUtils; |
|||
|
|||
/** |
|||
* @auther wuyuan |
|||
* @data 2025/5/12 |
|||
*/ |
|||
@RocketMQMessageListener(consumerGroup = "videoStart",topic = "videoStartConsum") |
|||
@Component |
|||
public class RocketMqConsum implements RocketMQListener<MessageExt> { |
|||
|
|||
@Autowired |
|||
private ILiveStreamService liveStreamService; |
|||
|
|||
@Override |
|||
public void onMessage(MessageExt message) { |
|||
String tags = message.getTags(); |
|||
String videoIds = new String(message.getBody()); |
|||
VideoId videoId = new VideoId(videoIds); |
|||
LiveTypeDTO liveTypeDTO = new LiveTypeDTO(); |
|||
liveTypeDTO.setUrlType(UrlTypeEnum.WHIP); |
|||
liveTypeDTO.setVideoType(LensChangeVideoTypeEnum.WIDE); |
|||
liveTypeDTO.setVideoQuality(VideoQualityEnum.ULTRA_HD); |
|||
liveTypeDTO.setVideoId(videoId); |
|||
if(tags.equals("videoStart")){ |
|||
liveStreamService.liveStart(liveTypeDTO); |
|||
}else if(tags.equals("videoStopStart")){ |
|||
liveStreamService.liveStop(videoId); |
|||
liveStreamService.liveStart(liveTypeDTO); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue