Commit 8a9f8c6cab1e619d1a0e10430ef49a7f2b62a1f2
1 parent
941b9a83
fix: 修复推流鉴权时 enable_audio 设置错误的问题
推流鉴权获取 ssrc 缓存事务时通过 zlm 回调参数中的 stream 查询,因回调参数中的 stream 为 ssrc,而缓存事务中的 stream 为 deviceId_channelId,故导致查询不到缓存事务信息,进而导致查询不到设备信息无法正确配置 enable_audio 信息,现改为通过 deviceId 与 channelId 查询缓存事务信息
Showing
1 changed file
with
24 additions
and
18 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -244,7 +244,6 @@ public class ZLMHttpHookListener { |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | HookResultForOnPublish result = HookResultForOnPublish.SUCCESS(); |
| 247 | - result.setEnable_audio(true); | |
| 248 | 247 | taskExecutor.execute(() -> { |
| 249 | 248 | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); |
| 250 | 249 | if (subscribe != null) { |
| ... | ... | @@ -262,29 +261,36 @@ public class ZLMHttpHookListener { |
| 262 | 261 | } else { |
| 263 | 262 | result.setEnable_mp4(userSetting.isRecordPushLive()); |
| 264 | 263 | } |
| 265 | - // 替换流地址 | |
| 266 | - if ("rtp".equals(param.getApp()) && !mediaInfo.isRtpEnable()) { | |
| 267 | - String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));; | |
| 264 | + | |
| 265 | + // 国标流 | |
| 266 | + if ("rtp".equals(param.getApp())) { | |
| 267 | + String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16)); | |
| 268 | 268 | InviteInfo inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc); |
| 269 | - if (inviteInfo != null) { | |
| 269 | + | |
| 270 | + // 单端口模式下修改流 ID | |
| 271 | + if (!mediaInfo.isRtpEnable() && inviteInfo != null) { | |
| 270 | 272 | result.setStream_replace(inviteInfo.getStream()); |
| 271 | 273 | logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream()); |
| 272 | 274 | } |
| 273 | - } | |
| 274 | - List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, param.getStream()); | |
| 275 | - if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { | |
| 276 | - String deviceId = ssrcTransactionForAll.get(0).getDeviceId(); | |
| 277 | - String channelId = ssrcTransactionForAll.get(0).getChannelId(); | |
| 278 | - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | |
| 279 | - if (deviceChannel != null) { | |
| 280 | - result.setEnable_audio(deviceChannel.isHasAudio()); | |
| 281 | - } | |
| 282 | - // 如果是录像下载就设置视频间隔十秒 | |
| 283 | - if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) { | |
| 284 | - result.setMp4_max_second(10); | |
| 285 | - result.setEnable_mp4(true); | |
| 275 | + | |
| 276 | + // 设置音频信息及录制信息 | |
| 277 | + List<SsrcTransaction> ssrcTransactionForAll = (inviteInfo == null ? null : | |
| 278 | + sessionManager.getSsrcTransactionForAll(inviteInfo.getDeviceId(), inviteInfo.getChannelId(), null, null)); | |
| 279 | + if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { | |
| 280 | + String deviceId = ssrcTransactionForAll.get(0).getDeviceId(); | |
| 281 | + String channelId = ssrcTransactionForAll.get(0).getChannelId(); | |
| 282 | + DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | |
| 283 | + if (deviceChannel != null) { | |
| 284 | + result.setEnable_audio(deviceChannel.isHasAudio()); | |
| 285 | + } | |
| 286 | + // 如果是录像下载就设置视频间隔十秒 | |
| 287 | + if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) { | |
| 288 | + result.setMp4_max_second(10); | |
| 289 | + result.setEnable_mp4(true); | |
| 290 | + } | |
| 286 | 291 | } |
| 287 | 292 | } |
| 293 | + | |
| 288 | 294 | if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) { |
| 289 | 295 | logger.info("推流时发现尚未设置录像路径,从assist服务中读取"); |
| 290 | 296 | JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null); | ... | ... |