zlm 回调接口延迟较久 导致全速推流时 从 rtmp 转推 rtp 期间 丢失 大量数据
故只能采用暴力轮询以最快速度启动rtp转推
This commit is contained in:
parent
89814f3e0d
commit
39467e9cfb
@ -114,11 +114,11 @@ public class DeviceProxyService {
|
|||||||
.retryIfException()
|
.retryIfException()
|
||||||
.retryIfRuntimeException()
|
.retryIfRuntimeException()
|
||||||
// 重试间隔
|
// 重试间隔
|
||||||
.withWaitStrategy(WaitStrategies.fixedWait(3, TimeUnit.SECONDS))
|
.withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.MILLISECONDS))
|
||||||
// 重试次数
|
// 重试次数
|
||||||
.withStopStrategy(StopStrategies.stopAfterAttempt(3))
|
.withStopStrategy(StopStrategies.stopAfterAttempt(1000))
|
||||||
.build();
|
.build();
|
||||||
zlmStreamChangeHookService.getRegistHandler(DEFAULT_ZLM_APP).put(callId,()->{
|
// zlmStreamChangeHookService.getRegistHandler(DEFAULT_ZLM_APP).put(callId,()->{
|
||||||
try {
|
try {
|
||||||
retryer.call(()->{
|
retryer.call(()->{
|
||||||
StartSendRtp startSendRtp = new StartSendRtp();
|
StartSendRtp startSendRtp = new StartSendRtp();
|
||||||
@ -139,7 +139,7 @@ public class DeviceProxyService {
|
|||||||
.ifPresent(ZlmStreamChangeHookService.ZlmStreamChangeHookHandler::handler);
|
.ifPresent(ZlmStreamChangeHookService.ZlmStreamChangeHookHandler::handler);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
// });
|
||||||
|
|
||||||
// });
|
// });
|
||||||
zlmStreamChangeHookService.getUnregistHandler(DEFAULT_ZLM_APP).put(callId,()->{
|
zlmStreamChangeHookService.getUnregistHandler(DEFAULT_ZLM_APP).put(callId,()->{
|
||||||
@ -234,9 +234,16 @@ public class DeviceProxyService {
|
|||||||
Flow.Subscriber<SIPRequest> task = ffmpegTask(request, downloadTask, callId, key, device);
|
Flow.Subscriber<SIPRequest> task = ffmpegTask(request, downloadTask, callId, key, device);
|
||||||
try {
|
try {
|
||||||
String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId);
|
String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId);
|
||||||
|
scheduledExecutorService.submit(()->{
|
||||||
|
try {
|
||||||
|
requestZlmPushStream(request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
|
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
|
||||||
Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
|
Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
|
||||||
requestZlmPushStream(request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc);
|
|
||||||
scheduledExecutorService.schedule(task::onComplete, time + 60, TimeUnit.SECONDS);
|
scheduledExecutorService.schedule(task::onComplete, time + 60, TimeUnit.SECONDS);
|
||||||
downloadTask.put(device.getDeviceCode(), executor);
|
downloadTask.put(device.getDeviceCode(), executor);
|
||||||
executeResultHandler.waitFor();
|
executeResultHandler.waitFor();
|
||||||
|
Loading…
Reference in New Issue
Block a user