Commit b25f3631eef140a058be690530d09ce9b219c44a
1 parent
b6bcb5f2
国标级联支持拉流代理自动拉起
Showing
1 changed file
with
30 additions
and
12 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -502,22 +502,18 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 502 | 502 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 503 | 503 | } |
| 504 | 504 | }else if ("proxy".equals(gbStream.getStreamType())){ |
| 505 | - if(null != proxyByAppAndStream &&proxyByAppAndStream.isStatus()){ | |
| 506 | - pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 507 | - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); | |
| 508 | - }else{ | |
| 509 | - //开启代理拉流 | |
| 510 | - boolean start1 = streamProxyService.start(gbStream.getApp(), gbStream.getStream()); | |
| 511 | - if(start1) { | |
| 505 | + if (null != proxyByAppAndStream) { | |
| 506 | + if(proxyByAppAndStream.isStatus()){ | |
| 512 | 507 | pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, |
| 513 | 508 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 514 | 509 | }else{ |
| 515 | - //失败后通知 | |
| 510 | + //开启代理拉流 | |
| 516 | 511 | notifyStreamOnline(evt, request,gbStream, null, platform, callIdHeader, mediaServerItem, port, tcpActive, |
| 517 | 512 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 518 | 513 | } |
| 519 | 514 | } |
| 520 | 515 | |
| 516 | + | |
| 521 | 517 | } |
| 522 | 518 | } |
| 523 | 519 | } |
| ... | ... | @@ -629,11 +625,33 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 629 | 625 | if ("proxy".equals(gbStream.getStreamType())) { |
| 630 | 626 | // TODO 控制启用以使设备上线 |
| 631 | 627 | logger.info("[ app={}, stream={} ]通道未推流,启用流后开始推流", gbStream.getApp(), gbStream.getStream()); |
| 632 | - try { | |
| 633 | - responseAck(request, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline"); | |
| 634 | - } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 635 | - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); | |
| 628 | + // 监听流上线 | |
| 629 | + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(gbStream.getApp(), gbStream.getStream(), true, "rtsp", mediaServerItem.getId()); | |
| 630 | + zlmHttpHookSubscribe.addSubscribe(hookSubscribe, (mediaServerItemInUSe, responseJSON) -> { | |
| 631 | + String app = responseJSON.getString("app"); | |
| 632 | + String stream = responseJSON.getString("stream"); | |
| 633 | + logger.info("[上级点播]拉流代理已经就绪, {}/{}", app, stream); | |
| 634 | + dynamicTask.stop(callIdHeader.getCallId()); | |
| 635 | + pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 636 | + mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); | |
| 637 | + }); | |
| 638 | + dynamicTask.startDelay(callIdHeader.getCallId(), () -> { | |
| 639 | + logger.info("[ app={}, stream={} ] 等待拉流代理流超时", gbStream.getApp(), gbStream.getStream()); | |
| 640 | + zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); | |
| 641 | + }, userSetting.getPlatformPlayTimeout()); | |
| 642 | + boolean start = streamProxyService.start(gbStream.getApp(), gbStream.getStream()); | |
| 643 | + if (!start) { | |
| 644 | + try { | |
| 645 | + responseAck(request, Response.BUSY_HERE, "channel [" + gbStream.getGbId() + "] offline"); | |
| 646 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 647 | + logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); | |
| 648 | + } | |
| 649 | + zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); | |
| 650 | + dynamicTask.stop(callIdHeader.getCallId()); | |
| 636 | 651 | } |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 637 | 655 | } else if ("push".equals(gbStream.getStreamType())) { |
| 638 | 656 | if (!platform.isStartOfflinePush()) { |
| 639 | 657 | // 平台设置中关闭了拉起离线的推流则直接回复 | ... | ... |