From b17280522b3569b49c0d524b7ed7fb45ef0e991a Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期五, 02 四月 2021 19:04:01 +0800
Subject: [PATCH] 增加推流转发到国标,尚不完善
---
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java | 89 ++++
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java | 3
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java | 4
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java | 101 +++-
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java | 56 ++
web_src/src/components/PushVideoList.vue | 44 +
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java | 12
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java | 5
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java | 32 -
src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java | 7
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java | 13
src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java | 3
src/main/java/com/genersoft/iot/vmp/service/IMediaService.java | 5
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java | 2
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java | 12
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 7
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 7
web_src/src/components/StreamProxyList.vue | 1
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java | 2
src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java | 57 ++
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java | 1
src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java | 23
src/main/resources/wvp.sqlite | 0
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java | 2
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 41 +
src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java | 2
web_src/src/components/dialog/chooseChannelForStream.vue | 2
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java | 33 +
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java | 8
/dev/null | 283 -------------
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java | 6
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 13
web_src/src/components/dialog/addStreamTOGB.vue | 138 ++++++
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java | 9
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java | 2
web_src/src/router/index.js | 5
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java | 124 +++--
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java | 12
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java | 15
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java | 2
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 10
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java | 36 +
42 files changed, 720 insertions(+), 509 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
index 8fb1980..fd46947 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
@@ -12,6 +12,7 @@
private double longitude;
private double latitude;
private String streamType;
+ private boolean status;
public String getApp() {
return app;
@@ -68,4 +69,12 @@
public void setStreamType(String streamType) {
this.streamType = streamType;
}
+
+ public boolean isStatus() {
+ return status;
+ }
+
+ public void setStatus(boolean status) {
+ this.status = status;
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
index a4871ae..a4f7730 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
@@ -28,4 +28,5 @@
public void setPlatformId(String platformId) {
this.platformId = platformId;
}
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
index de9d837..02eedc4 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
@@ -11,7 +11,7 @@
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IPlayService;
// import org.slf4j.Logger;
// import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
index 15d0638..9db7a29 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
@@ -13,24 +13,20 @@
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.*;
-import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IPlayService;
import gov.nist.javax.sip.address.AddressImpl;
import gov.nist.javax.sip.address.SipUri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Vector;
/**
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
index 8176f45..5277425 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -549,7 +549,7 @@
deviceChannel.setLatitude(gbStream.getLatitude());
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
- deviceChannel.setStatus(1);
+ deviceChannel.setStatus(gbStream.isStatus()?1:0);
// deviceChannel.setParentId(parentPlatform.getDeviceGBId());
deviceChannel.setRegisterWay(1);
deviceChannel.setCivilCode(cmder.getSipConfig().getSipDomain());
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index b2c1597..0065b21 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -9,7 +9,7 @@
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IPlayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -240,8 +240,9 @@
String streamId = json.getString("stream");
String schema = json.getString("schema");
boolean regist = json.getBoolean("regist");
- StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
+
if ("rtp".equals(app) && !regist ) {
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if (streamInfo!=null){
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
@@ -250,8 +251,12 @@
redisCatchStorage.stopPlayback(streamInfo);
}
}else {
- if (!"rtp".equals(app) && "rtsp".equals(schema)){
- zlmMediaListManager.updateMediaList();
+ if (!"rtp".equals(app) && "rtmp".equals(schema)){
+ if (regist) {
+ zlmMediaListManager.addMedia(app, streamId);
+ }else {
+ zlmMediaListManager.removeMedia(app, streamId);
+ }
}
}
JSONObject ret = new JSONObject();
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
index 129f8a3..5aee00c 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
@@ -70,6 +70,11 @@
return event;
}
+ /**
+ * 鑾峰彇鏌愪釜绫诲瀷鐨勬墍鏈夌殑璁㈤槄
+ * @param type
+ * @return
+ */
public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) {
ZLMHttpHookSubscribe.Event event= null;
Map<JSONObject, Event> eventMap = allSubscribes.get(type);
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
index 5ffa467..1bf5162 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
@@ -1,19 +1,20 @@
package com.genersoft.iot.vmp.media.zlm;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
-import com.genersoft.iot.vmp.common.RealVideo;
-import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
-import com.genersoft.iot.vmp.gb28181.session.SsrcUtil;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
+import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.impl.RedisCatchStorageImpl;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
+import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
@@ -29,60 +30,79 @@
@Autowired
private IRedisCatchStorage redisCatchStorage;
+ @Autowired
+ private IVideoManagerStorager storager;
+
+ @Autowired
+ private GbStreamMapper gbStreamMapper;
+
+ @Autowired
+ private PlatformGbStreamMapper platformGbStreamMapper;
+
+ @Autowired
+ private IStreamPushService streamPushService;
+
public void updateMediaList() {
- JSONObject mediaList = zlmresTfulUtils.getMediaList();
- if (mediaList == null) return;
- String dataStr = mediaList.getString("data");
+ storager.clearMediaList();
- Integer code = mediaList.getInteger("code");
- Map<String, RealVideo> result = new HashMap<>();
- if (code == 0 ) {
- if (dataStr != null) {
- List<MediaItem> mediaItems = JSON.parseObject(dataStr, new TypeReference<List<MediaItem>>() {});
- for (MediaItem item : mediaItems) {
- if ("rtp".equals(item.getApp())) {
- continue;
- }
- String key = item.getApp() + "_" + item.getStream();
- RealVideo realVideo = result.get(key);
- if (realVideo == null) {
- realVideo = new RealVideo();
- realVideo.setApp(item.getApp());
- realVideo.setStream(item.getStream());
- realVideo.setAliveSecond(item.getAliveSecond());
- realVideo.setCreateStamp(item.getCreateStamp());
- realVideo.setOriginSock(item.getOriginSock());
- realVideo.setTotalReaderCount(item.getTotalReaderCount());
- realVideo.setOriginType(item.getOriginType());
- realVideo.setOriginTypeStr(item.getOriginTypeStr());
- realVideo.setOriginUrl(item.getOriginUrl());
- realVideo.setCreateStamp(item.getCreateStamp());
- realVideo.setAliveSecond(item.getAliveSecond());
+ // 浣跨敤寮傛鐨勫綋鏃舵洿鏂板獟浣撴祦鍒楄〃
+ zlmresTfulUtils.getMediaList((mediaList ->{
+ if (mediaList == null) return;
+ String dataStr = mediaList.getString("data");
- ArrayList<RealVideo.MediaSchema> mediaSchemas = new ArrayList<>();
- realVideo.setSchemas(mediaSchemas);
- realVideo.setTracks(item.getTracks());
- realVideo.setVhost(item.getVhost());
- result.put(key, realVideo);
- }
-
- RealVideo.MediaSchema mediaSchema = new RealVideo.MediaSchema();
- mediaSchema.setSchema(item.getSchema());
- mediaSchema.setBytesSpeed(item.getBytesSpeed());
- realVideo.getSchemas().add(mediaSchema);
+ Integer code = mediaList.getInteger("code");
+ Map<String, StreamPushItem> result = new HashMap<>();
+ List<StreamPushItem> streamPushItems = null;
+ // 鑾峰彇鎵�鏈夌殑鍥芥爣鍏宠仈
+ List<GbStream> gbStreams = gbStreamMapper.selectAll();
+ if (code == 0 ) {
+ if (dataStr != null) {
+ streamPushItems = streamPushService.handleJSON(dataStr);
}
-
+ }else {
+ logger.warn("鏇存柊瑙嗛娴佸け璐ワ紝閿欒code锛� " + code);
}
- }else {
- logger.warn("鏇存柊瑙嗛娴佸け璐ワ紝閿欒code锛� " + code);
- }
- List<RealVideo> realVideos = new ArrayList<>(result.values());
- Collections.sort(realVideos);
- redisCatchStorage.updateMediaList(realVideos);
+ if (streamPushItems != null) {
+ storager.updateMediaList(streamPushItems);
+ }
+ }));
+
+ }
+
+ public void addMedia(String app, String streamId) {
+ //浣跨敤寮傛鏇存柊鎺ㄦ祦
+ zlmresTfulUtils.getMediaList(app, streamId, "rtmp", json->{
+
+ if (json == null) return;
+ String dataStr = json.getString("data");
+
+ Integer code = json.getInteger("code");
+ Map<String, StreamPushItem> result = new HashMap<>();
+ List<StreamPushItem> streamPushItems = null;
+ if (code == 0 ) {
+ if (dataStr != null) {
+ streamPushItems = streamPushService.handleJSON(dataStr);
+ }
+ }else {
+ logger.warn("鏇存柊瑙嗛娴佸け璐ワ紝閿欒code锛� " + code);
+ }
+
+ if (streamPushItems != null && streamPushItems.size() == 1) {
+ storager.updateMedia(streamPushItems.get(0));
+ }
+ });
}
-
+ public void removeMedia(String app, String streamId) {
+ // 鏌ユ壘鏄惁鍏宠仈浜嗗浗鏍囷紝 鍏宠仈浜嗕笉鍒犻櫎锛� 缃负绂荤嚎
+ StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(app, streamId);
+ if (streamProxyItem == null) {
+ storager.removeMedia(app, streamId);
+ }else {
+ storager.mediaOutline(app, streamId);
+ }
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
index 21752a0..0265815 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import okhttp3.*;
+import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -27,7 +28,11 @@
@Value("${media.secret}")
private String mediaSecret;
- public JSONObject sendPost(String api, Map<String, Object> param) {
+ public interface RequestCallback{
+ void run(JSONObject response);
+ }
+
+ public JSONObject sendPost(String api, Map<String, Object> param, RequestCallback callback) {
OkHttpClient client = new OkHttpClient();
String url = String.format("http://%s:%s/index/api/%s", mediaIp, mediaPort, api);
JSONObject responseJSON = null;
@@ -47,34 +52,68 @@
.post(body)
.url(url)
.build();
- try {
- Response response = client.newCall(request).execute();
- if (response.isSuccessful()) {
- String responseStr = response.body().string();
- if (responseStr != null) {
- responseJSON = JSON.parseObject(responseStr);
+ if (callback == null) {
+ try {
+ Response response = client.newCall(request).execute();
+ if (response.isSuccessful()) {
+ String responseStr = response.body().string();
+ if (responseStr != null) {
+ responseJSON = JSON.parseObject(responseStr);
+ }
+ }
+ } catch (ConnectException e) {
+ logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
+ logger.info("璇锋鏌edia閰嶇疆骞剁‘璁LM宸插惎鍔�...");
+ }catch (IOException e) {
+ e.printStackTrace();
}
+ }else {
+ client.newCall(request).enqueue(new Callback(){
+
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response){
+ if (response.isSuccessful()) {
+ try {
+ String responseStr = response.body().string();
+ if (responseStr != null) {
+ callback.run(JSON.parseObject(responseStr));
+ }else {
+ callback.run(null);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
+ logger.info("璇锋鏌edia閰嶇疆骞剁‘璁LM宸插惎鍔�...");
+ }
+ });
}
- } catch (ConnectException e) {
- logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
- logger.info("璇锋鏌edia閰嶇疆骞剁‘璁LM宸插惎鍔�...");
- }catch (IOException e) {
- e.printStackTrace();
- }
+
+
return responseJSON;
}
- public JSONObject getMediaList(String app, String schema){
+ public JSONObject getMediaList(String app, String stream, String schema, RequestCallback callback){
Map<String, Object> param = new HashMap<>();
- param.put("app",app);
- param.put("schema",schema);
+ if (app != null) param.put("app",app);
+ if (stream != null) param.put("stream",stream);
+ if (schema != null) param.put("schema",schema);
param.put("vhost","__defaultVhost__");
- return sendPost("getMediaList",param);
+ return sendPost("getMediaList",param, callback);
}
- public JSONObject getMediaList(){
- return sendPost("getMediaList",null);
+ public JSONObject getMediaList(String app, String stream){
+ return getMediaList(app, stream,null, null);
+ }
+
+ public JSONObject getMediaList(RequestCallback callback){
+ return sendPost("getMediaList",null, callback);
}
public JSONObject getMediaInfo(String app, String schema, String stream){
@@ -83,13 +122,13 @@
param.put("schema",schema);
param.put("stream",stream);
param.put("vhost","__defaultVhost__");
- return sendPost("getMediaInfo",param);
+ return sendPost("getMediaInfo",param, null);
}
public JSONObject getRtpInfo(String stream_id){
Map<String, Object> param = new HashMap<>();
param.put("stream_id",stream_id);
- return sendPost("getRtpInfo",param);
+ return sendPost("getRtpInfo",param, null);
}
public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){
@@ -99,37 +138,37 @@
param.put("src_url", src_url);
param.put("dst_url", dst_url);
param.put("timeout_ms", timeout_ms);
- return sendPost("addFFmpegSource",param);
+ return sendPost("addFFmpegSource",param, null);
}
public JSONObject delFFmpegSource(String key){
Map<String, Object> param = new HashMap<>();
param.put("key", key);
- return sendPost("delFFmpegSource",param);
+ return sendPost("delFFmpegSource",param, null);
}
public JSONObject getMediaServerConfig(){
- return sendPost("getServerConfig",null);
+ return sendPost("getServerConfig",null, null);
}
public JSONObject setServerConfig(Map<String, Object> param){
- return sendPost("setServerConfig",param);
+ return sendPost("setServerConfig",param, null);
}
public JSONObject openRtpServer(Map<String, Object> param){
- return sendPost("openRtpServer",param);
+ return sendPost("openRtpServer",param, null);
}
public JSONObject closeRtpServer(Map<String, Object> param) {
- return sendPost("closeRtpServer",param);
+ return sendPost("closeRtpServer",param, null);
}
public JSONObject startSendRtp(Map<String, Object> param) {
- return sendPost("startSendRtp",param);
+ return sendPost("startSendRtp",param, null);
}
public JSONObject stopSendRtp(Map<String, Object> param) {
- return sendPost("stopSendRtp",param);
+ return sendPost("stopSendRtp",param, null);
}
public JSONObject addStreamProxy(String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) {
@@ -141,7 +180,7 @@
param.put("enable_hls", enable_hls?1:0);
param.put("enable_mp4", enable_mp4?1:0);
param.put("rtp_type", rtp_type);
- return sendPost("addStreamProxy",param);
+ return sendPost("addStreamProxy",param, null);
}
public JSONObject closeStreams(String app, String stream) {
@@ -150,6 +189,6 @@
param.put("app", app);
param.put("stream", stream);
param.put("force", 1);
- return sendPost("close_streams",param);
+ return sendPost("close_streams",param, null);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
index 1340a68..edce411 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
@@ -8,7 +8,7 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
//import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
+import com.genersoft.iot.vmp.service.IStreamProxyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -75,9 +75,8 @@
@Override
public void run(String... strings) throws Exception {
- JSONObject subscribeKey = new JSONObject();
// 璁㈤槄 zlm鍚姩浜嬩欢
- hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,subscribeKey,(response)->{
+ hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{
MediaServerConfig mediaServerConfig = JSONObject.toJavaObject(response, MediaServerConfig.class);
zLmRunning(mediaServerConfig);
});
@@ -155,7 +154,7 @@
logger.info("zlm鎺ュ叆鎴愬姛...");
if (autoConfig) saveZLMConfig();
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
- if (System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){
+ if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){
logger.info("zlm鍒氬垰鏇存柊锛屽拷鐣ヨ繖娆℃洿鏂�");
return;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/common/RealVideo.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
similarity index 90%
rename from src/main/java/com/genersoft/iot/vmp/common/RealVideo.java
rename to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
index b5ed851..f745b2a 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/RealVideo.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
@@ -1,13 +1,12 @@
-package com.genersoft.iot.vmp.common;
+package com.genersoft.iot.vmp.media.zlm.dto;
-import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import org.jetbrains.annotations.NotNull;
import java.util.List;
-public class RealVideo implements Comparable<RealVideo>{
+public class StreamPushItem extends GbStream implements Comparable<StreamPushItem>{
/**
* 搴旂敤鍚�
@@ -85,9 +84,10 @@
this.vhost = vhost;
}
+
@Override
- public int compareTo(@NotNull RealVideo realVideo) {
- return new Long(this.createStamp - realVideo.getCreateStamp().intValue()).intValue();
+ public int compareTo(@NotNull StreamPushItem streamPushItem) {
+ return new Long(this.createStamp - streamPushItem.getCreateStamp().intValue()).intValue();
}
public static class MediaSchema {
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IGbStreamService.java b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
similarity index 87%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/IGbStreamService.java
rename to src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
index 877ec2a..49ba7b7 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IGbStreamService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
@@ -1,7 +1,6 @@
-package com.genersoft.iot.vmp.vmanager.service;
+package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
import com.github.pagehelper.PageInfo;
import java.util.List;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IMediaService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
similarity index 78%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/IMediaService.java
rename to src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
index 757a7ac..526da37 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IMediaService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
@@ -1,6 +1,8 @@
-package com.genersoft.iot.vmp.vmanager.service;
+package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
/**
* 濯掍綋淇℃伅涓氬姟
@@ -22,4 +24,5 @@
* @return
*/
StreamInfo getStreamInfoByAppAndStream(String app, String stream);
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
similarity index 92%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java
rename to src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
index 963fc8c..7f4d9c7 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -1,4 +1,4 @@
-package com.genersoft.iot.vmp.vmanager.service;
+package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IStreamProxyService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
similarity index 95%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/IStreamProxyService.java
rename to src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
index 49d1e8a..023c075 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/IStreamProxyService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
@@ -1,4 +1,4 @@
-package com.genersoft.iot.vmp.vmanager.service;
+package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
new file mode 100644
index 0000000..9724eb7
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
@@ -0,0 +1,36 @@
+package com.genersoft.iot.vmp.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+public interface IStreamPushService {
+
+ List<StreamPushItem> handleJSON(String json);
+
+ /**
+ * 灏嗗簲鐢ㄥ悕鍜屾祦ID鍔犲叆鍥芥爣鍏宠仈
+ * @param stream
+ * @return
+ */
+ boolean saveToGB(GbStream stream);
+
+ /**
+ * 灏嗗簲鐢ㄥ悕鍜屾祦ID绉诲嚭鍥芥爣鍏宠仈
+ * @param stream
+ * @return
+ */
+ boolean removeFromGB(GbStream stream);
+
+ /**
+ * 鑾峰彇
+ * @param page
+ * @param count
+ * @return
+ */
+ PageInfo<StreamPushItem> getPushList(Integer page, Integer count);
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/GbStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
similarity index 83%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/GbStreamServiceImpl.java
rename to src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
index b8caacd..5002d29 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/GbStreamServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
@@ -1,12 +1,9 @@
-package com.genersoft.iot.vmp.vmanager.service.impl;
+package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
-import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper;
-import com.genersoft.iot.vmp.vmanager.platform.PlatformController;
-import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
+import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
+import com.genersoft.iot.vmp.service.IGbStreamService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@@ -34,7 +31,7 @@
private GbStreamMapper gbStreamMapper;
@Autowired
- private PlarfotmGbStreamMapper plarfotmGbStreamMapper;
+ private PlatformGbStreamMapper platformGbStreamMapper;
@Override
public PageInfo<GbStream> getAll(Integer page, Integer count) {
@@ -57,7 +54,7 @@
try {
for (GbStream gbStream : gbStreams) {
gbStream.setPlatformId(platformId);
- plarfotmGbStreamMapper.add(gbStream);
+ platformGbStreamMapper.add(gbStream);
}
dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦
result = true;
@@ -76,7 +73,7 @@
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
try {
for (GbStream gbStream : gbStreams) {
- plarfotmGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
+ platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
}
dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦
result = true;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
similarity index 92%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/MediaServiceImpl.java
rename to src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
index 68a1c44..f721b90 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/MediaServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
@@ -1,13 +1,14 @@
-package com.genersoft.iot.vmp.vmanager.service.impl;
+package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.service.IMediaService;
-import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
+import com.genersoft.iot.vmp.service.IMediaService;
+import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -22,6 +23,8 @@
@Autowired
private ZLMRESTfulUtils zlmresTfulUtils;
+
+
@Override
public StreamInfo getStreamInfoByAppAndStream(String app, String stream) {
@@ -51,4 +54,7 @@
}
return streamInfo;
}
+
+
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
similarity index 96%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
rename to src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 694c74f..e7298d2 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -1,9 +1,8 @@
-package com.genersoft.iot.vmp.vmanager.service.impl;
+package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
@@ -15,8 +14,8 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
-import com.genersoft.iot.vmp.vmanager.service.IMediaService;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IMediaService;
+import com.genersoft.iot.vmp.service.IPlayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
similarity index 93%
rename from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/StreamProxyServiceImpl.java
rename to src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
index ec94844..ddf8183 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/StreamProxyServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -1,4 +1,4 @@
-package com.genersoft.iot.vmp.vmanager.service.impl;
+package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
@@ -7,9 +7,9 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
-import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper;
+import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
-import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
+import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -36,7 +36,7 @@
private GbStreamMapper gbStreamMapper;
@Autowired
- private PlarfotmGbStreamMapper plarfotmGbStreamMapper;
+ private PlatformGbStreamMapper platformGbStreamMapper;
@Override
@@ -94,7 +94,7 @@
videoManagerStorager.deleteStreamProxy(app, stream);
// 濡傛灉鍏宠仈浜嗗浗鏍囬偅涔堢Щ闄ゅ叧鑱�
gbStreamMapper.del(app, stream);
- plarfotmGbStreamMapper.delByAppAndStream(app, stream);
+ platformGbStreamMapper.delByAppAndStream(app, stream);
// TODO 濡傛灉鍏宠仈鐨勬帹娴侊紝 閭d箞鐘舵�佽缃负绂荤嚎
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
new file mode 100644
index 0000000..ce7f02b
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
@@ -0,0 +1,89 @@
+package com.genersoft.iot.vmp.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.service.IStreamPushService;
+import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
+import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class StreamPushServiceImpl implements IStreamPushService {
+
+ @Autowired
+ private GbStreamMapper gbStreamMapper;
+
+ @Autowired
+ private StreamPushMapper streamPushMapper;
+
+ @Override
+ public List<StreamPushItem> handleJSON(String jsonData) {
+ if (jsonData == null) return null;
+
+ Map<String, StreamPushItem> result = new HashMap<>();
+
+ List<MediaItem> mediaItems = JSON.parseObject(jsonData, new TypeReference<List<MediaItem>>() {});
+ for (MediaItem item : mediaItems) {
+
+ // 涓嶄繚瀛樺浗鏍囨帹鐞嗕互鍙婃媺娴佷唬鐞嗙殑娴�
+ if (item.getOriginType() == 3 || item.getOriginType() == 4 || item.getOriginType() == 5) {
+ continue;
+ }
+ String key = item.getApp() + "_" + item.getStream();
+ StreamPushItem streamPushItem = result.get(key);
+ if (streamPushItem == null) {
+ streamPushItem = new StreamPushItem();
+ streamPushItem.setApp(item.getApp());
+ streamPushItem.setStream(item.getStream());
+ streamPushItem.setAliveSecond(item.getAliveSecond());
+ streamPushItem.setCreateStamp(item.getCreateStamp());
+ streamPushItem.setOriginSock(item.getOriginSock());
+ streamPushItem.setTotalReaderCount(item.getTotalReaderCount());
+ streamPushItem.setOriginType(item.getOriginType());
+ streamPushItem.setOriginTypeStr(item.getOriginTypeStr());
+ streamPushItem.setOriginUrl(item.getOriginUrl());
+ streamPushItem.setCreateStamp(item.getCreateStamp());
+ streamPushItem.setAliveSecond(item.getAliveSecond());
+ streamPushItem.setStatus(true);
+ streamPushItem.setVhost(item.getVhost());
+ result.put(key, streamPushItem);
+ }
+ }
+
+ return new ArrayList<>(result.values());
+ }
+
+ @Override
+ public PageInfo<StreamPushItem> getPushList(Integer page, Integer count) {
+ PageHelper.startPage(page, count);
+ List<StreamPushItem> all = streamPushMapper.selectAll();
+ return new PageInfo<>(all);
+ }
+
+ @Override
+ public boolean saveToGB(GbStream stream) {
+ stream.setStreamType("push");
+ stream.setStatus(true);
+ int add = gbStreamMapper.add(stream);
+ return add > 0;
+ }
+
+ @Override
+ public boolean removeFromGB(GbStream stream) {
+ int del = gbStreamMapper.del(stream.getApp(), stream.getStream());
+ return del > 0;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
index ca4ebae..1aba063 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
@@ -1,7 +1,7 @@
package com.genersoft.iot.vmp.storager;
import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.RealVideo;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@@ -107,15 +107,4 @@
*/
boolean isChannelSendingRTP(String channelId);
- /**
- * 鏇存柊濯掍綋娴佸垪琛�
- * @param mediaList
- */
- void updateMediaList(List<RealVideo> mediaList);
-
- /**
- * 鑾峰彇褰撳墠濯掍綋娴佸垪琛�
- * @return List<RealVideo>
- */
- JSONObject getMediaList(int start, int end);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
index e8f3240..846e8c7 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
@@ -4,6 +4,7 @@
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
import com.github.pagehelper.PageInfo;
@@ -319,4 +320,36 @@
* @return
*/
List<GbStream> queryGbStreamListInPlatform(String platformId);
+
+ /**
+ * 鎵归噺鏇存柊鎺ㄦ祦鍒楄〃
+ * @param streamPushItems
+ */
+ void updateMediaList(List<StreamPushItem> streamPushItems);
+
+ /**
+ * 鏇存柊鍗曚釜鎺ㄦ祦
+ * @param streamPushItem
+ */
+ void updateMedia(StreamPushItem streamPushItem);
+
+ /**
+ * 绉婚櫎鍗曚釜鎺ㄦ祦
+ * @param app
+ * @param stream
+ */
+ void removeMedia(String app, String stream);
+
+
+ /**
+ * 娓呯┖鎺ㄦ祦鍒楄〃
+ */
+ void clearMediaList();
+
+ /**
+ * 璁剧疆娴佺绾�
+ * @param app
+ * @param streamId
+ */
+ void mediaOutline(String app, String streamId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
index 2b83a4a..2ada231 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
@@ -12,9 +12,9 @@
public interface GbStreamMapper {
@Insert("INSERT INTO gb_stream (app, stream, gbId, name, " +
- "longitude, latitude, streamType) VALUES" +
+ "longitude, latitude, streamType, status) VALUES" +
"('${app}', '${stream}', '${gbId}', '${name}', " +
- "'${longitude}', '${latitude}', '${streamType}')")
+ "'${longitude}', '${latitude}', '${streamType}', ${status})")
int add(GbStream gbStream);
@Update("UPDATE gb_stream " +
@@ -24,7 +24,8 @@
"name=#{name}," +
"streamType=#{streamType}," +
"longitude=#{longitude}, " +
- "latitude=#{latitude}, " +
+ "latitude=#{latitude} " +
+ "status=${status} " +
"WHERE app=#{app} AND stream=#{stream} AND gbId=#{gbId}")
int update(GbStream gbStream);
@@ -46,4 +47,9 @@
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
"WHERE pgs.platformId = '${platformId}'")
List<GbStream> queryGbStreamListInPlatform(String platformId);
+
+ @Update("UPDATE gb_stream " +
+ "SET status=${status} " +
+ "WHERE app=#{app} AND stream=#{stream}")
+ void setStatus(String app, String stream, boolean status);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlarfotmGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
similarity index 75%
rename from src/main/java/com/genersoft/iot/vmp/storager/dao/PlarfotmGbStreamMapper.java
rename to src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
index 1172aeb..aad93f6 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlarfotmGbStreamMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
@@ -11,7 +11,7 @@
@Mapper
@Repository
-public interface PlarfotmGbStreamMapper {
+public interface PlatformGbStreamMapper {
@Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" +
"('${app}', '${stream}', '${platformId}')")
@@ -20,9 +20,9 @@
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
int delByAppAndStream(String app, String stream);
- @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
+ @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}")
int delByPlatformId(String platformId);
- @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}")
- StreamProxyItem selectOne(String app, String stream, String platformId);
+ @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
+ List<StreamProxyItem> selectByAppAndStream(String app, String stream);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
new file mode 100644
index 0000000..c0472a4
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
@@ -0,0 +1,56 @@
+package com.genersoft.iot.vmp.storager.dao;
+
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import org.apache.ibatis.annotations.*;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface StreamPushMapper {
+
+ @Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
+ "createStamp, aliveSecond) VALUES" +
+ "('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
+ "'${createStamp}', '${aliveSecond}' )")
+ int add(StreamPushItem streamPushItem);
+
+ @Update("UPDATE stream_push " +
+ "SET app=#{app}," +
+ "stream=#{stream}," +
+ "totalReaderCount=#{totalReaderCount}, " +
+ "originType=#{originType}," +
+ "originTypeStr=#{originTypeStr}, " +
+ "createStamp=#{createStamp}, " +
+ "aliveSecond=#{aliveSecond} " +
+ "WHERE app=#{app} AND stream=#{stream}")
+ int update(StreamPushItem streamPushItem);
+
+ @Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}")
+ int del(String app, String stream);
+
+ @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")
+ List<StreamPushItem> selectAll();
+
+ @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}")
+ List<StreamPushItem> selectForEnable(boolean enable);
+
+ @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}")
+ StreamPushItem selectOne(String app, String stream);
+
+ @Insert("<script>" +
+ "INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
+ "createStamp, aliveSecond) " +
+ "VALUES <foreach collection='streamPushItems' item='item' index='index' >" +
+ "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', '${item.originType}', " +
+ "'${item.originTypeStr}','${item.createStamp}', '${item.aliveSecond}' )" +
+ " </foreach>" +
+ "</script>")
+ void addAll(List<StreamPushItem> streamPushItems);
+
+ @Delete("DELETE FROM stream_push")
+ void clear();
+
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
index 7b7f599..91017fa 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -1,7 +1,7 @@
package com.genersoft.iot.vmp.storager.impl;
import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.RealVideo;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
@@ -261,34 +261,4 @@
}
}
-
- /**
- * 鏇存柊濯掍綋娴佸垪琛�
- * @param mediaList
- */
- @Override
- public void updateMediaList(List<RealVideo> mediaList) {
- String key = VideoManagerConstants.MEDIA_STREAM_PREFIX;
- redis.del(key);
- for (int i = 0; i < mediaList.size(); i++) {
- RealVideo realVideo = mediaList.get(i);
- redis.zAdd(key, realVideo, realVideo.getCreateStamp());
- }
- }
-
-
- /**
- * 鑾峰彇褰撳墠濯掍綋娴佸垪琛�
- * @return List<RealVideo>
- */
- @Override
- public JSONObject getMediaList(int start, int end) {
- String key = VideoManagerConstants.MEDIA_STREAM_PREFIX;
- Set<Object> realVideos = redis.ZRange(key, start, end);
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("list", new ArrayList(realVideos));
- jsonObject.put("total", redis.zSize(key));
-
- return jsonObject;
- }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
index b2756e2..63fbbd1 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -4,6 +4,7 @@
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
@@ -52,6 +53,9 @@
@Autowired
private StreamProxyMapper streamProxyMapper;
+
+ @Autowired
+ private StreamPushMapper streamPushMapper;
@Autowired
private GbStreamMapper gbStreamMapper;
@@ -221,9 +225,10 @@
*/
@Override
public synchronized boolean outline(String deviceId) {
+ System.out.println("鏇存柊璁惧绂荤嚎: " + deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
+ if (device == null) return false;
device.setOnline(0);
- System.out.println("鏇存柊璁惧绂荤嚎");
return deviceMapper.update(device) > 0;
}
@@ -403,6 +408,7 @@
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
streamProxyItem.setStreamType("proxy");
+ streamProxyItem.setStatus(true);
try {
if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) {
//浜嬪姟鍥炴粴
@@ -504,4 +510,37 @@
public StreamProxyItem queryStreamProxy(String app, String stream){
return streamProxyMapper.selectOne(app, stream);
}
+
+ @Override
+ public void updateMediaList(List<StreamPushItem> streamPushItems) {
+ if (streamPushItems == null || streamPushItems.size() == 0) return;
+ System.out.printf("updateMediaList: " + streamPushItems.size());
+ streamPushMapper.addAll(streamPushItems);
+ // TODO 寰呬紭鍖�
+ for (int i = 0; i < streamPushItems.size(); i++) {
+ gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true);
+ }
+ }
+
+ @Override
+ public void updateMedia(StreamPushItem streamPushItem) {
+ streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream());
+ streamPushMapper.add(streamPushItem);
+ gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true);
+ }
+
+ @Override
+ public void removeMedia(String app, String stream) {
+ streamPushMapper.del(app, stream);
+ }
+
+ @Override
+ public void clearMediaList() {
+ streamPushMapper.clear();
+ }
+
+ @Override
+ public void mediaOutline(String app, String streamId) {
+ gbStreamMapper.setStatus(app, streamId, false);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java
index d6afb09..787a094 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gbStream/GbStreamController.java
@@ -1,19 +1,14 @@
package com.genersoft.iot.vmp.vmanager.gbStream;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam;
-import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
-import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
+import com.genersoft.iot.vmp.service.IGbStreamService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
@CrossOrigin
@RestController
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java
index 0710f9b..e01b06e 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/media/MediaController.java
@@ -2,9 +2,13 @@
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
+import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.vmanager.service.IMediaService;
-import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
+import com.genersoft.iot.vmp.service.IMediaService;
+import com.genersoft.iot.vmp.service.IStreamProxyService;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,25 +24,16 @@
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
@Autowired
- private IRedisCatchStorage redisCatchStorage;
+ private IVideoManagerStorager storager;
@Autowired
- private IStreamProxyService streamProxyService;
+ private IStreamPushService streamPushService;
@Autowired
private IMediaService mediaService;
- @RequestMapping(value = "/list")
- @ResponseBody
- public JSONObject list( @RequestParam(required = false)Integer page,
- @RequestParam(required = false)Integer count,
- @RequestParam(required = false)String q,
- @RequestParam(required = false)Boolean online ){
- JSONObject jsonObject = redisCatchStorage.getMediaList(page - 1, page - 1 + count);
- return jsonObject;
- }
@RequestMapping(value = "/getStreamInfoByAppAndStream")
@ResponseBody
@@ -46,4 +41,6 @@
return mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream);
}
+
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java
index f2db340..f040d1a 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/platformGbStream/PlatformGbStreamController.java
@@ -1,9 +1,8 @@
package com.genersoft.iot.vmp.vmanager.platformGbStream;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.service.IGbStreamService;
+import com.genersoft.iot.vmp.service.IGbStreamService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
index c4bee6d..d104b85 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
@@ -8,8 +8,8 @@
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
-import com.genersoft.iot.vmp.vmanager.service.IMediaService;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IMediaService;
+import com.genersoft.iot.vmp.service.IPlayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java
index 020a26c..9ce2672 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java
@@ -5,7 +5,7 @@
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
//import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.vmanager.service.IPlayService;
+import com.genersoft.iot.vmp.service.IPlayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
index 95b83ef..6fc3bee 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
@@ -3,7 +3,7 @@
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService;
+import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
new file mode 100644
index 0000000..1dd9036
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
@@ -0,0 +1,57 @@
+package com.genersoft.iot.vmp.vmanager.streamPush;
+
+import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.service.IStreamPushService;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.vmanager.media.MediaController;
+import com.github.pagehelper.PageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+@Controller
+@CrossOrigin
+@RequestMapping(value = "/api/push")
+public class StreamPushController {
+
+ private final static Logger logger = LoggerFactory.getLogger(StreamPushController.class);
+
+ @Autowired
+ private IStreamPushService streamPushService;
+
+ @RequestMapping(value = "/list")
+ @ResponseBody
+ public PageInfo<StreamPushItem> list(@RequestParam(required = false)Integer page,
+ @RequestParam(required = false)Integer count,
+ @RequestParam(required = false)String q,
+ @RequestParam(required = false)Boolean online ){
+
+ PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page - 1, page - 1 + count);
+ return pushList;
+ }
+
+ @RequestMapping(value = "/saveToGB")
+ @ResponseBody
+ public Object saveToGB(@RequestBody GbStream stream){
+ if (streamPushService.saveToGB(stream)){
+ return "success";
+ }else {
+ return "fail";
+ }
+ }
+
+ @RequestMapping(value = "/removeFormGB")
+ @ResponseBody
+ public Object removeFormGB(@RequestBody GbStream stream){
+ if (streamPushService.removeFromGB(stream)){
+ return "success";
+ }else {
+ return "fail";
+ }
+ }
+}
diff --git a/src/main/resources/wvp.sqlite b/src/main/resources/wvp.sqlite
index 315c689..f6c7257 100644
--- a/src/main/resources/wvp.sqlite
+++ b/src/main/resources/wvp.sqlite
Binary files differ
diff --git a/web_src/src/components/PLatformStreamList.vue b/web_src/src/components/PLatformStreamList.vue
deleted file mode 100644
index ef5b5ec..0000000
--- a/web_src/src/components/PLatformStreamList.vue
+++ /dev/null
@@ -1,283 +0,0 @@
-<template>
- <div id="pLatformStreamList">
- <el-container>
- <el-header>
- <uiHeader></uiHeader>
- </el-header>
- <el-main>
- <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
- <span style="font-size: 1rem; font-weight: bold;">鐩存挱绾ц仈鍒楄〃</span>
- </div>
- <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
- <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">娣诲姞浠g悊</el-button>
- </div>
- <devicePlayer ref="devicePlayer"></devicePlayer>
- <el-table :data="streamProxyList" border style="width: 100%" :height="winHeight">
- <el-table-column prop="app" label="搴旂敤鍚�" align="center" show-overflow-tooltip/>
- <el-table-column prop="stream" label="娴両D" align="center" show-overflow-tooltip/>
- <el-table-column prop="gbId" label="鍥芥爣骞冲彴" align="center" show-overflow-tooltip/>
-
- <el-table-column label="杞琀LS" width="120" align="center">
- <template slot-scope="scope">
- <div slot="reference" class="name-wrapper">
- <el-tag size="medium" v-if="scope.row.enable_hls">宸插惎鐢�</el-tag>
- <el-tag size="medium" type="info" v-if="!scope.row.enable_hls">鏈惎鐢�</el-tag>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="MP4褰曞埗" width="120" align="center">
- <template slot-scope="scope">
- <div slot="reference" class="name-wrapper">
- <el-tag size="medium" v-if="scope.row.enable_mp4">宸插惎鐢�</el-tag>
- <el-tag size="medium" type="info" v-if="!scope.row.enable_mp4">鏈惎鐢�</el-tag>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="鍚敤" width="120" align="center">
- <template slot-scope="scope">
- <div slot="reference" class="name-wrapper">
- <el-tag size="medium" v-if="scope.row.enable">宸插惎鐢�</el-tag>
- <el-tag size="medium" type="info" v-if="!scope.row.enable">鏈惎鐢�</el-tag>
- </div>
- </template>
- </el-table-column>
-
- <el-table-column label="鎿嶄綔" width="360" align="center" fixed="right">
- <template slot-scope="scope">
- <el-button-group>
- <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.enable" @click="play(scope.row)">鎾斁</el-button>
- <el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">鍋滅敤</el-button>
- <el-button size="mini" icon="el-icon-check" type="primary" v-if="!scope.row.enable" @click="start(scope.row)">鍚敤</el-button>
- <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">鍒犻櫎</el-button>
- <!-- <el-button size="mini" icon="el-icon-position" type="primary" >鍔犲叆鍥芥爣</el-button> -->
- </el-button-group>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- style="float: right"
- @size-change="handleSizeChange"
- @current-change="currentChange"
- :current-page="currentPage"
- :page-size="count"
- :page-sizes="[15, 25, 35, 50]"
- layout="total, sizes, prev, pager, next"
- :total="total">
- </el-pagination>
- <streamProxyEdit ref="streamProxyEdit" ></streamProxyEdit>
- </el-main>
- </el-container>
- </div>
-</template>
-
-<script>
- import streamProxyEdit from './dialog/StreamProxyEdit.vue'
- import devicePlayer from './dialog/devicePlayer.vue'
- import uiHeader from './UiHeader.vue'
- export default {
- name: 'pLatformStreamList',
- components: {
- devicePlayer,
- streamProxyEdit,
- uiHeader
- },
- data() {
- return {
- streamProxyList: [],
- currentPusher: {}, //褰撳墠鎿嶄綔璁惧瀵硅薄
- updateLooper: 0, //鏁版嵁鍒锋柊杞鏍囧織
- currentDeviceChannelsLenth:0,
- winHeight: window.innerHeight - 200,
- currentPage:1,
- count:15,
- total:0,
- getListLoading: false
- };
- },
- computed: {
- },
- mounted() {
- this.initData();
- // this.updateLooper = setInterval(this.initData, 10000);
- },
- destroyed() {
- this.$destroy('videojs');
- clearTimeout(this.updateLooper);
- },
- methods: {
- initData: function() {
- this.getStreamProxyList();
- },
- currentChange: function(val){
- this.currentPage = val;
- this.getStreamProxyList();
- },
- handleSizeChange: function(val){
- this.count = val;
- this.getStreamProxyList();
- },
- getStreamProxyList: function() {
- let that = this;
- this.getListLoading = true;
- this.$axios.get(`/api/proxy/list`,{
- params: {
- page: that.currentPage,
- count: that.count
- }
- } )
- .then(function (res) {
- console.log(res);
- console.log(res.data.list);
- that.total = res.data.total;
- that.streamProxyList = res.data.list;
- that.getListLoading = false;
- })
- .catch(function (error) {
- console.log(error);
- that.getListLoading = false;
- });
- },
- addStreamProxy: function(){
- this.$refs.streamProxyEdit.openDialog(null, this.initData)
- },
- saveStreamProxy: function(){
- },
- play: function(row){
- let that = this;
- this.getListLoading = true;
- this.$axios.get(`/api/media/getStreamInfoByAppAndStream`,{
- params: {
- app: row.app,
- stream: row.stream
- }
- })
- .then(function (res) {
- that.getListLoading = false;
- that.$refs.devicePlayer.openDialog("streamPlay", null, null, {
- streamInfo: res.data,
- hasAudio: true
- });
- })
- .catch(function (error) {
- console.log(error);
- that.getListLoading = false;
- });
-
- },
- deleteStreamProxy: function(row){
- console.log(1111)
- let that = this;
- this.getListLoading = true;
- this.$axios.get(`/api/proxy/del`,{
- params: {
- app: row.app,
- stream: row.stream
- }
- })
- .then(function (res) {
- that.getListLoading = false;
- that.initData()
- })
- .catch(function (error) {
- console.log(error);
- that.getListLoading = false;
- });
- },
- start: function(row){
- let that = this;
- this.getListLoading = true;
- this.$axios.get(`/api/proxy/start`,{
- params: {
- app: row.app,
- stream: row.stream
- }
- })
- .then(function (res) {
- that.getListLoading = false;
- that.initData()
- })
- .catch(function (error) {
- console.log(error);
- that.getListLoading = false;
- });
- },
- stop: function(row){
- let that = this;
- this.getListLoading = true;
- this.$axios.get(`/api/proxy/stop`,{
- params: {
- app: row.app,
- stream: row.stream
- }
- })
- .then(function (res) {
- that.getListLoading = false;
- that.initData()
- })
- .catch(function (error) {
- console.log(error);
- that.getListLoading = false;
- });
- }
-
- }
- };
-</script>
-
-<style>
- .videoList {
- display: flex;
- flex-wrap: wrap;
- align-content: flex-start;
- }
-
- .video-item {
- position: relative;
- width: 15rem;
- height: 10rem;
- margin-right: 1rem;
- background-color: #000000;
- }
-
- .video-item-img {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- margin: auto;
- width: 100%;
- height: 100%;
- }
-
- .video-item-img:after {
- content: "";
- display: inline-block;
- position: absolute;
- z-index: 2;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- margin: auto;
- width: 3rem;
- height: 3rem;
- background-image: url("../assets/loading.png");
- background-size: cover;
- background-color: #000000;
- }
-
- .video-item-title {
- position: absolute;
- bottom: 0;
- color: #000000;
- background-color: #ffffff;
- line-height: 1.5rem;
- padding: 0.3rem;
- width: 14.4rem;
- }
- .cpoy-btn {
- cursor: pointer;
- margin-right: 10px;
- }
-</style>
diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue
index bbfc5f8..0955cc9 100644
--- a/web_src/src/components/PushVideoList.vue
+++ b/web_src/src/components/PushVideoList.vue
@@ -8,16 +8,16 @@
<div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
<span style="font-size: 1rem; font-weight: bold;">鎺ㄦ祦鍒楄〃</span>
</div>
- <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
- <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">娣诲姞浠g悊</el-button>
- </div>
<devicePlayer ref="devicePlayer"></devicePlayer>
+ <addStreamTOGB ref="addStreamTOGB"></addStreamTOGB>
<el-table :data="pushList" border style="width: 100%" :height="winHeight">
<el-table-column prop="app" label="APP" width="180" align="center">
</el-table-column>
<el-table-column prop="stream" label="娴両D" width="240" align="center">
</el-table-column>
<el-table-column prop="totalReaderCount" label="鍦ㄧ嚎浜烘暟" width="240" align="center">
+ </el-table-column>
+ <el-table-column prop="gbId" label="鍥芥爣缂栫爜" width="150" align="center">
</el-table-column>
<el-table-column label="寮�濮嬫椂闂�" align="center" >
<template slot-scope="scope">
@@ -26,12 +26,19 @@
</el-button-group>
</template>
</el-table-column>
+ <el-table-column label="姝e湪鎺ㄦ祦" align="center" >
+ <template slot-scope="scope">
+ {{!!scope.row.status?'鏄�':'鍚�'}}
+ </template>
+ </el-table-column>
<el-table-column label="鎿嶄綔" width="360" align="center" fixed="right">
<template slot-scope="scope">
<el-button-group>
<el-button size="mini" icon="el-icon-video-play" @click="playPuhsh(scope.row)">鎾斁</el-button>
<el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="!!scope.row.streamId" @click="stopPuhsh(scope.row)">鍋滄</el-button>
+ <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!!scope.row.gbId" @click="addToGB(scope.row)">鍔犲叆鍥芥爣</el-button>
+ <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!scope.row.gbId" @click="removeFromGB(scope.row)">绉诲嚭鍥芥爣</el-button>
</el-button-group>
</template>
</el-table-column>
@@ -55,11 +62,13 @@
<script>
import streamProxyEdit from './dialog/StreamProxyEdit.vue'
import devicePlayer from './dialog/devicePlayer.vue'
+ import addStreamTOGB from './dialog/addStreamTOGB.vue'
import uiHeader from './UiHeader.vue'
export default {
name: 'pushVideoList',
components: {
devicePlayer,
+ addStreamTOGB,
streamProxyEdit,
uiHeader
},
@@ -80,10 +89,9 @@
},
mounted() {
this.initData();
- // this.updateLooper = setInterval(this.initData, 10000);
+ this.updateLooper = setInterval(this.initData, 2000);
},
destroyed() {
- this.$destroy('videojs');
clearTimeout(this.updateLooper);
},
methods: {
@@ -101,7 +109,7 @@
getPushList: function() {
let that = this;
this.getDeviceListLoading = true;
- this.$axios.get(`/api/media/list`,{
+ this.$axios.get(`/api/push/list`,{
params: {
page: that.currentPage,
count: that.count
@@ -119,12 +127,7 @@
that.getDeviceListLoading = false;
});
},
- addStreamProxy: function(){
- console.log(2222)
- this.$refs.streamProxyEdit.openDialog(null, this.initData)
- },
- saveStreamProxy: function(){
- },
+
playPuhsh: function(row){
let that = this;
this.getListLoading = true;
@@ -149,6 +152,23 @@
stopPuhsh: function(row){
console.log(row)
},
+ addToGB: function(row){
+ this.$refs.addStreamTOGB.openDialog({app: row.app, stream: row.stream}, this.initData);
+ },
+ removeFromGB: function(row){
+ var that = this;
+ that.$axios.post(`/api/push/removeFormGB`, row)
+ .then(function (res) {
+ console.log(res);
+ console.log(res.data == "success");
+ if (res.data == "success") {
+ that.initData()
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ },
dateFormat: function(/** timestamp=0 **/) {
var ts = arguments[0] || 0;
var t,y,m,d,h,i,s;
diff --git a/web_src/src/components/StreamProxyList.vue b/web_src/src/components/StreamProxyList.vue
index f76a164..23cda7f 100644
--- a/web_src/src/components/StreamProxyList.vue
+++ b/web_src/src/components/StreamProxyList.vue
@@ -64,7 +64,6 @@
<el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">鍋滅敤</el-button>
<el-button size="mini" icon="el-icon-check" type="primary" v-if="!scope.row.enable" @click="start(scope.row)">鍚敤</el-button>
<el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">鍒犻櫎</el-button>
- <!-- <el-button size="mini" icon="el-icon-position" type="primary" >鍔犲叆鍥芥爣</el-button> -->
</el-button-group>
</template>
</el-table-column>
diff --git a/web_src/src/components/dialog/addStreamTOGB.vue b/web_src/src/components/dialog/addStreamTOGB.vue
new file mode 100644
index 0000000..0b908f8
--- /dev/null
+++ b/web_src/src/components/dialog/addStreamTOGB.vue
@@ -0,0 +1,138 @@
+<template>
+ <div id="addStreamProxy" v-loading="isLoging">
+ <el-dialog
+ title=" 鍔犲叆"
+ width="40%"
+ top="2rem"
+ :close-on-click-modal="false"
+ :visible.sync="showDialog"
+ :destroy-on-close="true"
+ @close="close()"
+ >
+ <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
+ <el-form ref="streamProxy" :rules="rules" :model="proxyParam" label-width="140px">
+ <el-form-item label="鍚嶇О" prop="name">
+ <el-input v-model="proxyParam.name" clearable></el-input>
+ </el-form-item>
+ <el-form-item label="娴佸簲鐢ㄥ悕" prop="app">
+ <el-input v-model="proxyParam.app" clearable :disabled="true"></el-input>
+ </el-form-item>
+ <el-form-item label="娴両D" prop="stream">
+ <el-input v-model="proxyParam.stream" clearable :disabled="true"></el-input>
+ </el-form-item>
+ <el-form-item label="鍥芥爣缂栫爜" prop="gbId">
+ <el-input v-model="proxyParam.gbId" placeholder="璁剧疆鍥芥爣缂栫爜鍙帹閫佸埌鍥芥爣" clearable></el-input>
+ </el-form-item>
+ <el-form-item>
+ <div style="float: right;">
+ <el-button type="primary" @click="onSubmit">淇濆瓨</el-button>
+ <el-button @click="close">鍙栨秷</el-button>
+ </div>
+
+ </el-form-item>
+ </el-form>
+ </div>
+ </el-dialog>
+ </div>
+</template>
+
+<script>
+export default {
+ name: "streamProxyEdit",
+ props: {},
+ computed: {},
+ created() {},
+ data() {
+ // var deviceGBIdRules = async (rule, value, callback) => {
+ // console.log(value);
+ // if (value === "") {
+ // callback(new Error("璇疯緭鍏ヨ澶囧浗鏍囩紪鍙�"));
+ // } else {
+ // var exit = await this.deviceGBIdExit(value);
+ // console.log(exit);
+ // console.log(exit == "true");
+ // console.log(exit === "true");
+ // if (exit) {
+ // callback(new Error("璁惧鍥芥爣缂栧彿宸插瓨鍦�"));
+ // } else {
+ // callback();
+ // }
+ // }
+ // };
+ return {
+ listChangeCallback: null,
+ showDialog: false,
+ isLoging: false,
+ proxyParam: {
+ name: null,
+ app: null,
+ stream: null,
+ gbId: null,
+ },
+
+ rules: {
+ name: [{ required: true, message: "璇疯緭鍏ュ悕绉�", trigger: "blur" }],
+ app: [{ required: true, message: "璇疯緭鍏ュ簲鐢ㄥ悕", trigger: "blur" }],
+ stream: [{ required: true, message: "璇疯緭鍏ユ祦ID", trigger: "blur" }],
+ gbId: [{ required: true, message: "璇疯緭鍏ュ浗鏍囩紪鐮�", trigger: "blur" }],
+ },
+ };
+ },
+ methods: {
+ openDialog: function (proxyParam, callback) {
+ this.showDialog = true;
+ this.listChangeCallback = callback;
+ if (proxyParam != null) {
+ this.proxyParam = proxyParam;
+ }
+ },
+ onSubmit: function () {
+ console.log("onSubmit");
+ var that = this;
+ that.$axios
+ .post(`/api/push/saveToGB`, that.proxyParam)
+ .then(function (res) {
+ console.log(res);
+ console.log(res.data == "success");
+ if (res.data == "success") {
+ that.$message({
+ showClose: true,
+ message: "淇濆瓨鎴愬姛",
+ type: "success",
+ });
+ that.showDialog = false;
+ if (that.listChangeCallback != null) {
+ that.listChangeCallback();
+ }
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ },
+ close: function () {
+ console.log("鍏抽棴鍔犲叆GB");
+ this.showDialog = false;
+ this.$refs.streamProxy.resetFields();
+ },
+ deviceGBIdExit: async function (deviceGbId) {
+ var result = false;
+ var that = this;
+ await that.$axios
+ .post(`/api/platforms/exit/${deviceGbId}`)
+ .then(function (res) {
+ result = res.data;
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ return result;
+ },
+ checkExpires: function() {
+ if (this.platform.enable && this.platform.expires == "0") {
+ this.platform.expires = "300";
+ }
+ }
+ },
+};
+</script>
diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue
index 0824cbb..ff65532 100644
--- a/web_src/src/components/dialog/chooseChannelForStream.vue
+++ b/web_src/src/components/dialog/chooseChannelForStream.vue
@@ -10,8 +10,6 @@
</el-table-column>
<el-table-column prop="gbId" label="鍥芥爣缂栫爜" show-overflow-tooltip>
</el-table-column>
- <el-table-column prop="streamType" label="娴佹潵婧�" align="center" show-overflow-tooltip>
- </el-table-column>
<el-table-column label="娴佹潵婧�" width="100" align="center">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js
index 3df0823..4735e62 100644
--- a/web_src/src/router/index.js
+++ b/web_src/src/router/index.js
@@ -6,7 +6,6 @@
import channelList from '../components/channelList.vue'
import pushVideoList from '../components/PushVideoList.vue'
import streamProxyList from '../components/StreamProxyList.vue'
-import pLatformStreamList from '../components/PLatformStreamList.vue'
import devicePosition from '../components/devicePosition.vue'
import login from '../components/Login.vue'
import parentPlatformList from '../components/ParentPlatformList.vue'
@@ -33,10 +32,6 @@
{
path: '/pushVideoList',
component: pushVideoList,
- },
- {
- path: '/pLatformStreamList',
- component: pLatformStreamList,
},
{
path: '/streamProxyList',
--
Gitblit v1.8.0