public static String getSdp(final String contentType, final byte[] data) throws SdpParseException { final String text = new String(data); String sdpResult = null; if (contentType.equalsIgnoreCase("application/sdp")) { final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); sdpResult = sdp.toString(); } else { String boundary = contentType.split(";")[1].split("=")[1]; String[] parts = text.split(boundary); String sdpText = null; for (String part : parts) { if (part.contains("application/sdp")) { sdpText = part.replaceAll("Content.*", "").replaceAll("--", "").trim(); } } final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(sdpText); sdpResult = sdp.toString(); } return sdpResult; }
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; }
@SuppressWarnings("unchecked") private static String patch(final byte[] data, final String externalIp) throws UnknownHostException, SdpException { final String text = new String(data); if(logger.isInfoEnabled()){ logger.info("About to patch "); logger.info("SDP :" + text); logger.info("Using externalIP: " + externalIp); } final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); SessionName sessionName = SdpFactory.getInstance().createSessionName("Restcomm B2BUA"); sdp.setSessionName(sessionName); // Handle the connection at the session level. fix(sdp.getConnection(), externalIp); // Handle the connections at the media description level. final Vector<MediaDescription> descriptions = sdp.getMediaDescriptions(false); for (final MediaDescription description : descriptions) { fix(description.getConnection(), externalIp); } sdp.getOrigin().setAddress(externalIp); return sdp.toString(); }
protected void setLocalDescriptor(String sdp) throws SdpException { this.localSdp = sdpFactory.createSessionDescription(sdp); }
public SdpPortManagerImpl(NetworkConnectionImpl connection) { this.connection = connection; this.sdpProcessor = new SdpProcessor(); sdpFactory = SdpFactory.getInstance(); }
sdpFactory.createAttribute(ICE_OPTIONS, allOptions)); o = sdpFactory.createOrigin("ice4j.org", 0, 0, "IN", addressFamily, defaultAddress.getHostAddress()); for(IceMediaStream stream : streams) MediaDescription mLine = sdpFactory.createMediaDescription( stream.getName(), 0, //default port comes later 1, SdpConstants.RTP_AVP, new int[]{0});
: Connection.IP4; mediaDescription.setConnection(sdpFactory.createConnection( "IN", defaultAddress.getHostAddress(), addressFamily));
protected void setLocalDescriptor(String sdp) throws SdpException { this.localSdp = sdpFactory.createSessionDescription(sdp); }
public SdpPortManagerImpl(NetworkConnectionImpl connection) { this.connection = connection; this.sdpProcessor = new SdpProcessor(); sdpFactory = SdpFactory.getInstance(); }
private byte[] patchMedia(final String realIp, final byte[] data) throws UnknownHostException, SdpException { final String text = new String(data); final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); final Connection connection = sdp.getConnection(); if(Connection.IN.equals(connection.getNetworkType()) && Connection.IP4.equals(connection.getAddressType())) { final InetAddress address = InetAddress.getByName(connection.getAddress()); final String ip = address.getHostAddress(); if(!IPUtils.isRoutableAddress(ip)) { connection.setAddress(realIp); } } return sdp.toString().getBytes(); }
public void processSdpAnswer(byte[] sdp) throws SdpPortManagerException { connection.debug("Processing SDP answer"); try { this.remoteSdp = sdpFactory.createSessionDescription(new String(sdp)); } catch (Exception e) { throw new SdpPortManagerException(e.getMessage()); } try { connection.fsm.signal(ConnectionTransition.MODIFY); } catch (UnknownTransitionException e) { throw new SdpPortManagerException(e.getMessage()); } }
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; }
private String convertSDP(String sdpString) throws SdpException { SdpFactory factory = javax.sdp.SdpFactory.getInstance(); SessionDescription sd = factory.createSessionDescription(sdpString); Vector<?> mediaDescriptions = sd.getMediaDescriptions(false); for (Object object : mediaDescriptions) { MediaDescription md = (MediaDescription) object; Vector<?> attributes = md.getAttributes(false); for (Object object2 : attributes) { Attribute attribute = (Attribute) object2; if (attribute.getName().compareToIgnoreCase("rtpmap") == 0) { attribute.setValue(attribute.getValue().toUpperCase()); } } } return sd.toString(); }
public void processSdpAnswer(byte[] sdp) throws SdpPortManagerException { connection.debug("Processing SDP answer"); try { this.remoteSdp = sdpFactory.createSessionDescription(new String(sdp)); } catch (Exception e) { throw new SdpPortManagerException(e.getMessage()); } try { connection.fsm.signal(ConnectionTransition.MODIFY); } catch (UnknownTransitionException e) { throw new SdpPortManagerException(e.getMessage()); } }
public Collection<Attribute> encode() { ArrayList<Attribute> list = new ArrayList(); if (this.getEncoding().equals(VideoFormat.H261)) { list.add(sdpFactory.createAttribute("rtpmap", rtpmap())); } return list; } }
private String convertSDP(String sdpString) throws SdpException { SdpFactory factory = javax.sdp.SdpFactory.getInstance(); SessionDescription sd = factory.createSessionDescription(sdpString); Vector<?> mediaDescriptions = sd.getMediaDescriptions(false); for (Object object : mediaDescriptions) { MediaDescription md = (MediaDescription) object; Vector<?> attributes = md.getAttributes(false); for (Object object2 : attributes) { Attribute attribute = (Attribute) object2; if (attribute.getName().compareToIgnoreCase("rtpmap") == 0) { attribute.setValue(attribute.getValue().toUpperCase()); } } } return sd.toString(); }
public SDP parse(final Buffer data) throws SdpException { try { final SessionDescription sdp = sdpFactory.createSessionDescription(data.toString()); return new SDPWrapper(sdp); } catch (final javax.sdp.SdpParseException e) { throw new SdpParseException(e.getLineNumber(), e.getCharOffset(), e.getMessage(), e.getCause()); } }
public Collection<Attribute> encode() { ArrayList<Attribute> list = new ArrayList(); if (this.getEncoding().equals(VideoFormat.H261)) { list.add(sdpFactory.createAttribute("rtpmap", rtpmap())); } return list; } }
String patchedSdp = null; if (contentType.equalsIgnoreCase("application/sdp")) { final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(sdpText); fix(sdp.getConnection(), externalIp);
public SDP parse(final Buffer data) throws SdpException { try { final SessionDescription sdp = sdpFactory.createSessionDescription(data.toString()); return new SDPWrapper(sdp); } catch (final javax.sdp.SdpParseException e) { throw new SdpParseException(e.getLineNumber(), e.getCharOffset(), e.getMessage(), e.getCause()); } }