优化流变化处理位置
parent
c6dfb63f8f
commit
cad5f97c2f
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||||
|
import com.genersoft.iot.vmp.media.event.MediaArrivalEvent;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
||||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
@ -151,7 +152,7 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
|
||||||
- DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(streamPushItem.getCreateTime())).intValue();
|
- DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(streamPushItem.getCreateTime())).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamPushItem instance(StreamInfo streamInfo) {
|
public StreamPushItem getInstance(StreamInfo streamInfo) {
|
||||||
StreamPushItem streamPushItem = new StreamPushItem();
|
StreamPushItem streamPushItem = new StreamPushItem();
|
||||||
streamPushItem.setApp(streamInfo.getApp());
|
streamPushItem.setApp(streamInfo.getApp());
|
||||||
streamPushItem.setMediaServerId(streamInfo.getMediaServerId());
|
streamPushItem.setMediaServerId(streamInfo.getMediaServerId());
|
||||||
|
@ -172,6 +173,26 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StreamPushItem getInstance(MediaArrivalEvent event, String serverId){
|
||||||
|
StreamPushItem streamPushItem = new StreamPushItem();
|
||||||
|
streamPushItem.setApp(event.getApp());
|
||||||
|
streamPushItem.setMediaServerId(event.getMediaServer().getId());
|
||||||
|
streamPushItem.setStream(event.getStream());
|
||||||
|
streamPushItem.setAliveSecond(event.getMediaInfo().getAliveSecond());
|
||||||
|
// streamPushItem.setOriginSock(streamInfo.getMediaInfo().getOriginSock());
|
||||||
|
streamPushItem.setTotalReaderCount(event.getMediaInfo().getReaderCount() + "");
|
||||||
|
streamPushItem.setOriginType(event.getMediaInfo().getOriginType());
|
||||||
|
// streamPushItem.setOriginTypeStr(streamInfo.getMediaInfo().getOriginTypeStr());
|
||||||
|
// streamPushItem.setOriginUrl(streamInfo.getMediaInfo().getOriginUrl());
|
||||||
|
streamPushItem.setCreateTime(DateUtil.getNow());
|
||||||
|
streamPushItem.setAliveSecond(event.getMediaInfo().getAliveSecond());
|
||||||
|
streamPushItem.setStatus(true);
|
||||||
|
streamPushItem.setStreamType("push");
|
||||||
|
// streamPushItem.setVhost(streamInfo.getVhost());
|
||||||
|
streamPushItem.setServerId(serverId);
|
||||||
|
return streamPushItem;
|
||||||
|
}
|
||||||
|
|
||||||
public static class MediaSchema {
|
public static class MediaSchema {
|
||||||
private String schema;
|
private String schema;
|
||||||
private Long bytesSpeed;
|
private Long bytesSpeed;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||||
import com.genersoft.iot.vmp.media.event.MediaArrivalEvent;
|
import com.genersoft.iot.vmp.media.event.MediaArrivalEvent;
|
||||||
import com.genersoft.iot.vmp.media.event.MediaDepartureEvent;
|
import com.genersoft.iot.vmp.media.event.MediaDepartureEvent;
|
||||||
import com.genersoft.iot.vmp.media.event.MediaServerChangeEvent;
|
|
||||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServer;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||||
|
@ -114,8 +113,30 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||||
streamAuthorityInfo.setOriginType(mediaInfo.getOriginType());
|
streamAuthorityInfo.setOriginType(mediaInfo.getOriginType());
|
||||||
}
|
}
|
||||||
redisCatchStorage.updateStreamAuthorityInfo(event.getApp(), event.getStream(), streamAuthorityInfo);
|
redisCatchStorage.updateStreamAuthorityInfo(event.getApp(), event.getStream(), streamAuthorityInfo);
|
||||||
|
StreamPushItem transform = StreamPushItem.getInstance(event, userSetting.getServerId());
|
||||||
|
transform.setPushIng(true);
|
||||||
|
transform.setUpdateTime(DateUtil.getNow());
|
||||||
|
transform.setPushTime(DateUtil.getNow());
|
||||||
|
transform.setSelf(true);
|
||||||
|
StreamPushItem pushInDb = getPush(event.getApp(), event.getStream());
|
||||||
|
if (pushInDb == null) {
|
||||||
|
transform.setCreateTime(DateUtil.getNow());
|
||||||
|
streamPushMapper.add(transform);
|
||||||
|
}else {
|
||||||
|
streamPushMapper.update(transform);
|
||||||
|
gbStreamMapper.updateMediaServer(event.getApp(), event.getStream(), event.getMediaServer().getId());
|
||||||
|
}
|
||||||
|
// ChannelOnlineEvent channelOnlineEventLister = getChannelOnlineEventLister(transform.getApp(), transform.getStream());
|
||||||
|
// if ( channelOnlineEventLister != null) {
|
||||||
|
// try {
|
||||||
|
// channelOnlineEventLister.run(transform.getApp(), transform.getStream(), transform.getServerId());;
|
||||||
|
// } catch (ParseException e) {
|
||||||
|
// logger.error("addPush: ", e);
|
||||||
|
// }
|
||||||
|
// removedChannelOnlineEventLister(transform.getApp(), transform.getStream());
|
||||||
|
// }
|
||||||
|
// 冗余数据,自己系统中自用
|
||||||
|
redisCatchStorage.addPushListItem(event.getApp(), event.getStream(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +162,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||||
String key = streamInfo.getApp() + "_" + streamInfo.getStream();
|
String key = streamInfo.getApp() + "_" + streamInfo.getStream();
|
||||||
StreamPushItem streamPushItem = result.get(key);
|
StreamPushItem streamPushItem = result.get(key);
|
||||||
if (streamPushItem == null) {
|
if (streamPushItem == null) {
|
||||||
streamPushItem = streamPushItem.instance(streamInfo);
|
streamPushItem = streamPushItem.getInstance(streamInfo);
|
||||||
result.put(key, streamPushItem);
|
result.put(key, streamPushItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue