| | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | |
| | | // key的序列化采用StringRedisSerializer |
| | | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setHashKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setConnectionFactory(redisConnectionFactory); |
| | | redisTemplate.setConnectionFactory(lettuceConnectionFactory); |
| | | return redisTemplate; |
| | | } |
| | | |
| | |
| | | // 这里为例避免一个通道的点播只有一个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);
|
| | | });
|
| | | }
|
| | |
| | | String channelId = ssrcTransactionForAll.get(0).getChannelId();
|
| | | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
|
| | | if (deviceChannel != null) {
|
| | |
|
| | | result.setEnable_audio(deviceChannel.isHasAudio());
|
| | | }
|
| | | // 如果是录像下载就设置视频间隔十秒
|
| | |
| | | result.setEnable_audio(true);
|
| | | result.setEnable_mp4(true);
|
| | | }
|
| | | // 如果是talk对讲,则默认获取声音
|
| | | if (ssrcTransactionForAll.get(0).getType() == VideoStreamSessionManager.SessionType.talk) {
|
| | | result.setEnable_audio(true);
|
| | | }
|
| | |
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
| | | |
| | | 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; |
| | |
| | | sendRtpItem.setTcpActive(false); |
| | | sendRtpItem.setTcp(true); |
| | | sendRtpItem.setUsePs(false); |
| | | sendRtpItem.setReceiveStream(stream); |
| | | sendRtpItem.setReceiveStream(stream + "_talk"); |
| | | |
| | | |
| | | int port = zlmrtpServerFactory.keepPort(mediaServerItem, playSsrc); |
| | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | @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; |
| | |
| | | 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); |
| | |
| | | @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调用"); |
| | | } |
| | |
| | | throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到通道: " + channelId); |
| | | } |
| | | |
| | | return playService.audioBroadcast(device, channelId); |
| | | return playService.audioBroadcast(device, channelId, broadcastMode); |
| | | |
| | | } |
| | | |
| | |
| | | assetsPublicPath: './', |
| | | proxyTable: { |
| | | '/debug': { |
| | | target: 'https://default.wvp-pro.cn:18080', |
| | | target: 'https://default.wvp-pro.cn:18082', |
| | | changeOrigin: true, |
| | | pathRewrite: { |
| | | '^/debug': '/' |
| | |
| | | |
| | | </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;"/> |
| | |
| | | recordStartTime: 0, |
| | | showTimeText: "00:00:00", |
| | | streamInfo: null, |
| | | broadcastMode: true, |
| | | broadcastRtc: null, |
| | | broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功 |
| | | }; |
| | |
| | | // 发起语音对讲 |
| | | 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; |