改为 使用独立的zlm 服务 并 hook
视频 先 ffmpeg 推流到 zlm 再由zlm携带 ssrc 推流到目标 服务
This commit is contained in:
parent
995c10e1e8
commit
28d47f89b4
@ -80,12 +80,6 @@ public class DeviceProxyService {
|
|||||||
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, callbackTask);
|
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, callbackTask);
|
||||||
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
|
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
|
||||||
taskNum.getAndIncrement();
|
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,()->{
|
zlmStreamChangeHookService.handlerMap.put(key,()->{
|
||||||
StartSendRtp startSendRtp = new StartSendRtp();
|
StartSendRtp startSendRtp = new StartSendRtp();
|
||||||
startSendRtp.setApp("rtp");
|
startSendRtp.setApp("rtp");
|
||||||
@ -98,6 +92,12 @@ public class DeviceProxyService {
|
|||||||
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
|
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
|
||||||
log.info("startSendRtpResp {}",startSendRtpResp);
|
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);
|
scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS);
|
||||||
callbackTask.put(device.getDeviceCode(), executor);
|
callbackTask.put(device.getDeviceCode(), executor);
|
||||||
executeResultHandler.waitFor();
|
executeResultHandler.waitFor();
|
||||||
@ -112,11 +112,6 @@ public class DeviceProxyService {
|
|||||||
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, downloadTask);
|
Flow.Subscriber<SIPRequest> subscriber = byeSubscriber(key, device, downloadTask);
|
||||||
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
|
subscribe.getByeSubscribe().addSubscribe(key, subscriber);
|
||||||
taskNum.getAndIncrement();
|
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,()->{
|
zlmStreamChangeHookService.handlerMap.put(key,()->{
|
||||||
StartSendRtp startSendRtp = new StartSendRtp();
|
StartSendRtp startSendRtp = new StartSendRtp();
|
||||||
startSendRtp.setApp("rtp");
|
startSendRtp.setApp("rtp");
|
||||||
@ -129,8 +124,13 @@ public class DeviceProxyService {
|
|||||||
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
|
StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp);
|
||||||
log.info("startSendRtpResp {}",startSendRtpResp);
|
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);
|
scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS);
|
||||||
|
downloadTask.put(device.getDeviceCode(), executor);
|
||||||
executeResultHandler.waitFor();
|
executeResultHandler.waitFor();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class ZlmStreamChangeHookService {
|
|||||||
|
|
||||||
public ConcurrentMap<String, ZlmStreamChangeHookHandler> handlerMap = new ConcurrentHashMap<>();
|
public ConcurrentMap<String, ZlmStreamChangeHookHandler> handlerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
synchronized public void processEvent(String streamId, Boolean regist){
|
public void processEvent(String streamId, Boolean regist){
|
||||||
if(!regist){
|
if(!regist){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user