支持hook

This commit is contained in:
648540858
2024-03-25 17:59:09 +08:00
parent 7ce4f44caa
commit 2b0af3be14
4 changed files with 44 additions and 27 deletions

View File

@@ -41,4 +41,11 @@ public interface IMediaService {
* @return
*/
StreamInfo getStreamInfoByAppAndStream(MediaServer mediaServerItem, String app, String stream, MediaInfo mediaInfo, String addr, String callId, boolean isPlay);
/**
* 播放鉴权
*/
boolean authenticatePlay(String app, String stream, String callId);
boolean authenticatePublish(String app, String stream, String callId, String sign);
}

View File

@@ -4,10 +4,14 @@ import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaConfig;
import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.hook.HookResultForOnPublish;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -17,6 +21,8 @@ import java.util.List;
@Service
public class MediaServiceImpl implements IMediaService {
private final static Logger logger = LoggerFactory.getLogger(MediaServiceImpl.class);
@Autowired
private IRedisCatchStorage redisCatchStorage;
@@ -85,4 +91,16 @@ public class MediaServiceImpl implements IMediaService {
streamInfoResult.setMediaInfo(mediaInfo);
return streamInfoResult;
}
@Override
public boolean authenticatePlay(String app, String stream, String callId) {
if (app == null || stream == null) {
return false;
}
if ("rtp".equals(app)) {
return true;
}
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
return (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(callId));
}
}