RTPAudioFormat extends AudioFormat implements RTPFormat { public Collection<Attribute> encode() { Vector<Attribute> list = new Vector(); list.add(sdpFactory.createAttribute("rtpmap", toSdp())); if (getEncoding().equalsIgnoreCase("telephone-event")) { list.add(sdpFactory.createAttribute("fmtp", payloadType + " 0-15")); } else if (getEncoding().equalsIgnoreCase("g729")) { list.add(sdpFactory.createAttribute("fmtp", payloadType + " annex=b")); } return list; } RTPAudioFormat(int payload, String encodingName);  RTPAudioFormat(int payload, String encodingName, double sampleRate, int bits, int chans);  RTPAudioFormat(int payload, String encodingName, double sampleRate, int bits, int chans, int endian, int signed); int getPayloadType(); void setPayloadType(int payload); static RTPAudioFormat parseFormat(String rtpmap); Collection<Attribute> encode(); String toSdp();  }
@Test public void testEncodeG729() throws Exception { Collection<Attribute> attributes = AVProfile.G729.encode(); assertEquals(2, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("18 g729/8000",rtpmap.getValue()); Attribute fmtp = getAttribute(attributes, 1); assertEquals("fmtp",fmtp.getName()); assertEquals("18 annex=b",fmtp.getValue()); }
@Test public void testEncodeDTMF() throws Exception { Collection<Attribute> attributes = AVProfile.DTMF.encode(); assertEquals(2, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("101 telephone-event/8000",rtpmap.getValue()); Attribute fmtp = getAttribute(attributes, 1); assertEquals("fmtp",fmtp.getName()); assertEquals("101 0-15",fmtp.getValue()); }
@Test public void testEncodePCMA() throws Exception { Collection<Attribute> attributes = AVProfile.PCMA.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("8 pcma/8000",rtpmap.getValue()); }
@Test public void testEncodePCMU() throws Exception { Collection<Attribute> attributes = AVProfile.PCMU.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("0 pcmu/8000",rtpmap.getValue()); }
@Test public void testEncodeGSM() throws Exception { Collection<Attribute> attributes = AVProfile.GSM.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("3 gsm/8000",rtpmap.getValue()); }
@Test public void testEncodeSpeex() throws Exception { Collection<Attribute> attributes = AVProfile.SPEEX.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("97 speex/8000",rtpmap.getValue()); }
@Test public void testEncodeL16Stereo() throws Exception { Collection<Attribute> attributes = AVProfile.L16_STEREO.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("10 l16/44100/2",rtpmap.getValue()); }
@Test public void testEncodeL16Mono() throws Exception { Collection<Attribute> attributes = AVProfile.L16_MONO.encode(); assertEquals(1, attributes.size()); Attribute rtpmap = getAttribute(attributes, 0); assertEquals("rtpmap",rtpmap.getName()); assertEquals("11 l16/44100",rtpmap.getValue()); }