648540858
2022-09-09 221f99c764b51c3cd284c6e5a41492c26c5c7ffc
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
@@ -1,12 +1,14 @@
package com.genersoft.iot.vmp.vmanager.gb28181.media;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -51,7 +53,7 @@
    @Parameter(name = "useSourceIpAsStreamIp", description = "是否使用请求IP作为返回的地址IP")
    @GetMapping(value = "/stream_info_by_app_and_stream")
    @ResponseBody
    public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
    public StreamInfo getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
                                                             @RequestParam String stream,
                                                             @RequestParam(required = false) String mediaServerId,
                                                             @RequestParam(required = false) String callId,
@@ -63,10 +65,7 @@
            if (streamAuthorityInfo.getCallId().equals(callId)) {
                authority = true;
            }else {
                WVPResult<StreamInfo> result = new WVPResult<>();
                result.setCode(401);
                result.setMsg("fail");
                return result;
                throw new ControllerException(ErrorCode.ERROR400);
            }
        }else {
            // 是否登陆用户, 登陆用户返回完整信息
@@ -89,9 +88,7 @@
        WVPResult<StreamInfo> result = new WVPResult<>();
        if (streamInfo != null){
            result.setCode(0);
            result.setMsg("scccess");
            result.setData(streamInfo);
            return  streamInfo;
        }else {
            //获取流失败,重启拉流后重试一次
            streamProxyService.stop(app,stream);
@@ -110,14 +107,10 @@
                streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
            }
            if (streamInfo != null){
                result.setCode(0);
                result.setMsg("scccess");
                result.setData(streamInfo);
                return  streamInfo;
            }else {
                result.setCode(-1);
                result.setMsg("fail");
                throw new ControllerException(ErrorCode.ERROR100);
            }
        }
        return result;
    }
}