视频下载改为使用动态端口

This commit is contained in:
zxb 2024-03-16 23:45:38 +08:00
parent abe3194c5f
commit fb5f42baee
2 changed files with 16 additions and 3 deletions

View File

@ -47,6 +47,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/**
* SIP命令类型 ACK请求
@ -193,19 +194,30 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
zlmPublishHookService.getHandler(sendRtpItem.getApp()).put(sendRtpItem.getStreamId(),()->{
taskExecutor.submit(()->{
JSONObject startSendRtpStreamResult;
AtomicReference<String> failMag = new AtomicReference<>("");
Retryer<JSONObject> retryer = RetryerBuilder.<JSONObject>newBuilder()
.retryIfResult(resp -> resp == null || resp.getInteger("code") != 0)
.retryIfResult(resp -> {
if(resp != null && resp.getInteger("code") == -1){
String msg = resp.getString("msg");
if(!msg.equalsIgnoreCase(failMag.get())){
failMag.set(msg);
logger.debug(msg);
}
}
return resp == null || resp.getInteger("code") != 0;
})
.retryIfException()
.retryIfRuntimeException()
// 重试间隔
.withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.MILLISECONDS))
// 重试次数
.withStopStrategy(StopStrategies.stopAfterAttempt(20 * 1000))
.withStopStrategy(StopStrategies.stopAfterAttempt(15 * 1000))
.build();
try {
startSendRtpStreamResult = retryer.call(() -> zlmServerFactory.startSendRtpStream(mediaInfo, param));
logger.info("rtp转推成功 {} {} {}", channelId, mediaInfo, param);
} catch (ExecutionException | RetryException e) {
logger.error("rtp转推失败 {}",e.getMessage());
logger.error("rtp转推失败 {} {} {} {}", channelId, mediaInfo, param, e.getMessage());
startSendRtpStreamResult = null;
}
startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader);

View File

@ -596,6 +596,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());
sendRtpItem.setStreamId(ssrcInfo.getStream());
sendRtpItem.setLocalPort(0);
// 写入redis 超时时回复
redisCatchStorage.updateSendRTPSever(sendRtpItem);