重构点播,回放,下载时ssrc不一致以及TCP主动播放的逻辑

This commit is contained in:
648540858
2023-08-04 15:47:56 +08:00
parent ba884fa9ef
commit 988dc36fa5
9 changed files with 198 additions and 273 deletions

View File

@@ -46,6 +46,9 @@ public class DynamicTask {
* @return
*/
public void startCron(String key, Runnable task, int cycleForCatalog) {
if(ObjectUtils.isEmpty(key)) {
return;
}
ScheduledFuture<?> future = futureMap.get(key);
if (future != null) {
if (future.isCancelled()) {
@@ -74,6 +77,9 @@ public class DynamicTask {
* @return
*/
public void startDelay(String key, Runnable task, int delay) {
if(ObjectUtils.isEmpty(key)) {
return;
}
stop(key);
// 获取执行的时刻
@@ -100,9 +106,12 @@ public class DynamicTask {
}
public boolean stop(String key) {
if(ObjectUtils.isEmpty(key)) {
return false;
}
boolean result = false;
if (!ObjectUtils.isEmpty(futureMap.get(key)) && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) {
result = futureMap.get(key).cancel(false);
result = futureMap.get(key).cancel(true);
futureMap.remove(key);
runnableMap.remove(key);
}
@@ -110,6 +119,9 @@ public class DynamicTask {
}
public boolean contains(String key) {
if(ObjectUtils.isEmpty(key)) {
return false;
}
return futureMap.get(key) != null;
}
@@ -118,6 +130,9 @@ public class DynamicTask {
}
public Runnable get(String key) {
if(ObjectUtils.isEmpty(key)) {
return null;
}
return runnableMap.get(key);
}