/** * Returns Media object with the specified properties. * * @param media the media type, eg "audio" * @param port port number on which to receive media * @param numPorts number of ports used for this media stream * @param transport transport type, eg "RTP/AVP" * @param staticRtpAvpTypes vector to set * @throws SdpException * @return Media */ public Media createMedia( String media, int port, int numPorts, String transport, Vector staticRtpAvpTypes) throws SdpException { MediaField mediaImpl = new MediaField(); mediaImpl.setMediaType(media); mediaImpl.setMediaPort(port); mediaImpl.setPortCount(numPorts); mediaImpl.setProtocol(transport); mediaImpl.setMediaFormats(staticRtpAvpTypes); return mediaImpl; }
/** * Returns MediaDescription object with the specified properties. The returned object will respond * to Media.getMediaFormats(boolean) with a Vector of String objects specified by the 'formats * argument. * * @param media the media type, eg "audio" * @param port port number on which to receive media * @param numPorts number of ports used for this media stream * @param transport transport type, eg "RTP/AVP" * @param formats list of formats which should be specified by the returned MediaDescription * @return MediaDescription */ public MediaDescription createMediaDescription( String media, int port, int numPorts, String transport, String[] formats) { MediaDescriptionImpl mediaDescriptionImpl = new MediaDescriptionImpl(); try { MediaField mediaImpl = new MediaField(); mediaImpl.setMediaType(media); mediaImpl.setMediaPort(port); mediaImpl.setPortCount(numPorts); mediaImpl.setProtocol(transport); Vector formatsV = new Vector(formats.length); for (int i = 0; i < formats.length; i++) formatsV.add(formats[i]); mediaImpl.setMediaFormats(formatsV); mediaDescriptionImpl.setMedia(mediaImpl); } catch (SdpException s) { s.printStackTrace(); } return mediaDescriptionImpl; }