移除共享所有直播流功能

This commit is contained in:
648540858 2022-07-19 17:46:16 +08:00
parent fe6ca0c571
commit 64f6d596f4
12 changed files with 36 additions and 155 deletions

View File

@ -328,7 +328,6 @@ CREATE TABLE `parent_platform` (
`ptz` int DEFAULT NULL, `ptz` int DEFAULT NULL,
`rtcp` int DEFAULT NULL, `rtcp` int DEFAULT NULL,
`status` bit(1) DEFAULT NULL, `status` bit(1) DEFAULT NULL,
`shareAllLiveStream` int DEFAULT NULL,
`startOfflinePush` int DEFAULT '0', `startOfflinePush` int DEFAULT '0',
`administrativeDivision` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `administrativeDivision` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`catalogGroup` int DEFAULT '1', `catalogGroup` int DEFAULT '1',

View File

@ -55,6 +55,8 @@ alter table stream_push
add status int DEFAULT NULL; add status int DEFAULT NULL;
alter table stream_push alter table stream_push
add updateTime varchar(50) default null; add updateTime varchar(50) default null;
alter table stream_push
add pushIng int DEFAULT NULL;
alter table stream_push alter table stream_push
change createStamp createTime varchar(50) default null; change createStamp createTime varchar(50) default null;
@ -68,6 +70,7 @@ update user set pushKey='453df297a57a5a7438934sda801fc3' where id=1;
alter table parent_platform alter table parent_platform
add treeType varchar(50) not null; add treeType varchar(50) not null;
update parent_platform set parent_platform.treeType='BusinessGroup'; update parent_platform set parent_platform.treeType='BusinessGroup';
alter table parent_platform drop shareAllLiveStream;
alter table platform_catalog alter table platform_catalog
add civilCode varchar(50) default null; add civilCode varchar(50) default null;

View File

@ -104,11 +104,6 @@ public class ParentPlatform {
*/ */
private int channelCount; private int channelCount;
/**
* 共享所有的直播流
*/
private boolean shareAllLiveStream;
/** /**
* 默认目录Id,自动添加的通道多放在这个目录下 * 默认目录Id,自动添加的通道多放在这个目录下
*/ */
@ -319,15 +314,6 @@ public class ParentPlatform {
this.channelCount = channelCount; this.channelCount = channelCount;
} }
public boolean isShareAllLiveStream() {
return shareAllLiveStream;
}
public void setShareAllLiveStream(boolean shareAllLiveStream) {
this.shareAllLiveStream = shareAllLiveStream;
}
public String getCatalogId() { public String getCatalogId() {
return catalogId; return catalogId;
} }

View File

@ -116,6 +116,7 @@ public class ZLMMediaListManager {
// 查找此直播流是否存在redis预设gbId // 查找此直播流是否存在redis预设gbId
StreamPushItem transform = streamPushService.transform(mediaItem); StreamPushItem transform = streamPushService.transform(mediaItem);
StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream()); StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream());
transform.setPushIng(true);
transform.setUpdateTime(DateUtil.getNow()); transform.setUpdateTime(DateUtil.getNow());
transform.setPushTime(DateUtil.getNow()); transform.setPushTime(DateUtil.getNow());
if (pushInDb == null) { if (pushInDb == null) {
@ -123,34 +124,7 @@ public class ZLMMediaListManager {
streamPushMapper.add(transform); streamPushMapper.add(transform);
}else { }else {
streamPushMapper.update(transform); streamPushMapper.update(transform);
// if (!StringUtils.isEmpty(pushInDb.getGbId())) {
// List<GbStream> gbStreamList = gbStreamMapper.selectByGBId(transform.getGbId());
// if (gbStreamList != null && gbStreamList.size() == 1) {
// transform.setGbStreamId(gbStreamList.get(0).getGbStreamId());
// transform.setPlatformId(gbStreamList.get(0).getPlatformId());
// transform.setCatalogId(gbStreamList.get(0).getCatalogId());
// transform.setGbId(gbStreamList.get(0).getGbId());
// gbStreamMapper.update(transform);
// streamPushMapper.del(gbStreamList.get(0).getApp(), gbStreamList.get(0).getStream());
// }else {
// transform.setCreateTime(DateUtil.getNow());
// transform.setUpdateTime(DateUtil.getNow());
// gbStreamMapper.add(transform);
// }
// 通知通道上线
// if (transform != null) {
// if (channelOnlineEvents.get(transform.getGbId()) != null) {
// channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream(), transform.getServerId());
// channelOnlineEvents.remove(transform.getGbId());
// }
// }
// }
} }
return transform; return transform;
} }

