Commit b17280522b3569b49c0d524b7ed7fb45ef0e991a

Authored by panlinlin
1 parent f83a192b

增加推流转发到国标,尚不完善

Showing 42 changed files with 720 additions and 509 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
... ... @@ -12,6 +12,7 @@ public class GbStream extends PlatformGbStream{
12 12 private double longitude;
13 13 private double latitude;
14 14 private String streamType;
  15 + private boolean status;
15 16  
16 17 public String getApp() {
17 18 return app;
... ... @@ -68,4 +69,12 @@ public class GbStream extends PlatformGbStream{
68 69 public void setStreamType(String streamType) {
69 70 this.streamType = streamType;
70 71 }
  72 +
  73 + public boolean isStatus() {
  74 + return status;
  75 + }
  76 +
  77 + public void setStatus(boolean status) {
  78 + this.status = status;
  79 + }
71 80 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
... ... @@ -28,4 +28,5 @@ public class PlatformGbStream {
28 28 public void setPlatformId(String platformId) {
29 29 this.platformId = platformId;
30 30 }
  31 +
31 32 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
... ... @@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
11 11 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
12 12 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
13 13 import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
14   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  14 +import com.genersoft.iot.vmp.service.IPlayService;
15 15 // import org.slf4j.Logger;
16 16 // import org.slf4j.LoggerFactory;
17 17 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
... ... @@ -13,24 +13,20 @@ import javax.sip.message.Response;
13 13  
14 14 import com.genersoft.iot.vmp.conf.MediaServerConfig;
15 15 import com.genersoft.iot.vmp.gb28181.bean.*;
16   -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
17 16 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
18 17 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
19 18 import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
20   -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
21 19 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
22 20 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
23 21 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
24 22 import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
25   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  23 +import com.genersoft.iot.vmp.service.IPlayService;
26 24 import gov.nist.javax.sip.address.AddressImpl;
27 25 import gov.nist.javax.sip.address.SipUri;
28 26 import org.slf4j.Logger;
29 27 import org.slf4j.LoggerFactory;
30 28  
31 29 import java.text.ParseException;
32   -import java.util.HashMap;
33   -import java.util.Map;
34 30 import java.util.Vector;
35 31  
36 32 /**
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
... ... @@ -549,7 +549,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
549 549 deviceChannel.setLatitude(gbStream.getLatitude());
550 550 deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
551 551 deviceChannel.setManufacture("wvp-pro");
552   - deviceChannel.setStatus(1);
  552 + deviceChannel.setStatus(gbStream.isStatus()?1:0);
553 553 // deviceChannel.setParentId(parentPlatform.getDeviceGBId());
554 554 deviceChannel.setRegisterWay(1);
555 555 deviceChannel.setCivilCode(cmder.getSipConfig().getSipDomain());
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -9,7 +9,7 @@ import com.genersoft.iot.vmp.conf.MediaServerConfig;
9 9 import com.genersoft.iot.vmp.gb28181.bean.Device;
10 10 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
11 11 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
12   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  12 +import com.genersoft.iot.vmp.service.IPlayService;
13 13 import org.slf4j.Logger;
14 14 import org.slf4j.LoggerFactory;
15 15 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -240,8 +240,9 @@ public class ZLMHttpHookListener {
240 240 String streamId = json.getString("stream");
241 241 String schema = json.getString("schema");
242 242 boolean regist = json.getBoolean("regist");
243   - StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
  243 +
244 244 if ("rtp".equals(app) && !regist ) {
  245 + StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
245 246 if (streamInfo!=null){
246 247 redisCatchStorage.stopPlay(streamInfo);
247 248 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
... ... @@ -250,8 +251,12 @@ public class ZLMHttpHookListener {
250 251 redisCatchStorage.stopPlayback(streamInfo);
251 252 }
252 253 }else {
253   - if (!"rtp".equals(app) && "rtsp".equals(schema)){
254   - zlmMediaListManager.updateMediaList();
  254 + if (!"rtp".equals(app) && "rtmp".equals(schema)){
  255 + if (regist) {
  256 + zlmMediaListManager.addMedia(app, streamId);
  257 + }else {
  258 + zlmMediaListManager.removeMedia(app, streamId);
  259 + }
255 260 }
256 261 }
257 262 JSONObject ret = new JSONObject();
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
... ... @@ -70,6 +70,11 @@ public class ZLMHttpHookSubscribe {
70 70 return event;
71 71 }
72 72  
  73 + /**
  74 + * 获取某个类型的所有的订阅
  75 + * @param type
  76 + * @return
  77 + */
73 78 public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) {
74 79 ZLMHttpHookSubscribe.Event event= null;
75 80 Map<JSONObject, Event> eventMap = allSubscribes.get(type);
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
1 1 package com.genersoft.iot.vmp.media.zlm;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONArray;
5 4 import com.alibaba.fastjson.JSONObject;
6 5 import com.alibaba.fastjson.TypeReference;
7   -import com.genersoft.iot.vmp.common.RealVideo;
8   -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
9   -import com.genersoft.iot.vmp.gb28181.session.SsrcUtil;
  6 +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  7 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  8 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
10 9 import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
  10 +import com.genersoft.iot.vmp.service.IStreamPushService;
11 11 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
12   -import com.genersoft.iot.vmp.storager.impl.RedisCatchStorageImpl;
  12 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  13 +import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
  14 +import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
13 15 import org.slf4j.Logger;
14 16 import org.slf4j.LoggerFactory;
15 17 import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.beans.factory.annotation.Value;
17 18 import org.springframework.stereotype.Component;
18 19  
19 20 import java.util.*;
... ... @@ -29,60 +30,79 @@ public class ZLMMediaListManager {
29 30 @Autowired
30 31 private IRedisCatchStorage redisCatchStorage;
31 32  
  33 + @Autowired
  34 + private IVideoManagerStorager storager;
  35 +
  36 + @Autowired
  37 + private GbStreamMapper gbStreamMapper;
  38 +
  39 + @Autowired
  40 + private PlatformGbStreamMapper platformGbStreamMapper;
  41 +
  42 + @Autowired
  43 + private IStreamPushService streamPushService;
  44 +
32 45  
33 46 public void updateMediaList() {
34   - JSONObject mediaList = zlmresTfulUtils.getMediaList();
35   - if (mediaList == null) return;
36   - String dataStr = mediaList.getString("data");
37   -
38   - Integer code = mediaList.getInteger("code");
39   - Map<String, RealVideo> result = new HashMap<>();
40   - if (code == 0 ) {
41   - if (dataStr != null) {
42   - List<MediaItem> mediaItems = JSON.parseObject(dataStr, new TypeReference<List<MediaItem>>() {});
43   - for (MediaItem item : mediaItems) {
44   - if ("rtp".equals(item.getApp())) {
45   - continue;
46   - }
47   - String key = item.getApp() + "_" + item.getStream();
48   - RealVideo realVideo = result.get(key);
49   - if (realVideo == null) {
50   - realVideo = new RealVideo();
51   - realVideo.setApp(item.getApp());
52   - realVideo.setStream(item.getStream());
53   - realVideo.setAliveSecond(item.getAliveSecond());
54   - realVideo.setCreateStamp(item.getCreateStamp());
55   - realVideo.setOriginSock(item.getOriginSock());
56   - realVideo.setTotalReaderCount(item.getTotalReaderCount());
57   - realVideo.setOriginType(item.getOriginType());
58   - realVideo.setOriginTypeStr(item.getOriginTypeStr());
59   - realVideo.setOriginUrl(item.getOriginUrl());
60   - realVideo.setCreateStamp(item.getCreateStamp());
61   - realVideo.setAliveSecond(item.getAliveSecond());
62   -
63   - ArrayList<RealVideo.MediaSchema> mediaSchemas = new ArrayList<>();
64   - realVideo.setSchemas(mediaSchemas);
65   - realVideo.setTracks(item.getTracks());
66   - realVideo.setVhost(item.getVhost());
67   - result.put(key, realVideo);
68   - }
69   -
70   - RealVideo.MediaSchema mediaSchema = new RealVideo.MediaSchema();
71   - mediaSchema.setSchema(item.getSchema());
72   - mediaSchema.setBytesSpeed(item.getBytesSpeed());
73   - realVideo.getSchemas().add(mediaSchema);
  47 + storager.clearMediaList();
  48 +
  49 + // 使用异步的当时更新媒体流列表
  50 + zlmresTfulUtils.getMediaList((mediaList ->{
  51 + if (mediaList == null) return;
  52 + String dataStr = mediaList.getString("data");
  53 +
  54 + Integer code = mediaList.getInteger("code");
  55 + Map<String, StreamPushItem> result = new HashMap<>();
  56 + List<StreamPushItem> streamPushItems = null;
  57 + // 获取所有的国标关联
  58 + List<GbStream> gbStreams = gbStreamMapper.selectAll();
  59 + if (code == 0 ) {
  60 + if (dataStr != null) {
  61 + streamPushItems = streamPushService.handleJSON(dataStr);
74 62 }
  63 + }else {
  64 + logger.warn("更新视频流失败,错误code: " + code);
  65 + }
75 66  
  67 + if (streamPushItems != null) {
  68 + storager.updateMediaList(streamPushItems);
76 69 }
77   - }else {
78   - logger.warn("更新视频流失败,错误code: " + code);
79   - }
  70 + }));
80 71  
81   - List<RealVideo> realVideos = new ArrayList<>(result.values());
82   - Collections.sort(realVideos);
83   - redisCatchStorage.updateMediaList(realVideos);
84 72 }
85 73  
  74 + public void addMedia(String app, String streamId) {
  75 + //使用异步更新推流
  76 + zlmresTfulUtils.getMediaList(app, streamId, "rtmp", json->{
86 77  
  78 + if (json == null) return;
  79 + String dataStr = json.getString("data");
87 80  
  81 + Integer code = json.getInteger("code");
  82 + Map<String, StreamPushItem> result = new HashMap<>();
  83 + List<StreamPushItem> streamPushItems = null;
  84 + if (code == 0 ) {
  85 + if (dataStr != null) {
  86 + streamPushItems = streamPushService.handleJSON(dataStr);
  87 + }
  88 + }else {
  89 + logger.warn("更新视频流失败,错误code: " + code);
  90 + }
  91 +
  92 + if (streamPushItems != null && streamPushItems.size() == 1) {
  93 + storager.updateMedia(streamPushItems.get(0));
  94 + }
  95 + });
  96 + }
  97 +
  98 +
  99 + public void removeMedia(String app, String streamId) {
  100 + // 查找是否关联了国标, 关联了不删除, 置为离线
  101 + StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(app, streamId);
  102 + if (streamProxyItem == null) {
  103 + storager.removeMedia(app, streamId);
  104 + }else {
  105 + storager.mediaOutline(app, streamId);
  106 + }
  107 + }
88 108 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
... ... @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.media.zlm;
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import okhttp3.*;
  6 +import org.jetbrains.annotations.NotNull;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.factory.annotation.Value;
... ... @@ -27,7 +28,11 @@ public class ZLMRESTfulUtils {
27 28 @Value("${media.secret}")
28 29 private String mediaSecret;
29 30  
30   - public JSONObject sendPost(String api, Map<String, Object> param) {
  31 + public interface RequestCallback{
  32 + void run(JSONObject response);
  33 + }
  34 +
  35 + public JSONObject sendPost(String api, Map<String, Object> param, RequestCallback callback) {
31 36 OkHttpClient client = new OkHttpClient();
32 37 String url = String.format("http://%s:%s/index/api/%s", mediaIp, mediaPort, api);
33 38 JSONObject responseJSON = null;
... ... @@ -47,34 +52,68 @@ public class ZLMRESTfulUtils {
47 52 .post(body)
48 53 .url(url)
49 54 .build();
50   - try {
51   - Response response = client.newCall(request).execute();
52   - if (response.isSuccessful()) {
53   - String responseStr = response.body().string();
54   - if (responseStr != null) {
55   - responseJSON = JSON.parseObject(responseStr);
  55 + if (callback == null) {
  56 + try {
  57 + Response response = client.newCall(request).execute();
  58 + if (response.isSuccessful()) {
  59 + String responseStr = response.body().string();
  60 + if (responseStr != null) {
  61 + responseJSON = JSON.parseObject(responseStr);
  62 + }
  63 + }
  64 + } catch (ConnectException e) {
  65 + logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage()));
  66 + logger.info("请检查media配置并确认ZLM已启动...");
  67 + }catch (IOException e) {
  68 + e.printStackTrace();
56 69 }
  70 + }else {
  71 + client.newCall(request).enqueue(new Callback(){
  72 +
  73 + @Override
  74 + public void onResponse(@NotNull Call call, @NotNull Response response){
  75 + if (response.isSuccessful()) {
  76 + try {
  77 + String responseStr = response.body().string();
  78 + if (responseStr != null) {
  79 + callback.run(JSON.parseObject(responseStr));
  80 + }else {
  81 + callback.run(null);
  82 + }
  83 + } catch (IOException e) {
  84 + e.printStackTrace();
  85 + }
  86 + }
  87 + }
  88 +
  89 + @Override
  90 + public void onFailure(@NotNull Call call, @NotNull IOException e) {
  91 + logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage()));
  92 + logger.info("请检查media配置并确认ZLM已启动...");
  93 + }
  94 + });
57 95 }
58   - } catch (ConnectException e) {
59   - logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage()));
60   - logger.info("请检查media配置并确认ZLM已启动...");
61   - }catch (IOException e) {
62   - e.printStackTrace();
63   - }
  96 +
  97 +
64 98  
65 99 return responseJSON;
66 100 }
67 101  
68   - public JSONObject getMediaList(String app, String schema){
  102 + public JSONObject getMediaList(String app, String stream, String schema, RequestCallback callback){
69 103 Map<String, Object> param = new HashMap<>();
70   - param.put("app",app);
71   - param.put("schema",schema);
  104 + if (app != null) param.put("app",app);
  105 + if (stream != null) param.put("stream",stream);
  106 + if (schema != null) param.put("schema",schema);
72 107 param.put("vhost","__defaultVhost__");
73   - return sendPost("getMediaList",param);
  108 + return sendPost("getMediaList",param, callback);
  109 + }
  110 +
  111 + public JSONObject getMediaList(String app, String stream){
  112 + return getMediaList(app, stream,null, null);
74 113 }
75 114  
76   - public JSONObject getMediaList(){
77   - return sendPost("getMediaList",null);
  115 + public JSONObject getMediaList(RequestCallback callback){
  116 + return sendPost("getMediaList",null, callback);
78 117 }
79 118  
80 119 public JSONObject getMediaInfo(String app, String schema, String stream){
... ... @@ -83,13 +122,13 @@ public class ZLMRESTfulUtils {
83 122 param.put("schema",schema);
84 123 param.put("stream",stream);
85 124 param.put("vhost","__defaultVhost__");
86   - return sendPost("getMediaInfo",param);
  125 + return sendPost("getMediaInfo",param, null);
87 126 }
88 127  
89 128 public JSONObject getRtpInfo(String stream_id){
90 129 Map<String, Object> param = new HashMap<>();
91 130 param.put("stream_id",stream_id);
92   - return sendPost("getRtpInfo",param);
  131 + return sendPost("getRtpInfo",param, null);
93 132 }
94 133  
95 134 public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){
... ... @@ -99,37 +138,37 @@ public class ZLMRESTfulUtils {
99 138 param.put("src_url", src_url);
100 139 param.put("dst_url", dst_url);
101 140 param.put("timeout_ms", timeout_ms);
102   - return sendPost("addFFmpegSource",param);
  141 + return sendPost("addFFmpegSource",param, null);
103 142 }
104 143  
105 144 public JSONObject delFFmpegSource(String key){
106 145 Map<String, Object> param = new HashMap<>();
107 146 param.put("key", key);
108   - return sendPost("delFFmpegSource",param);
  147 + return sendPost("delFFmpegSource",param, null);
109 148 }
110 149  
111 150 public JSONObject getMediaServerConfig(){
112   - return sendPost("getServerConfig",null);
  151 + return sendPost("getServerConfig",null, null);
113 152 }
114 153  
115 154 public JSONObject setServerConfig(Map<String, Object> param){
116   - return sendPost("setServerConfig",param);
  155 + return sendPost("setServerConfig",param, null);
117 156 }
118 157  
119 158 public JSONObject openRtpServer(Map<String, Object> param){
120   - return sendPost("openRtpServer",param);
  159 + return sendPost("openRtpServer",param, null);
121 160 }
122 161  
123 162 public JSONObject closeRtpServer(Map<String, Object> param) {
124   - return sendPost("closeRtpServer",param);
  163 + return sendPost("closeRtpServer",param, null);
125 164 }
126 165  
127 166 public JSONObject startSendRtp(Map<String, Object> param) {
128   - return sendPost("startSendRtp",param);
  167 + return sendPost("startSendRtp",param, null);
129 168 }
130 169  
131 170 public JSONObject stopSendRtp(Map<String, Object> param) {
132   - return sendPost("stopSendRtp",param);
  171 + return sendPost("stopSendRtp",param, null);
133 172 }
134 173  
135 174 public JSONObject addStreamProxy(String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) {
... ... @@ -141,7 +180,7 @@ public class ZLMRESTfulUtils {
141 180 param.put("enable_hls", enable_hls?1:0);
142 181 param.put("enable_mp4", enable_mp4?1:0);
143 182 param.put("rtp_type", rtp_type);
144   - return sendPost("addStreamProxy",param);
  183 + return sendPost("addStreamProxy",param, null);
145 184 }
146 185  
147 186 public JSONObject closeStreams(String app, String stream) {
... ... @@ -150,6 +189,6 @@ public class ZLMRESTfulUtils {
150 189 param.put("app", app);
151 190 param.put("stream", stream);
152 191 param.put("force", 1);
153   - return sendPost("close_streams",param);
  192 + return sendPost("close_streams",param, null);
154 193 }
155 194 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
... ... @@ -8,7 +8,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
8 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
9 9 //import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
10 10 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
11   -import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
  11 +import com.genersoft.iot.vmp.service.IStreamProxyService;
12 12 import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -75,9 +75,8 @@ public class ZLMRunner implements CommandLineRunner {
75 75  
76 76 @Override
77 77 public void run(String... strings) throws Exception {
78   - JSONObject subscribeKey = new JSONObject();
79 78 // 订阅 zlm启动事件
80   - hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,subscribeKey,(response)->{
  79 + hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{
81 80 MediaServerConfig mediaServerConfig = JSONObject.toJavaObject(response, MediaServerConfig.class);
82 81 zLmRunning(mediaServerConfig);
83 82 });
... ... @@ -155,7 +154,7 @@ public class ZLMRunner implements CommandLineRunner {
155 154 logger.info("zlm接入成功...");
156 155 if (autoConfig) saveZLMConfig();
157 156 MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
158   - if (System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){
  157 + if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){
159 158 logger.info("zlm刚刚更新,忽略这次更新");
160 159 return;
161 160 }
... ...
src/main/java/com/genersoft/iot/vmp/common/RealVideo.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
1   -package com.genersoft.iot.vmp.common;
  1 +package com.genersoft.iot.vmp.media.zlm.dto;
2 2  
3   -import com.alibaba.fastjson.JSONObject;
4   -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
  3 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
5 4 import org.jetbrains.annotations.NotNull;
6 5  
7 6 import java.util.List;
8 7  
9 8  
10   -public class RealVideo implements Comparable<RealVideo>{
  9 +public class StreamPushItem extends GbStream implements Comparable<StreamPushItem>{
11 10  
12 11 /**
13 12 * 应用名
... ... @@ -85,9 +84,10 @@ public class RealVideo implements Comparable&lt;RealVideo&gt;{
85 84 this.vhost = vhost;
86 85 }
87 86  
  87 +
88 88 @Override
89   - public int compareTo(@NotNull RealVideo realVideo) {
90   - return new Long(this.createStamp - realVideo.getCreateStamp().intValue()).intValue();
  89 + public int compareTo(@NotNull StreamPushItem streamPushItem) {
  90 + return new Long(this.createStamp - streamPushItem.getCreateStamp().intValue()).intValue();
91 91 }
92 92  
93 93 public static class MediaSchema {
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/IGbStreamService.java renamed to src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
1   -package com.genersoft.iot.vmp.vmanager.service;
  1 +package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
4   -import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
5 4 import com.github.pagehelper.PageInfo;
6 5  
7 6 import java.util.List;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/IMediaService.java renamed to src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
1   -package com.genersoft.iot.vmp.vmanager.service;
  1 +package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.genersoft.iot.vmp.common.StreamInfo;
  4 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  5 +import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
4 6  
5 7 /**
6 8 * 媒体信息业务
... ... @@ -22,4 +24,5 @@ public interface IMediaService {
22 24 * @return
23 25 */
24 26 StreamInfo getStreamInfoByAppAndStream(String app, String stream);
  27 +
25 28 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java renamed to src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
1   -package com.genersoft.iot.vmp.vmanager.service;
  1 +package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/IStreamProxyService.java renamed to src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
1   -package com.genersoft.iot.vmp.vmanager.service;
  1 +package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
... ...
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  5 +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  6 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  7 +import com.github.pagehelper.PageInfo;
  8 +
  9 +import java.util.List;
  10 +
  11 +public interface IStreamPushService {
  12 +
  13 + List<StreamPushItem> handleJSON(String json);
  14 +
  15 + /**
  16 + * 将应用名和流ID加入国标关联
  17 + * @param stream
  18 + * @return
  19 + */
  20 + boolean saveToGB(GbStream stream);
  21 +
  22 + /**
  23 + * 将应用名和流ID移出国标关联
  24 + * @param stream
  25 + * @return
  26 + */
  27 + boolean removeFromGB(GbStream stream);
  28 +
  29 + /**
  30 + * 获取
  31 + * @param page
  32 + * @param count
  33 + * @return
  34 + */
  35 + PageInfo<StreamPushItem> getPushList(Integer page, Integer count);
  36 +}
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/GbStreamServiceImpl.java renamed to src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
1   -package com.genersoft.iot.vmp.vmanager.service.impl;
  1 +package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
4   -import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
5   -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
6 4 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
7   -import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper;
8   -import com.genersoft.iot.vmp.vmanager.platform.PlatformController;
9   -import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
  5 +import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
  6 +import com.genersoft.iot.vmp.service.IGbStreamService;
10 7 import com.github.pagehelper.PageHelper;
11 8 import com.github.pagehelper.PageInfo;
12 9 import org.slf4j.Logger;
... ... @@ -34,7 +31,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
34 31 private GbStreamMapper gbStreamMapper;
35 32  
36 33 @Autowired
37   - private PlarfotmGbStreamMapper plarfotmGbStreamMapper;
  34 + private PlatformGbStreamMapper platformGbStreamMapper;
38 35  
39 36 @Override
40 37 public PageInfo<GbStream> getAll(Integer page, Integer count) {
... ... @@ -57,7 +54,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
57 54 try {
58 55 for (GbStream gbStream : gbStreams) {
59 56 gbStream.setPlatformId(platformId);
60   - plarfotmGbStreamMapper.add(gbStream);
  57 + platformGbStreamMapper.add(gbStream);
61 58 }
62 59 dataSourceTransactionManager.commit(transactionStatus); //手动提交
63 60 result = true;
... ... @@ -76,7 +73,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
76 73 TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
77 74 try {
78 75 for (GbStream gbStream : gbStreams) {
79   - plarfotmGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
  76 + platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
80 77 }
81 78 dataSourceTransactionManager.commit(transactionStatus); //手动提交
82 79 result = true;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/MediaServiceImpl.java renamed to src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
1   -package com.genersoft.iot.vmp.vmanager.service.impl;
  1 +package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.common.StreamInfo;
5 5 import com.genersoft.iot.vmp.conf.MediaServerConfig;
  6 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
6 7 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
7 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 9 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
9   -import com.genersoft.iot.vmp.vmanager.service.IMediaService;
10   -import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
  10 +import com.genersoft.iot.vmp.service.IMediaService;
  11 +import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
11 12 import org.springframework.beans.factory.annotation.Autowired;
12 13 import org.springframework.stereotype.Service;
13 14  
... ... @@ -23,6 +24,8 @@ public class MediaServiceImpl implements IMediaService {
23 24 @Autowired
24 25 private ZLMRESTfulUtils zlmresTfulUtils;
25 26  
  27 +
  28 +
26 29 @Override
27 30 public StreamInfo getStreamInfoByAppAndStream(String app, String stream) {
28 31 MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
... ... @@ -51,4 +54,7 @@ public class MediaServiceImpl implements IMediaService {
51 54 }
52 55 return streamInfo;
53 56 }
  57 +
  58 +
  59 +
54 60 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java renamed to src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
1   -package com.genersoft.iot.vmp.vmanager.service.impl;
  1 +package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.genersoft.iot.vmp.common.StreamInfo;
6   -import com.genersoft.iot.vmp.conf.MediaServerConfig;
7 6 import com.genersoft.iot.vmp.gb28181.bean.Device;
8 7 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
9 8 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
... ... @@ -15,8 +14,8 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
15 14 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
16 15 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
17 16 import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
18   -import com.genersoft.iot.vmp.vmanager.service.IMediaService;
19   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  17 +import com.genersoft.iot.vmp.service.IMediaService;
  18 +import com.genersoft.iot.vmp.service.IPlayService;
20 19 import org.slf4j.Logger;
21 20 import org.slf4j.LoggerFactory;
22 21 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/StreamProxyServiceImpl.java renamed to src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
1   -package com.genersoft.iot.vmp.vmanager.service.impl;
  1 +package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.conf.MediaServerConfig;
... ... @@ -7,9 +7,9 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
7 7 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 8 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
9 9 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
10   -import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper;
  10 +import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
11 11 import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
12   -import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
  12 +import com.genersoft.iot.vmp.service.IStreamProxyService;
13 13 import com.github.pagehelper.PageInfo;
14 14 import org.springframework.beans.factory.annotation.Autowired;
15 15 import org.springframework.stereotype.Service;
... ... @@ -36,7 +36,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
36 36 private GbStreamMapper gbStreamMapper;
37 37  
38 38 @Autowired
39   - private PlarfotmGbStreamMapper plarfotmGbStreamMapper;
  39 + private PlatformGbStreamMapper platformGbStreamMapper;
40 40  
41 41  
42 42 @Override
... ... @@ -94,7 +94,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
94 94 videoManagerStorager.deleteStreamProxy(app, stream);
95 95 // 如果关联了国标那么移除关联
96 96 gbStreamMapper.del(app, stream);
97   - plarfotmGbStreamMapper.delByAppAndStream(app, stream);
  97 + platformGbStreamMapper.delByAppAndStream(app, stream);
98 98 // TODO 如果关联的推流, 那么状态设置为离线
99 99 }
100 100 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.alibaba.fastjson.TypeReference;
  6 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  7 +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
  8 +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  9 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  10 +import com.genersoft.iot.vmp.service.IStreamPushService;
  11 +import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
  12 +import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
  13 +import com.github.pagehelper.PageHelper;
  14 +import com.github.pagehelper.PageInfo;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Service;
  17 +
  18 +import java.util.ArrayList;
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +@Service
  24 +public class StreamPushServiceImpl implements IStreamPushService {
  25 +
  26 + @Autowired
  27 + private GbStreamMapper gbStreamMapper;
  28 +
  29 + @Autowired
  30 + private StreamPushMapper streamPushMapper;
  31 +
  32 + @Override
  33 + public List<StreamPushItem> handleJSON(String jsonData) {
  34 + if (jsonData == null) return null;
  35 +
  36 + Map<String, StreamPushItem> result = new HashMap<>();
  37 +
  38 + List<MediaItem> mediaItems = JSON.parseObject(jsonData, new TypeReference<List<MediaItem>>() {});
  39 + for (MediaItem item : mediaItems) {
  40 +
  41 + // 不保存国标推理以及拉流代理的流
  42 + if (item.getOriginType() == 3 || item.getOriginType() == 4 || item.getOriginType() == 5) {
  43 + continue;
  44 + }
  45 + String key = item.getApp() + "_" + item.getStream();
  46 + StreamPushItem streamPushItem = result.get(key);
  47 + if (streamPushItem == null) {
  48 + streamPushItem = new StreamPushItem();
  49 + streamPushItem.setApp(item.getApp());
  50 + streamPushItem.setStream(item.getStream());
  51 + streamPushItem.setAliveSecond(item.getAliveSecond());
  52 + streamPushItem.setCreateStamp(item.getCreateStamp());
  53 + streamPushItem.setOriginSock(item.getOriginSock());
  54 + streamPushItem.setTotalReaderCount(item.getTotalReaderCount());
  55 + streamPushItem.setOriginType(item.getOriginType());
  56 + streamPushItem.setOriginTypeStr(item.getOriginTypeStr());
  57 + streamPushItem.setOriginUrl(item.getOriginUrl());
  58 + streamPushItem.setCreateStamp(item.getCreateStamp());
  59 + streamPushItem.setAliveSecond(item.getAliveSecond());
  60 + streamPushItem.setStatus(true);
  61 + streamPushItem.setVhost(item.getVhost());
  62 + result.put(key, streamPushItem);
  63 + }
  64 + }
  65 +
  66 + return new ArrayList<>(result.values());
  67 + }
  68 +
  69 + @Override
  70 + public PageInfo<StreamPushItem> getPushList(Integer page, Integer count) {
  71 + PageHelper.startPage(page, count);
  72 + List<StreamPushItem> all = streamPushMapper.selectAll();
  73 + return new PageInfo<>(all);
  74 + }
  75 +
  76 + @Override
  77 + public boolean saveToGB(GbStream stream) {
  78 + stream.setStreamType("push");
  79 + stream.setStatus(true);
  80 + int add = gbStreamMapper.add(stream);
  81 + return add > 0;
  82 + }
  83 +
  84 + @Override
  85 + public boolean removeFromGB(GbStream stream) {
  86 + int del = gbStreamMapper.del(stream.getApp(), stream.getStream());
  87 + return del > 0;
  88 + }
  89 +}
... ...
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
1 1 package com.genersoft.iot.vmp.storager;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4   -import com.genersoft.iot.vmp.common.RealVideo;
  4 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
5 5 import com.genersoft.iot.vmp.common.StreamInfo;
6 6 import com.genersoft.iot.vmp.conf.MediaServerConfig;
7 7 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
... ... @@ -107,15 +107,4 @@ public interface IRedisCatchStorage {
107 107 */
108 108 boolean isChannelSendingRTP(String channelId);
109 109  
110   - /**
111   - * 更新媒体流列表
112   - * @param mediaList
113   - */
114   - void updateMediaList(List<RealVideo> mediaList);
115   -
116   - /**
117   - * 获取当前媒体流列表
118   - * @return List<RealVideo>
119   - */
120   - JSONObject getMediaList(int start, int end);
121 110 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
... ... @@ -4,6 +4,7 @@ import java.util.List;
4 4  
5 5 import com.genersoft.iot.vmp.gb28181.bean.*;
6 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  7 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
7 8 import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
8 9 import com.github.pagehelper.PageInfo;
9 10  
... ... @@ -319,4 +320,36 @@ public interface IVideoManagerStorager {
319 320 * @return
320 321 */
321 322 List<GbStream> queryGbStreamListInPlatform(String platformId);
  323 +
  324 + /**
  325 + * 批量更新推流列表
  326 + * @param streamPushItems
  327 + */
  328 + void updateMediaList(List<StreamPushItem> streamPushItems);
  329 +
  330 + /**
  331 + * 更新单个推流
  332 + * @param streamPushItem
  333 + */
  334 + void updateMedia(StreamPushItem streamPushItem);
  335 +
  336 + /**
  337 + * 移除单个推流
  338 + * @param app
  339 + * @param stream
  340 + */
  341 + void removeMedia(String app, String stream);
  342 +
  343 +
  344 + /**
  345 + * 清空推流列表
  346 + */
  347 + void clearMediaList();
  348 +
  349 + /**
  350 + * 设置流离线
  351 + * @param app
  352 + * @param streamId
  353 + */
  354 + void mediaOutline(String app, String streamId);
322 355 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
... ... @@ -12,9 +12,9 @@ import java.util.List;
12 12 public interface GbStreamMapper {
13 13  
14 14 @Insert("INSERT INTO gb_stream (app, stream, gbId, name, " +
15   - "longitude, latitude, streamType) VALUES" +
  15 + "longitude, latitude, streamType, status) VALUES" +
16 16 "('${app}', '${stream}', '${gbId}', '${name}', " +
17   - "'${longitude}', '${latitude}', '${streamType}')")
  17 + "'${longitude}', '${latitude}', '${streamType}', ${status})")
18 18 int add(GbStream gbStream);
19 19  
20 20 @Update("UPDATE gb_stream " +
... ... @@ -24,7 +24,8 @@ public interface GbStreamMapper {
24 24 "name=#{name}," +
25 25 "streamType=#{streamType}," +
26 26 "longitude=#{longitude}, " +
27   - "latitude=#{latitude}, " +
  27 + "latitude=#{latitude} " +
  28 + "status=${status} " +
28 29 "WHERE app=#{app} AND stream=#{stream} AND gbId=#{gbId}")
29 30 int update(GbStream gbStream);
30 31  
... ... @@ -46,4 +47,9 @@ public interface GbStreamMapper {
46 47 "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
47 48 "WHERE pgs.platformId = '${platformId}'")
48 49 List<GbStream> queryGbStreamListInPlatform(String platformId);
  50 +
  51 + @Update("UPDATE gb_stream " +
  52 + "SET status=${status} " +
  53 + "WHERE app=#{app} AND stream=#{stream}")
  54 + void setStatus(String app, String stream, boolean status);
49 55 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlarfotmGbStreamMapper.java renamed to src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
... ... @@ -11,7 +11,7 @@ import java.util.List;
11 11  
12 12 @Mapper
13 13 @Repository
14   -public interface PlarfotmGbStreamMapper {
  14 +public interface PlatformGbStreamMapper {
15 15  
16 16 @Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" +
17 17 "('${app}', '${stream}', '${platformId}')")
... ... @@ -20,9 +20,9 @@ public interface PlarfotmGbStreamMapper {
20 20 @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
21 21 int delByAppAndStream(String app, String stream);
22 22  
23   - @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
  23 + @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}")
24 24 int delByPlatformId(String platformId);
25 25  
26   - @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}")
27   - StreamProxyItem selectOne(String app, String stream, String platformId);
  26 + @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
  27 + List<StreamProxyItem> selectByAppAndStream(String app, String stream);
28 28 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java 0 → 100644
  1 +package com.genersoft.iot.vmp.storager.dao;
  2 +
  3 +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  4 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  5 +import org.apache.ibatis.annotations.*;
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +import java.util.List;
  9 +
  10 +@Mapper
  11 +@Repository
  12 +public interface StreamPushMapper {
  13 +
  14 + @Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
  15 + "createStamp, aliveSecond) VALUES" +
  16 + "('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
  17 + "'${createStamp}', '${aliveSecond}' )")
  18 + int add(StreamPushItem streamPushItem);
  19 +
  20 + @Update("UPDATE stream_push " +
  21 + "SET app=#{app}," +
  22 + "stream=#{stream}," +
  23 + "totalReaderCount=#{totalReaderCount}, " +
  24 + "originType=#{originType}," +
  25 + "originTypeStr=#{originTypeStr}, " +
  26 + "createStamp=#{createStamp}, " +
  27 + "aliveSecond=#{aliveSecond} " +
  28 + "WHERE app=#{app} AND stream=#{stream}")
  29 + int update(StreamPushItem streamPushItem);
  30 +
  31 + @Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}")
  32 + int del(String app, String stream);
  33 +
  34 + @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream")
  35 + List<StreamPushItem> selectAll();
  36 +
  37 + @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable}")
  38 + List<StreamPushItem> selectForEnable(boolean enable);
  39 +
  40 + @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
  41 + StreamPushItem selectOne(String app, String stream);
  42 +
  43 + @Insert("<script>" +
  44 + "INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
  45 + "createStamp, aliveSecond) " +
  46 + "VALUES <foreach collection='streamPushItems' item='item' index='index' >" +
  47 + "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', '${item.originType}', " +
  48 + "'${item.originTypeStr}','${item.createStamp}', '${item.aliveSecond}' )" +
  49 + " </foreach>" +
  50 + "</script>")
  51 + void addAll(List<StreamPushItem> streamPushItems);
  52 +
  53 + @Delete("DELETE FROM stream_push")
  54 + void clear();
  55 +
  56 +}
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
1 1 package com.genersoft.iot.vmp.storager.impl;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4   -import com.genersoft.iot.vmp.common.RealVideo;
  4 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
5 5 import com.genersoft.iot.vmp.common.StreamInfo;
6 6 import com.genersoft.iot.vmp.common.VideoManagerConstants;
7 7 import com.genersoft.iot.vmp.conf.MediaServerConfig;
... ... @@ -261,34 +261,4 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
261 261 }
262 262 }
263 263  
264   -
265   - /**
266   - * 更新媒体流列表
267   - * @param mediaList
268   - */
269   - @Override
270   - public void updateMediaList(List<RealVideo> mediaList) {
271   - String key = VideoManagerConstants.MEDIA_STREAM_PREFIX;
272   - redis.del(key);
273   - for (int i = 0; i < mediaList.size(); i++) {
274   - RealVideo realVideo = mediaList.get(i);
275   - redis.zAdd(key, realVideo, realVideo.getCreateStamp());
276   - }
277   - }
278   -
279   -
280   - /**
281   - * 获取当前媒体流列表
282   - * @return List<RealVideo>
283   - */
284   - @Override
285   - public JSONObject getMediaList(int start, int end) {
286   - String key = VideoManagerConstants.MEDIA_STREAM_PREFIX;
287   - Set<Object> realVideos = redis.ZRange(key, start, end);
288   - JSONObject jsonObject = new JSONObject();
289   - jsonObject.put("list", new ArrayList(realVideos));
290   - jsonObject.put("total", redis.zSize(key));
291   -
292   - return jsonObject;
293   - }
294 264 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
... ... @@ -4,6 +4,7 @@ import java.util.*;
4 4  
5 5 import com.genersoft.iot.vmp.gb28181.bean.*;
6 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  7 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
7 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 9 import com.genersoft.iot.vmp.storager.dao.*;
9 10 import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
... ... @@ -54,6 +55,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
54 55 private StreamProxyMapper streamProxyMapper;
55 56  
56 57 @Autowired
  58 + private StreamPushMapper streamPushMapper;
  59 +
  60 + @Autowired
57 61 private GbStreamMapper gbStreamMapper;
58 62  
59 63  
... ... @@ -221,9 +225,10 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
221 225 */
222 226 @Override
223 227 public synchronized boolean outline(String deviceId) {
  228 + System.out.println("更新设备离线: " + deviceId);
224 229 Device device = deviceMapper.getDeviceByDeviceId(deviceId);
  230 + if (device == null) return false;
225 231 device.setOnline(0);
226   - System.out.println("更新设备离线");
227 232 return deviceMapper.update(device) > 0;
228 233 }
229 234  
... ... @@ -403,6 +408,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
403 408 TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
404 409 boolean result = false;
405 410 streamProxyItem.setStreamType("proxy");
  411 + streamProxyItem.setStatus(true);
406 412 try {
407 413 if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) {
408 414 //事务回滚
... ... @@ -504,4 +510,37 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
504 510 public StreamProxyItem queryStreamProxy(String app, String stream){
505 511 return streamProxyMapper.selectOne(app, stream);
506 512 }
  513 +
  514 + @Override
  515 + public void updateMediaList(List<StreamPushItem> streamPushItems) {
  516 + if (streamPushItems == null || streamPushItems.size() == 0) return;
  517 + System.out.printf("updateMediaList: " + streamPushItems.size());
  518 + streamPushMapper.addAll(streamPushItems);
  519 + // TODO 待优化
  520 + for (int i = 0; i < streamPushItems.size(); i++) {
  521 + gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true);
  522 + }
  523 + }
  524 +
  525 + @Override
  526 + public void updateMedia(StreamPushItem streamPushItem) {
  527 + streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream());
  528 + streamPushMapper.add(streamPushItem);
  529 + gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true);
  530 + }
  531 +
  532 + @Override
  533 + public void removeMedia(String app, String stream) {
  534 + streamPushMapper.del(app, stream);
  535 + }
  536 +
  537 + @Override
  538 + public void clearMediaList() {
  539 + streamPushMapper.clear();
  540 + }
  541 +
  542 + @Override
  543 + public void mediaOutline(String app, String streamId) {
  544 + gbStreamMapper.setStatus(app, streamId, false);
  545 + }
507 546 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java
1 1 package com.genersoft.iot.vmp.vmanager.gbStream;
2 2  
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONArray;
5 3 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
6 4 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
7 5 import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam;
8   -import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
9   -import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
  6 +import com.genersoft.iot.vmp.service.IGbStreamService;
10 7 import com.github.pagehelper.PageInfo;
11 8 import org.slf4j.Logger;
12 9 import org.slf4j.LoggerFactory;
13 10 import org.springframework.beans.factory.annotation.Autowired;
14 11 import org.springframework.web.bind.annotation.*;
15 12  
16   -import java.util.List;
17   -
18 13 @CrossOrigin
19 14 @RestController
20 15 @RequestMapping("/api/gbStream")
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java
... ... @@ -2,9 +2,13 @@ package com.genersoft.iot.vmp.vmanager.media;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.common.StreamInfo;
  5 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  6 +import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
  7 +import com.genersoft.iot.vmp.service.IStreamPushService;
5 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
6   -import com.genersoft.iot.vmp.vmanager.service.IMediaService;
7   -import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
  9 +import com.genersoft.iot.vmp.service.IMediaService;
  10 +import com.genersoft.iot.vmp.service.IStreamProxyService;
  11 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
8 12 import org.slf4j.Logger;
9 13 import org.slf4j.LoggerFactory;
10 14 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -20,25 +24,16 @@ public class MediaController {
20 24 private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
21 25  
22 26 @Autowired
23   - private IRedisCatchStorage redisCatchStorage;
  27 + private IVideoManagerStorager storager;
24 28  
25 29 @Autowired
26   - private IStreamProxyService streamProxyService;
  30 + private IStreamPushService streamPushService;
27 31  
28 32 @Autowired
29 33 private IMediaService mediaService;
30 34  
31 35  
32   - @RequestMapping(value = "/list")
33   - @ResponseBody
34   - public JSONObject list( @RequestParam(required = false)Integer page,
35   - @RequestParam(required = false)Integer count,
36   - @RequestParam(required = false)String q,
37   - @RequestParam(required = false)Boolean online ){
38 36  
39   - JSONObject jsonObject = redisCatchStorage.getMediaList(page - 1, page - 1 + count);
40   - return jsonObject;
41   - }
42 37  
43 38 @RequestMapping(value = "/getStreamInfoByAppAndStream")
44 39 @ResponseBody
... ... @@ -46,4 +41,6 @@ public class MediaController {
46 41 return mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream);
47 42 }
48 43  
  44 +
  45 +
49 46 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java
1 1 package com.genersoft.iot.vmp.vmanager.platformGbStream;
2 2  
3 3 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
4   -import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
5 4 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
6   -import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
  5 +import com.genersoft.iot.vmp.service.IGbStreamService;
7 6 import com.github.pagehelper.PageInfo;
8 7 import org.slf4j.Logger;
9 8 import org.slf4j.LoggerFactory;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
... ... @@ -8,8 +8,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
8 8 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
9 9 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
10 10 import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
11   -import com.genersoft.iot.vmp.vmanager.service.IMediaService;
12   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  11 +import com.genersoft.iot.vmp.service.IMediaService;
  12 +import com.genersoft.iot.vmp.service.IPlayService;
13 13 import org.slf4j.Logger;
14 14 import org.slf4j.LoggerFactory;
15 15 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java
... ... @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
5 5 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
6 6 //import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
7 7 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8   -import com.genersoft.iot.vmp.vmanager.service.IPlayService;
  8 +import com.genersoft.iot.vmp.service.IPlayService;
9 9 import org.slf4j.Logger;
10 10 import org.slf4j.LoggerFactory;
11 11 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
... ... @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.vmanager.streamProxy;
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
5 5 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
6   -import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
  6 +import com.genersoft.iot.vmp.service.IStreamProxyService;
7 7 import com.github.pagehelper.PageInfo;
8 8 import org.slf4j.Logger;
9 9 import org.slf4j.LoggerFactory;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java 0 → 100644
  1 +package com.genersoft.iot.vmp.vmanager.streamPush;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  5 +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  6 +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  7 +import com.genersoft.iot.vmp.service.IStreamPushService;
  8 +import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  9 +import com.genersoft.iot.vmp.vmanager.media.MediaController;
  10 +import com.github.pagehelper.PageInfo;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Controller;
  15 +import org.springframework.web.bind.annotation.*;
  16 +
  17 +@Controller
  18 +@CrossOrigin
  19 +@RequestMapping(value = "/api/push")
  20 +public class StreamPushController {
  21 +
  22 + private final static Logger logger = LoggerFactory.getLogger(StreamPushController.class);
  23 +
  24 + @Autowired
  25 + private IStreamPushService streamPushService;
  26 +
  27 + @RequestMapping(value = "/list")
  28 + @ResponseBody
  29 + public PageInfo<StreamPushItem> list(@RequestParam(required = false)Integer page,
  30 + @RequestParam(required = false)Integer count,
  31 + @RequestParam(required = false)String q,
  32 + @RequestParam(required = false)Boolean online ){
  33 +
  34 + PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page - 1, page - 1 + count);
  35 + return pushList;
  36 + }
  37 +
  38 + @RequestMapping(value = "/saveToGB")
  39 + @ResponseBody
  40 + public Object saveToGB(@RequestBody GbStream stream){
  41 + if (streamPushService.saveToGB(stream)){
  42 + return "success";
  43 + }else {
  44 + return "fail";
  45 + }
  46 + }
  47 +
  48 + @RequestMapping(value = "/removeFormGB")
  49 + @ResponseBody
  50 + public Object removeFormGB(@RequestBody GbStream stream){
  51 + if (streamPushService.removeFromGB(stream)){
  52 + return "success";
  53 + }else {
  54 + return "fail";
  55 + }
  56 + }
  57 +}
... ...
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/PLatformStreamList.vue deleted 100644 → 0
1   -<template>
2   - <div id="pLatformStreamList">
3   - <el-container>
4   - <el-header>
5   - <uiHeader></uiHeader>
6   - </el-header>
7   - <el-main>
8   - <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
9   - <span style="font-size: 1rem; font-weight: bold;">直播级联列表</span>
10   - </div>
11   - <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
12   - <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">添加代理</el-button>
13   - </div>
14   - <devicePlayer ref="devicePlayer"></devicePlayer>
15   - <el-table :data="streamProxyList" border style="width: 100%" :height="winHeight">
16   - <el-table-column prop="app" label="应用名" align="center" show-overflow-tooltip/>
17   - <el-table-column prop="stream" label="流ID" align="center" show-overflow-tooltip/>
18   - <el-table-column prop="gbId" label="国标平台" align="center" show-overflow-tooltip/>
19   -
20   - <el-table-column label="转HLS" width="120" align="center">
21   - <template slot-scope="scope">
22   - <div slot="reference" class="name-wrapper">
23   - <el-tag size="medium" v-if="scope.row.enable_hls">已启用</el-tag>
24   - <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">未启用</el-tag>
25   - </div>
26   - </template>
27   - </el-table-column>
28   - <el-table-column label="MP4录制" width="120" align="center">
29   - <template slot-scope="scope">
30   - <div slot="reference" class="name-wrapper">
31   - <el-tag size="medium" v-if="scope.row.enable_mp4">已启用</el-tag>
32   - <el-tag size="medium" type="info" v-if="!scope.row.enable_mp4">未启用</el-tag>
33   - </div>
34   - </template>
35   - </el-table-column>
36   - <el-table-column label="启用" width="120" align="center">
37   - <template slot-scope="scope">
38   - <div slot="reference" class="name-wrapper">
39   - <el-tag size="medium" v-if="scope.row.enable">已启用</el-tag>
40   - <el-tag size="medium" type="info" v-if="!scope.row.enable">未启用</el-tag>
41   - </div>
42   - </template>
43   - </el-table-column>
44   -
45   - <el-table-column label="操作" width="360" align="center" fixed="right">
46   - <template slot-scope="scope">
47   - <el-button-group>
48   - <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.enable" @click="play(scope.row)">播放</el-button>
49   - <el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button>
50   - <el-button size="mini" icon="el-icon-check" type="primary" v-if="!scope.row.enable" @click="start(scope.row)">启用</el-button>
51   - <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">删除</el-button>
52   - <!-- <el-button size="mini" icon="el-icon-position" type="primary" >加入国标</el-button> -->
53   - </el-button-group>
54   - </template>
55   - </el-table-column>
56   - </el-table>
57   - <el-pagination
58   - style="float: right"
59   - @size-change="handleSizeChange"
60   - @current-change="currentChange"
61   - :current-page="currentPage"
62   - :page-size="count"
63   - :page-sizes="[15, 25, 35, 50]"
64   - layout="total, sizes, prev, pager, next"
65   - :total="total">
66   - </el-pagination>
67   - <streamProxyEdit ref="streamProxyEdit" ></streamProxyEdit>
68   - </el-main>
69   - </el-container>
70   - </div>
71   -</template>
72   -
73   -<script>
74   - import streamProxyEdit from './dialog/StreamProxyEdit.vue'
75   - import devicePlayer from './dialog/devicePlayer.vue'
76   - import uiHeader from './UiHeader.vue'
77   - export default {
78   - name: 'pLatformStreamList',
79   - components: {
80   - devicePlayer,
81   - streamProxyEdit,
82   - uiHeader
83   - },
84   - data() {
85   - return {
86   - streamProxyList: [],
87   - currentPusher: {}, //当前操作设备对象
88   - updateLooper: 0, //数据刷新轮训标志
89   - currentDeviceChannelsLenth:0,
90   - winHeight: window.innerHeight - 200,
91   - currentPage:1,
92   - count:15,
93   - total:0,
94   - getListLoading: false
95   - };
96   - },
97   - computed: {
98   - },
99   - mounted() {
100   - this.initData();
101   - // this.updateLooper = setInterval(this.initData, 10000);
102   - },
103   - destroyed() {
104   - this.$destroy('videojs');
105   - clearTimeout(this.updateLooper);
106   - },
107   - methods: {
108   - initData: function() {
109   - this.getStreamProxyList();
110   - },
111   - currentChange: function(val){
112   - this.currentPage = val;
113   - this.getStreamProxyList();
114   - },
115   - handleSizeChange: function(val){
116   - this.count = val;
117   - this.getStreamProxyList();
118   - },
119   - getStreamProxyList: function() {
120   - let that = this;
121   - this.getListLoading = true;
122   - this.$axios.get(`/api/proxy/list`,{
123   - params: {
124   - page: that.currentPage,
125   - count: that.count
126   - }
127   - } )
128   - .then(function (res) {
129   - console.log(res);
130   - console.log(res.data.list);
131   - that.total = res.data.total;
132   - that.streamProxyList = res.data.list;
133   - that.getListLoading = false;
134   - })
135   - .catch(function (error) {
136   - console.log(error);
137   - that.getListLoading = false;
138   - });
139   - },
140   - addStreamProxy: function(){
141   - this.$refs.streamProxyEdit.openDialog(null, this.initData)
142   - },
143   - saveStreamProxy: function(){
144   - },
145   - play: function(row){
146   - let that = this;
147   - this.getListLoading = true;
148   - this.$axios.get(`/api/media/getStreamInfoByAppAndStream`,{
149   - params: {
150   - app: row.app,
151   - stream: row.stream
152   - }
153   - })
154   - .then(function (res) {
155   - that.getListLoading = false;
156   - that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
157   - streamInfo: res.data,
158   - hasAudio: true
159   - });
160   - })
161   - .catch(function (error) {
162   - console.log(error);
163   - that.getListLoading = false;
164   - });
165   -
166   - },
167   - deleteStreamProxy: function(row){
168   - console.log(1111)
169   - let that = this;
170   - this.getListLoading = true;
171   - this.$axios.get(`/api/proxy/del`,{
172   - params: {
173   - app: row.app,
174   - stream: row.stream
175   - }
176   - })
177   - .then(function (res) {
178   - that.getListLoading = false;
179   - that.initData()
180   - })
181   - .catch(function (error) {
182   - console.log(error);
183   - that.getListLoading = false;
184   - });
185   - },
186   - start: function(row){
187   - let that = this;
188   - this.getListLoading = true;
189   - this.$axios.get(`/api/proxy/start`,{
190   - params: {
191   - app: row.app,
192   - stream: row.stream
193   - }
194   - })
195   - .then(function (res) {
196   - that.getListLoading = false;
197   - that.initData()
198   - })
199   - .catch(function (error) {
200   - console.log(error);
201   - that.getListLoading = false;
202   - });
203   - },
204   - stop: function(row){
205   - let that = this;
206   - this.getListLoading = true;
207   - this.$axios.get(`/api/proxy/stop`,{
208   - params: {
209   - app: row.app,
210   - stream: row.stream
211   - }
212   - })
213   - .then(function (res) {
214   - that.getListLoading = false;
215   - that.initData()
216   - })
217   - .catch(function (error) {
218   - console.log(error);
219   - that.getListLoading = false;
220   - });
221   - }
222   -
223   - }
224   - };
225   -</script>
226   -
227   -<style>
228   - .videoList {
229   - display: flex;
230   - flex-wrap: wrap;
231   - align-content: flex-start;
232   - }
233   -
234   - .video-item {
235   - position: relative;
236   - width: 15rem;
237   - height: 10rem;
238   - margin-right: 1rem;
239   - background-color: #000000;
240   - }
241   -
242   - .video-item-img {
243   - position: absolute;
244   - top: 0;
245   - bottom: 0;
246   - left: 0;
247   - right: 0;
248   - margin: auto;
249   - width: 100%;
250   - height: 100%;
251   - }
252   -
253   - .video-item-img:after {
254   - content: "";
255   - display: inline-block;
256   - position: absolute;
257   - z-index: 2;
258   - top: 0;
259   - bottom: 0;
260   - left: 0;
261   - right: 0;
262   - margin: auto;
263   - width: 3rem;
264   - height: 3rem;
265   - background-image: url("../assets/loading.png");
266   - background-size: cover;
267   - background-color: #000000;
268   - }
269   -
270   - .video-item-title {
271   - position: absolute;
272   - bottom: 0;
273   - color: #000000;
274   - background-color: #ffffff;
275   - line-height: 1.5rem;
276   - padding: 0.3rem;
277   - width: 14.4rem;
278   - }
279   - .cpoy-btn {
280   - cursor: pointer;
281   - margin-right: 10px;
282   - }
283   -</style>
web_src/src/components/PushVideoList.vue
... ... @@ -8,10 +8,8 @@
8 8 <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
9 9 <span style="font-size: 1rem; font-weight: bold;">推流列表</span>
10 10 </div>
11   - <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
12   - <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">添加代理</el-button>
13   - </div>
14 11 <devicePlayer ref="devicePlayer"></devicePlayer>
  12 + <addStreamTOGB ref="addStreamTOGB"></addStreamTOGB>
15 13 <el-table :data="pushList" border style="width: 100%" :height="winHeight">
16 14 <el-table-column prop="app" label="APP" width="180" align="center">
17 15 </el-table-column>
... ... @@ -19,6 +17,8 @@
19 17 </el-table-column>
20 18 <el-table-column prop="totalReaderCount" label="在线人数" width="240" align="center">
21 19 </el-table-column>
  20 + <el-table-column prop="gbId" label="国标编码" width="150" align="center">
  21 + </el-table-column>
22 22 <el-table-column label="开始时间" align="center" >
23 23 <template slot-scope="scope">
24 24 <el-button-group>
... ... @@ -26,12 +26,19 @@
26 26 </el-button-group>
27 27 </template>
28 28 </el-table-column>
  29 + <el-table-column label="正在推流" align="center" >
  30 + <template slot-scope="scope">
  31 + {{!!scope.row.status?'是':'否'}}
  32 + </template>
  33 + </el-table-column>
29 34  
30 35 <el-table-column label="操作" width="360" align="center" fixed="right">
31 36 <template slot-scope="scope">
32 37 <el-button-group>
33 38 <el-button size="mini" icon="el-icon-video-play" @click="playPuhsh(scope.row)">播放</el-button>
34 39 <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="!!scope.row.streamId" @click="stopPuhsh(scope.row)">停止</el-button>
  40 + <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!!scope.row.gbId" @click="addToGB(scope.row)">加入国标</el-button>
  41 + <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!scope.row.gbId" @click="removeFromGB(scope.row)">移出国标</el-button>
35 42 </el-button-group>
36 43 </template>
37 44 </el-table-column>
... ... @@ -55,11 +62,13 @@
55 62 <script>
56 63 import streamProxyEdit from './dialog/StreamProxyEdit.vue'
57 64 import devicePlayer from './dialog/devicePlayer.vue'
  65 + import addStreamTOGB from './dialog/addStreamTOGB.vue'
58 66 import uiHeader from './UiHeader.vue'
59 67 export default {
60 68 name: 'pushVideoList',
61 69 components: {
62 70 devicePlayer,
  71 + addStreamTOGB,
63 72 streamProxyEdit,
64 73 uiHeader
65 74 },
... ... @@ -80,10 +89,9 @@
80 89 },
81 90 mounted() {
82 91 this.initData();
83   - // this.updateLooper = setInterval(this.initData, 10000);
  92 + this.updateLooper = setInterval(this.initData, 2000);
84 93 },
85 94 destroyed() {
86   - this.$destroy('videojs');
87 95 clearTimeout(this.updateLooper);
88 96 },
89 97 methods: {
... ... @@ -101,7 +109,7 @@
101 109 getPushList: function() {
102 110 let that = this;
103 111 this.getDeviceListLoading = true;
104   - this.$axios.get(`/api/media/list`,{
  112 + this.$axios.get(`/api/push/list`,{
105 113 params: {
106 114 page: that.currentPage,
107 115 count: that.count
... ... @@ -119,12 +127,7 @@
119 127 that.getDeviceListLoading = false;
120 128 });
121 129 },
122   - addStreamProxy: function(){
123   - console.log(2222)
124   - this.$refs.streamProxyEdit.openDialog(null, this.initData)
125   - },
126   - saveStreamProxy: function(){
127   - },
  130 +
128 131 playPuhsh: function(row){
129 132 let that = this;
130 133 this.getListLoading = true;
... ... @@ -149,6 +152,23 @@
149 152 stopPuhsh: function(row){
150 153 console.log(row)
151 154 },
  155 + addToGB: function(row){
  156 + this.$refs.addStreamTOGB.openDialog({app: row.app, stream: row.stream}, this.initData);
  157 + },
  158 + removeFromGB: function(row){
  159 + var that = this;
  160 + that.$axios.post(`/api/push/removeFormGB`, row)
  161 + .then(function (res) {
  162 + console.log(res);
  163 + console.log(res.data == "success");
  164 + if (res.data == "success") {
  165 + that.initData()
  166 + }
  167 + })
  168 + .catch(function (error) {
  169 + console.log(error);
  170 + });
  171 + },
152 172 dateFormat: function(/** timestamp=0 **/) {
153 173 var ts = arguments[0] || 0;
154 174 var t,y,m,d,h,i,s;
... ...
web_src/src/components/StreamProxyList.vue
... ... @@ -64,7 +64,6 @@
64 64 <el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button>
65 65 <el-button size="mini" icon="el-icon-check" type="primary" v-if="!scope.row.enable" @click="start(scope.row)">启用</el-button>
66 66 <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">删除</el-button>
67   - <!-- <el-button size="mini" icon="el-icon-position" type="primary" >加入国标</el-button> -->
68 67 </el-button-group>
69 68 </template>
70 69 </el-table-column>
... ...
web_src/src/components/dialog/addStreamTOGB.vue 0 → 100644
  1 +<template>
  2 + <div id="addStreamProxy" v-loading="isLoging">
  3 + <el-dialog
  4 + title=" 加入"
  5 + width="40%"
  6 + top="2rem"
  7 + :close-on-click-modal="false"
  8 + :visible.sync="showDialog"
  9 + :destroy-on-close="true"
  10 + @close="close()"
  11 + >
  12 + <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
  13 + <el-form ref="streamProxy" :rules="rules" :model="proxyParam" label-width="140px">
  14 + <el-form-item label="名称" prop="name">
  15 + <el-input v-model="proxyParam.name" clearable></el-input>
  16 + </el-form-item>
  17 + <el-form-item label="流应用名" prop="app">
  18 + <el-input v-model="proxyParam.app" clearable :disabled="true"></el-input>
  19 + </el-form-item>
  20 + <el-form-item label="流ID" prop="stream">
  21 + <el-input v-model="proxyParam.stream" clearable :disabled="true"></el-input>
  22 + </el-form-item>
  23 + <el-form-item label="国标编码" prop="gbId">
  24 + <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input>
  25 + </el-form-item>
  26 + <el-form-item>
  27 + <div style="float: right;">
  28 + <el-button type="primary" @click="onSubmit">保存</el-button>
  29 + <el-button @click="close">取消</el-button>
  30 + </div>
  31 +
  32 + </el-form-item>
  33 + </el-form>
  34 + </div>
  35 + </el-dialog>
  36 + </div>
  37 +</template>
  38 +
  39 +<script>
  40 +export default {
  41 + name: "streamProxyEdit",
  42 + props: {},
  43 + computed: {},
  44 + created() {},
  45 + data() {
  46 + // var deviceGBIdRules = async (rule, value, callback) => {
  47 + // console.log(value);
  48 + // if (value === "") {
  49 + // callback(new Error("请输入设备国标编号"));
  50 + // } else {
  51 + // var exit = await this.deviceGBIdExit(value);
  52 + // console.log(exit);
  53 + // console.log(exit == "true");
  54 + // console.log(exit === "true");
  55 + // if (exit) {
  56 + // callback(new Error("设备国标编号已存在"));
  57 + // } else {
  58 + // callback();
  59 + // }
  60 + // }
  61 + // };
  62 + return {
  63 + listChangeCallback: null,
  64 + showDialog: false,
  65 + isLoging: false,
  66 + proxyParam: {
  67 + name: null,
  68 + app: null,
  69 + stream: null,
  70 + gbId: null,
  71 + },
  72 +
  73 + rules: {
  74 + name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  75 + app: [{ required: true, message: "请输入应用名", trigger: "blur" }],
  76 + stream: [{ required: true, message: "请输入流ID", trigger: "blur" }],
  77 + gbId: [{ required: true, message: "请输入国标编码", trigger: "blur" }],
  78 + },
  79 + };
  80 + },
  81 + methods: {
  82 + openDialog: function (proxyParam, callback) {
  83 + this.showDialog = true;
  84 + this.listChangeCallback = callback;
  85 + if (proxyParam != null) {
  86 + this.proxyParam = proxyParam;
  87 + }
  88 + },
  89 + onSubmit: function () {
  90 + console.log("onSubmit");
  91 + var that = this;
  92 + that.$axios
  93 + .post(`/api/push/saveToGB`, that.proxyParam)
  94 + .then(function (res) {
  95 + console.log(res);
  96 + console.log(res.data == "success");
  97 + if (res.data == "success") {
  98 + that.$message({
  99 + showClose: true,
  100 + message: "保存成功",
  101 + type: "success",
  102 + });
  103 + that.showDialog = false;
  104 + if (that.listChangeCallback != null) {
  105 + that.listChangeCallback();
  106 + }
  107 + }
  108 + })
  109 + .catch(function (error) {
  110 + console.log(error);
  111 + });
  112 + },
  113 + close: function () {
  114 + console.log("关闭加入GB");
  115 + this.showDialog = false;
  116 + this.$refs.streamProxy.resetFields();
  117 + },
  118 + deviceGBIdExit: async function (deviceGbId) {
  119 + var result = false;
  120 + var that = this;
  121 + await that.$axios
  122 + .post(`/api/platforms/exit/${deviceGbId}`)
  123 + .then(function (res) {
  124 + result = res.data;
  125 + })
  126 + .catch(function (error) {
  127 + console.log(error);
  128 + });
  129 + return result;
  130 + },
  131 + checkExpires: function() {
  132 + if (this.platform.enable && this.platform.expires == "0") {
  133 + this.platform.expires = "300";
  134 + }
  135 + }
  136 + },
  137 +};
  138 +</script>
... ...
web_src/src/components/dialog/chooseChannelForStream.vue
... ... @@ -10,8 +10,6 @@
10 10 </el-table-column>
11 11 <el-table-column prop="gbId" label="国标编码" show-overflow-tooltip>
12 12 </el-table-column>
13   - <el-table-column prop="streamType" label="流来源" align="center" show-overflow-tooltip>
14   - </el-table-column>
15 13 <el-table-column label="流来源" width="100" align="center">
16 14 <template slot-scope="scope">
17 15 <div slot="reference" class="name-wrapper">
... ...
web_src/src/router/index.js
... ... @@ -6,7 +6,6 @@ import deviceList from &#39;../components/DeviceList.vue&#39;
6 6 import channelList from '../components/channelList.vue'
7 7 import pushVideoList from '../components/PushVideoList.vue'
8 8 import streamProxyList from '../components/StreamProxyList.vue'
9   -import pLatformStreamList from '../components/PLatformStreamList.vue'
10 9 import devicePosition from '../components/devicePosition.vue'
11 10 import login from '../components/Login.vue'
12 11 import parentPlatformList from '../components/ParentPlatformList.vue'
... ... @@ -35,10 +34,6 @@ export default new VueRouter({
35 34 component: pushVideoList,
36 35 },
37 36 {
38   - path: '/pLatformStreamList',
39   - component: pLatformStreamList,
40   - },
41   - {
42 37 path: '/streamProxyList',
43 38 component: streamProxyList,
44 39 },
... ...