|
|
@ -1,23 +1,28 @@ |
|
|
|
package org.dromara.sample.manage.service.impl; |
|
|
|
|
|
|
|
import org.dromara.common.rocketmq.producer.MessageProducerUtil; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.DeviceDomainEnum; |
|
|
|
import org.dromara.common.sdk.cloudapi.device.VideoId; |
|
|
|
import org.dromara.common.sdk.cloudapi.livestream.*; |
|
|
|
import org.dromara.common.sdk.cloudapi.livestream.api.AbstractLivestreamService; |
|
|
|
import org.dromara.common.sdk.cloudapi.wayline.FlighttaskProgress; |
|
|
|
import org.dromara.common.sdk.common.HttpResultResponse; |
|
|
|
import org.dromara.common.sdk.common.SDKManager; |
|
|
|
import org.dromara.common.sdk.mqtt.services.ServicesReplyData; |
|
|
|
import org.dromara.common.sdk.mqtt.services.TopicServicesResponse; |
|
|
|
import org.dromara.sample.component.mqtt.model.EventsReceiver; |
|
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
|
import org.dromara.sample.manage.model.entity.DeviceEntity; |
|
|
|
import org.dromara.sample.manage.model.param.DeviceQueryParam; |
|
|
|
import org.dromara.sample.manage.service.*; |
|
|
|
import org.dromara.sample.wayline.model.dto.WaylineJobDTO; |
|
|
|
import org.dromara.sample.wayline.service.IWaylineJobService; |
|
|
|
import org.dromara.sample.wayline.service.IWaylineRedisService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -44,6 +49,16 @@ public class LiveStreamServiceImpl implements ILiveStreamService { |
|
|
|
@Autowired |
|
|
|
private AbstractLivestreamService abstractLivestreamService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IPlayTextService playTextService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IWaylineRedisService waylineRedisService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IWaylineJobService waylineJobService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CapacityDeviceDTO> getLiveCapacity(String workspaceId) { |
|
|
|
|
|
|
@ -68,26 +83,23 @@ public class LiveStreamServiceImpl implements ILiveStreamService { |
|
|
|
@Override |
|
|
|
public HttpResultResponse liveStart(LiveTypeDTO liveParam) { |
|
|
|
// Check if this lens is available live.
|
|
|
|
|
|
|
|
HttpResultResponse<DeviceDTO> responseResult = this.checkBeforeLive(liveParam.getVideoId()); |
|
|
|
if (HttpResultResponse.CODE_SUCCESS != responseResult.getCode()) { |
|
|
|
return responseResult; |
|
|
|
} |
|
|
|
Boolean flag = deviceRedisService.checkDeviceVideo(liveParam.getVideoId().getDroneSn()); |
|
|
|
|
|
|
|
|
|
|
|
ILivestreamUrl url = LiveStreamProperty.get(liveParam.getUrlType()); |
|
|
|
url = setExt(liveParam.getUrlType(), url, liveParam.getVideoId()); |
|
|
|
if (!flag) { |
|
|
|
TopicServicesResponse<ServicesReplyData<String>> response = abstractLivestreamService.liveStartPush( |
|
|
|
SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), |
|
|
|
new LiveStartPushRequest() |
|
|
|
.setUrl(url) |
|
|
|
.setUrlType(liveParam.getUrlType()) |
|
|
|
.setVideoId(liveParam.getVideoId()) |
|
|
|
.setVideoQuality(liveParam.getVideoQuality())); |
|
|
|
|
|
|
|
if (!response.getData().getResult().isSuccess()) { |
|
|
|
|
|
|
|
TopicServicesResponse<ServicesReplyData<String>> response = abstractLivestreamService.liveStartPush( |
|
|
|
SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()), |
|
|
|
new LiveStartPushRequest() |
|
|
|
.setUrl(url) |
|
|
|
.setUrlType(liveParam.getUrlType()) |
|
|
|
.setVideoId(liveParam.getVideoId()) |
|
|
|
.setVideoQuality(liveParam.getVideoQuality())); |
|
|
|
|
|
|
|
if (!response.getData().getResult().isSuccess()) { |
|
|
|
if(response.getData().getResult().getCode() != 513003){ |
|
|
|
return HttpResultResponse.error(response.getData().getResult()); |
|
|
|
} |
|
|
|
} |
|
|
@ -116,7 +128,22 @@ public class LiveStreamServiceImpl implements ILiveStreamService { |
|
|
|
default: |
|
|
|
return HttpResultResponse.error(LiveErrorCodeEnum.URL_TYPE_NOT_SUPPORTED); |
|
|
|
} |
|
|
|
DeviceEntity deviceBySn = deviceService.getDeviceByChildSn(liveParam.getVideoId().getDroneSn()); |
|
|
|
if(deviceBySn != null){ |
|
|
|
|
|
|
|
Optional<EventsReceiver<FlighttaskProgress>> runningWaylineJob = waylineRedisService.getRunningWaylineJob(deviceBySn.getDeviceSn()); |
|
|
|
Map<String,Object> reqMap = new HashMap<>(); |
|
|
|
if(runningWaylineJob.isPresent()) { |
|
|
|
String jobId = runningWaylineJob.get().getOutput().getExt().getFlightId(); |
|
|
|
Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobInternalId(jobId); |
|
|
|
reqMap.put("jobId",waylineJobDTO.get().getJobId()); |
|
|
|
reqMap.put("jobName",waylineJobDTO.get().getJobName()); |
|
|
|
reqMap.put("deviceSn",deviceBySn.getDeviceSn()); |
|
|
|
playTextService.streamType(reqMap); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// MessageProducerUtil.sendAsyncProducerMessage("videoStartConsum","videoStart",liveParam.getVideoId().getDroneSn(),liveParam.getVideoId().toString());
|
|
|
|
return HttpResultResponse.success(live); |
|
|
|
} |
|
|
|
|
|
|
|