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 | 346 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| 347 | 347 | || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() |
| 348 | 348 | || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { |
| 349 | - zlmMediaListManager.addMedia(item); | |
| 349 | + zlmMediaListManager.addPush(item); | |
| 350 | 350 | } |
| 351 | 351 | }else { |
| 352 | 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 | 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 9 | 9 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 10 | +import com.genersoft.iot.vmp.service.IStreamProxyService; | |
| 10 | 11 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| 11 | 12 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| 12 | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -48,6 +49,9 @@ public class ZLMMediaListManager { |
| 48 | 49 | private IStreamPushService streamPushService; |
| 49 | 50 | |
| 50 | 51 | @Autowired |
| 52 | + private IStreamProxyService streamProxyService; | |
| 53 | + | |
| 54 | + @Autowired | |
| 51 | 55 | private StreamPushMapper streamPushMapper; |
| 52 | 56 | |
| 53 | 57 | @Autowired |
| ... | ... | @@ -101,7 +105,7 @@ public class ZLMMediaListManager { |
| 101 | 105 | updateMedia(mediaServerItem, app, streamId); |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | - public void addMedia(MediaItem mediaItem) { | |
| 108 | + public void addPush(MediaItem mediaItem) { | |
| 105 | 109 | // 查找此直播流是否存在redis预设gbId |
| 106 | 110 | StreamPushItem transform = streamPushService.transform(mediaItem); |
| 107 | 111 | // 从streamId取出查询关键值 |
| ... | ... | @@ -179,6 +183,8 @@ public class ZLMMediaListManager { |
| 179 | 183 | return result; |
| 180 | 184 | } |
| 181 | 185 | |
| 186 | + | |
| 187 | + | |
| 182 | 188 | // public void clearAllSessions() { |
| 183 | 189 | // logger.info("清空所有国标相关的session"); |
| 184 | 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 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 5 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 7 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | |
| 7 | 9 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 8 | 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 | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 6 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 6 | 7 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 7 | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | 10 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 11 | +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; | |
| 9 | 12 | import com.genersoft.iot.vmp.service.IGbStreamService; |
| 10 | 13 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 11 | 14 | import com.genersoft.iot.vmp.service.IMediaService; |
| 12 | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 13 | 16 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 14 | 17 | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| 18 | +import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; | |
| 15 | 19 | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| 16 | 20 | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; |
| 17 | 21 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| ... | ... | @@ -21,6 +25,7 @@ import org.slf4j.Logger; |
| 21 | 25 | import org.slf4j.LoggerFactory; |
| 22 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | 27 | import org.springframework.stereotype.Service; |
| 28 | +import org.springframework.util.StringUtils; | |
| 24 | 29 | |
| 25 | 30 | import java.util.ArrayList; |
| 26 | 31 | import java.util.List; |
| ... | ... | @@ -52,6 +57,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 52 | 57 | private PlatformGbStreamMapper platformGbStreamMapper; |
| 53 | 58 | |
| 54 | 59 | @Autowired |
| 60 | + private ParentPlatformMapper parentPlatformMapper; | |
| 61 | + | |
| 62 | + @Autowired | |
| 55 | 63 | private IGbStreamService gbStreamService; |
| 56 | 64 | |
| 57 | 65 | @Autowired |
| ... | ... | @@ -112,7 +120,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 112 | 120 | }else { |
| 113 | 121 | result.append("保存失败"); |
| 114 | 122 | } |
| 115 | - if (param.getPlatformGbId() != null && streamLive) { | |
| 123 | + if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) { | |
| 116 | 124 | List<GbStream> gbStreams = new ArrayList<>(); |
| 117 | 125 | gbStreams.add(param); |
| 118 | 126 | if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId())){ |
| ... | ... | @@ -121,6 +129,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 121 | 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 | 144 | wvpResult.setMsg(result.toString()); |
| 125 | 145 | return wvpResult; |
| 126 | 146 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java