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 8 import org.springframework.context.annotation.Bean;
9 9 import org.springframework.context.annotation.Configuration;
10 10 import org.springframework.data.redis.connection.RedisConnectionFactory;
  11 +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
11 12 import org.springframework.data.redis.core.RedisTemplate;
12 13 import org.springframework.data.redis.listener.PatternTopic;
13 14 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
... ... @@ -48,6 +49,8 @@ public class RedisConfig extends CachingConfigurerSupport {
48 49  
49 50 @Bean
50 51 public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
  52 + LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) redisConnectionFactory;
  53 + lettuceConnectionFactory.afterPropertiesSet();
51 54 RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
52 55 // 使用fastJson序列化
53 56 FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
... ... @@ -58,7 +61,7 @@ public class RedisConfig extends CachingConfigurerSupport {
58 61 // key的序列化采用StringRedisSerializer
59 62 redisTemplate.setKeySerializer(new StringRedisSerializer());
60 63 redisTemplate.setHashKeySerializer(new StringRedisSerializer());
61   - redisTemplate.setConnectionFactory(redisConnectionFactory);
  64 + redisTemplate.setConnectionFactory(lettuceConnectionFactory);
62 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 641 // 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值
642 642 ResponseEvent responseEvent = (ResponseEvent) e.event;
643 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 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 249 String channelId = ssrcTransactionForAll.get(0).getChannelId();
250 250 DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
251 251 if (deviceChannel != null) {
  252 +
252 253 result.setEnable_audio(deviceChannel.isHasAudio());
253 254 }
254 255 // 如果是录像下载就设置视频间隔十秒
... ... @@ -257,6 +258,11 @@ public class ZLMHttpHookListener {
257 258 result.setEnable_audio(true);
258 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 267 return result;
262 268 }
... ...
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
... ... @@ -53,7 +53,7 @@ public interface IPlayService {
53 53  
54 54 void zlmServerOnline(String mediaServerId);
55 55  
56   - AudioBroadcastResult audioBroadcast(Device device, String channelId);
  56 + AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode);
57 57 void stopAudioBroadcast(String deviceId, String channelId);
58 58  
59 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 268 sendRtpItem.setTcpActive(false);
269 269 sendRtpItem.setTcp(true);
270 270 sendRtpItem.setUsePs(false);
271   - sendRtpItem.setReceiveStream(stream);
  271 + sendRtpItem.setReceiveStream(stream + "_talk");
272 272  
273 273  
274 274 int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc);
... ... @@ -348,7 +348,7 @@ public class PlayServiceImpl implements IPlayService {
348 348 sendRtpItem.setCallId(response.getCallIdHeader().getCallId());
349 349 redisCatchStorage.updateSendRTPSever(sendRtpItem);
350 350  
351   - streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(),
  351 + streamSession.put(device.getDeviceId(), channelId, "talk",
352 352 sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(),
353 353 response, VideoStreamSessionManager.SessionType.talk);
354 354 } else {
... ... @@ -940,7 +940,7 @@ public class PlayServiceImpl implements IPlayService {
940 940 }
941 941  
942 942 @Override
943   - public AudioBroadcastResult audioBroadcast(Device device, String channelId) {
  943 + public AudioBroadcastResult audioBroadcast(Device device, String channelId, Boolean broadcastMode) {
944 944 // TODO 必须多端口模式才支持语音喊话鹤语音对讲
945 945 if (device == null || channelId == null) {
946 946 return null;
... ... @@ -952,11 +952,11 @@ public class PlayServiceImpl implements IPlayService {
952 952 return null;
953 953 }
954 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 959 String stream = device.getDeviceId() + "_" + channelId;
959   - StreamInfo broadcast = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "broadcast", stream, null, null, null, false);
960 960 AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
961 961 audioBroadcastResult.setApp(app);
962 962 audioBroadcastResult.setStream(stream);
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
... ... @@ -249,7 +249,7 @@ public class PlayController {
249 249 @Parameter(name = "timeout", description = "推流超时时间(秒)", required = true)
250 250 @GetMapping("/broadcast/{deviceId}/{channelId}")
251 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 253 if (logger.isDebugEnabled()) {
254 254 logger.debug("语音广播API调用");
255 255 }
... ... @@ -261,7 +261,7 @@ public class PlayController {
261 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 12 assetsPublicPath: './',
13 13 proxyTable: {
14 14 '/debug': {
15   - target: 'https://default.wvp-pro.cn:18080',
  15 + target: 'https://default.wvp-pro.cn:18082',
16 16 changeOrigin: true,
17 17 pathRewrite: {
18 18 '^/debug': '/'
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -299,6 +299,10 @@
299 299  
300 300 </el-tab-pane>
301 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 306 <div class="trank" style="text-align: center;">
303 307 <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
304 308 circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
... ... @@ -390,6 +394,7 @@ export default {
390 394 recordStartTime: 0,
391 395 showTimeText: "00:00:00",
392 396 streamInfo: null,
  397 + broadcastMode: true,
393 398 broadcastRtc: null,
394 399 broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
395 400 };
... ... @@ -648,7 +653,7 @@ export default {
648 653 // 发起语音对讲
649 654 this.$axios({
650 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 657 }).then( (res)=> {
653 658 if (res.data.code == 0) {
654 659 let streamInfo = res.data.data.streamInfo;
... ...