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

pull/249/head
648540858 2021-11-24 15:09:43 +08:00
parent dbcd050c66
commit 20082441ef
10 changed files with 54 additions and 3 deletions

View File

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

View File

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

View File

@ -65,4 +65,10 @@ public interface IStreamProxyService {
* @return
*/
JSONObject getFFmpegCMDs(MediaServerItem mediaServerItem);
/**
* appstreamstreamProxy
* @return
*/
StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId);
}

View File

@ -228,4 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
return result;
}
@Override
public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) {
return videoManagerStorager.getStreamProxyByAppAndStream(app, streamId);
}
}

View File

@ -406,4 +406,12 @@ public interface IVideoManagerStorager {
* @param channelId ID
*/
void deviceChannelOffline(String deviceId, String channelId);
/**
* appstreamStreamProxy
* @param app
* @param streamId
* @return
*/
StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId);
}

View File

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

View File

@ -651,4 +651,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
}
return result;
}
@Override
public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) {
return streamProxyMapper.selectOne(app, streamId);
}
}

Binary file not shown.

View File

@ -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">

View File

@ -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",
},