Commit a000ed60625ef647d66a186a05bf5bed0e4de127

Authored by 648540858
1 parent 663130df

完善talk模式

src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
@@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CachingConfigurerSupport; @@ -8,6 +8,7 @@ import org.springframework.cache.annotation.CachingConfigurerSupport;
8 import org.springframework.context.annotation.Bean; 8 import org.springframework.context.annotation.Bean;
9 import org.springframework.context.annotation.Configuration; 9 import org.springframework.context.annotation.Configuration;
10 import org.springframework.data.redis.connection.RedisConnectionFactory; 10 import org.springframework.data.redis.connection.RedisConnectionFactory;
  11 +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
11 import org.springframework.data.redis.core.RedisTemplate; 12 import org.springframework.data.redis.core.RedisTemplate;
12 import org.springframework.data.redis.listener.PatternTopic; 13 import org.springframework.data.redis.listener.PatternTopic;
13 import org.springframework.data.redis.listener.RedisMessageListenerContainer; 14 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
@@ -48,6 +49,8 @@ public class RedisConfig extends CachingConfigurerSupport { @@ -48,6 +49,8 @@ public class RedisConfig extends CachingConfigurerSupport {
48 49
49 @Bean 50 @Bean
50 public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { 51 public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
  52 + LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) redisConnectionFactory;
  53 + lettuceConnectionFactory.afterPropertiesSet();
51 RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); 54 RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
52 // 使用fastJson序列化 55 // 使用fastJson序列化
53 FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class); 56 FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
@@ -58,7 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport { @@ -58,7 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport {
58 // key的序列化采用StringRedisSerializer 61 // key的序列化采用StringRedisSerializer
59 redisTemplate.setKeySerializer(new StringRedisSerializer()); 62 redisTemplate.setKeySerializer(new StringRedisSerializer());
60 redisTemplate.setHashKeySerializer(new StringRedisSerializer()); 63 redisTemplate.setHashKeySerializer(new StringRedisSerializer());
61 - redisTemplate.setConnectionFactory(redisConnectionFactory); 64 + redisTemplate.setConnectionFactory(lettuceConnectionFactory);
62 return redisTemplate; 65 return redisTemplate;
63 } 66 }
64 67
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -641,7 +641,7 @@ public class SIPCommander implements ISIPCommander { @@ -641,7 +641,7 @@ public class SIPCommander implements ISIPCommander {
641 // 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值 641 // 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值
642 ResponseEvent responseEvent = (ResponseEvent) e.event; 642 ResponseEvent responseEvent = (ResponseEvent) e.event;
643 SIPResponse response = (SIPResponse) responseEvent.getResponse(); 643 SIPResponse response = (SIPResponse) responseEvent.getResponse();
644 - streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.play); 644 + streamSession.put(device.getDeviceId(), channelId, "talk", stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.talk);
645 okEvent.response(e); 645 okEvent.response(e);
646 }); 646 });
647 } 647 }
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -249,6 +249,7 @@ public class ZLMHttpHookListener { @@ -249,6 +249,7 @@ public class ZLMHttpHookListener {
249 String channelId = ssrcTransactionForAll.get(0).getChannelId(); 249 String channelId = ssrcTransactionForAll.get(0).getChannelId();
250 DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); 250 DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
251 if (deviceChannel != null) { 251 if (deviceChannel != null) {
  252 +
252 result.setEnable_audio(deviceChannel.isHasAudio()); 253 result.setEnable_audio(deviceChannel.isHasAudio());
253 } 254 }
254 // 如果是录像下载就设置视频间隔十秒 255 // 如果是录像下载就设置视频间隔十秒
@@ -257,6 +258,11 @@ public class ZLMHttpHookListener { @@ -257,6 +258,11 @@ public class ZLMHttpHookListener {
257 result.setEnable_audio(true); 258 result.setEnable_audio(true);
258 result.setEnable_mp4(true); 259 result.setEnable_mp4(true);
259 } 260 }
  261 + // 如果是talk对讲,则默认获取声音
  262 + if (ssrcTransactionForAll.get(0).getType() == VideoStreamSessionManager.SessionType.talk) {
  263 + result.setEnable_audio(true);
  264 + }
  265 +
260 } 266 }
261 return result; 267 return result;
262 } 268 }
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -53,7 +53,7 @@ public interface IPlayService { @@ -53,7 +53,7 @@ public interface IPlayService {
53 53
54 void zlmServerOnline(String mediaServerId); 54 void zlmServerOnline(String mediaServerId);
55 55
56 - AudioBroadcastResult audioBroadcast(Device device, String channelId); 56 + AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode);
57 void stopAudioBroadcast(String deviceId, String channelId); 57 void stopAudioBroadcast(String deviceId, String channelId);
58 58
59 void audioBroadcastCmd(Device device, String channelId, MediaServerItem mediaServerItem, int timeout, AudioEvent event) throws InvalidArgumentException, ParseException, SipException; 59 void audioBroadcastCmd(Device device, String channelId, MediaServerItem mediaServerItem, int timeout, AudioEvent event) throws InvalidArgumentException, ParseException, SipException;
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -268,7 +268,7 @@ public class PlayServiceImpl implements IPlayService { @@ -268,7 +268,7 @@ public class PlayServiceImpl implements IPlayService {
268 sendRtpItem.setTcpActive(false); 268 sendRtpItem.setTcpActive(false);
269 sendRtpItem.setTcp(true); 269 sendRtpItem.setTcp(true);
270 sendRtpItem.setUsePs(false); 270 sendRtpItem.setUsePs(false);
271 - sendRtpItem.setReceiveStream(stream); 271 + sendRtpItem.setReceiveStream(stream + "_talk");
272 272
273 273
274 int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc); 274 int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc);
@@ -348,7 +348,7 @@ public class PlayServiceImpl implements IPlayService { @@ -348,7 +348,7 @@ public class PlayServiceImpl implements IPlayService {
348 sendRtpItem.setCallId(response.getCallIdHeader().getCallId()); 348 sendRtpItem.setCallId(response.getCallIdHeader().getCallId());
349 redisCatchStorage.updateSendRTPSever(sendRtpItem); 349 redisCatchStorage.updateSendRTPSever(sendRtpItem);
350 350
351 - streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), 351 + streamSession.put(device.getDeviceId(), channelId, "talk",
352 sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(), 352 sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(),
353 response, VideoStreamSessionManager.SessionType.talk); 353 response, VideoStreamSessionManager.SessionType.talk);
354 } else { 354 } else {
@@ -940,7 +940,7 @@ public class PlayServiceImpl implements IPlayService { @@ -940,7 +940,7 @@ public class PlayServiceImpl implements IPlayService {
940 } 940 }
941 941
942 @Override 942 @Override
943 - public AudioBroadcastResult audioBroadcast(Device device, String channelId) { 943 + public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) {
944 // TODO 必须多端口模式才支持语音喊话鹤语音对讲 944 // TODO 必须多端口模式才支持语音喊话鹤语音对讲
945 if (device == null || channelId == null) { 945 if (device == null || channelId == null) {
946 return null; 946 return null;
@@ -952,11 +952,11 @@ public class PlayServiceImpl implements IPlayService { @@ -952,11 +952,11 @@ public class PlayServiceImpl implements IPlayService {
952 return null; 952 return null;
953 } 953 }
954 MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null); 954 MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
955 - String app = "broadcast";  
956 - // TODO 从sip user agent中判断是什么品牌设备,大华默认使用talk模式,其他使用broadcast模式  
957 -// String app = "talk"; 955 + if (broadcastMode == null) {
  956 + broadcastMode = true;
  957 + }
  958 + String app = broadcastMode?"broadcast":"talk";
958 String stream = device.getDeviceId() + "_" + channelId; 959 String stream = device.getDeviceId() + "_" + channelId;
959 - StreamInfo broadcast = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "broadcast", stream, null, null, null, false);  
960 AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); 960 AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
961 audioBroadcastResult.setApp(app); 961 audioBroadcastResult.setApp(app);
962 audioBroadcastResult.setStream(stream); 962 audioBroadcastResult.setStream(stream);
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
@@ -249,7 +249,7 @@ public class PlayController { @@ -249,7 +249,7 @@ public class PlayController {
249 @Parameter(name = "timeout", description = "推流超时时间(秒)", required = true) 249 @Parameter(name = "timeout", description = "推流超时时间(秒)", required = true)
250 @GetMapping("/broadcast/{deviceId}/{channelId}") 250 @GetMapping("/broadcast/{deviceId}/{channelId}")
251 @PostMapping("/broadcast/{deviceId}/{channelId}") 251 @PostMapping("/broadcast/{deviceId}/{channelId}")
252 - public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) { 252 + public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout, Boolean broadcastMode) {
253 if (logger.isDebugEnabled()) { 253 if (logger.isDebugEnabled()) {
254 logger.debug("语音广播API调用"); 254 logger.debug("语音广播API调用");
255 } 255 }
@@ -261,7 +261,7 @@ public class PlayController { @@ -261,7 +261,7 @@ public class PlayController {
261 throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId); 261 throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId);
262 } 262 }
263 263
264 - return playService.audioBroadcast(device, channelId); 264 + return playService.audioBroadcast(device, channelId, broadcastMode);
265 265
266 } 266 }
267 267
web_src/config/index.js
@@ -12,7 +12,7 @@ module.exports = { @@ -12,7 +12,7 @@ module.exports = {
12 assetsPublicPath: './', 12 assetsPublicPath: './',
13 proxyTable: { 13 proxyTable: {
14 '/debug': { 14 '/debug': {
15 - target: 'https://default.wvp-pro.cn:18080', 15 + target: 'https://default.wvp-pro.cn:18082',
16 changeOrigin: true, 16 changeOrigin: true,
17 pathRewrite: { 17 pathRewrite: {
18 '^/debug': '/' 18 '^/debug': '/'
web_src/src/components/dialog/devicePlayer.vue
@@ -299,6 +299,10 @@ @@ -299,6 +299,10 @@
299 299
300 </el-tab-pane> 300 </el-tab-pane>
301 <el-tab-pane label="语音对讲" name="broadcast"> 301 <el-tab-pane label="语音对讲" name="broadcast">
  302 + <div style="padding: 0 10px">
  303 + <el-switch v-model="broadcastMode" :disabled="broadcastStatus !== -1" active-color="#409EFF" active-text="喊话"
  304 + inactive-text="对讲"></el-switch>
  305 + </div>
302 <div class="trank" style="text-align: center;"> 306 <div class="trank" style="text-align: center;">
303 <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2" 307 <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
304 circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/> 308 circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
@@ -390,6 +394,7 @@ export default { @@ -390,6 +394,7 @@ export default {
390 recordStartTime: 0, 394 recordStartTime: 0,
391 showTimeText: "00:00:00", 395 showTimeText: "00:00:00",
392 streamInfo: null, 396 streamInfo: null,
  397 + broadcastMode: true,
393 broadcastRtc: null, 398 broadcastRtc: null,
394 broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功 399 broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
395 }; 400 };
@@ -648,7 +653,7 @@ export default { @@ -648,7 +653,7 @@ export default {
648 // 发起语音对讲 653 // 发起语音对讲
649 this.$axios({ 654 this.$axios({
650 method: 'get', 655 method: 'get',
651 - url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30" 656 + url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30&broadcastMode=" + this.broadcastMode
652 }).then( (res)=> { 657 }).then( (res)=> {
653 if (res.data.code == 0) { 658 if (res.data.code == 0) {
654 let streamInfo = res.data.data.streamInfo; 659 let streamInfo = res.data.data.streamInfo;