Commit 963a74d2809d92384f6666cfe10fc84423d89555
Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
Showing
5 changed files
with
49 additions
and
20 deletions
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
| @@ -10,7 +10,7 @@ public class VideoManagerConstants { | @@ -10,7 +10,7 @@ public class VideoManagerConstants { | ||
| 10 | 10 | ||
| 11 | public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_"; | 11 | public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_"; |
| 12 | 12 | ||
| 13 | - public static final String WVP_SERVER_STREAM_PUSH_PREFIX = "VMP_SIGNALLING_STREAM_PUSH_"; | 13 | + public static final String WVP_SERVER_STREAM_PUSH_PREFIX = "VMP_SIGNALLING_STREAM_"; |
| 14 | 14 | ||
| 15 | public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_"; | 15 | public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_"; |
| 16 | 16 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.conf.UserSetup; | @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.conf.UserSetup; | ||
| 11 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 11 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 14 | +import com.genersoft.iot.vmp.media.zlm.dto.OriginType; | ||
| 14 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 15 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 15 | import com.genersoft.iot.vmp.service.IMediaServerService; | 16 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 16 | import com.genersoft.iot.vmp.service.IMediaService; | 17 | import com.genersoft.iot.vmp.service.IMediaService; |
| @@ -315,24 +316,23 @@ public class ZLMHttpHookListener { | @@ -315,24 +316,23 @@ public class ZLMHttpHookListener { | ||
| 315 | }else { | 316 | }else { |
| 316 | if (!"rtp".equals(app)){ | 317 | if (!"rtp".equals(app)){ |
| 317 | 318 | ||
| 318 | - boolean pushChange = false; | ||
| 319 | - | ||
| 320 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | 319 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| 321 | if (regist) { | 320 | if (regist) { |
| 322 | - if ((item.getOriginType() == 1 || item.getOriginType() == 2 || item.getOriginType() == 8)) { | ||
| 323 | - pushChange = true; | 321 | + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, streamId, tracks); |
| 322 | + redisCatchStorage.addStream(mediaServerItem, OriginType.values()[item.getOriginType()].getType(), app, streamId, streamInfo); | ||
| 323 | + if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() | ||
| 324 | + || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() | ||
| 325 | + || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | ||
| 324 | zlmMediaListManager.addMedia(item); | 326 | zlmMediaListManager.addMedia(item); |
| 325 | - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, streamId, tracks); | ||
| 326 | - redisCatchStorage.addPushStream(mediaServerItem, app, streamId, streamInfo); | ||
| 327 | } | 327 | } |
| 328 | }else { | 328 | }else { |
| 329 | - int result = zlmMediaListManager.removeMedia( app, streamId); | ||
| 330 | - redisCatchStorage.removePushStream(mediaServerItem, app, streamId); | ||
| 331 | - if (result > 0) { | ||
| 332 | - pushChange = true; | ||
| 333 | - } | 329 | + zlmMediaListManager.removeMedia( app, streamId); |
| 330 | + redisCatchStorage.removeStream(mediaServerItem, OriginType.values()[item.getOriginType()].getType(), app, streamId); | ||
| 331 | + | ||
| 334 | } | 332 | } |
| 335 | - if(pushChange) { | 333 | + if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| 334 | + || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() | ||
| 335 | + || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | ||
| 336 | // 发送流变化redis消息 | 336 | // 发送流变化redis消息 |
| 337 | JSONObject jsonObject = new JSONObject(); | 337 | JSONObject jsonObject = new JSONObject(); |
| 338 | jsonObject.put("serverId", userSetup.getServerId()); | 338 | jsonObject.put("serverId", userSetup.getServerId()); |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/OriginType.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto; | ||
| 2 | + | ||
| 3 | +public enum OriginType { | ||
| 4 | + UNKNOWN("UNKNOWN"), | ||
| 5 | + RTMP_PUSH("PUSH"), | ||
| 6 | + RTSP_PUSH("PUSH"), | ||
| 7 | + RTP_PUSH("RTP"), | ||
| 8 | + RTC_PUSH("PUSH"), | ||
| 9 | + PULL("PULL"), | ||
| 10 | + FFMPEG_PULL("PULL"), | ||
| 11 | + MP4_VOD("MP4_VOD"), | ||
| 12 | + DEVICE_CHN("DEVICE_CHN"); | ||
| 13 | + | ||
| 14 | + private final String type; | ||
| 15 | + OriginType(String type) { | ||
| 16 | + this.type = type; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public String getType() { | ||
| 20 | + return type; | ||
| 21 | + } | ||
| 22 | +} |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| @@ -135,7 +135,7 @@ public interface IRedisCatchStorage { | @@ -135,7 +135,7 @@ public interface IRedisCatchStorage { | ||
| 135 | * @param app | 135 | * @param app |
| 136 | * @param streamId | 136 | * @param streamId |
| 137 | */ | 137 | */ |
| 138 | - void addPushStream(MediaServerItem mediaServerItem, String app, String streamId, StreamInfo streamInfo); | 138 | + void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, StreamInfo streamInfo); |
| 139 | 139 | ||
| 140 | /** | 140 | /** |
| 141 | * 移除流信息从redis | 141 | * 移除流信息从redis |
| @@ -143,7 +143,7 @@ public interface IRedisCatchStorage { | @@ -143,7 +143,7 @@ public interface IRedisCatchStorage { | ||
| 143 | * @param app | 143 | * @param app |
| 144 | * @param streamId | 144 | * @param streamId |
| 145 | */ | 145 | */ |
| 146 | - void removePushStream(MediaServerItem mediaServerItem, String app, String streamId); | 146 | + void removeStream(MediaServerItem mediaServerItem, String type, String app, String streamId); |
| 147 | 147 | ||
| 148 | /** | 148 | /** |
| 149 | * 开始下载录像时存入 | 149 | * 开始下载录像时存入 |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.impl; | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.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.common.VideoManagerConstants; | 5 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 6 | +import com.genersoft.iot.vmp.conf.UserSetup; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 8 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| @@ -24,6 +25,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -24,6 +25,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 24 | @Autowired | 25 | @Autowired |
| 25 | private DeviceChannelMapper deviceChannelMapper; | 26 | private DeviceChannelMapper deviceChannelMapper; |
| 26 | 27 | ||
| 28 | + @Autowired | ||
| 29 | + private UserSetup userSetup; | ||
| 30 | + | ||
| 27 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 31 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 28 | 32 | ||
| 29 | /** | 33 | /** |
| @@ -313,15 +317,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -313,15 +317,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 313 | } | 317 | } |
| 314 | 318 | ||
| 315 | @Override | 319 | @Override |
| 316 | - public void addPushStream(MediaServerItem mediaServerItem, String app, String streamId, StreamInfo streamInfo) { | ||
| 317 | - String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + app + "_" + streamId + "_" + mediaServerItem.getId(); | 320 | + public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, StreamInfo streamInfo) { |
| 321 | + String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + userSetup.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); | ||
| 318 | redis.set(key, streamInfo); | 322 | redis.set(key, streamInfo); |
| 319 | } | 323 | } |
| 320 | 324 | ||
| 321 | @Override | 325 | @Override |
| 322 | - public void removePushStream(MediaServerItem mediaServerItem, String app, String streamId) { | ||
| 323 | - String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + app + "_" + streamId + "_" + mediaServerItem.getId(); | ||
| 324 | - redis.del(key); | 326 | + public void removeStream(MediaServerItem mediaServerItem, String type, String app, String streamId) { |
| 327 | + String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + userSetup.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerItem.getId(); | ||
| 328 | + List<Object> streams = redis.scan(key); | ||
| 329 | + for (Object stream : streams) { | ||
| 330 | + redis.del((String) stream); | ||
| 331 | + } | ||
| 325 | } | 332 | } |
| 326 | 333 | ||
| 327 | @Override | 334 | @Override |