修复sdp解析错误

This commit is contained in:
648540858 2023-06-12 22:54:40 +08:00
parent 52f9c295f9
commit fa80ba6f2b

View File

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