648540858 1 rok temu
rodzic
commit
0447b83c3a

+ 0 - 42
src/main/java/com/genersoft/iot/vmp/gb28181/session/AudioBroadcastManager.java

@@ -38,50 +38,8 @@ public class AudioBroadcastManager {
     @Autowired
     private SipConfig config;
 
-    @Autowired
-    private SIPCommander cmder;
-
-    @Autowired
-    private IRedisCatchStorage redisCatchStorage;
-
-    @Autowired
-    private IDeviceService deviceService;
-
     public static Map<String, AudioBroadcastCatch> data = new ConcurrentHashMap<>();
 
-    /**
-     * 流离开的处理
-     */
-    @Async("taskExecutor")
-    @EventListener
-    public void onApplicationEvent(MediaDepartureEvent event) {
-        List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(event.getStream());
-        if (!sendRtpItems.isEmpty()) {
-            for (SendRtpItem sendRtpItem : sendRtpItems) {
-                if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) {
-                    String platformId = sendRtpItem.getPlatformId();
-                    Device device = deviceService.getDevice(platformId);
-                    try {
-                        if (device != null) {
-                            cmder.streamByeCmd(device, sendRtpItem.getChannelId(), event.getStream(), sendRtpItem.getCallId());
-                            if (sendRtpItem.getPlayType().equals(InviteStreamType.BROADCAST)
-                                    || sendRtpItem.getPlayType().equals(InviteStreamType.TALK)) {
-                                AudioBroadcastCatch audioBroadcastCatch = get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
-                                if (audioBroadcastCatch != null) {
-                                    // 来自上级平台的停止对讲
-                                    logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
-                                    del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
-                                }
-                            }
-                        }
-                    } catch (SipException | InvalidArgumentException | ParseException |
-                             SsrcTransactionNotFoundException e) {
-                        logger.error("[命令发送失败] 发送BYE: {}", e.getMessage());
-                    }
-                }
-            }
-        }
-    }
 
     public void update(AudioBroadcastCatch audioBroadcastCatch) {
         if (SipUtils.isFrontEnd(audioBroadcastCatch.getDeviceId())) {

+ 11 - 0
src/main/java/com/genersoft/iot/vmp/media/event/MediaArrivalEvent.java

@@ -20,6 +20,7 @@ public class MediaArrivalEvent extends ApplicationEvent {
         mediaArrivalEvent.setStream(hookParam.getStream());
         mediaArrivalEvent.setMediaServer(mediaServer);
         mediaArrivalEvent.setSchema(hookParam.getSchema());
+        mediaArrivalEvent.setCallId(hookParam.getCallId());
         return mediaArrivalEvent;
     }
 
@@ -33,6 +34,8 @@ public class MediaArrivalEvent extends ApplicationEvent {
 
     private String schema;
 
+    private String callId;
+
     public MediaInfo getMediaInfo() {
         return mediaInfo;
     }
@@ -72,4 +75,12 @@ public class MediaArrivalEvent extends ApplicationEvent {
     public void setSchema(String schema) {
         this.schema = schema;
     }
+
+    public String getCallId() {
+        return callId;
+    }
+
+    public void setCallId(String callId) {
+        this.callId = callId;
+    }
 }

+ 0 - 1
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java

@@ -208,7 +208,6 @@ public class MediaServiceImpl implements IMediaService {
         ResultForOnPublish result = new ResultForOnPublish();
         result.setEnable_audio(true);
 
-
         // 是否录像
         if ("rtp".equals(app)) {
             result.setEnable_mp4(userSetting.getRecordSip());

+ 27 - 0
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -175,6 +175,33 @@ public class PlayServiceImpl implements IPlayService {
     @Async("taskExecutor")
     @EventListener
     public void onApplicationEvent(MediaDepartureEvent event) {
+        List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(event.getStream());
+        if (!sendRtpItems.isEmpty()) {
+            for (SendRtpItem sendRtpItem : sendRtpItems) {
+                if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) {
+                    String platformId = sendRtpItem.getPlatformId();
+                    Device device = deviceService.getDevice(platformId);
+                    try {
+                        if (device != null) {
+                            cmder.streamByeCmd(device, sendRtpItem.getChannelId(), event.getStream(), sendRtpItem.getCallId());
+                            if (sendRtpItem.getPlayType().equals(InviteStreamType.BROADCAST)
+                                    || sendRtpItem.getPlayType().equals(InviteStreamType.TALK)) {
+                                AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+                                if (audioBroadcastCatch != null) {
+                                    // 来自上级平台的停止对讲
+                                    logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+                                    audioBroadcastManager.del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+                                }
+                            }
+                        }
+                    } catch (SipException | InvalidArgumentException | ParseException |
+                             SsrcTransactionNotFoundException e) {
+                        logger.error("[命令发送失败] 发送BYE: {}", e.getMessage());
+                    }
+                }
+            }
+        }
+
         if ("broadcast".equals(event.getApp()) || "talk".equals(event.getApp())) {
             if (event.getStream().indexOf("_") > 0) {
                 String[] streamArray = event.getStream().split("_");

+ 3 - 3
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java

@@ -176,14 +176,14 @@ public class StreamPushServiceImpl implements IStreamPushService {
                 redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
             }
         }
-        GbStream gbStream = storager.getGbStream(event.getApp(), event.getStream());
+        GbStream gbStream = gbStreamMapper.selectOne(event.getApp(), event.getStream());
         if (gbStream != null) {
             if (userSetting.isUsePushingAsStatus()) {
-                storager.mediaOffline(event.getApp(), event.getStream());
+                streamPushMapper.updatePushStatus(event.getApp(), event.getStream(), false);
                 eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF);
             }
         }else {
-            storager.removeMedia(event.getApp(), event.getStream());
+            streamPushMapper.del(event.getApp(), event.getStream());
         }
     }
 

+ 2 - 1
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java

@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
+import com.genersoft.iot.vmp.media.event.MediaArrivalEvent;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
@@ -209,7 +210,7 @@ public interface IRedisCatchStorage {
 
     void sendPlatformStopPlayMsg(MessageForPushChannel messageForPushChannel);
 
-    void addPushListItem(String app, String stream, OnStreamChangedHookParam param);
+    void addPushListItem(String app, String stream, MediaArrivalEvent param);
 
     void removePushListItem(String app, String stream, String mediaServerId);
 }

+ 3 - 2
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
+import com.genersoft.iot.vmp.media.event.MediaArrivalEvent;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
@@ -651,9 +652,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     }
 
     @Override
-    public void addPushListItem(String app, String stream, OnStreamChangedHookParam param) {
+    public void addPushListItem(String app, String stream, MediaArrivalEvent event) {
         String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
-        redisTemplate.opsForValue().set(key, param);
+        redisTemplate.opsForValue().set(key, event);
     }
 
     @Override