Commit 20082441ef5f6d62b93d572cc5dfebb3616bea9a
1 parent
dbcd050c
拉流代理接口添加无人观看则自动移除参数,拉流代理返回值增加流地址信息
Showing
10 changed files
with
54 additions
and
3 deletions
sql/mysql.sql
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -11,8 +11,10 @@ import com.genersoft.iot.vmp.conf.UserSetup; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 12 | 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| 13 | 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 14 | +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | |
| 14 | 15 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 15 | 16 | import com.genersoft.iot.vmp.service.IMediaService; |
| 17 | +import com.genersoft.iot.vmp.service.IStreamProxyService; | |
| 16 | 18 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 17 | 19 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 18 | 20 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| ... | ... | @@ -60,6 +62,9 @@ public class ZLMHttpHookListener { |
| 60 | 62 | private IMediaServerService mediaServerService; |
| 61 | 63 | |
| 62 | 64 | @Autowired |
| 65 | + private IStreamProxyService streamProxyService; | |
| 66 | + | |
| 67 | + @Autowired | |
| 63 | 68 | private IMediaService mediaService; |
| 64 | 69 | |
| 65 | 70 | @Autowired |
| ... | ... | @@ -383,7 +388,15 @@ public class ZLMHttpHookListener { |
| 383 | 388 | }else { |
| 384 | 389 | JSONObject ret = new JSONObject(); |
| 385 | 390 | ret.put("code", 0); |
| 386 | - ret.put("close", false); | |
| 391 | + StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); | |
| 392 | + if (streamProxyItem != null && streamProxyItem.isEnable_remove_none_reader()) { | |
| 393 | + ret.put("close", true); | |
| 394 | + streamProxyService.del(app, streamId); | |
| 395 | + String url = streamProxyItem.getUrl() != null?streamProxyItem.getUrl():streamProxyItem.getSrc_url(); | |
| 396 | + logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, streamId, url); | |
| 397 | + }else { | |
| 398 | + ret.put("close", false); | |
| 399 | + } | |
| 387 | 400 | return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); |
| 388 | 401 | } |
| 389 | 402 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
| ... | ... | @@ -65,4 +65,10 @@ public interface IStreamProxyService { |
| 65 | 65 | * @return |
| 66 | 66 | */ |
| 67 | 67 | JSONObject getFFmpegCMDs(MediaServerItem mediaServerItem); |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 根据app与stream获取streamProxy | |
| 71 | + * @return | |
| 72 | + */ | |
| 73 | + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); | |
| 68 | 74 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| ... | ... | @@ -228,4 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 228 | 228 | |
| 229 | 229 | return result; |
| 230 | 230 | } |
| 231 | + | |
| 232 | + | |
| 233 | + @Override | |
| 234 | + public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { | |
| 235 | + return videoManagerStorager.getStreamProxyByAppAndStream(app, streamId); | |
| 236 | + } | |
| 231 | 237 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| ... | ... | @@ -406,4 +406,12 @@ public interface IVideoManagerStorager { |
| 406 | 406 | * @param channelId 通道ID |
| 407 | 407 | */ |
| 408 | 408 | void deviceChannelOffline(String deviceId, String channelId); |
| 409 | + | |
| 410 | + /** | |
| 411 | + * 通过app与stream获取StreamProxy | |
| 412 | + * @param app | |
| 413 | + * @param streamId | |
| 414 | + * @return | |
| 415 | + */ | |
| 416 | + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); | |
| 409 | 417 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
| ... | ... | @@ -11,9 +11,10 @@ import java.util.List; |
| 11 | 11 | public interface StreamProxyMapper { |
| 12 | 12 | |
| 13 | 13 | @Insert("INSERT INTO stream_proxy (type, app, stream,mediaServerId, url, src_url, dst_url, " + |
| 14 | - "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, createTime) VALUES" + | |
| 14 | + "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, enable_remove_none_reader, createTime) VALUES" + | |
| 15 | 15 | "('${type}','${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " + |
| 16 | - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, '${createTime}' )") | |
| 16 | + "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, " + | |
| 17 | + "${enable_remove_none_reader}, '${createTime}' )") | |
| 17 | 18 | int add(StreamProxyItem streamProxyDto); |
| 18 | 19 | |
| 19 | 20 | @Update("UPDATE stream_proxy " + |
| ... | ... | @@ -29,6 +30,7 @@ public interface StreamProxyMapper { |
| 29 | 30 | "rtp_type=#{rtp_type}, " + |
| 30 | 31 | "enable_hls=#{enable_hls}, " + |
| 31 | 32 | "enable=#{enable}, " + |
| 33 | + "enable_remove_none_reader=#{enable_remove_none_reader}, " + | |
| 32 | 34 | "enable_mp4=#{enable_mp4} " + |
| 33 | 35 | "WHERE app=#{app} AND stream=#{stream}") |
| 34 | 36 | int update(StreamProxyItem streamProxyDto); | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -651,4 +651,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 651 | 651 | } |
| 652 | 652 | return result; |
| 653 | 653 | } |
| 654 | + | |
| 655 | + @Override | |
| 656 | + public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { | |
| 657 | + return streamProxyMapper.selectOne(app, streamId); | |
| 658 | + } | |
| 654 | 659 | } | ... | ... |
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/StreamProxyList.vue
| ... | ... | @@ -66,6 +66,14 @@ |
| 66 | 66 | </div> |
| 67 | 67 | </template> |
| 68 | 68 | </el-table-column> |
| 69 | + <el-table-column label="无人观看自动删除" width="160" align="center"> | |
| 70 | + <template slot-scope="scope"> | |
| 71 | + <div slot="reference" class="name-wrapper"> | |
| 72 | + <el-tag size="medium" v-if="scope.row.enable_remove_none_reader">已启用</el-tag> | |
| 73 | + <el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader">未启用</el-tag> | |
| 74 | + </div> | |
| 75 | + </template> | |
| 76 | + </el-table-column> | |
| 69 | 77 | |
| 70 | 78 | |
| 71 | 79 | <el-table-column label="操作" width="360" align="center" fixed="right"> | ... | ... |
web_src/src/components/dialog/StreamProxyEdit.vue
| ... | ... | @@ -106,6 +106,7 @@ |
| 106 | 106 | <el-checkbox label="启用" v-model="proxyParam.enable" ></el-checkbox> |
| 107 | 107 | <el-checkbox label="转HLS" v-model="proxyParam.enable_hls" ></el-checkbox> |
| 108 | 108 | <el-checkbox label="MP4录制" v-model="proxyParam.enable_mp4" ></el-checkbox> |
| 109 | + <el-checkbox label="无人观看自动删除" v-model="proxyParam.enable_remove_none_reader" ></el-checkbox> | |
| 109 | 110 | </div> |
| 110 | 111 | |
| 111 | 112 | </el-form-item> |
| ... | ... | @@ -169,6 +170,7 @@ export default { |
| 169 | 170 | enable: true, |
| 170 | 171 | enable_hls: true, |
| 171 | 172 | enable_mp4: false, |
| 173 | + enable_remove_none_reader: false, | |
| 172 | 174 | platformGbId: null, |
| 173 | 175 | mediaServerId: "auto", |
| 174 | 176 | }, | ... | ... |