javax.sdp
Class SdpFactory

java.lang.Object
  extended by javax.sdp.SdpFactory

public class SdpFactory
extends Object

The SdpFactory enables applications to encode and decode SDP messages. The SdpFactory can be used to construct a SessionDescription object programmatically. The SdpFactory can also be used to construct a SessionDescription based on the contents of a String. Acknowledgement: Bugs reported by Brian J. Collins . and by Majdi Abuelbassal . Please refer to IETF RFC 2327 for a description of SDP.

Version:
1.0
Author:
Olivier Deruelle , M. Ranganathan

Method Summary
 Attribute createAttribute(String name, String value)
          Returns Attribute object with the specified values.
 BandWidth createBandwidth(String modifier, int value)
          Returns Bandwidth object with the specified values.
 Connection createConnection(String addr)
          Returns a Connection object with the specified address.
 Connection createConnection(String addr, int ttl, int numAddrs)
          Returns a Connection object with the specified properties and a network and address type of "IN" and "IP4" respectively.
 Connection createConnection(String netType, String addrType, String addr)
          Returns a Connection object with the specified properties and no TTL and a default number of addresses (1).
 Connection createConnection(String netType, String addrType, String addr, int ttl, int numAddrs)
          Returns a Connection object with the specified properties a
 EMail createEMail(String value)
          Returns EMail object with the specified value.
 Info createInfo(String value)
          Returns Info object with the specified value.
 Key createKey(String method, String key)
          Returns Key object with the specified value.
 Media createMedia(String media, int port, int numPorts, String transport, Vector staticRtpAvpTypes)
          Returns Media object with the specified properties.
 MediaDescription createMediaDescription(String media, int port, int numPorts, String transport, int[] staticRtpAvpTypes)
          Returns MediaDescription object with the specified properties.
 MediaDescription createMediaDescription(String media, int port, int numPorts, String transport, String[] formats)
          Returns MediaDescription object with the specified properties.
 Origin createOrigin(String userName, long sessionId, long sessionVersion, String networkType, String addrType, String address)
          Returns Origin object with the specified properties.
 Origin createOrigin(String userName, String address)
          Returns Origin object with the specified properties.
 Phone createPhone(String value)
          Returns Phone object with the specified value.
 RepeatTime createRepeatTime(int repeatInterval, int activeDuration, int[] offsets)
          Returns a RepeatTime object with the specified interval, duration, and time offsets.
 SessionDescription createSessionDescription()
          Creates a new, empty SessionDescription.
 SessionDescription createSessionDescription(SessionDescription otherSessionDescription)
          Creates a new SessionDescription, deep copy of another SessionDescription.
 SessionDescription createSessionDescription(String s)
          Creates a SessionDescription populated with the information contained within the string parameter.
 SessionName createSessionName(String name)
          Returns SessionName object with the specified name.
 Time createTime()
          Returns an unbounded Time specification (i.e., "t=0 0").
 Time createTime(Date start, Date stop)
          Returns a Time specification with the specified start and stop times.
 TimeDescription createTimeDescription()
          Returns TimeDescription unbounded (i.e.
 TimeDescription createTimeDescription(Date start, Date stop)
          Returns TimeDescription object with the specified properties.
 TimeDescription createTimeDescription(Time t)
          Returns TimeDescription object with the specified properties.
 TimeZoneAdjustment createTimeZoneAdjustment(Date d, int offset)
          Constructs a timezone adjustment record.
 URI createURI(URL value)
          Returns URI object with the specified value.
 Version createVersion(int value)
          Returns Version object with the specified values.
 String formatMulticastAddress(String addr, int ttl, int numAddrs)
          Returns a String containing the computed form for a multi-connection address.
static Date getDateFromNtp(long ntpTime)
           
static SdpFactory getInstance()
          Obtain an instance of an SdpFactory.
static long getNtpTime(Date d)
          Returns a long containing the NTP value for a given Java Date.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SdpFactory getInstance()
Obtain an instance of an SdpFactory. This static method returns a factory instance. Once an application has obtained a reference to an SdpFactory it can use the factory to configure and obtain parser instances and to create SDP objects.

Returns:
a factory instance

createSessionDescription

public SessionDescription createSessionDescription()
                                            throws SdpException
Creates a new, empty SessionDescription. The session is set as follows: v=0 o=this.createOrigin ("user", InetAddress.getLocalHost().toString()); s=- t=0 0

Returns:
a new, empty SessionDescription.
Throws:
SdpException - SdpException, - if there is a problem constructing the SessionDescription.

createSessionDescription

public SessionDescription createSessionDescription(SessionDescription otherSessionDescription)
                                            throws SdpException
Creates a new SessionDescription, deep copy of another SessionDescription.

Parameters:
otherSessionDescription - - the SessionDescription to copy from.
Returns:
a new SessionDescription, exact and deep copy of the otherSessionDescription.
Throws:
SdpException - - if there is a problem constructing the SessionDescription.

createSessionDescription

public SessionDescription createSessionDescription(String s)
                                            throws SdpParseException
Creates a SessionDescription populated with the information contained within the string parameter. Note: unknown field types should not cause exceptions.

Parameters:
s - s - the sdp message that is to be parsed.
Returns:
a populated SessionDescription object.
Throws:
SdpParseException - SdpParseException - if there is a problem parsing the String.

createBandwidth

public BandWidth createBandwidth(String modifier,
                                 int value)
Returns Bandwidth object with the specified values.

Parameters:
modifier - modifier - the bandwidth type
value - the bandwidth value measured in kilobits per second
Returns:
bandwidth

createAttribute

public Attribute createAttribute(String name,
                                 String value)
Returns Attribute object with the specified values.

Parameters:
name - the namee of the attribute
value - the value of the attribute
Returns:
Attribute

createInfo

public Info createInfo(String value)
Returns Info object with the specified value.

Parameters:
value - the string containing the description.
Returns:
Info

createPhone

public Phone createPhone(String value)
Returns Phone object with the specified value.

Parameters:
value - the string containing the description.
Returns:
Phone

createEMail

public EMail createEMail(String value)
Returns EMail object with the specified value.

Parameters:
value - the string containing the description.
Returns:
EMail

createURI

public URI createURI(URL value)
              throws SdpException
Returns URI object with the specified value.

Parameters:
value - the URL containing the description.
Returns:
URI
Throws:
SdpException

createSessionName

public SessionName createSessionName(String name)
Returns SessionName object with the specified name.

Parameters:
name - the string containing the name of the session.
Returns:
SessionName

createKey

public Key createKey(String method,
                     String key)
Returns Key object with the specified value.

Parameters:
method - the string containing the method type.
key - the key to set
Returns:
Key

createVersion

public Version createVersion(int value)
Returns Version object with the specified values.

Parameters:
value - the version number.
Returns:
Version

createMedia

public Media createMedia(String media,
                         int port,
                         int numPorts,
                         String transport,
                         Vector staticRtpAvpTypes)
                  throws SdpException
Returns Media object with the specified properties.

Parameters:
media - the media type, eg "audio"
port - port number on which to receive media
numPorts - number of ports used for this media stream
transport - transport type, eg "RTP/AVP"
staticRtpAvpTypes - vector to set
Returns:
Media
Throws:
SdpException

createOrigin

public Origin createOrigin(String userName,
                           String address)
                    throws SdpException
Returns Origin object with the specified properties.

Parameters:
userName - the user name.
address - the IP4 encoded address.
Returns:
Origin
Throws:
SdpException - if the parameters are null

createOrigin

public Origin createOrigin(String userName,
                           long sessionId,
                           long sessionVersion,
                           String networkType,
                           String addrType,
                           String address)
                    throws SdpException
Returns Origin object with the specified properties.

Parameters:
userName - String containing the user that created the string.
sessionId - long containing the session identifier.
sessionVersion - long containing the session version.
networkType - String network type for the origin (usually "IN").
addrType - String address type (usually "IP4").
address - String IP address usually the address of the host.
Returns:
Origin object with the specified properties.
Throws:
SdpException - if the parameters are null

createMediaDescription

public MediaDescription createMediaDescription(String media,
                                               int port,
                                               int numPorts,
                                               String transport,
                                               int[] staticRtpAvpTypes)
                                        throws IllegalArgumentException,
                                               SdpException
Returns MediaDescription object with the specified properties. The returned object will respond to Media.getMediaFormats(boolean) with a Vector of media formats.

Parameters:
media - media -
port - port number on which to receive media
numPorts - number of ports used for this media stream
transport - transport type, eg "RTP/AVP"
staticRtpAvpTypes - list of static RTP/AVP media payload types which should be specified by the returned MediaDescription throws IllegalArgumentException if passed an invalid RTP/AVP payload type
Returns:
MediaDescription
Throws:
IllegalArgumentException
SdpException

createMediaDescription

public MediaDescription createMediaDescription(String media,
                                               int port,
                                               int numPorts,
                                               String transport,
                                               String[] formats)
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.

Parameters:
media - the media type, eg "audio"
port - port number on which to receive media
numPorts - number of ports used for this media stream
transport - transport type, eg "RTP/AVP"
formats - list of formats which should be specified by the returned MediaDescription
Returns:
MediaDescription

createTimeDescription

public TimeDescription createTimeDescription(Time t)
                                      throws SdpException
Returns TimeDescription object with the specified properties.

Parameters:
t - the Time that the time description applies to. Returns TimeDescription object with the specified properties.
Returns:
TimeDescription
Throws:
SdpException

createTimeDescription

public TimeDescription createTimeDescription()
                                      throws SdpException
Returns TimeDescription unbounded (i.e. "t=0 0");

Returns:
TimeDescription unbounded (i.e. "t=0 0");
Throws:
SdpException

createTimeDescription

public TimeDescription createTimeDescription(Date start,
                                             Date stop)
                                      throws SdpException
Returns TimeDescription object with the specified properties.

Parameters:
start - start time.
stop - stop time.
Returns:
TimeDescription
Throws:
SdpException - if the parameters are null

formatMulticastAddress

public String formatMulticastAddress(String addr,
                                     int ttl,
                                     int numAddrs)
Returns a String containing the computed form for a multi-connection address. Parameters: addr - connection address ttl - time to live (TTL) for multicast addresses numAddrs - number of addresses used by the connection Returns: a String containing the computed form for a multi-connection address.


createConnection

public Connection createConnection(String netType,
                                   String addrType,
                                   String addr,
                                   int ttl,
                                   int numAddrs)
                            throws SdpException
Returns a Connection object with the specified properties a

Parameters:
netType - network type, eg "IN" for "Internet"
addrType - address type, eg "IP4" for IPv4 type addresses
addr - connection address
ttl - time to live (TTL) for multicast addresses
numAddrs - number of addresses used by the connection
Returns:
Connection
Throws:
SdpException

createConnection

public Connection createConnection(String netType,
                                   String addrType,
                                   String addr)
                            throws SdpException
Returns a Connection object with the specified properties and no TTL and a default number of addresses (1).

Parameters:
netType - network type, eg "IN" for "Internet"
addrType - address type, eg "IP4" for IPv4 type addresses
addr - connection address
Returns:
Connection
Throws:
SdpException - if the parameters are null

createConnection

public Connection createConnection(String addr,
                                   int ttl,
                                   int numAddrs)
                            throws SdpException
Returns a Connection object with the specified properties and a network and address type of "IN" and "IP4" respectively.

Parameters:
addr - connection address
ttl - time to live (TTL) for multicast addresses
numAddrs - number of addresses used by the connection
Returns:
Connection
Throws:
SdpException

createConnection

public Connection createConnection(String addr)
                            throws SdpException
Returns a Connection object with the specified address. This is equivalent to createConnection("IN", "IP4", addr);

Parameters:
addr - connection address
Returns:
Connection
Throws:
SdpException - if the parameter is null

createTime

public Time createTime(Date start,
                       Date stop)
                throws SdpException
Returns a Time specification with the specified start and stop times.

Parameters:
start - start time
stop - stop time
Returns:
a Time specification with the specified start and stop times.
Throws:
SdpException - if the parameters are null

createTime

public Time createTime()
                throws SdpException
Returns an unbounded Time specification (i.e., "t=0 0").

Returns:
an unbounded Time specification (i.e., "t=0 0").
Throws:
SdpException

createRepeatTime

public RepeatTime createRepeatTime(int repeatInterval,
                                   int activeDuration,
                                   int[] offsets)
Returns a RepeatTime object with the specified interval, duration, and time offsets.

Parameters:
repeatInterval - the "repeat interval" in seconds
activeDuration - the "active duration" in seconds
offsets - the list of offsets relative to the start time of the Time object with which the returned RepeatTime will be associated
Returns:
RepeatTime

createTimeZoneAdjustment

public TimeZoneAdjustment createTimeZoneAdjustment(Date d,
                                                   int offset)
Constructs a timezone adjustment record.

Parameters:
d - the Date at which the adjustment is going to take place.
offset - the adjustment in number of seconds relative to the start time of the SessionDescription with which this object is associated.
Returns:
TimeZoneAdjustment

getDateFromNtp

public static Date getDateFromNtp(long ntpTime)
Parameters:
ntpTime - long to set
Returns:
Returns a Date object for a given NTP date value.

getNtpTime

public static long getNtpTime(Date d)
                       throws SdpParseException
Returns a long containing the NTP value for a given Java Date.

Parameters:
d - Date to set
Returns:
long
Throws:
SdpParseException

main

public static void main(String[] args)
                 throws SdpParseException,
                        SdpException
Throws:
SdpParseException
SdpException


Copyright © 2012. All Rights Reserved.