| | |
| | | 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); |
| | | } |