Commit fa80ba6f2bf4b69c0c6ad64e164f21f0bad72fa4
1 parent
52f9c295
修复sdp解析错误
Showing
1 changed file
with
4 additions
and
8 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
| ... | ... | @@ -207,22 +207,18 @@ public class SipUtils { |
| 207 | 207 | if (mediaDescriptionIndex == 0 && ssrcIndex == 0) { |
| 208 | 208 | sdp = SdpFactory.getInstance().createSessionDescription(sdpStr); |
| 209 | 209 | }else { |
| 210 | - int baseSdpIndex = Math.min(mediaDescriptionIndex, ssrcIndex); | |
| 211 | - //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 | |
| 212 | - String substring = sdpStr.substring(0, baseSdpIndex); | |
| 213 | - sdp = SdpFactory.getInstance().createSessionDescription(substring); | |
| 214 | - | |
| 215 | 210 | String lines[] = sdpStr.split("\\r?\\n"); |
| 211 | + StringBuilder sdpBuffer = new StringBuilder(); | |
| 216 | 212 | for (String line : lines) { |
| 217 | 213 | if (line.trim().startsWith("y=")) { |
| 218 | 214 | ssrc = line.substring(2); |
| 219 | 215 | }else if (line.trim().startsWith("f=")) { |
| 220 | 216 | mediaDescription = line.substring(2); |
| 221 | - } | |
| 222 | - if (ssrc != null && mediaDescription != null) { | |
| 223 | - break; | |
| 217 | + }else { | |
| 218 | + sdpBuffer.append(line.trim()).append("\r\n"); | |
| 224 | 219 | } |
| 225 | 220 | } |
| 221 | + sdp = SdpFactory.getInstance().createSessionDescription(sdpBuffer.toString()); | |
| 226 | 222 | } |
| 227 | 223 | return Gb28181Sdp.getInstance(sdp, ssrc, mediaDescription); |
| 228 | 224 | } | ... | ... |