Browse Source

拉流代理接口添加无人观看则自动移除参数,拉流代理返回值增加流地址信息

pull/249/head
648540858 3 years ago
parent
commit
20082441ef
  1. 1
      sql/mysql.sql
  2. 15
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  3. 6
      src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
  4. 6
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
  5. 8
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  6. 6
      src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
  7. 5
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  8. BIN
      src/main/resources/wvp.sqlite
  9. 8
      web_src/src/components/StreamProxyList.vue
  10. 2
      web_src/src/components/dialog/StreamProxyEdit.vue

1
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)
);

15
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<String>(ret.toString(),HttpStatus.OK);
}

6
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);
}

6
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);
}
}

8
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);
}

6
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);

5
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);
}
}

BIN
src/main/resources/wvp.sqlite

Binary file not shown.

8
web_src/src/components/StreamProxyList.vue

@ -66,6 +66,14 @@
</div>
</template>
</el-table-column>
<el-table-column label="无人观看自动删除" width="160" align="center">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.enable_remove_none_reader">已启用</el-tag>
<el-tag size="medium" type="info" v-if="!scope.row.enable_remove_none_reader">未启用</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="360" align="center" fixed="right">

2
web_src/src/components/dialog/StreamProxyEdit.vue

@ -106,6 +106,7 @@
<el-checkbox label="启用" v-model="proxyParam.enable" ></el-checkbox>
<el-checkbox label="转HLS" v-model="proxyParam.enable_hls" ></el-checkbox>
<el-checkbox label="MP4录制" v-model="proxyParam.enable_mp4" ></el-checkbox>
<el-checkbox label="无人观看自动删除" v-model="proxyParam.enable_remove_none_reader" ></el-checkbox>
</div>
</el-form-item>
@ -169,6 +170,7 @@ export default {
enable: true,
enable_hls: true,
enable_mp4: false,
enable_remove_none_reader: false,
platformGbId: null,
mediaServerId: "auto",
},

Loading…
Cancel
Save