SdpFactory { public static void rejectMediaField(SessionDescription answer, MediaDescriptionField media) { MediaDescriptionField rejected = new MediaDescriptionField(); rejected.setMedia(media.getMedia()); rejected.setPort(0); rejected.setProtocol(media.getProtocol()); rejected.setPayloadTypes(media.getPayloadTypes()); rejected.setSession(answer); answer.addMediaDescription(rejected); }  static SessionDescription buildSdp(boolean offer, String localAddress, String externalAddress, MediaChannel... channels); static void rejectMediaField(SessionDescription answer, MediaDescriptionField media); static MediaDescriptionField buildMediaDescription(MediaChannel channel, boolean offer);  }
@Test public void testRejectApplication() throws SdpException { String applicationSdp = "m=application 9 DTLS/SCTP 5000"; MediaDescriptionFieldParser mediaFieldParser = new MediaDescriptionFieldParser(); MediaDescriptionField applicationField = mediaFieldParser.parse(applicationSdp); SessionDescription answer = new SessionDescription(); SdpFactory.rejectMediaField(answer, applicationField); MediaDescriptionField mediaDescription = answer.getMediaDescription("application"); Assert.assertNotNull(mediaDescription); Assert.assertEquals(0, mediaDescription.getPort()); Assert.assertEquals("DTLS/SCTP", mediaDescription.getProtocol()); String[] payloadTypes = mediaDescription.getPayloadTypes(); Assert.assertEquals(1, payloadTypes.length); Assert.assertEquals("5000", payloadTypes[0]); }
@Test public void testRejectImageMediaType() throws SdpException { String imageSDP = "m=image 52550 udptl t38\n\r"; MediaDescriptionFieldParser mediaFieldParser = new MediaDescriptionFieldParser(); MediaDescriptionField applicationField = mediaFieldParser.parse(imageSDP); SessionDescription answer = new SessionDescription(); SdpFactory.rejectMediaField(answer, applicationField); MediaDescriptionField mediaDescription = answer.getMediaDescription("image"); Assert.assertNotNull(mediaDescription); Assert.assertEquals(0, mediaDescription.getPort()); Assert.assertEquals("udptl", mediaDescription.getProtocol()); String[] payloadTypes = mediaDescription.getPayloadTypes(); Assert.assertEquals(1, payloadTypes.length); Assert.assertEquals("t38", payloadTypes[0]); }