@Scheduled(fixedDelay = 5 * 1000)//Every 5 seconds
public void killHLSStreams() {
long now = new Date().getTime();
Map<Thread, IStreamTask> HLSTasksFore = new HashMap(HLSTasks);
for (Entry<Thread, IStreamTask> entry : HLSTasksFore.entrySet()) {
HLSTask hlsTask = (HLSTask) entry.getValue();
if (hlsTask.getLastAccess() != null) {
long difference = (now - hlsTask.getLastAccess()) / 1000;
if (difference > config.getFfmpeg().getHls().getTimeout()) {
//Kill all stream processors using this task
for (ClientInfo client : new ArrayList<>(streamProcessorsSession.getClientInfoList())) {
for (IStreamProcessor streamProcessor : new ArrayList<>(client.getStreams())) {
IStreamTask streamBindedTask = streamProcessor.getTask();
if (streamBindedTask == hlsTask) {
try {
streamProcessor.stop(false);
streamProcessorsSession.removeClientInfo(client, streamProcessor);
} catch (Exception ex) {
}
}
}
}
}
}
}
}
ProcessorTasks.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:proxylive
作者:
评论列表
文章目录