添加拉流代理与国标关联, 支持代理rtsp/rtmp/...,转发到国标
This commit is contained in:
@@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.storager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyDto;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
/**
|
||||
@@ -238,7 +235,7 @@ public interface IVideoManagerStorager {
|
||||
|
||||
/**
|
||||
* 添加Mobile Position设备移动位置
|
||||
* @param MobilePosition
|
||||
* @param mobilePosition
|
||||
* @return
|
||||
*/
|
||||
public boolean insertMobilePosition(MobilePosition mobilePosition);
|
||||
@@ -268,14 +265,14 @@ public interface IVideoManagerStorager {
|
||||
* @param streamProxyDto
|
||||
* @return
|
||||
*/
|
||||
public int addStreamProxy(StreamProxyDto streamProxyDto);
|
||||
public boolean addStreamProxy(StreamProxyItem streamProxyDto);
|
||||
|
||||
/**
|
||||
* 更新代理流
|
||||
* @param streamProxyDto
|
||||
* @return
|
||||
*/
|
||||
public int updateStreamProxy(StreamProxyDto streamProxyDto);
|
||||
public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
|
||||
|
||||
/**
|
||||
* 移除代理流
|
||||
@@ -290,7 +287,7 @@ public interface IVideoManagerStorager {
|
||||
* @param enable
|
||||
* @return
|
||||
*/
|
||||
public List<StreamProxyDto> getStreamProxyListForEnable(boolean enable);
|
||||
public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
|
||||
|
||||
/**
|
||||
* 按照是app和stream获取代理流
|
||||
@@ -298,7 +295,7 @@ public interface IVideoManagerStorager {
|
||||
* @param stream
|
||||
* @return
|
||||
*/
|
||||
public StreamProxyDto queryStreamProxy(String app, String stream);
|
||||
public StreamProxyItem queryStreamProxy(String app, String stream);
|
||||
|
||||
/**
|
||||
* 获取代理流
|
||||
@@ -306,5 +303,20 @@ public interface IVideoManagerStorager {
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
PageInfo<StreamProxyDto> queryStreamProxyList(Integer page, Integer count);
|
||||
PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count);
|
||||
|
||||
/**
|
||||
* 根据国标ID获取平台关联的直播流
|
||||
* @param platformId
|
||||
* @param channelId
|
||||
* @return
|
||||
*/
|
||||
GbStream queryStreamInParentPlatform(String platformId, String channelId);
|
||||
|
||||
/**
|
||||
* 获取平台关联的直播流
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
List<GbStream> queryGbStreamListInPlatform(String platformId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface GbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO gb_stream (app, stream, gbId, name, " +
|
||||
"longitude, latitude, streamType) VALUES" +
|
||||
"('${app}', '${stream}', '${gbId}', '${name}', " +
|
||||
"'${longitude}', '${latitude}', '${streamType}')")
|
||||
int add(GbStream gbStream);
|
||||
|
||||
@Update("UPDATE gb_stream " +
|
||||
"SET app=#{app}," +
|
||||
"stream=#{stream}," +
|
||||
"gbId=#{gbId}," +
|
||||
"name=#{name}," +
|
||||
"streamType=#{streamType}," +
|
||||
"longitude=#{longitude}, " +
|
||||
"latitude=#{latitude}, " +
|
||||
"WHERE app=#{app} AND stream=#{stream} AND gbId=#{gbId}")
|
||||
int update(GbStream gbStream);
|
||||
|
||||
@Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
int del(String app, String stream);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream")
|
||||
List<GbStream> selectAll();
|
||||
|
||||
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
StreamProxyItem selectOne(String app, String stream);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
|
||||
GbStream queryStreamInPlatform(String platformId, String gbId);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE pgs.platformId = '${platformId}'")
|
||||
List<GbStream> queryGbStreamListInPlatform(String platformId);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PlarfotmGbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" +
|
||||
"('${app}', '${stream}', '${platformId}')")
|
||||
int add(PlatformGbStream platformGbStream);
|
||||
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
int delByAppAndStream(String app, String stream);
|
||||
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
int delByPlatformId(String platformId);
|
||||
|
||||
@Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}")
|
||||
StreamProxyItem selectOne(String app, String stream, String platformId);
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PatformChannelMapper {
|
||||
public interface PlatformChannelMapper {
|
||||
|
||||
/**
|
||||
* 查询列表里已经关联的
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyDto;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface StreamProxyMapper {
|
||||
"timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable) VALUES" +
|
||||
"('${type}','${app}', '${stream}', '${url}', '${src_url}', '${dst_url}', " +
|
||||
"'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable} )")
|
||||
int add(StreamProxyDto streamProxyDto);
|
||||
int add(StreamProxyItem streamProxyDto);
|
||||
|
||||
@Update("UPDATE stream_proxy " +
|
||||
"SET type=#{type}, " +
|
||||
@@ -30,17 +30,17 @@ public interface StreamProxyMapper {
|
||||
"enable=#{enable}, " +
|
||||
"enable_mp4=#{enable_mp4} " +
|
||||
"WHERE app=#{app} AND stream=#{stream}")
|
||||
int update(StreamProxyDto streamProxyDto);
|
||||
int update(StreamProxyItem streamProxyDto);
|
||||
|
||||
@Delete("DELETE FROM stream_proxy WHERE app=#{app} AND stream=#{stream}")
|
||||
int del(String app, String stream);
|
||||
|
||||
@Select("SELECT * FROM stream_proxy")
|
||||
List<StreamProxyDto> selectAll();
|
||||
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream")
|
||||
List<StreamProxyItem> selectAll();
|
||||
|
||||
@Select("SELECT * FROM stream_proxy WHERE enable=${enable}")
|
||||
List<StreamProxyDto> selectForEnable(boolean enable);
|
||||
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable}")
|
||||
List<StreamProxyItem> selectForEnable(boolean enable);
|
||||
|
||||
@Select("SELECT * FROM stream_proxy WHERE app=#{app} AND stream=#{stream}")
|
||||
StreamProxyDto selectOne(String app, String stream);
|
||||
@Select("SELECT st.*, pgs.gbId, pgs.name, pgs.longitude, pgs.latitude FROM stream_proxy st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
|
||||
StreamProxyItem selectOne(String app, String stream);
|
||||
}
|
||||
|
||||
@@ -2,21 +2,20 @@ package com.genersoft.iot.vmp.storager.impl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyDto;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import com.genersoft.iot.vmp.storager.dao.*;
|
||||
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -27,6 +26,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Component
|
||||
public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Autowired
|
||||
DataSourceTransactionManager dataSourceTransactionManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDefinition transactionDefinition;
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
@@ -44,12 +48,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private PatformChannelMapper patformChannelMapper;
|
||||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private StreamProxyMapper streamProxyMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private GbStreamMapper gbStreamMapper;
|
||||
|
||||
|
||||
/**
|
||||
@@ -283,7 +288,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
public boolean deleteParentPlatform(ParentPlatform parentPlatform) {
|
||||
int result = platformMapper.delParentPlatform(parentPlatform);
|
||||
// 删除关联的通道
|
||||
patformChannelMapper.cleanChannelForGB(parentPlatform.getServerGBId());
|
||||
platformChannelMapper.cleanChannelForGB(parentPlatform.getServerGBId());
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@@ -333,7 +338,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
}
|
||||
List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
|
||||
// 查询当前已经存在的
|
||||
List<String> relatedPlatformchannels = patformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList);
|
||||
List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList);
|
||||
if (relatedPlatformchannels != null) {
|
||||
deviceAndChannelList.removeAll(relatedPlatformchannels);
|
||||
}
|
||||
@@ -344,7 +349,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
// 对剩下的数据进行存储
|
||||
int result = 0;
|
||||
if (channelReducesToAdd.size() > 0) {
|
||||
result = patformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
||||
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -354,20 +359,20 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Override
|
||||
public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
|
||||
|
||||
int result = patformChannelMapper.delChannelForGB(platformId, channelReduces);
|
||||
int result = platformChannelMapper.delChannelForGB(platformId, channelReduces);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) {
|
||||
DeviceChannel channel = patformChannelMapper.queryChannelInParentPlatform(platformId, channelId);
|
||||
DeviceChannel channel = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId);
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
|
||||
Device device = patformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||
Device device = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -390,27 +395,54 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
|
||||
/**
|
||||
* 新增代理流
|
||||
* @param streamProxyDto
|
||||
* @param streamProxyItem
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addStreamProxy(StreamProxyDto streamProxyDto) {
|
||||
return streamProxyMapper.add(streamProxyDto);
|
||||
public boolean addStreamProxy(StreamProxyItem streamProxyItem) {
|
||||
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
||||
boolean result = false;
|
||||
streamProxyItem.setStreamType("proxy");
|
||||
try {
|
||||
if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
}
|
||||
result = true;
|
||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||
}catch (Exception e) {
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新代理流
|
||||
* @param streamProxyDto
|
||||
* @param streamProxyItem
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int updateStreamProxy(StreamProxyDto streamProxyDto) {
|
||||
return streamProxyMapper.update(streamProxyDto);
|
||||
public boolean updateStreamProxy(StreamProxyItem streamProxyItem) {
|
||||
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
||||
boolean result = false;
|
||||
streamProxyItem.setStreamType("proxy");
|
||||
try {
|
||||
if (gbStreamMapper.update(streamProxyItem)<0 || streamProxyMapper.update(streamProxyItem) < 0) {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
}
|
||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||
result = true;
|
||||
}catch (Exception e) {
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除代理流
|
||||
* @param id
|
||||
* @param app
|
||||
* @param stream
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -424,7 +456,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StreamProxyDto> getStreamProxyListForEnable(boolean enable) {
|
||||
public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable) {
|
||||
return streamProxyMapper.selectForEnable(enable);
|
||||
}
|
||||
|
||||
@@ -435,12 +467,32 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<StreamProxyDto> queryStreamProxyList(Integer page, Integer count) {
|
||||
public PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<StreamProxyDto> all = streamProxyMapper.selectAll();
|
||||
List<StreamProxyItem> all = streamProxyMapper.selectAll();
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据国标ID获取平台关联的直播流
|
||||
* @param platformId
|
||||
* @param gbId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GbStream queryStreamInParentPlatform(String platformId, String gbId) {
|
||||
return gbStreamMapper.queryStreamInPlatform(platformId, gbId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平台关联的直播流
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<GbStream> queryGbStreamListInPlatform(String platformId) {
|
||||
return gbStreamMapper.queryGbStreamListInPlatform(platformId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照是app和stream获取代理流
|
||||
@@ -449,7 +501,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StreamProxyDto queryStreamProxy(String app, String stream){
|
||||
public StreamProxyItem queryStreamProxy(String app, String stream){
|
||||
return streamProxyMapper.selectOne(app, stream);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user