diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java index f271a5d..57ac72a 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java @@ -571,7 +571,7 @@ public class Gb28181DownloadService { subscribe.getInviteSubscribe().addSubscribe(subscribeKey, subscriber); RedisUtil.StringOps.set(cacheKey, callId.getCallId()); // 用以 提前 启动 ffmpeg 预备录制 - result.completeAsync(() -> new VideoInfo(streamId, videoRtmpUrl(streamId), callId.getCallId(), device), executor); + // result.completeAsync(() -> new VideoInfo(streamId, videoRtmpUrl(streamId), callId.getCallId(), device), executor); return SipRequestBuilder.createInviteRequest(ip, port, docking, device.getGbDeviceChannelId(), description.toString(), SipUtil.generateViaTag(), SipUtil.generateFromTag(), null, ssrc, callId); }; } @@ -580,6 +580,7 @@ public class Gb28181DownloadService { ScheduledFuture[] schedule = new ScheduledFuture[1]; Flow.Subscriber subscriber = new Flow.Subscriber<>() { private Flow.Subscription subscription; + private boolean isStart = false; @Override public void onSubscribe(Flow.Subscription subscription) { this.subscription = subscription; @@ -594,10 +595,19 @@ public class Gb28181DownloadService { if (statusCode == Response.TRYING) { log.info("订阅 {} {} 尝试连接流媒体服务", MessageProcessor.Method.INVITE, subscribeKey); subscription.request(1); + String callId = item.getCallId().getCallId(); + if(!isStart){ + isStart = true; + result.completeAsync(() -> new VideoInfo(streamId,videoRtmpUrl(streamId), callId, device), executor); + } } else if (statusCode >= Response.OK && statusCode < Response.MULTIPLE_CHOICES) { log.info("订阅 {} {} 流媒体服务连接成功, 开始推送视频流", MessageProcessor.Method.INVITE, subscribeKey); log.info("收到响应状态 {}", statusCode); String callId = item.getCallId().getCallId(); + if(!isStart){ + isStart = true; + result.completeAsync(() -> new VideoInfo(streamId,videoRtmpUrl(streamId), callId, device), executor); + } sender.sendRequest(((provider, ip, port) -> { String fromTag = item.getFromTag(); String toTag = item.getToTag();