From e14cef80624602d873b1062aed93022b8ad13182 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期四, 05 一月 2023 16:38:33 +0800 Subject: [PATCH] 优化语音对讲 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 64 +++++++------------------------- 1 files changed, 14 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 6f40ef8..20946ea 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -344,70 +344,34 @@ } }else if ("broadcast".equals(param.getApp())){ // 璇煶瀵硅鎺ㄦ祦 stream闇�瑕佹弧瓒虫牸寮廳eviceId_channelId - if (param.isRegist() && param.getStream().indexOf("_") > 0) { + if (param.getStream().indexOf("_") > 0) { String[] streamArray = param.getStream().split("_"); if (streamArray.length == 2) { String deviceId = streamArray[0]; String channelId = streamArray[1]; Device device = deviceService.getDevice(deviceId); if (device != null) { - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); - if (deviceChannel != null) { + if (param.isRegist()) { if (audioBroadcastManager.exit(deviceId, channelId)) { - // 鐩存帴鎺ㄦ祦 - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, param.getStream(), null); - if (sendRtpItem == null) { - // TODO 鍙兘鏁版嵁閿欒锛岄噸鏂板紑鍚闊抽�氶亾 - }else { - String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - logger.info("rtp/{}寮�濮嬪悜涓婄骇鎺ㄦ祦, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); - Map<String, Object> sendParam = new HashMap<>(12); - sendParam.put("vhost","__defaultVhost__"); - sendParam.put("app",sendRtpItem.getApp()); - sendParam.put("stream",sendRtpItem.getStreamId()); - sendParam.put("ssrc", sendRtpItem.getSsrc()); - sendParam.put("src_port", sendRtpItem.getLocalPort()); - sendParam.put("pt", sendRtpItem.getPt()); - sendParam.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0"); - sendParam.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0"); - - JSONObject jsonObject; - if (sendRtpItem.isTcpActive()) { - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, sendParam); - } else { - sendParam.put("is_udp", is_Udp); - sendParam.put("dst_url", sendRtpItem.getIp()); - sendParam.put("dst_port", sendRtpItem.getPort()); - jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, sendParam); - } - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - logger.info("[璇煶瀵硅] 鑷姩鎺ㄦ祦鎴愬姛, device: {}, channel: {}", deviceId, channelId); - }else { - logger.info("[璇煶瀵硅] 鎺ㄦ祦澶辫触, 缁撴灉锛� {}", jsonObject); - } - - } - }else { - // 寮�鍚闊冲璁查�氶亾 - try { - playService.audioBroadcastCmd(device, channelId, 60, (msg)->{ - logger.info("[璇煶瀵硅] 閫氶亾寤虹珛鎴愬姛, device: {}, channel: {}", deviceId, channelId); - }); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅: {}", e.getMessage()); - } + playService.stopAudioBroadcast(deviceId, channelId); } - + // 寮�鍚闊冲璁查�氶亾 + try { + playService.audioBroadcastCmd(device, channelId, 60, (msg)->{ + logger.info("[璇煶瀵硅] 閫氶亾寤虹珛鎴愬姛, device: {}, channel: {}", deviceId, channelId); + }); + } catch (InvalidArgumentException | ParseException | SipException e) { + logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅: {}", e.getMessage()); + } }else { - logger.info("[璇煶瀵硅] 鏈壘鍒伴�氶亾锛歿}", channelId); + // 娴佹敞閿� + playService.stopAudioBroadcast(deviceId, channelId); } - }else{ + } else{ logger.info("[璇煶瀵硅] 鏈壘鍒拌澶囷細{}", deviceId); } } } - }else if ("talk".equals(param.getApp())){ // 璇煶瀵硅鎺ㄦ祦 stream闇�瑕佹弧瓒虫牸寮廳eviceId_channelId if (param.isRegist() && param.getStream().indexOf("_") > 0) { -- Gitblit v1.8.0