From 07b182da98ac54fffa8f36b8db27d6212e1e0bf7 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 26 十二月 2023 15:38:40 +0800 Subject: [PATCH] Merge branch 'wvp-28181-2.0' into feature/record --- src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 44 +++++++++++++++++++++++++------------------- 1 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 7ca07ee..20f4522 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -32,6 +32,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; +import com.genersoft.iot.vmp.utils.CloudRecordUtils; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import gov.nist.javax.sip.message.SIPResponse; @@ -232,6 +233,15 @@ HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); subscribe.removeSubscribe(hookSubscribe); } + }else { + logger.info("[鐐规挱瓒呮椂] 鏀舵祦瓒呮椂 deviceId: {}, channelId: {},鐮佹祦绫诲瀷锛歿}锛岀鍙o細{}, SSRC: {}", + device.getDeviceId(), channelId, device.isSwitchPrimarySubStream() ? "杈呯爜娴�" : "涓荤爜娴�", + ssrcInfo.getPort(), ssrcInfo.getSsrc()); + + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); + + mediaServerService.closeRTPServer(mediaServerItem.getId(), ssrcInfo.getStream()); + streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); } }, userSetting.getPlayTimeout()); @@ -262,6 +272,7 @@ InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, timeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAY); }, (event) -> { + logger.info("[鐐规挱澶辫触] deviceId: {}, channelId:{}, {}: {}", device.getDeviceId(), channelId, event.statusCode, event.msg); dynamicTask.stop(timeOutTaskKey); mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); // 閲婃斁ssrc @@ -303,7 +314,13 @@ if (!device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { return; } - String substring = contentString.substring(0, contentString.indexOf("y=")); + + String substring; + if (contentString.indexOf("y=") > 0) { + substring = contentString.substring(0, contentString.indexOf("y=")); + }else { + substring = contentString; + } try { SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); int port = -1; @@ -393,7 +410,7 @@ deviceChannel.setStreamId(streamInfo.getStream()); storager.startPlay(deviceId, channelId, streamInfo.getStream()); } - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAYBACK, deviceId, channelId); + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, ((OnStreamChangedHookParam) param).getStream()); if (inviteInfo != null) { inviteInfo.setStatus(InviteSessionStatus.ok); @@ -536,7 +553,6 @@ // 澶勭悊鏀跺埌200ok鍚庣殑TCP涓诲姩杩炴帴浠ュ強SSRC涓嶄竴鑷寸殑闂 InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, playBackTimeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAYBACK); - }, errorEvent); } catch (InvalidArgumentException | SipException | ParseException e) { logger.error("[鍛戒护鍙戦�佸け璐 褰曞儚鍥炴斁: {}", e.getMessage()); @@ -557,6 +573,10 @@ ResponseEvent responseEvent = (ResponseEvent) eventResult.event; String contentString = new String(responseEvent.getResponse().getRawContent()); String ssrcInResponse = SipUtils.getSsrcFromSdp(contentString); + // 鍏煎鍥炲鐨勬秷鎭腑缂哄皯ssrc(y瀛楁)鐨勬儏鍐� + if (ssrcInResponse == null) { + ssrcInResponse = ssrcInfo.getSsrc(); + } if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { // ssrc 涓�鑷� if (mediaServerItem.isRtpEnable()) { @@ -632,6 +652,7 @@ } } } + @@ -728,7 +749,7 @@ logger.info("[褰曞儚涓嬭浇] 鏀跺埌褰曞儚鍐欏叆纾佺洏娑堟伅鍐呭锛� " + hookParam); OnRecordMp4HookParam recordMp4HookParam = (OnRecordMp4HookParam)hookParam; String filePath = recordMp4HookParam.getFile_path(); - DownloadFileInfo downloadFileInfo = getDownloadFilePath(mediaServerItem, filePath); + DownloadFileInfo downloadFileInfo = CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath); InviteInfo inviteInfoForNew = inviteStreamService.getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId() , inviteInfo.getChannelId(), inviteInfo.getStream()); inviteInfoForNew.getStreamInfo().setDownLoadFilePath(downloadFileInfo); @@ -822,21 +843,6 @@ } inviteStreamService.updateInviteInfo(inviteInfo); return inviteInfo.getStreamInfo(); - } - - private DownloadFileInfo getDownloadFilePath(MediaServerItem mediaServerItem, String filePath) { - DownloadFileInfo downloadFileInfo = new DownloadFileInfo(); - - String pathTemplate = "%s://%s:%s/index/api/downloadFile?file_path=" + filePath; - - downloadFileInfo.setHttpPath(String.format(pathTemplate, "http", mediaServerItem.getStreamIp(), - mediaServerItem.getHttpPort())); - - if (mediaServerItem.getHttpSSlPort() > 0) { - downloadFileInfo.setHttpsPath(String.format(pathTemplate, "https", mediaServerItem.getStreamIp(), - mediaServerItem.getHttpSSlPort())); - } - return downloadFileInfo; } private StreamInfo onPublishHandlerForDownload(MediaServerItem mediaServerItemInuse, HookParam hookParam, String deviceId, String channelId, String startTime, String endTime) { -- Gitblit v1.8.0