diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java index 29f1654c..1d4ce4b4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java @@ -207,22 +207,18 @@ public class SipUtils { if (mediaDescriptionIndex == 0 && ssrcIndex == 0) { sdp = SdpFactory.getInstance().createSessionDescription(sdpStr); }else { - int baseSdpIndex = Math.min(mediaDescriptionIndex, ssrcIndex); - //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 - String substring = sdpStr.substring(0, baseSdpIndex); - sdp = SdpFactory.getInstance().createSessionDescription(substring); - String lines[] = sdpStr.split("\\r?\\n"); + StringBuilder sdpBuffer = new StringBuilder(); for (String line : lines) { if (line.trim().startsWith("y=")) { ssrc = line.substring(2); }else if (line.trim().startsWith("f=")) { mediaDescription = line.substring(2); - } - if (ssrc != null && mediaDescription != null) { - break; + }else { + sdpBuffer.append(line.trim()).append("\r\n"); } } + sdp = SdpFactory.getInstance().createSessionDescription(sdpBuffer.toString()); } return Gb28181Sdp.getInstance(sdp, ssrc, mediaDescription); }