@Test public void testParseFirefox54Offer() throws SdpException { SessionDescription sdp; sdp = SessionDescriptionParser.parse(firefox54offer); MediaDescriptionField audio = sdp.getMediaDescription("audio"); Assert.assertNotNull(audio); }
public static SessionDescription parse(String text) throws SdpException { if (text == null || text.isEmpty()) { throw new SdpException(PARSE_ERROR_EMPTY); } SdpParsingInfo info = new SdpParsingInfo(); String[] lines = text.split(NEWLINE); for (String line : lines) { try { char fieldType = line.charAt(0); switch (fieldType) { case AttributeField.FIELD_TYPE: int separator = line .indexOf(AttributeField.ATTRIBUTE_SEPARATOR); String attributeType = (separator == -1) ? line .substring(2).trim() : line.substring(2, separator); SdpParser<? extends AttributeField> attributeParser = PARSERS .getAttributeParser(attributeType); if (attributeParser != null) { convertAndApplyAttribute(attributeParser.parse(line), info); } break; default: SdpParser<? extends SdpField> fieldParser = PARSERS .getFieldParser(fieldType); if (fieldParser != null) { convertAndApplyField(fieldParser.parse(line), info); } break; } } catch (Exception e) { throw new SdpException("Could not parse SDP: " + line, e); } } return info.sdp; }
SessionDescriptionParser { public static SessionDescription parse(String text) throws SdpException { if (text == null || text.isEmpty()) { throw new SdpException(PARSE_ERROR_EMPTY); } SdpParsingInfo info = new SdpParsingInfo(); String[] lines = text.split(NEWLINE); for (String line : lines) { try { char fieldType = line.charAt(0); switch (fieldType) { case AttributeField.FIELD_TYPE: int separator = line .indexOf(AttributeField.ATTRIBUTE_SEPARATOR); String attributeType = (separator == -1) ? line .substring(2).trim() : line.substring(2, separator); SdpParser<? extends AttributeField> attributeParser = PARSERS .getAttributeParser(attributeType); if (attributeParser != null) { convertAndApplyAttribute(attributeParser.parse(line), info); } break; default: SdpParser<? extends SdpField> fieldParser = PARSERS .getFieldParser(fieldType); if (fieldParser != null) { convertAndApplyField(fieldParser.parse(line), info); } break; } } catch (Exception e) { throw new SdpException("Could not parse SDP: " + line, e); } } return info.sdp; } }
SessionDescriptionParser { public static SessionDescription parse(String text) throws SdpException { if (text == null || text.isEmpty()) { throw new SdpException(PARSE_ERROR_EMPTY); } SdpParsingInfo info = new SdpParsingInfo(); String[] lines = text.split(NEWLINE); for (String line : lines) { try { char fieldType = line.charAt(0); switch (fieldType) { case AttributeField.FIELD_TYPE: int separator = line .indexOf(AttributeField.ATTRIBUTE_SEPARATOR); String attributeType = (separator == -1) ? line .substring(2).trim() : line.substring(2, separator); SdpParser<? extends AttributeField> attributeParser = PARSERS .getAttributeParser(attributeType); if (attributeParser != null) { convertAndApplyAttribute(attributeParser.parse(line), info); } break; default: SdpParser<? extends SdpField> fieldParser = PARSERS .getFieldParser(fieldType); if (fieldParser != null) { convertAndApplyField(fieldParser.parse(line), info); } break; } } catch (Exception e) { throw new SdpException("Could not parse SDP: " + line, e); } } return info.sdp; }  }
SessionDescriptionParser { public static SessionDescription parse(String text) throws SdpException { if (text == null || text.isEmpty()) { throw new SdpException(PARSE_ERROR_EMPTY); } SdpParsingInfo info = new SdpParsingInfo(); String[] lines = text.split(NEWLINE); for (String line : lines) { try { char fieldType = line.charAt(0); switch (fieldType) { case AttributeField.FIELD_TYPE: int separator = line .indexOf(AttributeField.ATTRIBUTE_SEPARATOR); String attributeType = (separator == -1) ? line .substring(2).trim() : line.substring(2, separator); SdpParser<? extends AttributeField> attributeParser = PARSERS .getAttributeParser(attributeType); if (attributeParser != null) { convertAndApplyAttribute(attributeParser.parse(line), info); } break; default: SdpParser<? extends SdpField> fieldParser = PARSERS .getFieldParser(fieldType); if (fieldParser != null) { convertAndApplyField(fieldParser.parse(line), info); } break; } } catch (Exception e) { throw new SdpException("Could not parse SDP: " + line, e); } } return info.sdp; }  static SessionDescription parse(String text); }
SessionDescriptionParser { public static SessionDescription parse(String text) throws SdpException { if (text == null || text.isEmpty()) { throw new SdpException(PARSE_ERROR_EMPTY); } SdpParsingInfo info = new SdpParsingInfo(); String[] lines = text.split(NEWLINE); for (String line : lines) { try { char fieldType = line.charAt(0); switch (fieldType) { case AttributeField.FIELD_TYPE: int separator = line .indexOf(AttributeField.ATTRIBUTE_SEPARATOR); String attributeType = (separator == -1) ? line .substring(2).trim() : line.substring(2, separator); SdpParser<? extends AttributeField> attributeParser = PARSERS .getAttributeParser(attributeType); if (attributeParser != null) { convertAndApplyAttribute(attributeParser.parse(line), info); } break; default: SdpParser<? extends SdpField> fieldParser = PARSERS .getFieldParser(fieldType); if (fieldParser != null) { convertAndApplyField(fieldParser.parse(line), info); } break; } } catch (Exception e) { throw new SdpException("Could not parse SDP: " + line, e); } } return info.sdp; }  static SessionDescription parse(String text);  }