222
liusuyi
2025-02-18 6e33e3f0ee952d768026fda82dc0000204e21c72
ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java
@@ -49,6 +49,8 @@
import com.ard.tianyu.netty.protobuf.TelemetryDataPB;
import com.ard.tianyu.service.ITyService;
import com.ard.tianyu.websocket.utils.WebSocketUtil;
import com.ard.vtdu.domain.ArdVtdu;
import com.ard.vtdu.service.IMediaService;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import lombok.extern.slf4j.Slf4j;
@@ -76,6 +78,8 @@
    @Resource
    private TyConfiguration tyConfiguration;
    @Resource
    private IMediaService mediaService;
    /**
     * 获取天宇token信息
@@ -96,7 +100,7 @@
    public List<BoxInfoReceiver> getBoxList() {
        //请求云盒列表
        try {
            TyHttpCommonReceiver<List<BoxInfoReceiver>> boxListReveiver = tyClient.getBoxList(tyConfiguration.getAccessToken().convertFromDTO());
            TyHttpCommonReceiver<List<BoxInfoReceiver>> boxListReveiver = tyClient.getBoxList();
            return boxListReveiver.getContent();
        } catch (Exception e) {
            log.error("获取云盒列表失败:{}", e.getMessage());
@@ -112,7 +116,7 @@
    @Override
    public BoxStreamUrlReceiver getBoxLiveUrl(String boxSn) {
        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(boxSn, tyConfiguration.getAccessToken().convertFromDTO());
        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(boxSn);
        return boxLiveUrl.getContent();
    }
@@ -123,7 +127,7 @@
     */
    @Override
    public List<BoxHistoryReceiver> getBoxHistory(BoxHistoryDTO boxHistoryDTO) {
        TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(boxHistoryDTO, tyConfiguration.getAccessToken().convertFromDTO());
        TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(boxHistoryDTO);
        return boxHistory.getContent();
    }
@@ -134,7 +138,7 @@
     */
    @Override
    public List<BoxPhotosReceiver> getBoxPhotos(BoxPhotosDTO boxPhotosDTO) {
        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(boxPhotosDTO, tyConfiguration.getAccessToken().convertFromDTO());
        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(boxPhotosDTO);
        return boxPhotos.getContent();
    }
@@ -143,7 +147,7 @@
     */
    @Override
    public Boolean updateBoxSettings(BoxSettingsDTO boxSettingsDTO) {
        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(boxSettingsDTO, tyConfiguration.getAccessToken().convertFromDTO());
        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(boxSettingsDTO);
        return result.getState() == 1;
    }
@@ -561,6 +565,20 @@
    }
    /**
     * 点播
     */
    @Override
    public String play(String boxSn) {
        BoxStreamUrlReceiver boxLiveUrl = getBoxLiveUrl(boxSn);
        if(boxLiveUrl == null||boxLiveUrl.getRtsp() == null) {
            return "";
        }
        ArdVtdu ardVtdu = ArdVtdu.builder().name(boxSn).rtspSource(boxLiveUrl.getRtsp()).build();
        ardVtdu = mediaService.addPath(ardVtdu);
        return ardVtdu.getWebrtcUrl();
    }
    /**
     * 处理天宇服务器返回的消息
     */
    @Override
@@ -783,4 +801,5 @@
            log.error("发送消息异常:{}", e.getMessage());
        }
    }
}