改为 使用独立的zlm 服务 并 hook

视频 先 ffmpeg 推流到 zlm
再由zlm携带 ssrc 推流到目标 服务
This commit is contained in:
shikong 2023-10-01 03:30:58 +08:00
parent 995c10e1e8
commit 28d47f89b4
2 changed files with 13 additions and 13 deletions

View File

@ -80,12 +80,6 @@ public class DeviceProxyService {
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, callbackTask);
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
taskNum.getAndIncrement();
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key));
log.info("openRtpServerResp {}",openRtpServerResp);
Integer port = openRtpServerResp.getPort();
String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port;
Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
zlmStreamChangeHookService.handlerMap.put(key,()->{
StartSendRtp startSendRtp = new StartSendRtp();
startSendRtp.setApp("rtp");
@ -98,6 +92,12 @@ public class DeviceProxyService {
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
log.info("startSendRtpResp {}",startSendRtpResp);
});
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key));
log.info("openRtpServerResp {}",openRtpServerResp);
Integer port = openRtpServerResp.getPort();
String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port;
Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS);
callbackTask.put(device.getDeviceCode(), executor);
executeResultHandler.waitFor();
@ -112,11 +112,6 @@ public class DeviceProxyService {
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, downloadTask);
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
taskNum.getAndIncrement();
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key));
Integer port = openRtpServerResp.getPort();
String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port;
Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
zlmStreamChangeHookService.handlerMap.put(key,()->{
StartSendRtp startSendRtp = new StartSendRtp();
startSendRtp.setApp("rtp");
@ -129,8 +124,13 @@ public class DeviceProxyService {
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
log.info("startSendRtpResp {}",startSendRtpResp);
});
downloadTask.put(device.getDeviceCode(), executor);
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key));
Integer port = openRtpServerResp.getPort();
String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port;
Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler);
scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS);
downloadTask.put(device.getDeviceCode(), executor);
executeResultHandler.waitFor();
};
}

View File

@ -16,7 +16,7 @@ public class ZlmStreamChangeHookService {
public ConcurrentMap<String, ZlmStreamChangeHookHandler> handlerMap = new ConcurrentHashMap<>();
synchronized public void processEvent(String streamId, Boolean regist){
public void processEvent(String streamId, Boolean regist){
if(!regist){
return;
}