Commit 2753e1acf3cbe184b686a1e050d8cde0728cdb7f
1 parent
86cd03ce
拉流代理支持国标级联之间共享
Showing
5 changed files
with
33 additions
and
3 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -346,7 +346,7 @@ public class ZLMHttpHookListener { | @@ -346,7 +346,7 @@ public class ZLMHttpHookListener { | ||
| 346 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() | 346 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| 347 | || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() | 347 | || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() |
| 348 | || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | 348 | || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { |
| 349 | - zlmMediaListManager.addMedia(item); | 349 | + zlmMediaListManager.addPush(item); |
| 350 | } | 350 | } |
| 351 | }else { | 351 | }else { |
| 352 | // 兼容流注销时类型错误的问题,等zlm更新后删除 | 352 | // 兼容流注销时类型错误的问题,等zlm更新后删除 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | ||
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 9 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 10 | +import com.genersoft.iot.vmp.service.IStreamProxyService; | ||
| 10 | import com.genersoft.iot.vmp.service.IStreamPushService; | 11 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| 11 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; | 12 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| @@ -48,6 +49,9 @@ public class ZLMMediaListManager { | @@ -48,6 +49,9 @@ public class ZLMMediaListManager { | ||
| 48 | private IStreamPushService streamPushService; | 49 | private IStreamPushService streamPushService; |
| 49 | 50 | ||
| 50 | @Autowired | 51 | @Autowired |
| 52 | + private IStreamProxyService streamProxyService; | ||
| 53 | + | ||
| 54 | + @Autowired | ||
| 51 | private StreamPushMapper streamPushMapper; | 55 | private StreamPushMapper streamPushMapper; |
| 52 | 56 | ||
| 53 | @Autowired | 57 | @Autowired |
| @@ -101,7 +105,7 @@ public class ZLMMediaListManager { | @@ -101,7 +105,7 @@ public class ZLMMediaListManager { | ||
| 101 | updateMedia(mediaServerItem, app, streamId); | 105 | updateMedia(mediaServerItem, app, streamId); |
| 102 | } | 106 | } |
| 103 | 107 | ||
| 104 | - public void addMedia(MediaItem mediaItem) { | 108 | + public void addPush(MediaItem mediaItem) { |
| 105 | // 查找此直播流是否存在redis预设gbId | 109 | // 查找此直播流是否存在redis预设gbId |
| 106 | StreamPushItem transform = streamPushService.transform(mediaItem); | 110 | StreamPushItem transform = streamPushService.transform(mediaItem); |
| 107 | // 从streamId取出查询关键值 | 111 | // 从streamId取出查询关键值 |
| @@ -179,6 +183,8 @@ public class ZLMMediaListManager { | @@ -179,6 +183,8 @@ public class ZLMMediaListManager { | ||
| 179 | return result; | 183 | return result; |
| 180 | } | 184 | } |
| 181 | 185 | ||
| 186 | + | ||
| 187 | + | ||
| 182 | // public void clearAllSessions() { | 188 | // public void clearAllSessions() { |
| 183 | // logger.info("清空所有国标相关的session"); | 189 | // logger.info("清空所有国标相关的session"); |
| 184 | // JSONObject allSessionJSON = zlmresTfulUtils.getAllSession(); | 190 | // JSONObject allSessionJSON = zlmresTfulUtils.getAllSession(); |
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
| @@ -2,8 +2,10 @@ package com.genersoft.iot.vmp.service; | @@ -2,8 +2,10 @@ package com.genersoft.iot.vmp.service; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.genersoft.iot.vmp.common.StreamInfo; | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | ||
| 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 7 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | ||
| 7 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 9 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 8 | import com.github.pagehelper.PageInfo; | 10 | import com.github.pagehelper.PageInfo; |
| 9 | 11 |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| @@ -3,15 +3,19 @@ package com.genersoft.iot.vmp.service.impl; | @@ -3,15 +3,19 @@ package com.genersoft.iot.vmp.service.impl; | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.genersoft.iot.vmp.common.StreamInfo; | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; | 5 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 6 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ||
| 6 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 7 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | ||
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 11 | +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | ||
| 9 | import com.genersoft.iot.vmp.service.IGbStreamService; | 12 | import com.genersoft.iot.vmp.service.IGbStreamService; |
| 10 | import com.genersoft.iot.vmp.service.IMediaServerService; | 13 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 11 | import com.genersoft.iot.vmp.service.IMediaService; | 14 | import com.genersoft.iot.vmp.service.IMediaService; |
| 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 13 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 16 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 14 | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; | 17 | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| 18 | +import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; | ||
| 15 | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; | 19 | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| 16 | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; | 20 | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; |
| 17 | import com.genersoft.iot.vmp.service.IStreamProxyService; | 21 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| @@ -21,6 +25,7 @@ import org.slf4j.Logger; | @@ -21,6 +25,7 @@ import org.slf4j.Logger; | ||
| 21 | import org.slf4j.LoggerFactory; | 25 | import org.slf4j.LoggerFactory; |
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
| 28 | +import org.springframework.util.StringUtils; | ||
| 24 | 29 | ||
| 25 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
| 26 | import java.util.List; | 31 | import java.util.List; |
| @@ -52,6 +57,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -52,6 +57,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 52 | private PlatformGbStreamMapper platformGbStreamMapper; | 57 | private PlatformGbStreamMapper platformGbStreamMapper; |
| 53 | 58 | ||
| 54 | @Autowired | 59 | @Autowired |
| 60 | + private ParentPlatformMapper parentPlatformMapper; | ||
| 61 | + | ||
| 62 | + @Autowired | ||
| 55 | private IGbStreamService gbStreamService; | 63 | private IGbStreamService gbStreamService; |
| 56 | 64 | ||
| 57 | @Autowired | 65 | @Autowired |
| @@ -112,7 +120,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -112,7 +120,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 112 | }else { | 120 | }else { |
| 113 | result.append("保存失败"); | 121 | result.append("保存失败"); |
| 114 | } | 122 | } |
| 115 | - if (param.getPlatformGbId() != null && streamLive) { | 123 | + if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) { |
| 116 | List<GbStream> gbStreams = new ArrayList<>(); | 124 | List<GbStream> gbStreams = new ArrayList<>(); |
| 117 | gbStreams.add(param); | 125 | gbStreams.add(param); |
| 118 | if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId())){ | 126 | if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId())){ |
| @@ -121,6 +129,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -121,6 +129,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 121 | result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); | 129 | result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); |
| 122 | } | 130 | } |
| 123 | } | 131 | } |
| 132 | + // 查找开启了全部直播流共享的上级平台 | ||
| 133 | + List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); | ||
| 134 | + if (parentPlatforms.size() > 0) { | ||
| 135 | + for (ParentPlatform parentPlatform : parentPlatforms) { | ||
| 136 | + param.setPlatformId(parentPlatform.getServerGBId()); | ||
| 137 | + String stream = param.getStream(); | ||
| 138 | + StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); | ||
| 139 | + if (streamProxyItems == null) { | ||
| 140 | + platformGbStreamMapper.add(param); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + } | ||
| 124 | wvpResult.setMsg(result.toString()); | 144 | wvpResult.setMsg(result.toString()); |
| 125 | return wvpResult; | 145 | return wvpResult; |
| 126 | } | 146 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| @@ -514,6 +514,8 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -514,6 +514,8 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 514 | logger.error("向数据库添加流代理失败:", e); | 514 | logger.error("向数据库添加流代理失败:", e); |
| 515 | dataSourceTransactionManager.rollback(transactionStatus); | 515 | dataSourceTransactionManager.rollback(transactionStatus); |
| 516 | } | 516 | } |
| 517 | + | ||
| 518 | + | ||
| 517 | return result; | 519 | return result; |
| 518 | } | 520 | } |
| 519 | 521 |