Browse Source

优化zlm上线与下线过时通道的移除

pull/324/head
648540858 3 years ago
parent
commit
c547851487
  1. 8
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
  2. 13
      src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
  3. 2
      src/main/resources/application-dev.yml
  4. 2
      src/main/resources/application-docker.yml

8
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java

@ -118,7 +118,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Override @Override
public List<StreamPushItem> getPushList(String mediaServerId) { public List<StreamPushItem> getPushList(String mediaServerId) {
return streamPushMapper.selectAllByMediaServerId(mediaServerId); return streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId);
} }
@Override @Override
@ -204,7 +204,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>(); Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>();
if (pushList.size() > 0) { if (pushList.size() > 0) {
for (StreamPushItem streamPushItem : pushList) { for (StreamPushItem streamPushItem : pushList) {
pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); if (StringUtils.isEmpty(streamPushItem.getGbId())) {
pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
}
} }
} }
if (mediaItems.size() > 0) { if (mediaItems.size() > 0) {
@ -268,7 +270,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Override @Override
public void zlmServerOffline(String mediaServerId) { public void zlmServerOffline(String mediaServerId) {
List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerId(mediaServerId); List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId);
// 移除没有GBId的推流 // 移除没有GBId的推流
streamPushMapper.deleteWithoutGBId(mediaServerId); streamPushMapper.deleteWithoutGBId(mediaServerId);
gbStreamMapper.deleteWithoutGBId("push", mediaServerId); gbStreamMapper.deleteWithoutGBId("push", mediaServerId);

13
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java

@ -32,6 +32,14 @@ public interface StreamPushMapper {
@Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}") @Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream); int del(String app, String stream);
@Delete("<script> "+
"DELETE sp FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
"(sp.app=#{item.app} and sp.stream=#{item.stream} and gs.gbId is null) " +
"</foreach>" +
"</script>")
int delAllWithoutGBId(List<StreamPushItem> streamPushItems);
@Delete("<script> "+ @Delete("<script> "+
"DELETE FROM stream_push where " + "DELETE FROM stream_push where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" + "<foreach collection='streamPushItems' item='item' separator='or'>" +
@ -62,10 +70,13 @@ public interface StreamPushMapper {
@Delete("DELETE FROM stream_push") @Delete("DELETE FROM stream_push")
void clear(); void clear();
@Delete("DELETE FROM stream_push WHERE mediaServerId=#{mediaServerId}") @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 ")
void deleteWithoutGBId(String mediaServerId); void deleteWithoutGBId(String mediaServerId);
@Select("SELECT * FROM stream_push WHERE mediaServerId=#{mediaServerId}") @Select("SELECT * FROM stream_push WHERE mediaServerId=#{mediaServerId}")
List<StreamPushItem> selectAllByMediaServerId(String mediaServerId); List<StreamPushItem> selectAllByMediaServerId(String mediaServerId);
@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")
List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
} }

2
src/main/resources/application-dev.yml

@ -20,7 +20,7 @@ spring:
datasource: datasource:
# 使用mysql 打开23-28行注释, 删除29-36行 # 使用mysql 打开23-28行注释, 删除29-36行
name: wvp name: wvp
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
username: username:
password: password:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource

2
src/main/resources/application-docker.yml

@ -20,7 +20,7 @@ spring:
datasource: datasource:
# 使用mysql 打开23-28行注释, 删除29-36行 # 使用mysql 打开23-28行注释, 删除29-36行
name: wvp name: wvp
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
username: root username: root
password: root password: root
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource

Loading…
Cancel
Save