From ae4d33013136dfdceb129e96ae52bdf375d91dbe Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: 星期一, 11 一月 2021 20:51:58 +0800 Subject: [PATCH] 修正播放回放ssrc --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 63 +++++++++++++------------------ 1 files changed, 26 insertions(+), 37 deletions(-) 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 4a76e9a..b3447f9 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 @@ -185,11 +185,11 @@ /** * 浜戝彴鎸囦护鐮佽绠� * - * @param cmdCode 鎸囦护鐮� - * @param parameter1 鏁版嵁1 - * @param parameter2 鏁版嵁2 - * @param combineCode2 缁勫悎鐮�2 - */ + * @param cmdCode 鎸囦护鐮� + * @param parameter1 鏁版嵁1 + * @param parameter2 鏁版嵁2 + * @param combineCode2 缁勫悎鐮�2 + */ public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { StringBuilder builder = new StringBuilder("A50F01"); String strTmp; @@ -211,13 +211,13 @@ /** * 浜戝彴鎺у埗锛屾敮鎸佹柟鍚戜笌缂╂斁鎺у埗 * - * @param device 鎺у埗璁惧 - * @param channelId 棰勮閫氶亾 - * @param leftRight 闀滃ご宸︾Щ鍙崇Щ 0:鍋滄 1:宸︾Щ 2:鍙崇Щ - * @param upDown 闀滃ご涓婄Щ涓嬬Щ 0:鍋滄 1:涓婄Щ 2:涓嬬Щ - * @param inOut 闀滃ご鏀惧ぇ缂╁皬 0:鍋滄 1:缂╁皬 2:鏀惧ぇ - * @param moveSpeed 闀滃ご绉诲姩閫熷害 - * @param zoomSpeed 闀滃ご缂╂斁閫熷害 + * @param device 鎺у埗璁惧 + * @param channelId 棰勮閫氶亾 + * @param leftRight 闀滃ご宸︾Щ鍙崇Щ 0:鍋滄 1:宸︾Щ 2:鍙崇Щ + * @param upDown 闀滃ご涓婄Щ涓嬬Щ 0:鍋滄 1:涓婄Щ 2:涓嬬Щ + * @param inOut 闀滃ご鏀惧ぇ缂╁皬 0:鍋滄 1:缂╁皬 2:鏀惧ぇ + * @param moveSpeed 闀滃ご绉诲姩閫熷害 + * @param zoomSpeed 闀滃ご缂╂斁閫熷害 */ @Override public boolean ptzCmd(Device device, String channelId, int leftRight, int upDown, int inOut, int moveSpeed, @@ -290,12 +290,8 @@ @Override public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { try { - String ssrc = ""; - if (rtpEnable) { - ssrc = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); - }else { - ssrc = streamSession.createPlaySsrc(); - } + + String ssrc = streamSession.createPlaySsrc(); String streamId = null; if (rtpEnable) { streamId = String.format("gb_play_%s_%s", device.getDeviceId(), channelId); @@ -333,13 +329,14 @@ if (seniorSdp) { if("TCP-PASSIVE".equals(streamMode)) { - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); }else if ("TCP-ACTIVE".equals(streamMode)) { - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); }else if("UDP".equals(streamMode)) { - content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" RTP/AVP 96 126 125 99 34 98 97\r\n"); } content.append("a=recvonly\r\n"); + content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); content.append("a=rtpmap:126 H264/90000\r\n"); content.append("a=rtpmap:125 H264S/90000\r\n"); @@ -348,7 +345,6 @@ content.append("a=fmtp:99 profile-level-id=3\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); if("TCP-PASSIVE".equals(streamMode)){ // tcp琚姩妯″紡 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); @@ -387,9 +383,6 @@ content.append("y="+ssrc+"\r\n");//ssrc -// String fromTag = UUID.randomUUID().toString(); -// Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, fromTag, null, ssrc); - Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null, ssrc); ClientTransaction transaction = transmitRequest(device, request, errorEvent); @@ -415,13 +408,13 @@ , SipSubscribe.Event errorEvent) { try { MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); - String ssrc = null; + String ssrc = streamSession.createPlayBackSsrc(); + String streamId = null; if (rtpEnable) { - ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); + streamId = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); }else { - ssrc = streamSession.createPlayBackSsrc(); + streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); } - String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); // 娣诲姞璁㈤槄 JSONObject subscribeKey = new JSONObject(); subscribeKey.put("app", "rtp"); @@ -429,7 +422,6 @@ subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event); - // StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n"); @@ -449,13 +441,14 @@ if (seniorSdp) { if("TCP-PASSIVE".equals(streamMode)) { - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); }else if ("TCP-ACTIVE".equals(streamMode)) { - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); }else if("UDP".equals(streamMode)) { - content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); + content.append("m=video "+ mediaPort +" RTP/AVP 96 126 125 99 34 98 97\r\n"); } content.append("a=recvonly\r\n"); + content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); content.append("a=rtpmap:126 H264/90000\r\n"); content.append("a=rtpmap:125 H264S/90000\r\n"); @@ -464,7 +457,6 @@ content.append("a=fmtp:99 profile-level-id=3\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); if("TCP-PASSIVE".equals(streamMode)){ // tcp琚姩妯″紡 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); @@ -533,9 +525,6 @@ if (dialog == null) { return; } - - - Request byeRequest = dialog.createRequest(Request.BYE); SipURI byeURI = (SipURI) byeRequest.getRequestURI(); String vh = transaction.getRequest().getHeader(ViaHeader.NAME).toString(); -- Gitblit v1.8.0