优化设备列表查询,支持搜索。支持获取流信息

结构优化
648540858 2023-12-25 17:50:37 +08:00
parent 8b9bac5cb3
commit 746cd2543d
14 changed files with 410 additions and 18 deletions

View File

@ -17,10 +17,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.dto.HookType; import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy;
import com.genersoft.iot.vmp.media.zlm.dto.hook.*; import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
@ -355,7 +352,7 @@ public class ZLMHttpHookListener {
subscribe.response(mediaInfo, param); subscribe.response(mediaInfo, param);
} }
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks(); List<StreamMediaTrack> tracks = param.getTracks();
// TODO 重构此处逻辑 // TODO 重构此处逻辑
boolean isPush = false; boolean isPush = false;
if (param.isRegist()) { if (param.isRegist()) {

View File

@ -0,0 +1,61 @@
package com.genersoft.iot.vmp.media.zlm.dto;
import java.util.List;
public class StreamMediaInfo {
private Boolean online;
private Integer readerCount;
private Integer totalReaderCount;
private Integer bytesSpeed;
private Integer aliveSecond;
private List<StreamMediaTrack> tracks;
public Boolean getOnline() {
return online;
}
public void setOnline(Boolean online) {
this.online = online;
}
public Integer getReaderCount() {
return readerCount;
}
public void setReaderCount(Integer readerCount) {
this.readerCount = readerCount;
}
public Integer getTotalReaderCount() {
return totalReaderCount;
}
public void setTotalReaderCount(Integer totalReaderCount) {
this.totalReaderCount = totalReaderCount;
}
public Integer getBytesSpeed() {
return bytesSpeed;
}
public void setBytesSpeed(Integer bytesSpeed) {
this.bytesSpeed = bytesSpeed;
}
public Integer getAliveSecond() {
return aliveSecond;
}
public void setAliveSecond(Integer aliveSecond) {
this.aliveSecond = aliveSecond;
}
public List<StreamMediaTrack> getTracks() {
return tracks;
}
public void setTracks(List<StreamMediaTrack> tracks) {
this.tracks = tracks;
}
}

View File

@ -0,0 +1,200 @@
package com.genersoft.iot.vmp.media.zlm.dto;
public class StreamMediaTrack {
/**
*
*/
private Integer channels;
/**
* H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4
*/
private Integer codec_id;
/**
* CodecAAC CodecH264
*/
private String codec_id_name;
/**
* Video = 0, Audio = 1
*/
private Integer codec_type;
/**
*
*/
private Boolean ready;
/**
*
*/
private Integer sample_bit;
/**
*
*/
private Integer sample_rate;
/**
* fps
*/
private Float fps;
/**
*
*/
private Integer height;
/**
*
*/
private Integer width;
/**
*
*/
private Integer frames;
/**
*
*/
private Integer key_frames;
/**
* GOP
*/
private Integer gop_size;
/**
* GOP(ms)
*/
private Integer gop_interval_ms;
/**
*
*/
private Float loss;
public Integer getChannels() {
return channels;
}
public void setChannels(Integer channels) {
this.channels = channels;
}
public Integer getCodec_id() {
return codec_id;
}
public void setCodec_id(Integer codec_id) {
this.codec_id = codec_id;
}
public String getCodec_id_name() {
return codec_id_name;
}
public void setCodec_id_name(String codec_id_name) {
this.codec_id_name = codec_id_name;
}
public Integer getCodec_type() {
return codec_type;
}
public void setCodec_type(Integer codec_type) {
this.codec_type = codec_type;
}
public Boolean getReady() {
return ready;
}
public void setReady(Boolean ready) {
this.ready = ready;
}
public Integer getSample_bit() {
return sample_bit;
}
public void setSample_bit(Integer sample_bit) {
this.sample_bit = sample_bit;
}
public Integer getSample_rate() {
return sample_rate;
}
public void setSample_rate(Integer sample_rate) {
this.sample_rate = sample_rate;
}
public Float getFps() {
return fps;
}
public void setFps(Float fps) {
this.fps = fps;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getFrames() {
return frames;
}
public void setFrames(Integer frames) {
this.frames = frames;
}
public Integer getKey_frames() {
return key_frames;
}
public void setKey_frames(Integer key_frames) {
this.key_frames = key_frames;
}
public Integer getGop_size() {
return gop_size;
}
public void setGop_size(Integer gop_size) {
this.gop_size = gop_size;
}
public Integer getGop_interval_ms() {
return gop_interval_ms;
}
public void setGop_interval_ms(Integer gop_interval_ms) {
this.gop_interval_ms = gop_interval_ms;
}
public Float getLoss() {
return loss;
}
public void setLoss(Float loss) {
this.loss = loss;
}
}

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook; package com.genersoft.iot.vmp.media.zlm.dto.hook;
import com.genersoft.iot.vmp.media.zlm.dto.StreamMediaTrack;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import java.util.List; import java.util.List;
@ -91,7 +92,7 @@ public class OnStreamChangedHookParam extends HookParam{
/** /**
* *
*/ */
private List<MediaTrack> tracks; private List<StreamMediaTrack> tracks;
/** /**
* *
@ -424,11 +425,11 @@ public class OnStreamChangedHookParam extends HookParam{
this.aliveSecond = aliveSecond; this.aliveSecond = aliveSecond;
} }
public List<MediaTrack> getTracks() { public List<StreamMediaTrack> getTracks() {
return tracks; return tracks;
} }
public void setTracks(List<MediaTrack> tracks) { public void setTracks(List<StreamMediaTrack> tracks) {
this.tracks = tracks; this.tracks = tracks;
} }

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree; import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.github.pagehelper.PageInfo;
import java.util.List; import java.util.List;
@ -168,4 +169,9 @@ public interface IDeviceService {
* *
*/ */
List<Device> getAll(); List<Device> getAll();
/**
* /
*/
PageInfo<Device> getDeviceList(int page, int count, String searchStr, Boolean online);
} }

View File

@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.common.CommonCallback;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
import com.genersoft.iot.vmp.media.zlm.dto.StreamMediaInfo;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.vmanager.bean.RecordFile; import com.genersoft.iot.vmp.vmanager.bean.RecordFile;
@ -104,4 +105,9 @@ public interface IMediaServerService {
* *
*/ */
List<String> getRecordDates(String app, String stream, int year, int month, List<MediaServerItem> mediaServerItems); List<String> getRecordDates(String app, String stream, int year, int month, List<MediaServerItem> mediaServerItems);
/**
*
*/
StreamMediaInfo getMediaInfo(String mediaServerId, String app, String stream);
} }

View File

@ -509,7 +509,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
} }
// 对于只发送了行政区划编号,没有发送行政区划的情况进行兼容,自动为通道创建一个行政区划。 // 对于只发送了行政区划编号,没有发送行政区划的情况进行兼容,自动为通道创建一个行政区划。
for (String civilCode : civilCodeSet) { for (String civilCode : civilCodeSet) {
if (!regionMap.containsKey(civilCode)) { if (civilCode != null && !regionMap.containsKey(civilCode)) {
logger.warn("[通道信息中缺少地区信息]补充地区信息 civilCode {}", civilCode ); logger.warn("[通道信息中缺少地区信息]补充地区信息 civilCode {}", civilCode );
if (civilCode.length() == 8) { if (civilCode.length() == 8) {
Region parentRegion = civilCodeFileConf.createRegion(civilCode.substring(0, 6)); Region parentRegion = civilCodeFileConf.createRegion(civilCode.substring(0, 6));
@ -586,11 +586,13 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
addCommonChannelList.stream().forEach(commonGbChannel ->{ addCommonChannelList.stream().forEach(commonGbChannel ->{
commonChannelDeviceAndIdMap.put(commonGbChannel.getCommonGbDeviceID(), commonGbChannel.getCommonGbId()); commonChannelDeviceAndIdMap.put(commonGbChannel.getCommonGbDeviceID(), commonGbChannel.getCommonGbId());
}); });
if (!addChannelList.isEmpty()) {
addChannelList.stream().forEach(channel ->{ addChannelList.stream().forEach(channel ->{
channel.setCommonGbChannelId(commonChannelDeviceAndIdMap.get(channel.getChannelId())); channel.setCommonGbChannelId(commonChannelDeviceAndIdMap.get(channel.getChannelId()));
}); });
addChannelHandler(addChannelList); addChannelHandler(addChannelList);
} }
}
if (!updateChannelList.isEmpty()) { if (!updateChannelList.isEmpty()) {
commonGbChannelService.batchUpdate(updateCommonChannelList); commonGbChannelService.batchUpdate(updateCommonChannelList);
updateChannelHandler(updateChannelList); updateChannelHandler(updateChannelList);

View File

@ -13,12 +13,15 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.Group;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree; import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -594,5 +597,10 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceMapper.getAll(); return deviceMapper.getAll();
} }
@Override
public PageInfo<Device> getDeviceList(int page, int count, String searchStr, Boolean online) {
PageHelper.startPage(page, count);
List<Device> deviceList = deviceMapper.getDeviceList(searchStr, online);
return new PageInfo<>(deviceList);
}
} }

View File

@ -14,6 +14,8 @@ import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
import com.genersoft.iot.vmp.media.zlm.*; import com.genersoft.iot.vmp.media.zlm.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
import com.genersoft.iot.vmp.media.zlm.dto.StreamMediaInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamMediaTrack;
import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
@ -848,4 +850,48 @@ public class MediaServerServiceImpl implements IMediaServerService {
} }
return CompletableFuture.completedFuture(new ArrayList<>()); return CompletableFuture.completedFuture(new ArrayList<>());
} }
@Override
public StreamMediaInfo getMediaInfo(String mediaServerId, String app, String stream) {
MediaServerItem mediaServerItem = getOne(mediaServerId);
if (mediaServerItem == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体节点");
}
JSONObject mediaInfoJson = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtsp", stream);
if (mediaInfoJson == null || mediaInfoJson.getInteger("code") != 0) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), mediaInfoJson == null?"获取信息失败":mediaInfoJson.getString("msg"));
}
StreamMediaInfo streamMediaInfo = new StreamMediaInfo();
streamMediaInfo.setOnline(mediaInfoJson.getBoolean("online"));
streamMediaInfo.setTotalReaderCount(mediaInfoJson.getInteger("totalReaderCount"));
streamMediaInfo.setAliveSecond(mediaInfoJson.getInteger("aliveSecond"));
streamMediaInfo.setBytesSpeed(mediaInfoJson.getInteger("bytesSpeed"));
JSONArray tracks = mediaInfoJson.getJSONArray("tracks");
if (!tracks.isEmpty()) {
for (int i = 0; i < tracks.size(); i++) {
JSONObject tracksJson = tracks.getJSONObject(i);
StreamMediaTrack streamMediaTrack = new StreamMediaTrack();
streamMediaTrack.setChannels(tracksJson.getInteger("channels"));
streamMediaTrack.setCodec_id(tracksJson.getInteger("codec_id"));
streamMediaTrack.setCodec_id_name(tracksJson.getString("codec_id_name"));
streamMediaTrack.setCodec_type(tracksJson.getInteger("codec_type"));
streamMediaTrack.setReady(tracksJson.getBoolean("ready"));
streamMediaTrack.setSample_bit(tracksJson.getInteger("sample_bit"));
streamMediaTrack.setSample_rate(tracksJson.getInteger("sample_rate"));
streamMediaTrack.setFps(tracksJson.getFloat("fps"));
streamMediaTrack.setHeight(tracksJson.getInteger("height"));
streamMediaTrack.setWidth(tracksJson.getInteger("width"));
streamMediaTrack.setLoss(tracksJson.getFloat("loss"));
streamMediaTrack.setKey_frames(tracksJson.getInteger("key_frames"));
streamMediaTrack.setGop_size(tracksJson.getInteger("gop_size"));
streamMediaTrack.setGop_interval_ms(tracksJson.getInteger("gop_interval_ms"));
if (streamMediaInfo.getTracks() == null) {
streamMediaInfo.setTracks(new ArrayList<>());
}
streamMediaInfo.getTracks().add(streamMediaTrack);
}
}
return streamMediaInfo;
}
} }