View File

@ -103,6 +103,11 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
*/ */
private String createTime; private String createTime;
/**
* 是否正在推流
*/
private boolean pushIng;
public String getVhost() { public String getVhost() {
return vhost; return vhost;
} }
@ -277,5 +282,13 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
public void setCreateTime(String createTime) { public void setCreateTime(String createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public boolean isPushIng() {
return pushIng;
}
public void setPushIng(boolean pushIng) {
this.pushIng = pushIng;
}
} }

View File

@ -156,24 +156,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
} }
} }
if (!StringUtils.isEmpty(param.getGbId())) {
// 查找开启了全部直播流共享的上级平台
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
if (parentPlatforms.size() > 0) {
for (ParentPlatform parentPlatform : parentPlatforms) {
param.setPlatformId(parentPlatform.getServerGBId());
param.setCatalogId(parentPlatform.getCatalogId());
String stream = param.getStream();
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
if (streamProxyItems == null) {
platformGbStreamMapper.add(param);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD);
}
}
}
}
wvpResult.setMsg(result.toString()); wvpResult.setMsg(result.toString());
return wvpResult; return wvpResult;
} }

View File

@ -134,29 +134,6 @@ public class StreamPushServiceImpl implements IStreamPushService {
stream.setStatus(true); stream.setStatus(true);
stream.setCreateTime(DateUtil.getNow()); stream.setCreateTime(DateUtil.getNow());
int add = gbStreamMapper.add(stream); int add = gbStreamMapper.add(stream);
// 查找开启了全部直播流共享的上级平台
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
if (parentPlatforms.size() > 0) {
for (ParentPlatform parentPlatform : parentPlatforms) {
stream.setCatalogId(parentPlatform.getCatalogId());
stream.setPlatformId(parentPlatform.getServerGBId());
String streamId = stream.getStream();
StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId());
if (streamProxyItem == null) {
platformGbStreamMapper.add(stream);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
}else {
if (!streamProxyItem.getGbId().equals(stream.getGbId())) {
// 此流使用另一个国标Id已经与该平台关联移除此记录
platformGbStreamMapper.delByAppAndStreamAndPlatform(stream.getApp(), streamId, parentPlatform.getServerGBId());
platformGbStreamMapper.add(stream);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
}
}
}
}
return add > 0; return add > 0;
} }
@ -345,31 +322,6 @@ public class StreamPushServiceImpl implements IStreamPushService {
public void batchAdd(List<StreamPushItem> streamPushItems) { public void batchAdd(List<StreamPushItem> streamPushItems) {
streamPushMapper.addAll(streamPushItems); streamPushMapper.addAll(streamPushItems);
gbStreamMapper.batchAdd(streamPushItems); gbStreamMapper.batchAdd(streamPushItems);
// 查找开启了全部直播流共享的上级平台
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
if (parentPlatforms.size() > 0) {
for (StreamPushItem stream : streamPushItems) {
for (ParentPlatform parentPlatform : parentPlatforms) {
stream.setCatalogId(parentPlatform.getCatalogId());
stream.setPlatformId(parentPlatform.getServerGBId());
String streamId = stream.getStream();
StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId());
if (streamProxyItem == null) {
platformGbStreamMapper.add(stream);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
}else {
if (!streamProxyItem.getGbId().equals(stream.getGbId())) {
// 此流使用另一个国标Id已经与该平台关联移除此记录
platformGbStreamMapper.delByAppAndStreamAndPlatform(stream.getApp(), streamId, parentPlatform.getServerGBId());
platformGbStreamMapper.add(stream);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD);
stream.setGbId(streamProxyItem.getGbId());
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.DEL);
}
}
}
}
}
} }
@Override @Override

