public class SdpUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ZRTP_HASH_ATTR
The name of the SDP attribute that defines zrtp hello hash.
|
Constructor and Description |
---|
SdpUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsAttribute(javax.sdp.MediaDescription description,
java.lang.String attributeName)
Returns whether description contains the specified
attributeName.
|
static javax.sdp.Attribute |
createAttribute(java.lang.String name,
java.lang.String value)
Creates an Attribute object with the specified values.
|
static javax.sdp.MediaDescription |
createDisablingAnswer(javax.sdp.MediaDescription offer)
Creates and returns a MediaDescription in answer of the
specified offer that disables the corresponding stream by
setting a 0 port and keeping the original list of formats and
eliminating all attributes.
|
static javax.sdp.MediaDescription |
createMediaDescription(java.lang.String transport,
java.util.List<org.jitsi.service.neomedia.format.MediaFormat> formats,
org.jitsi.service.neomedia.StreamConnector connector,
org.jitsi.service.neomedia.MediaDirection direction,
java.util.List<org.jitsi.service.neomedia.RTPExtension> rtpExtensions,
DynamicPayloadTypeRegistry dynamicPayloadTypes,
DynamicRTPExtensionsRegistry rtpExtensionsRegistry)
Creates a new MediaDescription instance according to the
specified formats, connector and direction,
and using the dynamicPayloadTypes registry to handle dynamic
payload type registrations.
|
static javax.sdp.SessionDescription |
createSessionDescription(java.net.InetAddress localAddress)
Creates an empty instance of a SessionDescription with
preinitialized s, v, c, o and
t parameters.
|
static javax.sdp.SessionDescription |
createSessionDescription(java.net.InetAddress localAddress,
java.lang.String userName,
java.util.List<javax.sdp.MediaDescription> mediaDescriptions)
Creates an empty instance of a SessionDescription with
preinitialized s, v, c, o and
t parameters.
|
static javax.sdp.SessionDescription |
createSessionUpdateDescription(javax.sdp.SessionDescription descToUpdate,
java.net.InetAddress newConnectionAddress,
java.util.List<javax.sdp.MediaDescription> newMediaDescriptions)
Creates and returns a new SessionDescription that is supposed to
update our previous descToUpdate and advertise the brand new
newMediaDescriptions.
|
static org.jitsi.service.neomedia.MediaStreamTarget |
extractDefaultTarget(javax.sdp.MediaDescription mediaDesc,
javax.sdp.SessionDescription sessDesc)
Returns a MediaStreamTarget instance reflecting the address pair
(RTP + RTCP) where we should send media in this stream.
|
static java.util.List<org.jitsi.service.neomedia.format.MediaFormat> |
extractFormats(javax.sdp.MediaDescription mediaDesc,
DynamicPayloadTypeRegistry ptRegistry)
Extracts and returns the list of MediaFormats advertised in
mediaDesc preserving their oder and registering dynamic payload
type numbers in the specified ptRegistry.
|
static java.util.Vector<javax.sdp.MediaDescription> |
extractMediaDescriptions(javax.sdp.SessionDescription sessionDescription)
Extracts and returns all MediaDescriptions provided in
sessionDescription.
|
static java.util.List<org.jitsi.service.neomedia.RTPExtension> |
extractRTPExtensions(javax.sdp.MediaDescription mediaDesc,
DynamicRTPExtensionsRegistry extMap)
Extracts and returns the list of RTPExtensions advertised in
mediaDesc and registers newly encountered ones into the
specified extMap.
|
static java.net.URL |
getCallInfoURL(javax.sdp.SessionDescription sessDesc)
Returns a URL pointing to a location with more details (and
possibly call control utilities) about the session.
|
static java.lang.String |
getContentAsString(javax.sip.message.Message message)
Gets the content of the specified SIP Message in the form of a
String value.
|
static org.jitsi.service.neomedia.MediaDirection |
getDirection(javax.sdp.MediaDescription mediaDesc)
Determines the direction of the media stream that mediaDesc
describes and returns the corresponding MediaDirection enum
entry.
|
static org.jitsi.service.neomedia.MediaType |
getMediaType(javax.sdp.MediaDescription description)
Returns the media type (e.g.
|
static javax.sdp.SessionDescription |
parseSdpString(java.lang.String sdp)
Parses the specified sdp String into a
SessionDescription.
|
static void |
setIceCredentials(javax.sdp.SessionDescription sDes,
java.lang.String uFrag,
java.lang.String pwd)
Sets the specified ICE user fragment and password as attributes of the
specified session description.
|
static void |
setSessionDirection(javax.sdp.SessionDescription sdp)
Adds an inactive|sendonly|recvonly|sendrecv session-level attribute to
sdp, according to the directions of the media descriptions in
sdp.
|
public static final java.lang.String ZRTP_HASH_ATTR
public static boolean containsAttribute(javax.sdp.MediaDescription description, java.lang.String attributeName) throws java.lang.IllegalArgumentException
description
- the MediaDescriptionattributeName
- name of the attribute to checkjava.lang.IllegalArgumentException
- if description does not contain
a known media type.public static javax.sdp.Attribute createAttribute(java.lang.String name, java.lang.String value)
name
- the name of the Attributevalue
- the value of the Attributepublic static javax.sdp.MediaDescription createDisablingAnswer(javax.sdp.MediaDescription offer) throws java.lang.IllegalArgumentException
offer
- the MediaDescription of the stream that we'd like
to disable.java.lang.IllegalArgumentException
- if the offer argument is so
in-parsable that there was no way we could create a meaningful answer.public static javax.sdp.MediaDescription createMediaDescription(java.lang.String transport, java.util.List<org.jitsi.service.neomedia.format.MediaFormat> formats, org.jitsi.service.neomedia.StreamConnector connector, org.jitsi.service.neomedia.MediaDirection direction, java.util.List<org.jitsi.service.neomedia.RTPExtension> rtpExtensions, DynamicPayloadTypeRegistry dynamicPayloadTypes, DynamicRTPExtensionsRegistry rtpExtensionsRegistry) throws OperationFailedException
transport
- the profile name (RTP/SAVP or RTP/AVP)formats
- the list of formats that should be advertised in the newly
created MediaDescription.connector
- the socket couple that will be used for the media stream
which we are advertising with the media description created here.direction
- the direction of the media stream that we are describing
here.rtpExtensions
- a list of RTPExtensions supported by the
MediaDevice that we will be advertising.dynamicPayloadTypes
- a reference to the
DynamicPayloadTypeRegistry that we should be using to lookup
and register dynamic RTP mappings.rtpExtensionsRegistry
- a reference to the
DynamicRTPExtensionRegistry that we should be using to lookup
and register URN to ID mappings.OperationFailedException
- in case we fail to get payload type
numbers for dynamic payload types or in case our SDP generation fails for
some other reason.public static javax.sdp.SessionDescription createSessionDescription(java.net.InetAddress localAddress) throws OperationFailedException
localAddress
- the InetAddress corresponding to the local
address that we'd like to use when talking to the remote party.OperationFailedException
- if the SDP creation failedpublic static javax.sdp.SessionDescription createSessionDescription(java.net.InetAddress localAddress, java.lang.String userName, java.util.List<javax.sdp.MediaDescription> mediaDescriptions) throws OperationFailedException
localAddress
- the InetAddress corresponding to the local
address that we'd like to use when talking to the remote party.userName
- the user name to use in the origin parameter or
null in case we'd like to use a default.mediaDescriptions
- a Vector containing the list of
MediaDescriptions that we'd like to advertise (leave
null if you'd like to add these later).OperationFailedException
- if the SDP creation failedpublic static javax.sdp.SessionDescription createSessionUpdateDescription(javax.sdp.SessionDescription descToUpdate, java.net.InetAddress newConnectionAddress, java.util.List<javax.sdp.MediaDescription> newMediaDescriptions) throws OperationFailedException
descToUpdate
- the SessionDescription to update.newConnectionAddress
- the InetAddress to use in the new
c= field.newMediaDescriptions
- the descriptions of the new streams to have
in the updated session.OperationFailedException
- if the SDP creation failedpublic static org.jitsi.service.neomedia.MediaStreamTarget extractDefaultTarget(javax.sdp.MediaDescription mediaDesc, javax.sdp.SessionDescription sessDesc) throws java.lang.IllegalArgumentException
mediaDesc
- the media description that we'd like to extract our RTP
and RTCP destination addresses.sessDesc
- the session description that we received
mediaDesc in.java.lang.IllegalArgumentException
- in case we couldn't find connection
data or stumble upon other problems while analyzing the SDP.public static java.util.List<org.jitsi.service.neomedia.format.MediaFormat> extractFormats(javax.sdp.MediaDescription mediaDesc, DynamicPayloadTypeRegistry ptRegistry)
mediaDesc
- the MediaDescription to probe for a list of
MediaFormatsptRegistry
- a reference to the DynamycPayloadTypeRegistry
where we should be registering newly added payload type number to format
mappings.public static java.util.Vector<javax.sdp.MediaDescription> extractMediaDescriptions(javax.sdp.SessionDescription sessionDescription) throws java.lang.IllegalArgumentException
sessionDescription
- the SessionDescription that we'd like
to extract MediaDescriptions from.java.lang.IllegalArgumentException
- in case there were no media descriptions
in sessionDescription.public static java.util.List<org.jitsi.service.neomedia.RTPExtension> extractRTPExtensions(javax.sdp.MediaDescription mediaDesc, DynamicRTPExtensionsRegistry extMap)
mediaDesc
- the MediaDescription to probe for a list of
RTPExtensionsextMap
- a reference to the DynamycRTPExtensionsRegistry
where we should be registering newly added extension mappings.public static java.net.URL getCallInfoURL(javax.sdp.SessionDescription sessDesc)
sessDesc
- the session description that we'd like to extract an
URL form.public static java.lang.String getContentAsString(javax.sip.message.Message message)
message
- the SIP Message to get the content ofpublic static org.jitsi.service.neomedia.MediaDirection getDirection(javax.sdp.MediaDescription mediaDesc)
mediaDesc
- the description of the media stream whose direction
we are trying to determine.public static org.jitsi.service.neomedia.MediaType getMediaType(javax.sdp.MediaDescription description) throws java.lang.IllegalArgumentException
description
- the MediaDescription whose media type we'd
like to extract.java.lang.IllegalArgumentException
- if description does not
contain a known media type.public static javax.sdp.SessionDescription parseSdpString(java.lang.String sdp) throws java.lang.IllegalArgumentException
sdp
- the sdp String that we'd like to parse.java.lang.IllegalArgumentException
- if sdp is not a valid SDP
String.public static void setIceCredentials(javax.sdp.SessionDescription sDes, java.lang.String uFrag, java.lang.String pwd)
sDes
- the session description where we'd like to set a user
fragment and a password.uFrag
- the ICE user name fragment that we'd like to set on the
session descriptionpwd
- the ICE password that we'd like to set on the session
descriptionjava.lang.NullPointerException
- if the either of the parameters is nullpublic static void setSessionDirection(javax.sdp.SessionDescription sdp)
sdp
- the SessionDescription to which to add an attribute.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.