View File

@ -291,4 +291,44 @@ public interface DeviceMapper {
@Select("select * FROM wvp_device where as_message_channel = true") @Select("select * FROM wvp_device where as_message_channel = true")
List<Device> queryDeviceWithAsMessageChannel(); List<Device> queryDeviceWithAsMessageChannel();
@Select(" <script>" +
"SELECT " +
"device_id, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"stream_mode," +
"ip,"+
"sdp_ip,"+
"local_ip,"+
"port,"+
"host_address,"+
"expires,"+
"register_time,"+
"keepalive_time,"+
"create_time,"+
"update_time,"+
"charset,"+
"subscribe_cycle_for_catalog,"+
"subscribe_cycle_for_mobile_position,"+
"mobile_position_submission_interval,"+
"subscribe_cycle_for_alarm,"+
"ssrc_check,"+
"as_message_channel,"+
"geo_coord_sys,"+
"on_line,"+
"media_server_id,"+
"switch_primary_sub_stream switchPrimarySubStream, "+
"(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_id = de.device_id) as channel_count " +
" FROM wvp_device de" +
" where 1= 1 "+
" <if test='online != null'> AND de.on_line=${online}</if>"+
" <if test='query != null'> AND (de.device_id LIKE '%${query}%' OR de.name LIKE '%${query}%' OR de.custom_name LIKE '%${query}%')</if> " +
" order by create_time desc "+
" </script>")
List<Device> getDeviceList(@Param("query") String query, @Param("online") Boolean online);
} }