View File

@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " + " status, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " +
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})") " ${status}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
int addParentPlatform(ParentPlatform parentPlatform); int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE parent_platform " + @Update("UPDATE parent_platform " +
@ -41,7 +41,6 @@ public interface ParentPlatformMapper {
"ptz=#{ptz}, " + "ptz=#{ptz}, " +
"rtcp=#{rtcp}, " + "rtcp=#{rtcp}, " +
"status=#{status}, " + "status=#{status}, " +
"shareAllLiveStream=#{shareAllLiveStream}, " +
"startOfflinePush=${startOfflinePush}, " + "startOfflinePush=${startOfflinePush}, " +
"catalogGroup=#{catalogGroup}, " + "catalogGroup=#{catalogGroup}, " +
"administrativeDivision=#{administrativeDivision}, " + "administrativeDivision=#{administrativeDivision}, " +
@ -84,9 +83,6 @@ public interface ParentPlatformMapper {
@Update("UPDATE parent_platform SET status=#{online} WHERE serverGBId=#{platformGbID}" ) @Update("UPDATE parent_platform SET status=#{online} WHERE serverGBId=#{platformGbID}" )
int updateParentPlatformStatus(String platformGbID, boolean online); int updateParentPlatformStatus(String platformGbID, boolean online);
@Select("SELECT * FROM parent_platform WHERE shareAllLiveStream=true")
List<ParentPlatform> selectAllAhareAllLiveStream();
@Update(value = {" <script>" + @Update(value = {" <script>" +
"UPDATE parent_platform " + "UPDATE parent_platform " +
"SET catalogId=#{catalogId}, updateTime=#{updateTime}" + "SET catalogId=#{catalogId}, updateTime=#{updateTime}" +

View File

@ -15,9 +15,9 @@ import java.util.List;
public interface StreamPushMapper { public interface StreamPushMapper {
@Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + @Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"pushTime, aliveSecond, mediaServerId, serverId, updateTime, createTime) VALUES" + "pushTime, aliveSecond, mediaServerId, serverId, updateTime, createTime, pushIng) VALUES" +
"('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " + "('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
"'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}' )") "'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}', ${pushIng} )")
int add(StreamPushItem streamPushItem); int add(StreamPushItem streamPushItem);
@ -30,6 +30,7 @@ public interface StreamPushMapper {
"<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" + "<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" +
"<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" + "<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" +
"<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" + "<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" +
"<if test=\"pushIng != null\">, pushIng=${pushIng}</if>" +
"WHERE app=#{app} AND stream=#{stream}"+ "WHERE app=#{app} AND stream=#{stream}"+
" </script>"}) " </script>"})
int update(StreamPushItem streamPushItem); int update(StreamPushItem streamPushItem);
@ -88,10 +89,11 @@ public interface StreamPushMapper {
@Insert("<script>" + @Insert("<script>" +
"Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + "Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createTime, aliveSecond, mediaServerId, status) " + "createTime, aliveSecond, mediaServerId, status, pushIng) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" + "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " + "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
"'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} )" + "'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} ," +
" ${item.pushIng} )" +
" </foreach>" + " </foreach>" +
"</script>") "</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@ -114,6 +116,11 @@ public interface StreamPushMapper {
"WHERE app=#{app} AND stream=#{stream}") "WHERE app=#{app} AND stream=#{stream}")
int updateStatus(String app, String stream, boolean status); int updateStatus(String app, String stream, boolean status);
@Update("UPDATE stream_push " +
"SET pushIng=${pushIng} " +
"WHERE app=#{app} AND stream=#{stream}")
int updatePushStatus(String app, String stream, boolean status);
@Update("UPDATE stream_push " + @Update("UPDATE stream_push " +
"SET status=#{status} " + "SET status=#{status} " +
"WHERE mediaServerId=#{mediaServerId}") "WHERE mediaServerId=#{mediaServerId}")

View File

@ -443,20 +443,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
// 更新缓存 // 更新缓存
parentPlatformCatch.setParentPlatform(parentPlatform); parentPlatformCatch.setParentPlatform(parentPlatform);
redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
if (parentPlatform.isEnable()) {
// 共享所有视频流需要将现有视频流添加到此平台
List<GbStream> gbStreams = gbStreamMapper.queryStreamNotInPlatform();
if (gbStreams.size() > 0) {
for (GbStream gbStream : gbStreams) {
gbStream.setCatalogId(parentPlatform.getCatalogId());
}
if (parentPlatform.isShareAllLiveStream()) {
gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId());
}else {
gbStreamService.delPlatformInfo(parentPlatform.getServerGBId(), gbStreams);
}
}
}
return result > 0; return result > 0;
} }
@ -673,24 +659,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream());
streamPushMapper.add(streamPushItem); streamPushMapper.add(streamPushItem);
mediaOffline(streamPushItem.getApp(), streamPushItem.getStream()); mediaOffline(streamPushItem.getApp(), streamPushItem.getStream());
if(!StringUtils.isEmpty(streamPushItem.getGbId() )){
// 查找开启了全部直播流共享的上级平台
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
if (parentPlatforms.size() > 0) {
for (ParentPlatform parentPlatform : parentPlatforms) {
StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(streamPushItem.getApp(), streamPushItem.getStream(),
parentPlatform.getServerGBId());
if (streamProxyItem == null) {
streamPushItem.setCatalogId(parentPlatform.getCatalogId());
streamPushItem.setPlatformId(parentPlatform.getServerGBId());
platformGbStreamMapper.add(streamPushItem);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD);
}
}
}
}
} }
@Override @Override

