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

This commit is contained in:
648540858 2022-01-25 19:38:04 +08:00
parent abc65c6317
commit c547851487
4 changed files with 19 additions and 6 deletions

View File

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

View File

@ -32,6 +32,14 @@ public interface StreamPushMapper {
@Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{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 FROM stream_push where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
@ -62,10 +70,13 @@ public interface StreamPushMapper {
@Delete("DELETE FROM stream_push")
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);
@Select("SELECT * FROM stream_push WHERE mediaServerId=#{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);
}

View File

@ -20,7 +20,7 @@ spring:
datasource:
# 使用mysql 打开23-28行注释 删除29-36行
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:
password:
type: com.alibaba.druid.pool.DruidDataSource

View File

@ -20,7 +20,7 @@ spring:
datasource:
# 使用mysql 打开23-28行注释 删除29-36行
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
password: root
type: com.alibaba.druid.pool.DruidDataSource