View File

@ -105,11 +105,25 @@ public class DeviceQuery {
@GetMapping("/devices") @GetMapping("/devices")
@Options() @Options()
public PageInfo<Device> devices(int page, int count){ public PageInfo<Device> devices(int page, int count){
// if (page == null) page = 0;
// if (count == null) count = 20;
return storager.queryVideoDeviceList(page, count,null); return storager.queryVideoDeviceList(page, count,null);
} }
/**
*
* @param page
* @param count
* @return
*/
@Operation(summary = "分页查询国标设备")
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页查询数量", required = true)
@GetMapping("/device/list")
@Options()
public PageInfo<Device> getDeviceList(int page, int count, String query, Boolean online){
return deviceService.getDeviceList(page, count, query, online);
}
/** /**
* *
* *

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.server;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.common.VersionPo; import com.genersoft.iot.vmp.common.VersionPo;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
@ -12,6 +13,7 @@ import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamMediaInfo;
import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@ -266,4 +268,14 @@ public class ServerController {
return result; return result;
} }
@GetMapping(value = "/media_server/getMediaInfo")
@ResponseBody
@Operation(summary = "获取流信息")
public StreamMediaInfo getMediaInfo(@RequestParam(required = false) String mediaServerId, String app, String stream) {
if (ObjectUtils.isEmpty(mediaServerId)) {
mediaServerId = mediaServerService.getDefaultMediaServer().getId();
}
return mediaServerService.getMediaInfo(mediaServerId, app, stream);
}
} }

View File

@ -80,7 +80,6 @@ export default {
webrtcPlayer.close(); webrtcPlayer.close();
webrtcPlayer = null; webrtcPlayer = null;
} }
}, },
eventcallbacK: function(type, message) { eventcallbacK: function(type, message) {
console.log("player 事件回调") console.log("player 事件回调")