合并271分支

pull/1524/head
648540858 2024-06-25 10:24:35 +08:00
parent 57a230afb3
commit 87c071fd5e
6 changed files with 47 additions and 26 deletions

View File

@ -27,6 +27,7 @@ import com.genersoft.iot.vmp.media.event.hook.HookType;
import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 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.StreamPushItem;
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.IStreamPushService;
@ -593,12 +594,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
sendRtpItem.setPlayType(InviteStreamType.PUSH); sendRtpItem.setPlayType(InviteStreamType.PUSH);
if (streamPushItem != null) { if (streamPushItem != null) {
// 从redis查询是否正在接收这个推流 // 从redis查询是否正在接收这个推流
StreamPushItem pushListItem = redisCatchStorage.getPushListItem(gbStream.getApp(), gbStream.getStream()); OnStreamChangedHookParam pushListItem = redisCatchStorage.getPushListItem(gbStream.getApp(), gbStream.getStream());
if (pushListItem != null) { if (pushListItem != null) {
sendRtpItem.setServerId(pushListItem.getServerId()); sendRtpItem.setServerId(pushListItem.getSeverId());
sendRtpItem.setMediaServerId(pushListItem.getMediaServerId()); sendRtpItem.setMediaServerId(pushListItem.getMediaServerId());
pushListItem.setSelf(userSetting.getServerId().equals(pushListItem.getServerId()));
redisCatchStorage.updateSendRTPSever(sendRtpItem); redisCatchStorage.updateSendRTPSever(sendRtpItem);
// 开始推流 // 开始推流
sendPushStream(sendRtpItem, mediaServerItem, platform, request); sendPushStream(sendRtpItem, mediaServerItem, platform, request);

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.media.event.media;
import com.genersoft.iot.vmp.media.bean.MediaInfo; import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
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.vmanager.bean.StreamContent;
/** /**
* *
@ -19,7 +20,8 @@ public class MediaArrivalEvent extends MediaEvent {
mediaArrivalEvent.setStream(hookParam.getStream()); mediaArrivalEvent.setStream(hookParam.getStream());
mediaArrivalEvent.setMediaServer(mediaServer); mediaArrivalEvent.setMediaServer(mediaServer);
mediaArrivalEvent.setSchema(hookParam.getSchema()); mediaArrivalEvent.setSchema(hookParam.getSchema());
mediaArrivalEvent.setCallId(hookParam.getCallId()); mediaArrivalEvent.setSchema(hookParam.getSchema());
mediaArrivalEvent.setHookParam(hookParam);
return mediaArrivalEvent; return mediaArrivalEvent;
} }
@ -27,6 +29,10 @@ public class MediaArrivalEvent extends MediaEvent {
private String callId; private String callId;
private OnStreamChangedHookParam hookParam;
private StreamContent streamInfo;
public MediaInfo getMediaInfo() { public MediaInfo getMediaInfo() {
return mediaInfo; return mediaInfo;
} }
@ -43,4 +49,20 @@ public class MediaArrivalEvent extends MediaEvent {
public void setCallId(String callId) { public void setCallId(String callId) {
this.callId = callId; this.callId = callId;
} }
public OnStreamChangedHookParam getHookParam() {
return hookParam;
}
public void setHookParam(OnStreamChangedHookParam hookParam) {
this.hookParam = hookParam;
}
public StreamContent getStreamInfo() {
return streamInfo;
}
public void setStreamInfo(StreamContent streamInfo) {
this.streamInfo = streamInfo;
}
} }

View File

@ -809,6 +809,13 @@ public class MediaServerServiceImpl implements IMediaServerService {
streamInfoResult.setRtc(addr, mediaServer.getHttpPort(),mediaServer.getHttpSSlPort(), app, stream, callIdParam, isPlay); streamInfoResult.setRtc(addr, mediaServer.getHttpPort(),mediaServer.getHttpSSlPort(), app, stream, callIdParam, isPlay);
streamInfoResult.setMediaInfo(mediaInfo); streamInfoResult.setMediaInfo(mediaInfo);
if (!"broadcast".equalsIgnoreCase(app) && !ObjectUtils.isEmpty(mediaServer.getTranscodeSuffix()) && !"null".equalsIgnoreCase(mediaServer.getTranscodeSuffix())) {
String newStream = stream + "_" + mediaServer.getTranscodeSuffix();
mediaServer.setTranscodeSuffix(null);
StreamInfo transcodeStreamInfo = getStreamInfoByAppAndStream(mediaServer, app, newStream, null, addr, callId, isPlay);
streamInfoResult.setTranscodeStream(transcodeStreamInfo);
}
return streamInfoResult; return streamInfoResult;
} }

View File

@ -26,6 +26,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -126,18 +127,13 @@ public class StreamPushServiceImpl implements IStreamPushService {
streamPushMapper.update(transform); streamPushMapper.update(transform);
gbStreamMapper.updateMediaServer(event.getApp(), event.getStream(), event.getMediaServer().getId()); gbStreamMapper.updateMediaServer(event.getApp(), event.getStream(), event.getMediaServer().getId());
} }
// TODO 相关的事件自行管理不需要写入ZLMMediaListManager
// 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); if (!"broadcast".equals(event.getApp()) && !"talk".equals(event.getApp())) {
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(
event.getMediaServer(), event.getApp(), event.getStream(), event.getMediaInfo(), event.getCallId());
event.getHookParam().setStreamInfo(new StreamContent(streamInfo));
redisCatchStorage.addPushListItem(event.getApp(), event.getStream(), event);
}
// 发送流变化redis消息 // 发送流变化redis消息
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();

View File

@ -7,7 +7,7 @@ import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
@ -216,7 +216,7 @@ public interface IRedisCatchStorage {
void addPushListItem(String app, String stream, MediaArrivalEvent param); void addPushListItem(String app, String stream, MediaArrivalEvent param);
StreamPushItem getPushListItem(String app, String stream); OnStreamChangedHookParam getPushListItem(String app, String stream);
void removePushListItem(String app, String stream, String mediaServerId); void removePushListItem(String app, String stream, String mediaServerId);

View File

@ -5,16 +5,13 @@ import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.media.bean.MediaInfo; import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@ -698,14 +695,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override @Override
public void addPushListItem(String app, String stream, MediaArrivalEvent event) { public void addPushListItem(String app, String stream, MediaArrivalEvent event) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream; String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
StreamPushItem streamPushItem = StreamPushItem.getInstance(event, userSetting.getServerId()); redisTemplate.opsForValue().set(key, event.getHookParam());
redisTemplate.opsForValue().set(key, streamPushItem);
} }
@Override @Override
public StreamPushItem getPushListItem(String app, String stream) { public OnStreamChangedHookParam getPushListItem(String app, String stream) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream; String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
return (StreamPushItem)redisTemplate.opsForValue().get(key); return (OnStreamChangedHookParam)redisTemplate.opsForValue().get(key);
} }
@Override @Override