修复sdp解析错误
parent
52f9c295f9
commit
fa80ba6f2b
|
@ -207,22 +207,18 @@ public class SipUtils {
|
||||||
if (mediaDescriptionIndex == 0 && ssrcIndex == 0) {
|
if (mediaDescriptionIndex == 0 && ssrcIndex == 0) {
|
||||||
sdp = SdpFactory.getInstance().createSessionDescription(sdpStr);
|
sdp = SdpFactory.getInstance().createSessionDescription(sdpStr);
|
||||||
}else {
|
}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");
|
String lines[] = sdpStr.split("\\r?\\n");
|
||||||
|
StringBuilder sdpBuffer = new StringBuilder();
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (line.trim().startsWith("y=")) {
|
if (line.trim().startsWith("y=")) {
|
||||||
ssrc = line.substring(2);
|
ssrc = line.substring(2);
|
||||||
}else if (line.trim().startsWith("f=")) {
|
}else if (line.trim().startsWith("f=")) {
|
||||||
mediaDescription = line.substring(2);
|
mediaDescription = line.substring(2);
|
||||||
}
|
}else {
|
||||||
if (ssrc != null && mediaDescription != null) {
|
sdpBuffer.append(line.trim()).append("\r\n");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sdp = SdpFactory.getInstance().createSessionDescription(sdpBuffer.toString());
|
||||||
}
|
}
|
||||||
return Gb28181Sdp.getInstance(sdp, ssrc, mediaDescription);
|
return Gb28181Sdp.getInstance(sdp, ssrc, mediaDescription);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue