Commit c547851487a8e24f93405ace3c0359d0d6790364
1 parent
abc65c63
优化zlm上线与下线过时通道的移除
Showing
4 changed files
with
19 additions
and
6 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| @@ -118,7 +118,7 @@ public class StreamPushServiceImpl implements IStreamPushService { | @@ -118,7 +118,7 @@ public class StreamPushServiceImpl implements IStreamPushService { | ||
| 118 | 118 | ||
| 119 | @Override | 119 | @Override |
| 120 | public List<StreamPushItem> getPushList(String mediaServerId) { | 120 | public List<StreamPushItem> getPushList(String mediaServerId) { |
| 121 | - return streamPushMapper.selectAllByMediaServerId(mediaServerId); | 121 | + return streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | @Override | 124 | @Override |
| @@ -204,7 +204,9 @@ public class StreamPushServiceImpl implements IStreamPushService { | @@ -204,7 +204,9 @@ public class StreamPushServiceImpl implements IStreamPushService { | ||
| 204 | Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>(); | 204 | Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>(); |
| 205 | if (pushList.size() > 0) { | 205 | if (pushList.size() > 0) { |
| 206 | for (StreamPushItem streamPushItem : pushList) { | 206 | for (StreamPushItem streamPushItem : pushList) { |
| 207 | - pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); | 207 | + if (StringUtils.isEmpty(streamPushItem.getGbId())) { |
| 208 | + pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); | ||
| 209 | + } | ||
| 208 | } | 210 | } |
| 209 | } | 211 | } |
| 210 | if (mediaItems.size() > 0) { | 212 | if (mediaItems.size() > 0) { |
| @@ -268,7 +270,7 @@ public class StreamPushServiceImpl implements IStreamPushService { | @@ -268,7 +270,7 @@ public class StreamPushServiceImpl implements IStreamPushService { | ||
| 268 | 270 | ||
| 269 | @Override | 271 | @Override |
| 270 | public void zlmServerOffline(String mediaServerId) { | 272 | public void zlmServerOffline(String mediaServerId) { |
| 271 | - List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerId(mediaServerId); | 273 | + List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId); |
| 272 | // 移除没有GBId的推流 | 274 | // 移除没有GBId的推流 |
| 273 | streamPushMapper.deleteWithoutGBId(mediaServerId); | 275 | streamPushMapper.deleteWithoutGBId(mediaServerId); |
| 274 | gbStreamMapper.deleteWithoutGBId("push", mediaServerId); | 276 | gbStreamMapper.deleteWithoutGBId("push", mediaServerId); |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
| @@ -33,6 +33,14 @@ public interface StreamPushMapper { | @@ -33,6 +33,14 @@ public interface StreamPushMapper { | ||
| 33 | int del(String app, String stream); | 33 | int del(String app, String stream); |
| 34 | 34 | ||
| 35 | @Delete("<script> "+ | 35 | @Delete("<script> "+ |
| 36 | + "DELETE sp FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where " + | ||
| 37 | + "<foreach collection='streamPushItems' item='item' separator='or'>" + | ||
| 38 | + "(sp.app=#{item.app} and sp.stream=#{item.stream} and gs.gbId is null) " + | ||
| 39 | + "</foreach>" + | ||
| 40 | + "</script>") | ||
| 41 | + int delAllWithoutGBId(List<StreamPushItem> streamPushItems); | ||
| 42 | + | ||
| 43 | + @Delete("<script> "+ | ||
| 36 | "DELETE FROM stream_push where " + | 44 | "DELETE FROM stream_push where " + |
| 37 | "<foreach collection='streamPushItems' item='item' separator='or'>" + | 45 | "<foreach collection='streamPushItems' item='item' separator='or'>" + |
| 38 | "(app=#{item.app} and stream=#{item.stream}) " + | 46 | "(app=#{item.app} and stream=#{item.stream}) " + |
| @@ -62,10 +70,13 @@ public interface StreamPushMapper { | @@ -62,10 +70,13 @@ public interface StreamPushMapper { | ||
| 62 | @Delete("DELETE FROM stream_push") | 70 | @Delete("DELETE FROM stream_push") |
| 63 | void clear(); | 71 | void clear(); |
| 64 | 72 | ||
| 65 | - @Delete("DELETE FROM stream_push WHERE mediaServerId=#{mediaServerId}") | 73 | + @Delete("DELETE sp FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null ") |
| 66 | void deleteWithoutGBId(String mediaServerId); | 74 | void deleteWithoutGBId(String mediaServerId); |
| 67 | 75 | ||
| 68 | @Select("SELECT * FROM stream_push WHERE mediaServerId=#{mediaServerId}") | 76 | @Select("SELECT * FROM stream_push WHERE mediaServerId=#{mediaServerId}") |
| 69 | List<StreamPushItem> selectAllByMediaServerId(String mediaServerId); | 77 | List<StreamPushItem> selectAllByMediaServerId(String mediaServerId); |
| 70 | 78 | ||
| 79 | + @Select("SELECT sp.* FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null") | ||
| 80 | + List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId); | ||
| 81 | + | ||
| 71 | } | 82 | } |
src/main/resources/application-dev.yml
| @@ -20,7 +20,7 @@ spring: | @@ -20,7 +20,7 @@ spring: | ||
| 20 | datasource: | 20 | datasource: |
| 21 | # 使用mysql 打开23-28行注释, 删除29-36行 | 21 | # 使用mysql 打开23-28行注释, 删除29-36行 |
| 22 | name: wvp | 22 | name: wvp |
| 23 | - url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true | 23 | + url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false |
| 24 | username: | 24 | username: |
| 25 | password: | 25 | password: |
| 26 | type: com.alibaba.druid.pool.DruidDataSource | 26 | type: com.alibaba.druid.pool.DruidDataSource |
src/main/resources/application-docker.yml
| @@ -20,7 +20,7 @@ spring: | @@ -20,7 +20,7 @@ spring: | ||
| 20 | datasource: | 20 | datasource: |
| 21 | # 使用mysql 打开23-28行注释, 删除29-36行 | 21 | # 使用mysql 打开23-28行注释, 删除29-36行 |
| 22 | name: wvp | 22 | name: wvp |
| 23 | - url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true | 23 | + url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false |
| 24 | username: root | 24 | username: root |
| 25 | password: root | 25 | password: root |
| 26 | type: com.alibaba.druid.pool.DruidDataSource | 26 | type: com.alibaba.druid.pool.DruidDataSource |