调整 ffmpeg 启动时机
This commit is contained in:
parent
fdc826e246
commit
2dc1f43401
@ -592,14 +592,17 @@ public class Gb28181DownloadService {
|
||||
public void onNext(SIPResponse item) {
|
||||
int statusCode = item.getStatusCode();
|
||||
log.debug("{} 收到订阅消息 {}", subscribeKey, item);
|
||||
if (statusCode == Response.TRYING) {
|
||||
log.info("订阅 {} {} 尝试连接流媒体服务", MessageProcessor.Method.INVITE, subscribeKey);
|
||||
subscription.request(1);
|
||||
if(statusCode == Response.OK){
|
||||
String callId = item.getCallId().getCallId();
|
||||
if(!isStart){
|
||||
isStart = true;
|
||||
result.completeAsync(() -> new VideoInfo(streamId,videoRtmpUrl(streamId), callId, device), executor);
|
||||
}
|
||||
}
|
||||
|
||||
if (statusCode == Response.TRYING) {
|
||||
log.info("订阅 {} {} 尝试连接流媒体服务", MessageProcessor.Method.INVITE, subscribeKey);
|
||||
subscription.request(1);
|
||||
} else if (statusCode >= Response.OK && statusCode < Response.MULTIPLE_CHOICES) {
|
||||
log.info("订阅 {} {} 流媒体服务连接成功, 开始推送视频流", MessageProcessor.Method.INVITE, subscribeKey);
|
||||
log.info("收到响应状态 {}", statusCode);
|
||||
@ -608,14 +611,16 @@ public class Gb28181DownloadService {
|
||||
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();
|
||||
String key = GenericSubscribe.Helper.getKey(Request.BYE, callId);
|
||||
subscribe.getByeSubscribe().addPublisher(key);
|
||||
subscribe.getByeSubscribe().addSubscribe(key, byeSubscriber(key, device, cacheKey, streamId, time, unit));
|
||||
return SipRequestBuilder.createAckRequest(Response.OK, ip, port, docking, device.getGbDeviceChannelId(), fromTag, toTag, callId);
|
||||
}));
|
||||
scheduledExecutorService.schedule(()->{
|
||||
sender.sendRequest(((provider, ip, port) -> {
|
||||
String fromTag = item.getFromTag();
|
||||
String toTag = item.getToTag();
|
||||
String key = GenericSubscribe.Helper.getKey(Request.BYE, callId);
|
||||
subscribe.getByeSubscribe().addPublisher(key);
|
||||
subscribe.getByeSubscribe().addSubscribe(key, byeSubscriber(key, device, cacheKey, streamId, time, unit));
|
||||
return SipRequestBuilder.createAckRequest(Response.OK, ip, port, docking, device.getGbDeviceChannelId(), fromTag, toTag, callId);
|
||||
}));
|
||||
},100, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
log.info("订阅 {} {} 连接流媒体服务时出现异常, 终止订阅", MessageProcessor.Method.INVITE, subscribeKey);
|
||||
zlmMediaService.closeRtpServer(new CloseRtpServer(streamId));
|
||||
|
Loading…
Reference in New Issue
Block a user