View File

@ -62,7 +62,12 @@
</el-table-column> </el-table-column>
<el-table-column label="正在推流" min-width="100"> <el-table-column label="正在推流" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.status ? '是' : '否' }} {{scope.row.pushIng ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column label="本平台推流" min-width="100">
<template slot-scope="scope">
{{scope.row.pushIng && !!!scope.row.serverId ? '是' : '否' }}
</template> </template>
</el-table-column> </el-table-column>

View File

@ -97,7 +97,6 @@
<el-form-item label="其他选项"> <el-form-item label="其他选项">
<el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox> <el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox>
<el-checkbox label="云台控制" v-model="platform.ptz"></el-checkbox> <el-checkbox label="云台控制" v-model="platform.ptz"></el-checkbox>
<el-checkbox label="共享所有直播流" v-model="platform.shareAllLiveStream"></el-checkbox>
<el-checkbox label="拉起离线推流" v-model="platform.startOfflinePush"></el-checkbox> <el-checkbox label="拉起离线推流" v-model="platform.startOfflinePush"></el-checkbox>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -159,7 +158,6 @@ export default {
keepTimeout: 60, keepTimeout: 60,
transport: "UDP", transport: "UDP",
characterSet: "GB2312", characterSet: "GB2312",
shareAllLiveStream: false,
startOfflinePush: false, startOfflinePush: false,
catalogGroup: 1, catalogGroup: 1,
administrativeDivision: null, administrativeDivision: null,
@ -225,7 +223,6 @@ export default {
this.platform.keepTimeout = platform.keepTimeout; this.platform.keepTimeout = platform.keepTimeout;
this.platform.transport = platform.transport; this.platform.transport = platform.transport;
this.platform.characterSet = platform.characterSet; this.platform.characterSet = platform.characterSet;
this.platform.shareAllLiveStream = platform.shareAllLiveStream;
this.platform.catalogId = platform.catalogId; this.platform.catalogId = platform.catalogId;
this.platform.startOfflinePush = platform.startOfflinePush; this.platform.startOfflinePush = platform.startOfflinePush;
this.platform.catalogGroup = platform.catalogGroup; this.platform.catalogGroup = platform.catalogGroup;
@ -320,7 +317,6 @@ export default {
transport: "UDP", transport: "UDP",
characterSet: "GB2312", characterSet: "GB2312",
treeType: "BusinessGroup", treeType: "BusinessGroup",
shareAllLiveStream: false,
startOfflinePush: false, startOfflinePush: false,
catalogGroup: 1, catalogGroup: 1,
} }