public class SimpleSessionDescription extends Object
Here is an example code to create a session description.
SimpleSessionDescription description = new SimpleSessionDescription( System.currentTimeMillis(), "1.2.3.4"); Media media = description.newMedia("audio", 56789, 1, "RTP/AVP"); media.setRtpPayload(0, "PCMU/8000", null); media.setRtpPayload(8, "PCMA/8000", null); media.setRtpPayload(127, "telephone-event/8000", "0-15"); media.setAttribute("sendrecv", "");
Invoking description.encode()
will produce a result like the
one below.
v=0 o=- 1284970442706 1284970442709 IN IP4 1.2.3.4 s=- c=IN IP4 1.2.3.4 t=0 0 m=audio 56789 RTP/AVP 0 8 127 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:127 telephone-event/8000 a=fmtp:127 0-15 a=sendrecv
Modifier and Type | Class and Description |
---|---|
static class |
SimpleSessionDescription.Media
This class represents a media description of a session description.
|
Constructor and Description |
---|
SimpleSessionDescription(long sessionId,
String address)
Creates a minimal session description from the given session ID and
unicast address.
|
SimpleSessionDescription(String message)
Creates a session description from the given message.
|
Modifier and Type | Method and Description |
---|---|
String |
encode()
Encodes the session description and all its media descriptions in a
string.
|
String |
getAddress()
Returns the connection address or
null if it is not present. |
String |
getAttribute(String name)
Returns the attribute of the given name or
null if it is not
present. |
String[] |
getAttributeNames()
Returns the names of all the attributes.
|
int |
getBandwidth(String type)
Returns the bandwidth limit of the given type or
-1 if it is not
present. |
String[] |
getBandwidthTypes()
Returns the types of the bandwidth limits.
|
String |
getEncryptionKey()
Returns the encryption key or
null if it is not present. |
String |
getEncryptionMethod()
Returns the encryption method or
null if it is not present. |
SimpleSessionDescription.Media[] |
getMedia()
Returns all the media descriptions in this session description.
|
SimpleSessionDescription.Media |
newMedia(String type,
int port,
int portCount,
String protocol)
Creates a new media description in this session description.
|
void |
setAddress(String address)
Sets the connection address.
|
void |
setAttribute(String name,
String value)
Sets the attribute for the given name.
|
void |
setBandwidth(String type,
int value)
Sets the bandwith limit for the given type.
|
void |
setEncryption(String method,
String key)
Sets the encryption method and the encryption key.
|
public SimpleSessionDescription(long sessionId, String address)
SimpleSessionDescription
for an
example of its usage.public SimpleSessionDescription(String message)
IllegalArgumentException
- if message is invalid.public SimpleSessionDescription.Media newMedia(String type, int port, int portCount, String protocol)
type
- The media type, e.g. "audio"
.port
- The first transport port used by this media.portCount
- The number of contiguous ports used by this media.protocol
- The transport protocol, e.g. "RTP/AVP"
.public SimpleSessionDescription.Media[] getMedia()
public String encode()
public String getAddress()
null
if it is not present.public void setAddress(String address)
null
.public String getEncryptionMethod()
null
if it is not present.public String getEncryptionKey()
null
if it is not present.public void setEncryption(String method, String key)
null
.public String[] getBandwidthTypes()
public int getBandwidth(String type)
-1
if it is not
present.public void setBandwidth(String type, int value)
public String[] getAttributeNames()
public String getAttribute(String name)
null
if it is not
present.