| | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | 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序列化 |
| | |
| | | // key的序列化采用StringRedisSerializer |
| | | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setHashKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setConnectionFactory(lettuceConnectionFactory); |
| | | redisTemplate.setConnectionFactory(redisConnectionFactory); |
| | | return redisTemplate; |
| | | } |
| | | |
| | |
| | | return sipTransactionInfo; |
| | | } |
| | | |
| | | public String getApp() { |
| | | return app; |
| | | } |
| | | |
| | | public void setApp(String app) { |
| | | this.app = app; |
| | | } |
| | | |
| | | public String getStream() { |
| | | return stream; |
| | | } |
| | | |
| | | public void setStream(String stream) { |
| | | this.stream = stream; |
| | | } |
| | | |
| | | public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { |
| | | this.sipTransactionInfo = sipTransactionInfo; |
| | | } |
| | | |
| | | public void setSipTransactionInfoByRequset(SIPResponse response) { |
| | | this.sipTransactionInfo = new SipTransactionInfo(response, false); |
| | | } |
| | | |
| | | public MediaServerItem getMediaServerItem() { |
| | | return mediaServerItem; |
| | | } |
| | | |
| | | public void setMediaServerItem(MediaServerItem mediaServerItem) { |
| | | this.mediaServerItem = mediaServerItem; |
| | | } |
| | | |
| | | public AudioBroadcastEvent getEvent() { |
| | | return event; |
| | | } |
| | | |
| | | public void setEvent(AudioBroadcastEvent event) { |
| | | this.event = event; |
| | | } |
| | | |
| | | public String getApp() { |
| | |
| | | isFromPlatform = fromPlatform; |
| | | } |
| | | |
| | | public MediaServerItem getMediaServerItem() { |
| | | return mediaServerItem; |
| | | public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { |
| | | this.sipTransactionInfo = sipTransactionInfo; |
| | | } |
| | | |
| | | public void setMediaServerItem(MediaServerItem mediaServerItem) { |
| | | this.mediaServerItem = mediaServerItem; |
| | | public AudioBroadcastEvent getEvent() { |
| | | return event; |
| | | } |
| | | |
| | | public void setEvent(AudioBroadcastEvent event) { |
| | | this.event = event; |
| | | } |
| | | |
| | | public void setSipTransactionInfoByRequset(SIPResponse sipResponse) { |
| | | this.sipTransactionInfo = new SipTransactionInfo(sipResponse); |
| | | } |
| | | } |
| | |
| | | |
| | | public JSONObject startSendRtp(MediaServerItem mediaInfo, SendRtpItem sendRtpItem) { |
| | | String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; |
| | | logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); |
| | | logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); |
| | | Map<String, Object> param = new HashMap<>(12); |
| | | param.put("vhost","__defaultVhost__"); |
| | | param.put("app",sendRtpItem.getApp()); |
| | | param.put("stream",sendRtpItem.getStreamId()); |
| | | param.put("stream",sendRtpItem.getStream()); |
| | | param.put("ssrc", sendRtpItem.getSsrc()); |
| | | param.put("src_port", sendRtpItem.getLocalPort()); |
| | | param.put("pt", sendRtpItem.getPt()); |
| | |
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import gov.nist.javax.sip.message.SIPResponse; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.SipException; |
| | |
| | | boolean audioBroadcastInUse(Device device, String channelId); |
| | | |
| | | void stopAudioBroadcast(String deviceId, String channelId); |
| | | |
| | | void audioBroadcastCmd(Device device, String channelId, int timeout, MediaServerItem mediaServerItem, String sourceApp, String sourceStream, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException; |
| | | |
| | | void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; |
| | | |
| | |
| | | if (streamReady) { |
| | | logger.warn("[语音对讲] 进行中: {}", channelId); |
| | | event.call("语音对讲进行中"); |
| | | return; |
| | | return false; |
| | | } else { |
| | | stopTalk(device, channelId); |
| | | } |
| | |
| | | if (sendRtpItem != null && sendRtpItem.isOnlyAudio()) { |
| | | // 查询流是否存在,不存在则认为是异常状态 |
| | | MediaServerItem mediaServerServiceOne = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| | | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerServiceOne, sendRtpItem.getApp(), sendRtpItem.getStreamId()); |
| | | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerServiceOne, sendRtpItem.getApp(), sendRtpItem.getStream()); |
| | | if (streamReady) { |
| | | logger.warn("语音广播通道使用中: {}", channelId); |
| | | return true; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void zlmServerOnline(String mediaServerId) { |
| | | // TODO 查找之前的点播,流如果不存在则给下级发送bye |
| | |
| | | method: 'get', |
| | | url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30&broadcastMode=" + this.broadcastMode |
| | | }).then( (res)=> { |
| | | if (res.data.code == 0) { |
| | | if (res.data.code === 0) { |
| | | let streamInfo = res.data.data.streamInfo; |
| | | if (document.location.protocol.includes("https")) { |
| | | this.startBroadcast(streamInfo.rtcs) |