net.sourceforge.jsdp
Class Media

java.lang.Object
  extended by net.sourceforge.jsdp.Media
All Implemented Interfaces:
Serializable, Cloneable, Field

public class Media
extends Object
implements Field

A Media represents a m=<field value> field contained in a SDP message. The media field identifies information about the formats of the media associated with the session. A media field includes:

Since:
0.1.0
Version:
1.0
Author:
Claudio Di Vita
See Also:
Serialized Form

Field Summary
protected  Vector formats
          The media formats
protected  String media
          The media type
protected  int port
          The transport port to which the media stream will be sent
protected  int portsCount
          The number of transport port where the media stream will be sent
protected  String protocol
          The transport protocol
 
Fields inherited from interface net.sourceforge.jsdp.Field
ATTRIBUTE_FIELD, BANDWITH_FIELD, CONNECTION_FIELD, EMAIL_FIELD, END_OF_FIELD, INFORMATION_FIELD, KEY_FIELD, MEDIA_FIELD, ORIGIN_FIELD, PHONE_FIELD, REPEAT_TIME_FIELD, SESSION_NAME_FIELD, TIME_FIELD, TIMEZONE_FIELD, URI_FIELD, VERSION_FIELD
 
Constructor Summary
protected Media()
          Creates a new Media.
  Media(String media, int port, int portsCount, String protocol, String format)
          Creates a new Media.
  Media(String media, int port, String protocol, String format)
          Creates a new Media.
 
Method Summary
 void addMediaFormat(String format)
          Adds a media format.
 Object clone()
          Returns a clone of this field.
 String[] getMediaFormats()
          Returns the media formats
 String getMediaType()
          Returns the type of the media.
 int getPort()
          Returns the transport port to which the media stream will be sent.
 int getPortsCount()
          Returns the number of ports associated with this media.
 String getProtocol()
          Returns the protocol over which this media should be transmitted.
 char getType()
          Returns the type character for the field.
static Media parse(String field)
          Parse an input string and constructs the equivalent media field.
 void setMediaFormats(String[] formats)
          Sets the media formats.
 void setMediaType(String media)
          Sets the media type.
 void setPort(int port)
          Sets the media transport port.
 void setPortsCount(int n)
          Sets the number of transport ports where the media stream will be sent.
 void setProtocol(String protocol)
          Sets the protocol over which this media should be transmitted.
 String toString()
          Returns a string representation of the field.The representation has the form: m=<media> <port>/<portsCount> <protocol> <formats>
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

media

protected String media
The media type


port

protected int port
The transport port to which the media stream will be sent


portsCount

protected int portsCount
The number of transport port where the media stream will be sent


protocol

protected String protocol
The transport protocol


formats

protected Vector formats
The media formats

Constructor Detail

Media

protected Media()
Creates a new Media.


Media

public Media(String media,
             int port,
             int portsCount,
             String protocol,
             String format)
      throws SDPException
Creates a new Media.

Parameters:
media - the media type
port - the transport port to which the media stream will be sent
portsCount - the number of transport ports where the media stream will be sent
protocol - the transport protocol
format - the media default format
Throws:
SDPException - if the parameters are not valid

Media

public Media(String media,
             int port,
             String protocol,
             String format)
      throws SDPException
Creates a new Media.

Parameters:
media - the media type
port - the transport port to which the media stream will be sent
protocol - the transport protocol
format - the media default format
Throws:
SDPException - if the parameters are not valid
Method Detail

parse

public static Media parse(String field)
                   throws SDPParseException
Parse an input string and constructs the equivalent media field.

Parameters:
field - the string to parse
Returns:
a new Origin instance
Throws:
SDPParseException - if an error occurs while parsing

addMediaFormat

public void addMediaFormat(String format)
                    throws SDPException
Adds a media format.

Parameters:
format - the media format to add
Throws:
SDPException - if the media format is not valid

clone

public Object clone()
Returns a clone of this field.

Specified by:
clone in interface Field
Overrides:
clone in class Object
Returns:
a clone of this field

getMediaFormats

public String[] getMediaFormats()
Returns the media formats

Returns:
the media formats

getMediaType

public String getMediaType()
Returns the type of the media.

Returns:
the media tpye

getPort

public int getPort()
Returns the transport port to which the media stream will be sent.

Returns:
the transport port

getPortsCount

public int getPortsCount()
Returns the number of ports associated with this media.

Returns:
the ports count

getProtocol

public String getProtocol()
Returns the protocol over which this media should be transmitted.

Returns:
the transport protocol

getType

public char getType()
Returns the type character for the field.

Specified by:
getType in interface Field
Returns:
the field type character: m

setMediaFormats

public void setMediaFormats(String[] formats)
                     throws SDPException
Sets the media formats.

Parameters:
formats - the formats to set
Throws:
SDPException - if one or more media formats are not valid
IllegalArgumentException - if the media formats are null

setMediaType

public void setMediaType(String media)
                  throws SDPException
Sets the media type.

Parameters:
media - the media type to set
Throws:
SDPException - if the media type is not valid

setPort

public void setPort(int port)
             throws SDPException
Sets the media transport port.

Parameters:
port - the transport port
Throws:
SDPException - if the transport port is less than 1

setPortsCount

public void setPortsCount(int n)
                   throws SDPException
Sets the number of transport ports where the media stream will be sent.

Parameters:
n - the number of ports
Throws:
SDPException - if the number of ports is less than 1

setProtocol

public void setProtocol(String protocol)
                 throws SDPException
Sets the protocol over which this media should be transmitted.

Parameters:
protocol - the transport protocol
Throws:
SDPException - if the transport protocol is not valid

toString

public String toString()
Returns a string representation of the field.The representation has the form: m=<media> <port>/<portsCount> <protocol> <formats>

Specified by:
toString in interface Field
Overrides:
toString in class Object
Returns:
the string representation of the field


Copyright © 2004-2008. All Rights Reserved.