diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java index 1eca1319..dcb2bdd7 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java @@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.PatternTopic; import org.springframework.data.redis.listener.RedisMessageListenerContainer; @@ -48,6 +49,8 @@ public class RedisConfig extends CachingConfigurerSupport { @Bean public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { + LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) redisConnectionFactory; + lettuceConnectionFactory.afterPropertiesSet(); RedisTemplate redisTemplate = new RedisTemplate<>(); // 使用fastJson序列化 FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class); @@ -58,7 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport { // key的序列化采用StringRedisSerializer redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); - redisTemplate.setConnectionFactory(redisConnectionFactory); + redisTemplate.setConnectionFactory(lettuceConnectionFactory); return redisTemplate; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 79d47898..3b6565a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -641,7 +641,7 @@ public class SIPCommander implements ISIPCommander { // 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值 ResponseEvent responseEvent = (ResponseEvent) e.event; SIPResponse response = (SIPResponse) responseEvent.getResponse(); - streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.play); + streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.talk); okEvent.response(e); }); } 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 a59106f2..d046fe72 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 @@ -249,6 +249,7 @@ public class ZLMHttpHookListener { String channelId = ssrcTransactionForAll.get(0).getChannelId(); DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); if (deviceChannel != null) { + result.setEnable_audio(deviceChannel.isHasAudio()); } // 如果是录像下载就设置视频间隔十秒 @@ -257,6 +258,11 @@ public class ZLMHttpHookListener { result.setEnable_audio(true); result.setEnable_mp4(true); } + // 如果是talk对讲,则默认获取声音 + if (ssrcTransactionForAll.get(0).getType() == VideoStreamSessionManager.SessionType.talk) { + result.setEnable_audio(true); + } + } return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java index 23c29c7c..d9730eb1 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java @@ -53,7 +53,7 @@ public interface IPlayService { void zlmServerOnline(String mediaServerId); - AudioBroadcastResult audioBroadcast(Device device, String channelId); + AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode); void stopAudioBroadcast(String deviceId, String channelId); void audioBroadcastCmd(Device device, String channelId, MediaServerItem mediaServerItem, int timeout, AudioEvent event) throws InvalidArgumentException, ParseException, SipException; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 1708f6ed..d071118d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -268,7 +268,7 @@ public class PlayServiceImpl implements IPlayService { sendRtpItem.setTcpActive(false); sendRtpItem.setTcp(true); sendRtpItem.setUsePs(false); - sendRtpItem.setReceiveStream(stream); + sendRtpItem.setReceiveStream(stream + "_talk"); int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc); @@ -348,7 +348,7 @@ public class PlayServiceImpl implements IPlayService { sendRtpItem.setCallId(response.getCallIdHeader().getCallId()); redisCatchStorage.updateSendRTPSever(sendRtpItem); - streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), + streamSession.put(device.getDeviceId(), channelId, "talk", sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(), response, VideoStreamSessionManager.SessionType.talk); } else { @@ -940,7 +940,7 @@ public class PlayServiceImpl implements IPlayService { } @Override - public AudioBroadcastResult audioBroadcast(Device device, String channelId) { + public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) { // TODO 必须多端口模式才支持语音喊话鹤语音对讲 if (device == null || channelId == null) { return null; @@ -952,11 +952,11 @@ public class PlayServiceImpl implements IPlayService { return null; } MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null); - String app = "broadcast"; - // TODO 从sip user agent中判断是什么品牌设备,大华默认使用talk模式,其他使用broadcast模式 -// String app = "talk"; + if (broadcastMode == null) { + broadcastMode = true; + } + String app = broadcastMode?"broadcast":"talk"; String stream = device.getDeviceId() + "_" + channelId; - StreamInfo broadcast = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "broadcast", stream, null, null, null, false); AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); audioBroadcastResult.setApp(app); audioBroadcastResult.setStream(stream); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index c0f64cf4..3eba74ec 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -249,7 +249,7 @@ public class PlayController { @Parameter(name = "timeout", description = "推流超时时间(秒)", required = true) @GetMapping("/broadcast/{deviceId}/{channelId}") @PostMapping("/broadcast/{deviceId}/{channelId}") - public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) { + public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout, Boolean broadcastMode) { if (logger.isDebugEnabled()) { logger.debug("语音广播API调用"); } @@ -261,7 +261,7 @@ public class PlayController { throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId); } - return playService.audioBroadcast(device, channelId); + return playService.audioBroadcast(device, channelId, broadcastMode); } diff --git a/web_src/config/index.js b/web_src/config/index.js index fc0aa1ff..a04493e0 100644 --- a/web_src/config/index.js +++ b/web_src/config/index.js @@ -12,7 +12,7 @@ module.exports = { assetsPublicPath: './', proxyTable: { '/debug': { - target: 'https://default.wvp-pro.cn:18080', + target: 'https://default.wvp-pro.cn:18082', changeOrigin: true, pathRewrite: { '^/debug': '/' diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 78df785c..0bc3335a 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -299,6 +299,10 @@ +
+ +
@@ -390,6 +394,7 @@ export default { recordStartTime: 0, showTimeText: "00:00:00", streamInfo: null, + broadcastMode: true, broadcastRtc: null, broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功 }; @@ -648,7 +653,7 @@ export default { // 发起语音对讲 this.$axios({ method: 'get', - url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30" + url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30&broadcastMode=" + this.broadcastMode }).then( (res)=> { if (res.data.code == 0) { let streamInfo = res.data.data.streamInfo;