Commit db8971302a848875e50acfb7c2a5403461567efc
1 parent
d5f26faf
完善支持语音级联
Showing
6 changed files
with
16 additions
and
24 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| ... | ... | @@ -92,7 +92,7 @@ public class ZLMRTPServerFactory { |
| 92 | 92 | return result; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port) { | |
| 95 | + public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port, Boolean onlyAuto) { | |
| 96 | 96 | int result = -1; |
| 97 | 97 | // 查询此rtp server 是否已经存在 |
| 98 | 98 | JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId); |
| ... | ... | @@ -108,7 +108,7 @@ public class ZLMRTPServerFactory { |
| 108 | 108 | JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param); |
| 109 | 109 | if (jsonObject != null ) { |
| 110 | 110 | if (jsonObject.getInteger("code") == 0) { |
| 111 | - return createRTPServer(mediaServerItem, streamId, ssrc, port); | |
| 111 | + return createRTPServer(mediaServerItem, streamId, ssrc, port, onlyAuto); | |
| 112 | 112 | }else { |
| 113 | 113 | logger.warn("[开启rtpServer], 重启RtpServer错误"); |
| 114 | 114 | } |
| ... | ... | @@ -131,6 +131,9 @@ public class ZLMRTPServerFactory { |
| 131 | 131 | param.put("port", port); |
| 132 | 132 | } |
| 133 | 133 | param.put("ssrc", ssrc); |
| 134 | + if (onlyAuto != null) { | |
| 135 | + param.put("only_audio", onlyAuto?"1":"0"); | |
| 136 | + } | |
| 134 | 137 | JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); |
| 135 | 138 | logger.info(JSONObject.toJSONString(openRtpServerResultJson)); |
| 136 | 139 | if (openRtpServerResultJson != null) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
| ... | ... | @@ -47,7 +47,7 @@ public interface IMediaServerService { |
| 47 | 47 | |
| 48 | 48 | SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback); |
| 49 | 49 | |
| 50 | - SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback, Integer port); | |
| 50 | + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback, Integer port, Boolean onlyAuto); | |
| 51 | 51 | |
| 52 | 52 | void closeRTPServer(MediaServerItem mediaServerItem, String streamId); |
| 53 | 53 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| 1 | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | |
| 3 | -import java.time.LocalDateTime; | |
| 4 | -import java.util.ArrayList; | |
| 5 | -import java.util.Collections; | |
| 6 | -import java.util.HashMap; | |
| 7 | -import java.util.List; | |
| 8 | -import java.util.Map; | |
| 9 | -import java.util.Set; | |
| 10 | - | |
| 11 | -import com.genersoft.iot.vmp.media.zlm.ZLMRunner; | |
| 12 | -import com.genersoft.iot.vmp.service.IStreamProxyService; | |
| 13 | -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | |
| 14 | 3 | import com.alibaba.fastjson2.JSON; |
| 15 | 4 | import com.alibaba.fastjson2.JSONArray; |
| 16 | 5 | import com.alibaba.fastjson2.JSONObject; |
| ... | ... | @@ -39,8 +28,6 @@ import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 39 | 28 | import okhttp3.OkHttpClient; |
| 40 | 29 | import okhttp3.Request; |
| 41 | 30 | import okhttp3.Response; |
| 42 | -import java.time.LocalDateTime; | |
| 43 | -import java.util.*; | |
| 44 | 31 | import org.slf4j.Logger; |
| 45 | 32 | import org.slf4j.LoggerFactory; |
| 46 | 33 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -134,7 +121,8 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 134 | 121 | } |
| 135 | 122 | |
| 136 | 123 | @Override |
| 137 | - public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback, Integer port) { | |
| 124 | + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, | |
| 125 | + boolean isPlayback, Integer port, Boolean onlyAuto) { | |
| 138 | 126 | if (mediaServerItem == null || mediaServerItem.getId() == null) { |
| 139 | 127 | logger.info("[openRTPServer] 失败, mediaServerItem == null || mediaServerItem.getId() == null"); |
| 140 | 128 | return null; |
| ... | ... | @@ -163,7 +151,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 163 | 151 | } |
| 164 | 152 | int rtpServerPort; |
| 165 | 153 | if (mediaServerItem.isRtpEnable()) { |
| 166 | - rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port); | |
| 154 | + rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port, onlyAuto); | |
| 167 | 155 | } else { |
| 168 | 156 | rtpServerPort = mediaServerItem.getRtpProxyPort(); |
| 169 | 157 | } |
| ... | ... | @@ -174,7 +162,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 174 | 162 | |
| 175 | 163 | @Override |
| 176 | 164 | public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback) { |
| 177 | - return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, null); | |
| 165 | + return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, null, null); | |
| 178 | 166 | } |
| 179 | 167 | |
| 180 | 168 | @Override | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
| ... | ... | @@ -367,7 +367,7 @@ public class PlatformServiceImpl implements IPlatformService { |
| 367 | 367 | } |
| 368 | 368 | // 默认不进行SSRC校验, TODO 后续可改为配置 |
| 369 | 369 | boolean ssrcCheck = false; |
| 370 | - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrcCheck, false); | |
| 370 | + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, ssrcCheck, false, null, true); | |
| 371 | 371 | if (ssrcInfo == null || ssrcInfo.getPort() < 0) { |
| 372 | 372 | logger.info("[国标级联] 发起语音喊话 开启端口监听失败, platform: {}, channel: {}", platform.getServerGBId(), channelId); |
| 373 | 373 | errorEvent.response(new SipSubscribe.EventResult(-1, "端口监听失败")); |
| ... | ... | @@ -449,7 +449,8 @@ public class PlatformServiceImpl implements IPlatformService { |
| 449 | 449 | // 关闭rtp server |
| 450 | 450 | mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); |
| 451 | 451 | // 重新开启ssrc server |
| 452 | - mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, false, false, ssrcInfo.getPort()); | |
| 452 | + mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, false, false, ssrcInfo.getPort(), true); | |
| 453 | + | |
| 453 | 454 | |
| 454 | 455 | } |
| 455 | 456 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| ... | ... | @@ -535,7 +535,7 @@ public class PlayServiceImpl implements IPlayService { |
| 535 | 535 | // 关闭rtp server |
| 536 | 536 | mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); |
| 537 | 537 | // 重新开启ssrc server |
| 538 | - mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, ssrcInfo.getPort()); | |
| 538 | + mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, ssrcInfo.getPort(), false); | |
| 539 | 539 | |
| 540 | 540 | } |
| 541 | 541 | } |
| ... | ... | @@ -776,7 +776,7 @@ public class PlayServiceImpl implements IPlayService { |
| 776 | 776 | // 关闭rtp server |
| 777 | 777 | mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); |
| 778 | 778 | // 重新开启ssrc server |
| 779 | - mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), true, ssrcInfo.getPort()); | |
| 779 | + mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), true, ssrcInfo.getPort(), false); | |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | } | ... | ... |
src/main/resources/logback-spring-local.xml
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/> |
| 5 | 5 | <property name="LOG_HOME" value="logs" /> |
| 6 | 6 | |
| 7 | - <substitutionProperty name="log.pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr(%-80.80logger{79}){cyan} %clr(:){faint} %m%n%wEx"/> | |
| 7 | + <substitutionProperty name="log.pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr(%-1.30logger{0}){cyan} %clr(:){faint} %m%n%wEx"/> | |
| 8 | 8 | |
| 9 | 9 | <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> |
| 10 | 10 | <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> | ... | ... |