@Test public void testFromSDP() throws Exception { SDP sdp = new SDP(); sdp.fromSDP(sampleSDP); }
public Element fromSDP(final String sdpData) throws XMLException { final String[] sdp = sdpData.split(LINE); final Element jingle = ElementFactory.create("jingle"); jingle.setXMLNS("urn:xmpp:jingle:1"); String[] groups = findContentsNames(sdp); for (String groupName : groups) { final String[] mediaLines = getMediaLines(groupName, sdp); String[] m = mediaLines[0].substring(2).split(" "); final String mediaType = m[0]; JingleContent content = new JingleContent(ElementFactory.create("content")); jingle.addChild(content); content.setAttribute("name", groupName); content.setAttribute("senders", "both"); content.setAttribute("creator", "responder"); Description description = new Description(ElementFactory.create("description")); description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1"); description.setAttribute("media", mediaType); content.addChild(description); findLine("a=rtcp-mux", mediaLines, line -> description.addChild(ElementFactory.create("rtcp-mux"))); String[] payloadIds = Arrays.copyOfRange(m, 3, m.length); for (String payloadId : payloadIds) { Payload payload = createPayload(payloadId, mediaLines); description.addChild(payload); } content.addChild(fromSDPTransport(mediaLines)); } String grLine = findLine("a=group:", sdp); if (grLine != null) { String[] g = grLine.substring(8).split(" "); Element group = ElementFactory.create("group", null, "urn:xmpp:jingle:apps:grouping:0"); group.setAttribute("semantics", g[0]); for (int i = 1; i < g.length; i++) { Element c = ElementFactory.create("content"); c.setAttribute("name", g[i]); group.addChild(c); } jingle.addChild(group); } return jingle; }
SDP { public Element fromSDP(final String sdpData) throws XMLException { final String[] sdp = sdpData.split(LINE); final Element jingle = ElementFactory.create("jingle"); jingle.setXMLNS("urn:xmpp:jingle:1"); String[] groups = findContentsNames(sdp); for (String groupName : groups) { final String[] mediaLines = getMediaLines(groupName, sdp); String[] m = mediaLines[0].substring(2).split(" "); final String mediaType = m[0]; JingleContent content = new JingleContent(ElementFactory.create("content")); jingle.addChild(content); content.setAttribute("name", groupName); content.setAttribute("senders", "both"); content.setAttribute("creator", "responder"); Description description = new Description(ElementFactory.create("description")); description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1"); description.setAttribute("media", mediaType); content.addChild(description); findLine("a=rtcp-mux", mediaLines, line -> description.addChild(ElementFactory.create("rtcp-mux"))); String[] payloadIds = Arrays.copyOfRange(m, 3, m.length); for (String payloadId : payloadIds) { Payload payload = createPayload(payloadId, mediaLines); description.addChild(payload); } content.addChild(fromSDPTransport(mediaLines)); } String grLine = findLine("a=group:", sdp); if (grLine != null) { String[] g = grLine.substring(8).split(" "); Element group = ElementFactory.create("group", null, "urn:xmpp:jingle:apps:grouping:0"); group.setAttribute("semantics", g[0]); for (int i = 1; i < g.length; i++) { Element c = ElementFactory.create("content"); c.setAttribute("name", g[i]); group.addChild(c); } jingle.addChild(group); } return jingle; } }
SDP { public Element fromSDP(final String sdpData) throws XMLException { final String[] sdp = sdpData.split(LINE); final Element jingle = ElementFactory.create("jingle"); jingle.setXMLNS("urn:xmpp:jingle:1"); String[] groups = findContentsNames(sdp); for (String groupName : groups) { final String[] mediaLines = getMediaLines(groupName, sdp); String[] m = mediaLines[0].substring(2).split(" "); final String mediaType = m[0]; JingleContent content = new JingleContent(ElementFactory.create("content")); jingle.addChild(content); content.setAttribute("name", groupName); content.setAttribute("senders", "both"); content.setAttribute("creator", "responder"); Description description = new Description(ElementFactory.create("description")); description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1"); description.setAttribute("media", mediaType); content.addChild(description); findLine("a=rtcp-mux", mediaLines, line -> description.addChild(ElementFactory.create("rtcp-mux"))); String[] payloadIds = Arrays.copyOfRange(m, 3, m.length); for (String payloadId : payloadIds) { Payload payload = createPayload(payloadId, mediaLines); description.addChild(payload); } content.addChild(fromSDPTransport(mediaLines)); } String grLine = findLine("a=group:", sdp); if (grLine != null) { String[] g = grLine.substring(8).split(" "); Element group = ElementFactory.create("group", null, "urn:xmpp:jingle:apps:grouping:0"); group.setAttribute("semantics", g[0]); for (int i = 1; i < g.length; i++) { Element c = ElementFactory.create("content"); c.setAttribute("name", g[i]); group.addChild(c); } jingle.addChild(group); } return jingle; }  }
SDP { public Element fromSDP(final String sdpData) throws XMLException { final String[] sdp = sdpData.split(LINE); final Element jingle = ElementFactory.create("jingle"); jingle.setXMLNS("urn:xmpp:jingle:1"); String[] groups = findContentsNames(sdp); for (String groupName : groups) { final String[] mediaLines = getMediaLines(groupName, sdp); String[] m = mediaLines[0].substring(2).split(" "); final String mediaType = m[0]; JingleContent content = new JingleContent(ElementFactory.create("content")); jingle.addChild(content); content.setAttribute("name", groupName); content.setAttribute("senders", "both"); content.setAttribute("creator", "responder"); Description description = new Description(ElementFactory.create("description")); description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1"); description.setAttribute("media", mediaType); content.addChild(description); findLine("a=rtcp-mux", mediaLines, line -> description.addChild(ElementFactory.create("rtcp-mux"))); String[] payloadIds = Arrays.copyOfRange(m, 3, m.length); for (String payloadId : payloadIds) { Payload payload = createPayload(payloadId, mediaLines); description.addChild(payload); } content.addChild(fromSDPTransport(mediaLines)); } String grLine = findLine("a=group:", sdp); if (grLine != null) { String[] g = grLine.substring(8).split(" "); Element group = ElementFactory.create("group", null, "urn:xmpp:jingle:apps:grouping:0"); group.setAttribute("semantics", g[0]); for (int i = 1; i < g.length; i++) { Element c = ElementFactory.create("content"); c.setAttribute("name", g[i]); group.addChild(c); } jingle.addChild(group); } return jingle; }  static String getOriginalSDP(Element jingleElement); Transport fromSDPTransport(final String[] mediaLines); Element fromSDP(final String sdpData); String toSDP(final JingleContent content); String toSDP(final String id, final String sid, final JingleElement jingleElement); String toSDP(final Transport transport); }
SDP { public Element fromSDP(final String sdpData) throws XMLException { final String[] sdp = sdpData.split(LINE); final Element jingle = ElementFactory.create("jingle"); jingle.setXMLNS("urn:xmpp:jingle:1"); String[] groups = findContentsNames(sdp); for (String groupName : groups) { final String[] mediaLines = getMediaLines(groupName, sdp); String[] m = mediaLines[0].substring(2).split(" "); final String mediaType = m[0]; JingleContent content = new JingleContent(ElementFactory.create("content")); jingle.addChild(content); content.setAttribute("name", groupName); content.setAttribute("senders", "both"); content.setAttribute("creator", "responder"); Description description = new Description(ElementFactory.create("description")); description.setAttribute("xmlns", "urn:xmpp:jingle:apps:rtp:1"); description.setAttribute("media", mediaType); content.addChild(description); findLine("a=rtcp-mux", mediaLines, line -> description.addChild(ElementFactory.create("rtcp-mux"))); String[] payloadIds = Arrays.copyOfRange(m, 3, m.length); for (String payloadId : payloadIds) { Payload payload = createPayload(payloadId, mediaLines); description.addChild(payload); } content.addChild(fromSDPTransport(mediaLines)); } String grLine = findLine("a=group:", sdp); if (grLine != null) { String[] g = grLine.substring(8).split(" "); Element group = ElementFactory.create("group", null, "urn:xmpp:jingle:apps:grouping:0"); group.setAttribute("semantics", g[0]); for (int i = 1; i < g.length; i++) { Element c = ElementFactory.create("content"); c.setAttribute("name", g[i]); group.addChild(c); } jingle.addChild(group); } return jingle; }  static String getOriginalSDP(Element jingleElement); Transport fromSDPTransport(final String[] mediaLines); Element fromSDP(final String sdpData); String toSDP(final JingleContent content); String toSDP(final String id, final String sid, final JingleElement jingleElement); String toSDP(final Transport transport); static final String LINE; static final String TIGASE_SDP_XMLNS; }