| | |
| | | |
| | | public enum InviteStreamType { |
| | | |
| | | PLAY,PLAYBACK,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY |
| | | PLAY,PLAYBACK,DOWNLOAD,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY |
| | | |
| | | |
| | | } |
| | |
| | |
|
| | | content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
|
| | | logger.debug("此时请求下载信令的ssrc===>{}",ssrcInfo.getSsrc());
|
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId());
|
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
|
| | | // 添加订阅
|
| | | CallIdHeader newCallIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport());
|
| | | String callId= newCallIdHeader.getCallId();
|
| | |
| | | InviteErrorCallback<Object> errorEvent = ((statusCode, msg, data) -> { |
| | | // 未知错误。直接转发设备点播的错误 |
| | | try { |
| | | if (statusCode > 0) { |
| | | Response response = getMessageFactory().createResponse(statusCode, evt.getRequest()); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | } |
| | | } catch (ParseException | SipException e) { |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | |
| | | errorEvent.run(code, msg, data); |
| | | } |
| | | }); |
| | | }else if ("Download".equalsIgnoreCase(sessionName)) { |
| | | // 获取指定的下载速度 |
| | | Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true); |
| | | MediaDescription mediaDescription = null; |
| | | String downloadSpeed = "1"; |
| | | if (sdpMediaDescriptions.size() > 0) { |
| | | mediaDescription = (MediaDescription)sdpMediaDescriptions.get(0); |
| | | } |
| | | if (mediaDescription != null) { |
| | | downloadSpeed = mediaDescription.getAttribute("downloadspeed"); |
| | | } |
| | | |
| | | sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD); |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); |
| | | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
| | | // 写入redis, 超时时回复 |
| | | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| | | playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start), |
| | | DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed), |
| | | (code, msg, data) -> { |
| | | if (code == InviteErrorCode.SUCCESS.getCode()){ |
| | | hookEvent.run(code, msg, data); |
| | | }else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){ |
| | | logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId); |
| | | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); |
| | | errorEvent.run(code, msg, data); |
| | | }else { |
| | | errorEvent.run(code, msg, data); |
| | | } |
| | | }); |
| | | } else { |
| | | sendRtpItem.setPlayType(InviteStreamType.PLAY); |
| | | String streamId = null; |
| | |
| | | @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
|
| | | public JSONObject onStreamNoneReader(@RequestBody OnStreamNoneReaderHookParam param) {
|
| | |
|
| | | logger.info("[ZLM HOOK]流无人观看:{]->{}->{}/{}" + param.getMediaServerId(), param.getSchema(),
|
| | | logger.info("[ZLM HOOK]流无人观看:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(),
|
| | | param.getApp(), param.getStream());
|
| | | JSONObject ret = new JSONObject();
|
| | | ret.put("code", 0);
|
| | |
| | | node.setBasicData(channel); |
| | | node.setParent(false); |
| | | if (channel.getChannelId().length() > 8) { |
| | | if (channel.getChannelId().length() > 13) { |
| | | String gbCodeType = channel.getChannelId().substring(10, 13); |
| | | node.setParent(gbCodeType.equals(ChannelIdType.BUSINESS_GROUP) || gbCodeType.equals(ChannelIdType.VIRTUAL_ORGANIZATION) ); |
| | | } |
| | | }else { |
| | | node.setParent(true); |
| | | } |
| | |
| | | null); |
| | | return; |
| | | } |
| | | logger.info("[录像下载] deviceId: {}, channelId: {},收流端口:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); |
| | | logger.info("[录像下载] deviceId: {}, channelId: {}, 下载速度:{}, 收流端口:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, downloadSpeed, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); |
| | | // 初始化redis中的invite消息状态 |
| | | InviteInfo inviteInfo = InviteInfo.getinviteInfo(device.getDeviceId(), channelId, ssrcInfo.getStream(), ssrcInfo, |
| | | mediaServerItem.getSdpIp(), ssrcInfo.getPort(), device.getStreamMode(), InviteSessionType.DOWNLOAD, |
| | |
| | | cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null, null); |
| | | } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { |
| | | logger.error("[命令发送失败] 停止点播, 发送BYE: {}", e.getMessage()); |
| | | |
| | | } |
| | | |
| | | dynamicTask.stop(downLoadTimeOutTaskKey); |
| | |
| | | private StreamInfo onPublishHandlerForDownload(MediaServerItem mediaServerItemInuse, JSONObject response, String deviceId, String channelId, String startTime, String endTime) { |
| | | StreamInfo streamInfo = onPublishHandler(mediaServerItemInuse, response, deviceId, channelId); |
| | | if (streamInfo != null) { |
| | | streamInfo.setProgress(0); |
| | | streamInfo.setStartTime(startTime); |
| | | streamInfo.setEndTime(endTime); |
| | | InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.DOWNLOAD, deviceId, channelId); |
| | | InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, deviceId, channelId, streamInfo.getStream()); |
| | | if (inviteInfo != null) { |
| | | logger.info("[录像下载] 更新invite消息中的stream信息"); |
| | | inviteInfo.setStatus(InviteSessionStatus.ok); |
| | | inviteInfo.setStreamInfo(streamInfo); |
| | | inviteStreamService.updateInviteInfo(inviteInfo); |
| | |
| | | this.playerStyle["height"] = this.winHeight + "px"; |
| | | this.chooseDate = moment().format('YYYY-MM-DD') |
| | | this.dateChange(); |
| | | window.addEventListener('beforeunload', this.stopPlayRecord) |
| | | }, |
| | | destroyed() { |
| | | this.$destroy('recordVideoPlayer'); |
| | | window.removeEventListener('beforeunload', this.stopPlayRecord) |
| | | }, |
| | | methods: { |
| | | dateChange(){ |
| | |
| | | }); |
| | | }, |
| | | stopPlayRecord: function (callback) { |
| | | console.log("停止录像回放") |
| | | if (this.streamId !== "") { |
| | | this.$refs["recordVideoPlayer"].pause(); |
| | | this.videoUrl = ''; |
| | | this.$axios({ |
| | |
| | | }).then(function (res) { |
| | | if (callback) callback() |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | getDataWidth(item){ |
| | | let timeForFile = this.getTimeForFile(item); |
| | |
| | | return hStr + ":" + mStr + ":" + sStr |
| | | }, |
| | | goBack(){ |
| | | window.history.go(-1); |
| | | // 如果正在进行录像回放则,发送停止 |
| | | if (this.streamId !== "") { |
| | | this.stopPlayRecord(()=> { |
| | | this.streamId = ""; |
| | | }) |
| | | } |
| | | window.history.go(-1); |
| | | }, |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | export default { |
| | | name: 'recordDownload', |
| | | created() { |
| | | |
| | | window.addEventListener('beforeunload', this.stopDownloadRecord) |
| | | |
| | | }, |
| | | data() { |
| | |
| | | console.log(error); |
| | | }); |
| | | } |
| | | }, |
| | | destroyed() { |
| | | window.removeEventListener('beforeunload', this.stopDownloadRecord) |
| | | } |
| | | }; |
| | | </script> |