fix: 修复推流鉴权时 enable_audio 设置错误的问题
推流鉴权获取 ssrc 缓存事务时通过 zlm 回调参数中的 stream 查询,因回调参数中的 stream 为 ssrc,而缓存事务中的 stream 为 deviceId_channelId,故导致查询不到缓存事务信息,进而导致查询不到设备信息无法正确配置 enable_audio 信息,现改为通过 deviceId 与 channelId 查询缓存事务信息
This commit is contained in:
parent
941b9a8374
commit
8a9f8c6cab
@ -244,7 +244,6 @@ public class ZLMHttpHookListener {
|
|||||||
|
|
||||||
|
|
||||||
HookResultForOnPublish result = HookResultForOnPublish.SUCCESS();
|
HookResultForOnPublish result = HookResultForOnPublish.SUCCESS();
|
||||||
result.setEnable_audio(true);
|
|
||||||
taskExecutor.execute(() -> {
|
taskExecutor.execute(() -> {
|
||||||
ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
|
ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
|
||||||
if (subscribe != null) {
|
if (subscribe != null) {
|
||||||
@ -262,29 +261,36 @@ public class ZLMHttpHookListener {
|
|||||||
} else {
|
} else {
|
||||||
result.setEnable_mp4(userSetting.isRecordPushLive());
|
result.setEnable_mp4(userSetting.isRecordPushLive());
|
||||||
}
|
}
|
||||||
// 替换流地址
|
|
||||||
if ("rtp".equals(param.getApp()) && !mediaInfo.isRtpEnable()) {
|
// 国标流
|
||||||
String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));;
|
if ("rtp".equals(param.getApp())) {
|
||||||
|
String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));
|
||||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
|
InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
|
||||||
if (inviteInfo != null) {
|
|
||||||
|
// 单端口模式下修改流 ID
|
||||||
|
if (!mediaInfo.isRtpEnable() && inviteInfo != null) {
|
||||||
result.setStream_replace(inviteInfo.getStream());
|
result.setStream_replace(inviteInfo.getStream());
|
||||||
logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream());
|
logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, param.getStream());
|
// 设置音频信息及录制信息
|
||||||
if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
|
List<SsrcTransaction> ssrcTransactionForAll = (inviteInfo == null ? null :
|
||||||
String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
|
sessionManager.getSsrcTransactionForAll(inviteInfo.getDeviceId(), inviteInfo.getChannelId(), null, null));
|
||||||
String channelId = ssrcTransactionForAll.get(0).getChannelId();
|
if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
|
||||||
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
|
||||||
if (deviceChannel != null) {
|
String channelId = ssrcTransactionForAll.get(0).getChannelId();
|
||||||
result.setEnable_audio(deviceChannel.isHasAudio());
|
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
||||||
}
|
if (deviceChannel != null) {
|
||||||
// 如果是录像下载就设置视频间隔十秒
|
result.setEnable_audio(deviceChannel.isHasAudio());
|
||||||
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
|
}
|
||||||
result.setMp4_max_second(10);
|
// 如果是录像下载就设置视频间隔十秒
|
||||||
result.setEnable_mp4(true);
|
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
|
||||||
|
result.setMp4_max_second(10);
|
||||||
|
result.setEnable_mp4(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) {
|
if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) {
|
||||||
logger.info("推流时发现尚未设置录像路径,从assist服务中读取");
|
logger.info("推流时发现尚未设置录像路径,从assist服务中读取");
|
||||||
JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null);
|
JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user