@Test public void test() throws Exception { URL pdmlUrl = RtpExtracterTest.class.getResource("sipcall.pdml"); Assert.assertNotNull(pdmlUrl); Pdml pdml = new PdmlReader().unmarshall(pdmlUrl); Assert.assertNotNull(pdml); RtpStream[] streams = new RtpExtracter().parse(pdml); Assert.assertNotNull(streams); Assert.assertEquals(2, streams.length); Assert.assertEquals("ce8947be", streams[0].getSsrc()); Assert.assertEquals("607f30aa", streams[1].getSsrc()); Assert.assertEquals(700, streams[0].getPackets().length); Assert.assertEquals(707, streams[1].getPackets().length); Assert.assertArrayEquals(new byte[] {0x08, 0x0b, (byte) 0xe4, 0x53, 0x14, 0x7e, 0x10}, streams[0].getPackets()[0].getPayload()); }
public RtpStream[] parse(Pdml pdml) { Map<String,RtpStream> out = new LinkedHashMap<String,RtpStream>(); for (Packet packet : pdml.packets) { for (Protocol protocol : packet.protocols) { if ("rtp".equals(protocol.name)) { Map<String, Field> fields = protocol.asMap(); if (fields.containsKey("rtp.ssrc")) { String ssrc = fields.get("rtp.ssrc").value; RtpStream stream = out.get(ssrc); if (null == stream) { stream = new RtpStream(ssrc); out.put(ssrc, stream); if (fields.containsKey("rtp.setup")) { int setupFrame = Integer.parseInt(fields.get("rtp.setup").asMap().get("rtp.setup-frame").show); stream.setSetupPacket(pdml.packets[setupFrame-1]); } } stream.add(new RtpPacket(fields)); } } } } return out.values().toArray(new RtpStream[out.size()]); }
RtpExtracter { public RtpStream[] parse(Pdml pdml) { Map<String,RtpStream> out = new LinkedHashMap<String,RtpStream>(); for (Packet packet : pdml.packets) { for (Protocol protocol : packet.protocols) { if ("rtp".equals(protocol.name)) { Map<String, Field> fields = protocol.asMap(); if (fields.containsKey("rtp.ssrc")) { String ssrc = fields.get("rtp.ssrc").value; RtpStream stream = out.get(ssrc); if (null == stream) { stream = new RtpStream(ssrc); out.put(ssrc, stream); if (fields.containsKey("rtp.setup")) { int setupFrame = Integer.parseInt(fields.get("rtp.setup").asMap().get("rtp.setup-frame").show); stream.setSetupPacket(pdml.packets[setupFrame-1]); } } stream.add(new RtpPacket(fields)); } } } } return out.values().toArray(new RtpStream[out.size()]); } }
RtpExtracter { public RtpStream[] parse(Pdml pdml) { Map<String,RtpStream> out = new LinkedHashMap<String,RtpStream>(); for (Packet packet : pdml.packets) { for (Protocol protocol : packet.protocols) { if ("rtp".equals(protocol.name)) { Map<String, Field> fields = protocol.asMap(); if (fields.containsKey("rtp.ssrc")) { String ssrc = fields.get("rtp.ssrc").value; RtpStream stream = out.get(ssrc); if (null == stream) { stream = new RtpStream(ssrc); out.put(ssrc, stream); if (fields.containsKey("rtp.setup")) { int setupFrame = Integer.parseInt(fields.get("rtp.setup").asMap().get("rtp.setup-frame").show); stream.setSetupPacket(pdml.packets[setupFrame-1]); } } stream.add(new RtpPacket(fields)); } } } } return out.values().toArray(new RtpStream[out.size()]); }  }
RtpExtracter { public RtpStream[] parse(Pdml pdml) { Map<String,RtpStream> out = new LinkedHashMap<String,RtpStream>(); for (Packet packet : pdml.packets) { for (Protocol protocol : packet.protocols) { if ("rtp".equals(protocol.name)) { Map<String, Field> fields = protocol.asMap(); if (fields.containsKey("rtp.ssrc")) { String ssrc = fields.get("rtp.ssrc").value; RtpStream stream = out.get(ssrc); if (null == stream) { stream = new RtpStream(ssrc); out.put(ssrc, stream); if (fields.containsKey("rtp.setup")) { int setupFrame = Integer.parseInt(fields.get("rtp.setup").asMap().get("rtp.setup-frame").show); stream.setSetupPacket(pdml.packets[setupFrame-1]); } } stream.add(new RtpPacket(fields)); } } } } return out.values().toArray(new RtpStream[out.size()]); }  RtpStream[] parse(Pdml pdml); }
RtpExtracter { public RtpStream[] parse(Pdml pdml) { Map<String,RtpStream> out = new LinkedHashMap<String,RtpStream>(); for (Packet packet : pdml.packets) { for (Protocol protocol : packet.protocols) { if ("rtp".equals(protocol.name)) { Map<String, Field> fields = protocol.asMap(); if (fields.containsKey("rtp.ssrc")) { String ssrc = fields.get("rtp.ssrc").value; RtpStream stream = out.get(ssrc); if (null == stream) { stream = new RtpStream(ssrc); out.put(ssrc, stream); if (fields.containsKey("rtp.setup")) { int setupFrame = Integer.parseInt(fields.get("rtp.setup").asMap().get("rtp.setup-frame").show); stream.setSetupPacket(pdml.packets[setupFrame-1]); } } stream.add(new RtpPacket(fields)); } } } } return out.values().toArray(new RtpStream[out.size()]); }  RtpStream[] parse(Pdml pdml);  }