支持国标移动位置订阅,收到新位置发送redis消息;支持通道redis消息拉起第三方推流;云台控制添加ControlPriority字段;处理sql的bug
This commit is contained in:
@@ -2,12 +2,10 @@ package com.genersoft.iot.vmp.media.zlm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.MediaConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetup;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
@@ -17,9 +15,8 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -54,7 +51,7 @@ public class ZLMHttpHookListener {
|
||||
private IPlayService playService;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
@@ -81,7 +78,7 @@ public class ZLMHttpHookListener {
|
||||
private ZLMHttpHookSubscribe subscribe;
|
||||
|
||||
@Autowired
|
||||
private UserSetup userSetup;
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager sessionManager;
|
||||
@@ -189,6 +186,12 @@ public class ZLMHttpHookListener {
|
||||
ret.put("code", 0);
|
||||
ret.put("msg", "success");
|
||||
ret.put("enable_hls", true);
|
||||
if (json.getInteger("originType") == 1
|
||||
|| json.getInteger("originType") == 2
|
||||
|| json.getInteger("originType") == 3) {
|
||||
ret.put("enable_audio", true);
|
||||
}
|
||||
|
||||
String mediaServerId = json.getString("mediaServerId");
|
||||
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
||||
if (subscribe != null) {
|
||||
@@ -203,9 +206,9 @@ public class ZLMHttpHookListener {
|
||||
String app = json.getString("app");
|
||||
String stream = json.getString("stream");
|
||||
if ("rtp".equals(app)) {
|
||||
ret.put("enable_mp4", userSetup.getRecordSip());
|
||||
ret.put("enable_mp4", userSetting.getRecordSip());
|
||||
}else {
|
||||
ret.put("enable_mp4", userSetup.isRecordPushLive());
|
||||
ret.put("enable_mp4", userSetting.isRecordPushLive());
|
||||
}
|
||||
List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream);
|
||||
if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
|
||||
@@ -412,7 +415,7 @@ public class ZLMHttpHookListener {
|
||||
if (type != null) {
|
||||
// 发送流变化redis消息
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("serverId", userSetup.getServerId());
|
||||
jsonObject.put("serverId", userSetting.getServerId());
|
||||
jsonObject.put("app", app);
|
||||
jsonObject.put("stream", streamId);
|
||||
jsonObject.put("register", regist);
|
||||
@@ -506,7 +509,7 @@ public class ZLMHttpHookListener {
|
||||
}
|
||||
String mediaServerId = json.getString("mediaServerId");
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
||||
if (userSetup.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) {
|
||||
if (userSetting.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) {
|
||||
String app = json.getString("app");
|
||||
String streamId = json.getString("stream");
|
||||
if ("rtp".equals(app)) {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package com.genersoft.iot.vmp.media.zlm;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.UserSetup;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.service.IStreamPushService;
|
||||
import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,6 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -37,7 +36,7 @@ public class ZLMMediaListManager {
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private GbStreamMapper gbStreamMapper;
|
||||
@@ -58,7 +57,9 @@ public class ZLMMediaListManager {
|
||||
private ZLMHttpHookSubscribe subscribe;
|
||||
|
||||
@Autowired
|
||||
private UserSetup userSetup;
|
||||
private UserSetting userSetting;
|
||||
|
||||
private Map<String, ChannelOnlineEvent> channelOnlineEvents = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void updateMediaList(MediaServerItem mediaServerItem) {
|
||||
@@ -109,7 +110,7 @@ public class ZLMMediaListManager {
|
||||
// 查找此直播流是否存在redis预设gbId
|
||||
StreamPushItem transform = streamPushService.transform(mediaItem);
|
||||
// 从streamId取出查询关键值
|
||||
Pattern pattern = Pattern.compile(userSetup.getThirdPartyGBIdReg());
|
||||
Pattern pattern = Pattern.compile(userSetting.getThirdPartyGBIdReg());
|
||||
Matcher matcher = pattern.matcher(mediaItem.getStream());// 指定要匹配的字符串
|
||||
String queryKey = null;
|
||||
if (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
|
||||
@@ -157,7 +158,15 @@ public class ZLMMediaListManager {
|
||||
transform.setCreateStamp(System.currentTimeMillis());
|
||||
gbStreamMapper.add(transform);
|
||||
}
|
||||
if (transform != null) {
|
||||
if (channelOnlineEvents.get(transform.getGbId()) != null) {
|
||||
channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream());
|
||||
channelOnlineEvents.remove(transform.getGbId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
storager.updateMedia(transform);
|
||||
return transform;
|
||||
}
|
||||
@@ -200,6 +209,14 @@ public class ZLMMediaListManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addChannelOnlineEventLister(String key, ChannelOnlineEvent callback) {
|
||||
this.channelOnlineEvents.put(key,callback);
|
||||
}
|
||||
|
||||
public void removedChannelOnlineEventLister(String key) {
|
||||
this.channelOnlineEvents.remove(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public void clearAllSessions() {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||
|
||||
public interface ChannelOnlineEvent {
|
||||
|
||||
void run(String app, String stream);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.media.zlm.event;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
|
||||
import com.genersoft.iot.vmp.conf.UserSetup;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
@@ -12,7 +12,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -33,13 +32,13 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
|
||||
private ZLMRESTfulUtils zlmresTfulUtils;
|
||||
|
||||
@Autowired
|
||||
private UserSetup userSetup;
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
|
||||
super(listenerContainer, userSetup);
|
||||
public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
|
||||
super(listenerContainer, userSetting);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +51,7 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
// 获取失效的key
|
||||
String expiredKey = message.toString();
|
||||
String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetup.getServerId() + "_";
|
||||
String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_";
|
||||
if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user