Commit 760b14eaaaf86884960a355e77f1586119f0afa9
1 parent
4ae8c5ac
恢复级联点播
Showing
1 changed file
with
50 additions
and
42 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -18,10 +18,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; |
| 18 | 18 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 19 | 19 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 20 | 20 | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; |
| 21 | -import com.genersoft.iot.vmp.service.IMediaServerService; | |
| 22 | -import com.genersoft.iot.vmp.service.IPlayService; | |
| 23 | -import com.genersoft.iot.vmp.service.IStreamProxyService; | |
| 24 | -import com.genersoft.iot.vmp.service.IStreamPushService; | |
| 21 | +import com.genersoft.iot.vmp.service.*; | |
| 25 | 22 | import com.genersoft.iot.vmp.service.bean.ErrorCallback; |
| 26 | 23 | import com.genersoft.iot.vmp.service.bean.InviteErrorCode; |
| 27 | 24 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; |
| ... | ... | @@ -80,6 +77,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 80 | 77 | private IRedisCatchStorage redisCatchStorage; |
| 81 | 78 | |
| 82 | 79 | @Autowired |
| 80 | + private IInviteStreamService inviteStreamService; | |
| 81 | + | |
| 82 | + @Autowired | |
| 83 | 83 | private SSRCFactory ssrcFactory; |
| 84 | 84 | |
| 85 | 85 | @Autowired |
| ... | ... | @@ -479,47 +479,55 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 479 | 479 | errorEvent.run(code, msg, data); |
| 480 | 480 | } |
| 481 | 481 | }); |
| 482 | - } else { | |
| 483 | - sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 484 | - sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 485 | -// SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null); | |
| 486 | - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId); | |
| 487 | - if (streamInfo != null) { | |
| 488 | - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, streamInfo.getApp(), streamInfo.getStream()); | |
| 489 | - if (!streamReady) { | |
| 490 | - redisCatchStorage.stopPlay(streamInfo); | |
| 491 | - storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | |
| 492 | - streamInfo = null; | |
| 493 | - } | |
| 482 | + } else if ("Download".equalsIgnoreCase(sessionName)) { | |
| 483 | + // 获取指定的下载速度 | |
| 484 | + Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true); | |
| 485 | + MediaDescription mediaDescription = null; | |
| 486 | + String downloadSpeed = "1"; | |
| 487 | + if (sdpMediaDescriptions.size() > 0) { | |
| 488 | + mediaDescription = (MediaDescription) sdpMediaDescriptions.get(0); | |
| 494 | 489 | } |
| 495 | - if (streamInfo == null) { | |
| 496 | - String streamId = null; | |
| 497 | - if (mediaServerItem.isRtpEnable()) { | |
| 498 | - streamId = String.format("%s_%s", device.getDeviceId(), channelId); | |
| 499 | - } | |
| 500 | - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false, 0, false, device.getStreamModeForParam()); | |
| 501 | - logger.info(JSONObject.toJSONString(ssrcInfo)); | |
| 502 | - sendRtpItem.setStreamId(ssrcInfo.getStream()); | |
| 503 | - sendRtpItem.setSsrc(ssrc); | |
| 504 | - | |
| 505 | - // 写入redis, 超时时回复 | |
| 506 | - redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 507 | - MediaServerItem finalMediaServerItem = mediaServerItem; | |
| 508 | - playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> { | |
| 490 | + if (mediaDescription != null) { | |
| 491 | + downloadSpeed = mediaDescription.getAttribute("downloadspeed"); | |
| 492 | + } | |
| 493 | + | |
| 494 | + sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD); | |
| 495 | + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); | |
| 496 | + sendRtpItem.setStreamId(ssrcInfo.getStream()); | |
| 497 | + // 写入redis, 超时时回复 | |
| 498 | + redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 499 | + playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start), | |
| 500 | + DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed), | |
| 501 | + (code, msg, data) -> { | |
| 502 | + if (code == InviteErrorCode.SUCCESS.getCode()) { | |
| 503 | + hookEvent.run(code, msg, data); | |
| 504 | + } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { | |
| 505 | + logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId); | |
| 506 | + redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); | |
| 507 | + errorEvent.run(code, msg, data); | |
| 508 | + } else { | |
| 509 | + errorEvent.run(code, msg, data); | |
| 510 | + } | |
| 511 | + }); | |
| 512 | + } else { | |
| 513 | + | |
| 514 | + SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> { | |
| 515 | + if (code == InviteErrorCode.SUCCESS.getCode()) { | |
| 516 | + hookEvent.run(code, msg, data); | |
| 517 | + } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { | |
| 509 | 518 | logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); |
| 510 | 519 | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); |
| 511 | - }); | |
| 512 | - } else { | |
| 513 | - // 当前系统作为下级平台使用,当上级平台点播时不携带ssrc时,并且设备在当前系统中已经点播了。这个时候需要重新给生成一个ssrc,不使用默认的"0000000000"。 | |
| 514 | - sendRtpItem.setSsrc(ssrc); | |
| 515 | - sendRtpItem.setStreamId(playTransaction.getStream()); | |
| 516 | - // 写入redis, 超时时回复 | |
| 517 | - redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 518 | - JSONObject jsonObject = new JSONObject(); | |
| 519 | - jsonObject.put("app", sendRtpItem.getApp()); | |
| 520 | - jsonObject.put("stream", sendRtpItem.getStreamId()); | |
| 521 | - hookEvent.response(mediaServerItem, jsonObject); | |
| 522 | - } | |
| 520 | + errorEvent.run(code, msg, data); | |
| 521 | + } else { | |
| 522 | + errorEvent.run(code, msg, data); | |
| 523 | + } | |
| 524 | + })); | |
| 525 | + sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 526 | + String streamId = String.format("%s_%s", device.getDeviceId(), channelId); | |
| 527 | + sendRtpItem.setStreamId(streamId); | |
| 528 | + sendRtpItem.setSsrc(ssrcInfo.getSsrc()); | |
| 529 | + redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 530 | + | |
| 523 | 531 | } |
| 524 | 532 | } else if (gbStream != null) { |
| 525 | 533 | ... | ... |