public boolean containsMedia(String media, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { if (m.getMedia().getMediaType().equalsIgnoreCase(media)) { return true; } } return false; }
@Override public Collection<RTPInfo> getRTPInfo() { final List<RTPInfo> list = new ArrayList<RTPInfo>(); try { final Connection c = this.sdp.getConnection(); @SuppressWarnings("unchecked") final Vector<MediaDescription> mds = this.sdp.getMediaDescriptions(false); if (mds != null) { for (final MediaDescription md : mds) { final RTPInfo rtpInfo = processMediaDescription(c, md); if (rtpInfo != null) { list.add(rtpInfo); } } } } catch (final SdpException e) { throw new RuntimeException("TODO: throw real exception", e); } 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(); }
Vector<Attribute> sessionAttributes = sDes.getAttributes(true); sessionAttributes.add(sdpFactory.createAttribute(ICE_PWD, pwd)); sDes.setAttributes(sessionAttributes);
Version otherVersion = otherSessionDescription.getVersion(); if (otherVersion != null) { this.setVersion((Version) otherVersion.clone()); Origin otherOrigin = otherSessionDescription.getOrigin(); if (otherOrigin != null) { this.setOrigin((Origin) otherOrigin.clone()); SessionName otherSessionName = otherSessionDescription.getSessionName(); if (otherSessionName != null) { this.setSessionName((SessionName) otherSessionName.clone()); Info otherInfo = otherSessionDescription.getInfo(); if (otherInfo != null) { this.setInfo((Info) otherInfo.clone()); URIField otherUriField = (URIField) otherSessionDescription.getURI(); if (otherUriField != null) { URIField newUF = new URIField(); Connection otherConnection = (Connection) otherSessionDescription.getConnection(); if (otherConnection != null) { this.setConnection((Connection) otherConnection.clone()); Key otherKey = (Key) otherSessionDescription.getKey(); if (otherKey != null) { this.setKey((Key) otherKey.clone()); Vector otherTimeDescriptions = otherSessionDescription.getTimeDescriptions(false);
final SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(text); fix(sdp.getConnection(), externalIp); fix(sdp.getOrigin(), externalIp); final Vector<MediaDescription> descriptions = sdp.getMediaDescriptions(false); for (final MediaDescription description : descriptions) { fix(description.getConnection(), externalIp); fix(sdp.getConnection(), externalIp); fix(sdp.getOrigin(), externalIp); final Vector<MediaDescription> descriptions = sdp.getMediaDescriptions(false); for (final MediaDescription description : descriptions) { fix(description.getConnection(), externalIp);
Vector<Attribute> sessionAttributes = sDes.getAttributes(true); Origin o = sDes.getOrigin(); sDes.setOrigin(o); sDes.setMediaDescriptions(mDescs);
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(); }
try { sessionDescription = SdpFactory.getInstance().createSessionDescription(mdcx.getRemoteConnectionDescriptor().toString()); isNonValidSdp = sessionDescription.getSessionName().getValue().contains("NonValidSDP"); } catch (SdpParseException e) { logger.error("Error while trying to get SDP from MDCX");
try { sessionDescription = SdpFactory.getInstance().createSessionDescription(mdcx.getRemoteConnectionDescriptor().toString()); isNonValidSdp = sessionDescription.getSessionName().getValue().contains("NonValidSDP"); } catch (SdpParseException e) { logger.error("Error while trying to get SDP from MDCX");
public boolean containsMedia(String media, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { if (m.getMedia().getMediaType().equalsIgnoreCase(media)) { return true; } } return false; }
@Override public Collection<RTPInfo> getRTPInfo() { final List<RTPInfo> list = new ArrayList<RTPInfo>(); try { final Connection c = this.sdp.getConnection(); @SuppressWarnings("unchecked") final Vector<MediaDescription> mds = this.sdp.getMediaDescriptions(false); if (mds != null) { for (final MediaDescription md : mds) { final RTPInfo rtpInfo = processMediaDescription(c, md); if (rtpInfo != null) { list.add(rtpInfo); } } } } catch (final SdpException e) { throw new RuntimeException("TODO: throw real exception", e); } return list; }
public boolean containsFormat(String format, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { Vector<Attribute> attributes = m.getAttributes(false); for (Attribute a : attributes) { if (a.getName().equalsIgnoreCase("rtpmap") && a.getValue().toLowerCase().contains(format.toLowerCase())) { return true; } } } return false; }
SessionDescription sourceSessionDescription = sdpFactory.createSessionDescription(sourceSDP); SessionDescription destinationSessionDescription = sdpFactory.createSessionDescription(destinationSDP); Vector<MediaDescription> sourceMediaDescriptions = sourceSessionDescription.getMediaDescriptions(false); Vector<MediaDescription> destinationMediaDescriptions = destinationSessionDescription.getMediaDescriptions(false); Vector<AttributeField> attributes; Vector<BandwidthField> bandwidth; rtcpAddress = sourceMediaDescriptions.get(i).getConnection().getAddress(); else rtcpAddress = sourceSessionDescription.getConnection().getAddress(); rtcpAddress = destinationMediaDescriptions.get(i).getConnection().getAddress(); else rtcpAddress = destinationSessionDescription.getConnection().getAddress();
public boolean containsFormat(String format, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { Vector<Attribute> attributes = m.getAttributes(false); for (Attribute a : attributes) { if (a.getName().equalsIgnoreCase("rtpmap") && a.getValue().toLowerCase().contains(format.toLowerCase())) { return true; } } } return false; }
SdpFactory sdpFactory = SdpFactory.getInstance(); SessionDescription sourceSessionDescription = sdpFactory.createSessionDescription(sourceSDP); Vector<MediaDescription> sourceMediaDescriptions = sourceSessionDescription.getMediaDescriptions(false); Vector<AttributeField> attributes; Vector<BandwidthField> bandwidth; rtcpAddress = sourceMediaDescriptions.get(i).getConnection().getAddress(); else rtcpAddress = sourceSessionDescription.getConnection().getAddress();
public static synchronized HashMap<Integer, Format> getFormats(SessionDescription sdp, String mediaType) throws SdpParseException, SdpException { HashMap<Integer, Format> formats = new HashMap<Integer, Format>(); Enumeration mediaDescriptions = sdp.getMediaDescriptions(false).elements(); while (mediaDescriptions.hasMoreElements()) { MediaDescription md = (MediaDescription) mediaDescriptions.nextElement(); if (md.getMedia().getMediaType().equals(mediaType)) { HashMap<Integer, Format> fmts = getFormats(md); if (fmts != null) { formats.putAll(fmts); } } } return formats; }
public static synchronized HashMap<Integer, Format> getFormats(SessionDescription sdp, String mediaType) throws SdpParseException, SdpException { HashMap<Integer, Format> formats = new HashMap<Integer, Format>(); Enumeration mediaDescriptions = sdp.getMediaDescriptions(false).elements(); while (mediaDescriptions.hasMoreElements()) { MediaDescription md = (MediaDescription) mediaDescriptions.nextElement(); if (md.getMedia().getMediaType().equals(mediaType)) { HashMap<Integer, Format> fmts = getFormats(md); if (fmts != null) { formats.putAll(fmts); } } } return formats; }
public void exclude(String f, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { Collection<RTPFormat> fmts = getRTPFormats(m); for (RTPFormat rtpFormat : fmts) { if (rtpFormat.description.toLowerCase().contains(f.toLowerCase())) { this.excludeFormat(rtpFormat.id, m); this.excludeAttribute(rtpFormat.id, m); } } } }
public void exclude(String f, SessionDescription sdp) throws SdpException { Vector<MediaDescription> mds = sdp.getMediaDescriptions(false); for (MediaDescription m : mds) { Collection<RTPFormat> fmts = getRTPFormats(m); for (RTPFormat rtpFormat : fmts) { if (rtpFormat.description.toLowerCase().contains(f.toLowerCase())) { this.excludeFormat(rtpFormat.id, m); this.excludeAttribute(rtpFormat.id, m); } } } }