648540858
2023-07-10 04e7f48fde1b1a653d413eb41186ec7354f5ae31
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -22,14 +23,12 @@
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.bean.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
@@ -105,6 +104,9 @@
    @Autowired
    private AssistRESTfulUtils assistRESTfulUtils;
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;
    @Qualifier("taskExecutor")
    @Autowired
@@ -220,9 +222,6 @@
        HookResultForOnPublish result = HookResultForOnPublish.SUCCESS();
        if (!"rtp".equals(param.getApp())) {
            result.setEnable_audio(true);
        }
        taskExecutor.execute(() -> {
            ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
@@ -255,6 +254,7 @@
                result.setEnable_mp4(true);
            }
        }
        if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) {
            logger.info("推流时发现尚未设置录像路径,从assist服务中读取");
            JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null);
@@ -273,6 +273,18 @@
                }
            }
        }
        if (param.getApp().equalsIgnoreCase("rtp")) {
            String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + param.getStream();
            System.out.println(receiveKey);
            OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(receiveKey);
            System.out.println("otherRtpSendInfo != null ====>" + (otherRtpSendInfo != null));
            if (otherRtpSendInfo != null) {
                System.out.println("otherRtpSendInfo != null");
                result.setEnable_audio(true);
                result.setEnable_mp4(true);
            }
        }
        logger.info("[ZLM HOOK]推流鉴权 响应:{}->{}->>>>{}", param.getMediaServerId(), param, result);
        return result;
    }