From 20082441ef5f6d62b93d572cc5dfebb3616bea9a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 24 Nov 2021 15:09:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E6=B5=81=E4=BB=A3=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=B7=BB=E5=8A=A0=E6=97=A0=E4=BA=BA=E8=A7=82=E7=9C=8B?= =?UTF-8?q?=E5=88=99=E8=87=AA=E5=8A=A8=E7=A7=BB=E9=99=A4=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E6=8B=89=E6=B5=81=E4=BB=A3=E7=90=86=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E5=A2=9E=E5=8A=A0=E6=B5=81=E5=9C=B0=E5=9D=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 1 + .../vmp/media/zlm/ZLMHttpHookListener.java | 15 ++++++++++++++- .../iot/vmp/service/IStreamProxyService.java | 6 ++++++ .../service/impl/StreamProxyServiceImpl.java | 6 ++++++ .../vmp/storager/IVideoManagerStorager.java | 8 ++++++++ .../vmp/storager/dao/StreamProxyMapper.java | 6 ++++-- .../impl/VideoManagerStoragerImpl.java | 5 +++++ src/main/resources/wvp.sqlite | Bin 143360 -> 143360 bytes web_src/src/components/StreamProxyList.vue | 8 ++++++++ .../src/components/dialog/StreamProxyEdit.vue | 2 ++ 10 files changed, 54 insertions(+), 3 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index cd5bbea7..38cc8814 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -208,6 +208,7 @@ create table stream_proxy enable_hls bit null, enable_mp4 bit null, enable bit not null, + enable_remove_none_reader bit not null, createTime varchar(50) not null, primary key (app, stream) ); 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 16802cbb..d6e77c74 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 @@ -11,8 +11,10 @@ import com.genersoft.iot.vmp.conf.UserSetup; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaService; +import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; @@ -59,6 +61,9 @@ public class ZLMHttpHookListener { @Autowired private IMediaServerService mediaServerService; + @Autowired + private IStreamProxyService streamProxyService; + @Autowired private IMediaService mediaService; @@ -383,7 +388,15 @@ public class ZLMHttpHookListener { }else { JSONObject ret = new JSONObject(); ret.put("code", 0); - ret.put("close", false); + StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); + if (streamProxyItem != null && streamProxyItem.isEnable_remove_none_reader()) { + ret.put("close", true); + streamProxyService.del(app, streamId); + String url = streamProxyItem.getUrl() != null?streamProxyItem.getUrl():streamProxyItem.getSrc_url(); + logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, streamId, url); + }else { + ret.put("close", false); + } return new ResponseEntity(ret.toString(),HttpStatus.OK); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java index 4c68c61c..60f3303b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java @@ -65,4 +65,10 @@ public interface IStreamProxyService { * @return */ JSONObject getFFmpegCMDs(MediaServerItem mediaServerItem); + + /** + * 根据app与stream获取streamProxy + * @return + */ + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index a10e3404..3ffc68e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -228,4 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { return result; } + + + @Override + public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { + return videoManagerStorager.getStreamProxyByAppAndStream(app, streamId); + } } 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 3f4b73fa..570718b3 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java @@ -406,4 +406,12 @@ public interface IVideoManagerStorager { * @param channelId 通道ID */ void deviceChannelOffline(String deviceId, String channelId); + + /** + * 通过app与stream获取StreamProxy + * @param app + * @param streamId + * @return + */ + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java index 7346da5c..11753f7e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java @@ -11,9 +11,10 @@ import java.util.List; public interface StreamProxyMapper { @Insert("INSERT INTO stream_proxy (type, app, stream,mediaServerId, url, src_url, dst_url, " + - "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, createTime) VALUES" + + "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, enable_remove_none_reader, createTime) VALUES" + "('${type}','${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " + - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, '${createTime}' )") + "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, " + + "${enable_remove_none_reader}, '${createTime}' )") int add(StreamProxyItem streamProxyDto); @Update("UPDATE stream_proxy " + @@ -29,6 +30,7 @@ public interface StreamProxyMapper { "rtp_type=#{rtp_type}, " + "enable_hls=#{enable_hls}, " + "enable=#{enable}, " + + "enable_remove_none_reader=#{enable_remove_none_reader}, " + "enable_mp4=#{enable_mp4} " + "WHERE app=#{app} AND stream=#{stream}") int update(StreamProxyItem streamProxyDto); 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 37905eca..9ad44d40 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 @@ -651,4 +651,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { } return result; } + + @Override + public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { + return streamProxyMapper.selectOne(app, streamId); + } } diff --git a/src/main/resources/wvp.sqlite b/src/main/resources/wvp.sqlite index 88aea8ed9553093903711d0bdd6559469522be1b..f969514a31bb26b222e37d31fa254e41e3912b5b 100644 GIT binary patch delta 913 zcmZp8z|ru4V}i8cGX@3*WgwOTVkQO#X03@j#*EK4Cd}t&lv*SZu&IGtfRTN(V89pt zO${s))cBYk82H!moaE`@T*6t%Zp8MP^)>4fmMbj%%nm%^JW5=TxXy5$*(@kv$0*2n zOI%Wtv7KuZ<3({*RmQgX?H1mQEsRPEsdIjQkQsk!-OsquOFc_4OTN@|gUr(cMx zyKB(&-9C(p+Z}`%OW7FwXqR<|_=lm}fIh zXG)kjaS~UvvMD>*Bb?KL9+8z}cMfuO3~^Nmadh%=RZxODs-P&pqEd-VWBLUTM)8ou zf&zsQ*N6~>y!;Y{ywaQ;9WG9YLJZ;3q8zXoNJUX{JQ6phxCG2~^6_^9%1;02%_tJi znUmocTqW>6v*UAWuWn56D4EXvWB~-Oh>8hM7&ps-1S hMPM_F0J{LABsdo>Y7m$hz|P7D%x=;!fn^sM697}g4(tE` delta 415 zcmZp8z|ru4V}i8cT?PgQWgzANVkQO#X2pp*#*BA2Cd}t&6kQ|`uw7vR<8%Ir3lvxx zfeP5S3oc;%!oMkjTVONygrD^)Jj@OZ{Ofp5^7L>n;Vfh~V*AYcnso`w6_$Qx2N>Ke zDB!@z!FWqtQj)QqbGo}bqdad)YFTD-DwhTq*MG(pKm|(}w>t(0o}#O7_nCLV7&eW5d>#Ps>{jO>&9xzx8SxG;WT;%d#7WfxafW$c!mypctAyQMGV zai;Ad-i-W=(r!RD3l%CEm&3I$_0Wn6Q>GPx*xj8ktG)<-1 z#66WkhAT{Ob7B + + + diff --git a/web_src/src/components/dialog/StreamProxyEdit.vue b/web_src/src/components/dialog/StreamProxyEdit.vue index c9330fdf..fa09cf8d 100644 --- a/web_src/src/components/dialog/StreamProxyEdit.vue +++ b/web_src/src/components/dialog/StreamProxyEdit.vue @@ -106,6 +106,7 @@ + @@ -169,6 +170,7 @@ export default { enable: true, enable_hls: true, enable_mp4: false, + enable_remove_none_reader: false, platformGbId: null, mediaServerId: "auto", },