648540858
2023-03-20 a000ed60625ef647d66a186a05bf5bed0e4de127
完善talk模式
8个文件已修改
42 ■■■■■ 已修改文件
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
web_src/config/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
web_src/src/components/dialog/devicePlayer.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
@@ -8,6 +8,7 @@
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 @@
    @Bean
    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        LettuceConnectionFactory lettuceConnectionFactory = (LettuceConnectionFactory) redisConnectionFactory;
        lettuceConnectionFactory.afterPropertiesSet();
        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
        // 使用fastJson序列化
        FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
@@ -58,7 +61,7 @@
        // key的序列化采用StringRedisSerializer
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        redisTemplate.setConnectionFactory(lettuceConnectionFactory);
        return redisTemplate;
    }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -641,7 +641,7 @@
            // 这里为例避免一个通道的点播只有一个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);
        });
    }
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -249,6 +249,7 @@
            String channelId = ssrcTransactionForAll.get(0).getChannelId();
            DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
            if (deviceChannel != null) {
                result.setEnable_audio(deviceChannel.isHasAudio());
            }
            // 如果是录像下载就设置视频间隔十秒
@@ -257,6 +258,11 @@
                result.setEnable_audio(true);
                result.setEnable_mp4(true);
            }
            // 如果是talk对讲,则默认获取声音
            if (ssrcTransactionForAll.get(0).getType() == VideoStreamSessionManager.SessionType.talk) {
                result.setEnable_audio(true);
            }
        }
        return result;
    }
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -53,7 +53,7 @@
    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;
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -268,7 +268,7 @@
        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 @@
                        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 @@
    }
    @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 @@
            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);
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
@@ -249,7 +249,7 @@
    @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 @@
            throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId);
        }
        return playService.audioBroadcast(device, channelId);
        return playService.audioBroadcast(device, channelId, broadcastMode);
    }
web_src/config/index.js
@@ -12,7 +12,7 @@
    assetsPublicPath: './',
    proxyTable: {
      '/debug': {
        target: 'https://default.wvp-pro.cn:18080',
        target: 'https://default.wvp-pro.cn:18082',
        changeOrigin: true,
        pathRewrite: {
          '^/debug': '/'
web_src/src/components/dialog/devicePlayer.vue
@@ -299,6 +299,10 @@
          </el-tab-pane>
          <el-tab-pane label="语音对讲" name="broadcast">
            <div style="padding: 0 10px">
              <el-switch v-model="broadcastMode" :disabled="broadcastStatus !== -1" active-color="#409EFF" active-text="喊话"
                         inactive-text="对讲"></el-switch>
            </div>
            <div class="trank" style="text-align: center;">
              <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2"
                         circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
@@ -390,6 +394,7 @@
      recordStartTime: 0,
      showTimeText: "00:00:00",
      streamInfo: null,
      broadcastMode: true,
      broadcastRtc: null,
      broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
    };
@@ -648,7 +653,7 @@
        // 发起语音对讲
        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;