| | |
| | | `ptz` int DEFAULT NULL, |
| | | `rtcp` int DEFAULT NULL, |
| | | `status` bit(1) DEFAULT NULL, |
| | | `shareAllLiveStream` int DEFAULT NULL, |
| | | `startOfflinePush` int DEFAULT '0', |
| | | `administrativeDivision` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| | | `catalogGroup` int DEFAULT '1', |
| | |
| | | alter table stream_push |
| | | add updateTime varchar(50) default null; |
| | | alter table stream_push |
| | | add pushIng int DEFAULT NULL; |
| | | alter table stream_push |
| | | change createStamp createTime varchar(50) default null; |
| | | |
| | | alter table gb_stream |
| | |
| | | alter table parent_platform |
| | | add treeType varchar(50) not null; |
| | | update parent_platform set parent_platform.treeType='BusinessGroup'; |
| | | alter table parent_platform drop shareAllLiveStream; |
| | | |
| | | alter table platform_catalog |
| | | add civilCode varchar(50) default null; |
| | |
| | | private int channelCount; |
| | | |
| | | /** |
| | | * 共享所有的直播流 |
| | | */ |
| | | private boolean shareAllLiveStream; |
| | | |
| | | /** |
| | | * 默认目录Id,自动添加的通道多放在这个目录下 |
| | | */ |
| | | private String catalogId; |
| | |
| | | |
| | | public void setChannelCount(int channelCount) { |
| | | this.channelCount = channelCount; |
| | | } |
| | | |
| | | |
| | | public boolean isShareAllLiveStream() { |
| | | return shareAllLiveStream; |
| | | } |
| | | |
| | | public void setShareAllLiveStream(boolean shareAllLiveStream) { |
| | | this.shareAllLiveStream = shareAllLiveStream; |
| | | } |
| | | |
| | | public String getCatalogId() { |
| | |
| | | // 查找此直播流是否存在redis预设gbId |
| | | StreamPushItem transform = streamPushService.transform(mediaItem); |
| | | StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream()); |
| | | transform.setPushIng(true); |
| | | transform.setUpdateTime(DateUtil.getNow()); |
| | | transform.setPushTime(DateUtil.getNow()); |
| | | if (pushInDb == null) { |
| | |
| | | streamPushMapper.add(transform); |
| | | }else { |
| | | 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; |
| | | } |
| | | |
| | |
| | | */ |
| | | private String createTime; |
| | | |
| | | /** |
| | | * 是否正在推流 |
| | | */ |
| | | private boolean pushIng; |
| | | |
| | | public String getVhost() { |
| | | return vhost; |
| | | } |
| | |
| | | public void setCreateTime(String createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public boolean isPushIng() { |
| | | return pushIng; |
| | | } |
| | | |
| | | public void setPushIng(boolean pushIng) { |
| | | this.pushIng = pushIng; |
| | | } |
| | | } |
| | | |
| | |
| | | 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()); |
| | | return wvpResult; |
| | | } |
| | |
| | | stream.setStatus(true); |
| | | stream.setCreateTime(DateUtil.getNow()); |
| | | 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; |
| | | } |
| | | |
| | |
| | | public void batchAdd(List<StreamPushItem> streamPushItems) { |
| | | streamPushMapper.addAll(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 |
| | |
| | | |
| | | @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + |
| | | " 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}', " + |
| | | " '${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); |
| | | |
| | | @Update("UPDATE parent_platform " + |
| | |
| | | "ptz=#{ptz}, " + |
| | | "rtcp=#{rtcp}, " + |
| | | "status=#{status}, " + |
| | | "shareAllLiveStream=#{shareAllLiveStream}, " + |
| | | "startOfflinePush=${startOfflinePush}, " + |
| | | "catalogGroup=#{catalogGroup}, " + |
| | | "administrativeDivision=#{administrativeDivision}, " + |
| | |
| | | |
| | | @Update("UPDATE parent_platform SET status=#{online} WHERE serverGBId=#{platformGbID}" ) |
| | | int updateParentPlatformStatus(String platformGbID, boolean online); |
| | | |
| | | @Select("SELECT * FROM parent_platform WHERE shareAllLiveStream=true") |
| | | List<ParentPlatform> selectAllAhareAllLiveStream(); |
| | | |
| | | @Update(value = {" <script>" + |
| | | "UPDATE parent_platform " + |
| | |
| | | public interface StreamPushMapper { |
| | | |
| | | @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}', " + |
| | | "'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}' )") |
| | | "'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}', ${pushIng} )") |
| | | int add(StreamPushItem streamPushItem); |
| | | |
| | | |
| | |
| | | "<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" + |
| | | "<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" + |
| | | "<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" + |
| | | "<if test=\"pushIng != null\">, pushIng=${pushIng}</if>" + |
| | | "WHERE app=#{app} AND stream=#{stream}"+ |
| | | " </script>"}) |
| | | int update(StreamPushItem streamPushItem); |
| | |
| | | |
| | | @Insert("<script>" + |
| | | "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=','>" + |
| | | "( '${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>" + |
| | | "</script>") |
| | | @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") |
| | |
| | | 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 " + |
| | | "SET status=#{status} " + |
| | | "WHERE mediaServerId=#{mediaServerId}") |
| | | void updateStatusByMediaServerId(String mediaServerId, boolean status); |
| | |
| | | // 更新缓存 |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | 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; |
| | | } |
| | |
| | | streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); |
| | | streamPushMapper.add(streamPushItem); |
| | | 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 |
| | |
| | | </el-table-column> |
| | | <el-table-column label="正在推流" min-width="100"> |
| | | <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> |
| | | </el-table-column> |
| | | |
| | |
| | | <el-form-item label="其他选项"> |
| | | <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.shareAllLiveStream"></el-checkbox> |
| | | <el-checkbox label="拉起离线推流" v-model="platform.startOfflinePush"></el-checkbox> |
| | | </el-form-item> |
| | | <el-form-item> |
| | |
| | | keepTimeout: 60, |
| | | transport: "UDP", |
| | | characterSet: "GB2312", |
| | | shareAllLiveStream: false, |
| | | startOfflinePush: false, |
| | | catalogGroup: 1, |
| | | administrativeDivision: null, |
| | |
| | | this.platform.keepTimeout = platform.keepTimeout; |
| | | this.platform.transport = platform.transport; |
| | | this.platform.characterSet = platform.characterSet; |
| | | this.platform.shareAllLiveStream = platform.shareAllLiveStream; |
| | | this.platform.catalogId = platform.catalogId; |
| | | this.platform.startOfflinePush = platform.startOfflinePush; |
| | | this.platform.catalogGroup = platform.catalogGroup; |
| | |
| | | transport: "UDP", |
| | | characterSet: "GB2312", |
| | | treeType: "BusinessGroup", |
| | | shareAllLiveStream: false, |
| | | startOfflinePush: false, |
| | | catalogGroup: 1, |
| | | } |