From 01c20a994657186af811c2ca3e82b10c4e536f3c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 15 Oct 2021 15:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=82=B9=E6=92=AD=E4=B8=8E?= =?UTF-8?q?=E5=BD=95=E5=83=8F=E5=9B=9E=E6=94=BEsdp=E4=BF=A1=E6=81=AFsdp-ip?= =?UTF-8?q?=E7=9A=84=E5=8F=96=E5=80=BC=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=9B=9E=E6=94=BE=E4=BF=A1=E4=BB=A4=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transmit/cmd/SIPRequestHeaderProvider.java | 13 ++++++++----- .../gb28181/transmit/cmd/impl/SIPCommander.java | 8 ++++---- .../iot/vmp/service/IMediaServerService.java | 2 ++ .../vmp/service/impl/MediaServerServiceImpl.java | 13 ++++++++++++- .../gb28181/playback/DownloadController.java | 2 +- .../gb28181/playback/PlaybackController.java | 2 +- src/main/resources/wvpssl.jks | Bin 0 -> 2196 bytes 7 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/wvpssl.jks diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java index 160b850a..48facf65 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java @@ -99,13 +99,13 @@ public class SIPRequestHeaderProvider { return request; } - public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { + public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException { Request request = null; //请求行 - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); + SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getIp(), device.getPort(), device.getTransport(), viaTag); + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); viaHeader.setRPort(); viaHeaders.add(viaHeader); //from @@ -113,7 +113,7 @@ public class SIPRequestHeaderProvider { Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack //to - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getDomain()); + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, sipConfig.getDomain()); Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); @@ -127,7 +127,10 @@ public class SIPRequestHeaderProvider { Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); - + // Subject + SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); + request.addHeader(subjectHeader); + ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); request.setContent(content, contentTypeHeader); return request; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index cec64ccb..ef60da67 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -468,7 +468,7 @@ public class SIPCommander implements ISIPCommander { StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); - content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n"); + content.append("o="+sipConfig.getId()+" 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); content.append("s=Playback\r\n"); content.append("u="+channelId+":0\r\n"); content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); @@ -532,7 +532,7 @@ public class SIPCommander implements ISIPCommander { CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader); + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc()); transmitRequest(device, request, errorEvent, okEvent -> { Dialog dialog = okEvent.getClientTransaction().getDialog(); @@ -575,7 +575,7 @@ public class SIPCommander implements ISIPCommander { StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); - content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n"); + content.append("o="+sipConfig.getId()+" 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); content.append("s=Download\r\n"); content.append("u="+channelId+":0\r\n"); content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); @@ -640,7 +640,7 @@ public class SIPCommander implements ISIPCommander { CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader); + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc()); ClientTransaction transaction = transmitRequest(device, request, errorEvent); streamSession.put(device.getDeviceId(), channelId, ssrcInfo.getSsrc(), ssrcInfo.getStreamId(), mediaServerItem.getId(), transaction); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index b222e70f..f42b8679 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -36,6 +36,8 @@ public interface IMediaServerService { SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId); + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback); + void closeRTPServer(Device device, String channelId); void clearRTPServer(MediaServerItem mediaServerItem); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 1e5b0794..4ba361c0 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -96,6 +96,11 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR @Override public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId) { + return openRTPServer(mediaServerItem, streamId, false); + } + + @Override + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback) { if (mediaServerItem == null || mediaServerItem.getId() == null) { return null; } @@ -107,7 +112,13 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR logger.info("media server [ {} ] ssrcConfig is null", mediaServerItem.getId()); return null; }else { - String ssrc = ssrcConfig.getPlaySsrc(); + String ssrc = null; + if (isPlayback) { + ssrc = ssrcConfig.getPlayBackSsrc(); + }else { + ssrc = ssrcConfig.getPlaySsrc(); + } + if (streamId == null) { streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/DownloadController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/DownloadController.java index 167b7ee1..d963c315 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/DownloadController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/DownloadController.java @@ -103,7 +103,7 @@ public class DownloadController { return result; } - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); cmder.downloadStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, (MediaServerItem mediaServerItem, JSONObject response) -> { logger.info("收到订阅消息: " + response.toJSONString()); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index 9fd05b2e..511ce85c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -85,7 +85,7 @@ public class PlaybackController { return result; } MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); // 超时处理 result.onTimeout(()->{ diff --git a/src/main/resources/wvpssl.jks b/src/main/resources/wvpssl.jks new file mode 100644 index 0000000000000000000000000000000000000000..92b98b77a52553ec4fc23caf8bb08d5af33b18f7 GIT binary patch literal 2196 zcmcK4`8(8$9tZIG&Wte(L&m<(Oo+^w(BLR#$xvwK7@4sm1x%YWaf583W^TX?>&+}QH_x|esDhLDu9~SVvV4)$D zz(DdLBVF=&)IlH~Fo6c$Cm><`$6){zPy-(U03HyO23_Xbs*D)a>A11Bq5gZqBexNv zmOhFTsPLm-o%Xe#&@2NUj<}EPK9O#cPTSGFGCSv@qn!83YoM)k4W&y^~2HdC?2G+UI&Pi&)V{KA7UpWOzpYDIH@KfA!1=8Y!_BXxD! zWlnus{l;@EaRf~YiV59%$e|i}s5WF3Un9D6QfN`Q2C(*>UV5>gtDN#yH8Qy$ zU9invV@L2Y!^Q#9)l(ZqJMMUI>CyHFKMh@A)pTlm&A&=b$+2oh3)$n#PVSv3*N3NM z0vSb?@?%NExTESBcV{EnBUa*DP^`p+UyN8E{{>3IP zsP)fbu_fLNLRv*k6vKfw(sq88@}>TzP^#lRMH#Y-a4}p_e^=KqoJn5?sUm|c#$r+0 z%`w-%I2~~7XRCZU0_YV(8dTy>QT}_0Ro9Z#0>AWhI_lQ^0GGh=DqCjmpIcK=C6A{IAmv^P zXL%Q~ZN<#3QK z&hG|#Jb22TcF%TMOx=O2uHDDJP}nuPYv^03kjcDuemg)dN3Oo-GkuGkv0z%~A9$+I zP`nha-c;4QeRQf?op0>YA4_+=(u#Xpy1!!74rHLC! z#TThM6_p}FYziiAK;{wWU09rGuJvevtls#%f9ROD{cMf5a({t=`- z36gT#g!C@h?oky-$a+>UWFfI+?f93H%NWavgKG`$ZpX`95Xktc&A-<}8U6 z(j}oS>c=Z5wbafDqB_)ypHBq8aum|q6Pmn2MQkCkvbR1k`{0fbnk#7}nSIf=!mp<6 zb`SB&$DyV>?$F}y0w~(}j8?;lT}3!Xu3`q)i&A3yZbWfRJwUcC*$2mw82)U@Ele3w z67WqtX7Ax+5o9h>&b#vSLyNqNI}G^tQ^@FyL3K3rF@o6H6DUm1i{8BR)=qoS_!A3- zV@im0Gy?4nY3zl$PwMV&m%k*$*<=JwE~Ekh%h8xR;<)!DQ%7q566~20?s7PuH)9VB z0YE@0nxH_CJG{6Y5-JWAb?EeuBfWvg^-}7enTvF*PTqM>|K}19f8=n904OIR!|)Gf zYh{L5u0buSr!5530k#)mS(RYZCRsj+76>M%u5X8p)#eH^P+-a_KENGc} z%g{i^|D(9?BTK>I2K1CK%p&yadM(FUGFY&wtjipq<4vitwirj?ew|y}7bj)4>s;4u2;~fy6g-F?kDQtIvo`6KE}W@iXcX zYzGI6>i1V2OxQHJ^_783E=N_TswIEk4#0R=akOh1dQjMz=$@hp? MBy-i6op7^%1J2R82><{9 literal 0 HcmV?d00001