This commit is contained in:
shikong 2024-03-15 16:01:27 +08:00
parent 5061c3fdda
commit 279ae44a25

View File

@ -222,7 +222,7 @@ public class Gb28181DownloadService {
});
}
download(deviceCode, startTime, endTime, useDownload).whenCompleteAsync((videoInfo, e) -> {
download(deviceCode, startTime, endTime, useDownload).whenComplete((videoInfo, e) -> {
writeFileHeader(response, deviceCode, startTime, endTime, fileHeader);
log.info("videoInfo {}", videoInfo);
if (e != null) {
@ -241,7 +241,7 @@ public class Gb28181DownloadService {
} else {
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND) + 15);
}
}, executor);
});
} catch(Exception e) {
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
} finally {
@ -371,7 +371,7 @@ public class Gb28181DownloadService {
DateTime start = DateUtil.date();
HttpServletResponse asyncResponse = (HttpServletResponse)asyncContext.getResponse();
try{
download(deviceCode, startTime,endTime).whenCompleteAsync((videoInfo, e)->{
download(deviceCode, startTime,endTime).whenComplete((videoInfo, e)->{
streamHeader(asyncResponse);
if(e != null){
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
@ -389,7 +389,7 @@ public class Gb28181DownloadService {
} else {
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND) + 15);
}
}, executor);
});
} catch(Exception e) {
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
@ -593,7 +593,7 @@ public class Gb28181DownloadService {
subscribe.getInviteSubscribe().addSubscribe(subscribeKey, subscriber);
RedisUtil.StringOps.set(cacheKey, callId.getCallId());
// 用以 提前 启动 ffmpeg 预备录制, 需要配置 ffmpeg rw_timeout 时长 避免收不到流
result.completeAsync(() -> new VideoInfo(streamId, videoRtmpUrl(streamId), callId.getCallId(), device), executor);
result.complete(new VideoInfo(streamId, videoRtmpUrl(streamId), callId.getCallId(), device));
return SipRequestBuilder.createInviteRequest(ip, port, docking, device.getGbDeviceChannelId(), description.toString(), SipUtil.generateViaTag(), SipUtil.generateFromTag(), null, ssrc, callId);
};
}