Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol.media
Class DynamicRTPExtensionsRegistry

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.media.DynamicRTPExtensionsRegistry

public class DynamicRTPExtensionsRegistry
extends Object

RFC [RFC 5285] defines a mechanism for attaching multiple extensions to RTP packets. Part of this mechanism consists in negotiating their identifiers using extmap attributes pretty much the same way one would negotiate payload types with rtpmap attributes.

Mappings of extension IDs are handled with SDP. They are created for a particular session and remain the same for its entire lifetime. They may however change in following sessions.

We use this class as a utility for easily creating and tracking extension mappings for the lifetime of a particular session. One instance of this registry is supposed to be mapped to one media session and they should have the same life cycle.

Author:
Emil Ivov

Field Summary
static int MAX_ONE_BYTE_HEADER_ID
          The maximum integer that is allowed for use when mapping extensions using the one-byte header.
static int MAX_TWO_BYTE_HEADER_ID
          The maximum integer that is allowed for use when mapping extensions using the two-byte header.
static int MIN_HEADER_ID
          The minimum integer that is allowed for use when mapping extensions using the one-byte header.
 
Constructor Summary
DynamicRTPExtensionsRegistry()
           
 
Method Summary
 void addMapping(RTPExtension extension, byte extID)
          Adds the specified extension to extID mapping to the list of mappings known to this registry.
 RTPExtension findExtension(byte extID)
          Returns a reference to the RTPExtension with the specified mapping or null if the number specified by extID has not been allocated yet.
 byte getExtensionMapping(RTPExtension extension)
          Returns the ID that has been allocated for extension or -1 if no extension exists.
 Map<RTPExtension,Byte> getMappings()
          Returns a copy of all mappings currently registered in this registry.
 byte obtainExtensionMapping(RTPExtension extension)
          Returns the ID that has been allocated for extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_HEADER_ID

public static final int MIN_HEADER_ID
The minimum integer that is allowed for use when mapping extensions using the one-byte header.

See Also:
Constant Field Values

MAX_ONE_BYTE_HEADER_ID

public static final int MAX_ONE_BYTE_HEADER_ID
The maximum integer that is allowed for use when mapping extensions using the one-byte header. Note that 15 is reserved for future use by 5285

See Also:
Constant Field Values

MAX_TWO_BYTE_HEADER_ID

public static final int MAX_TWO_BYTE_HEADER_ID
The maximum integer that is allowed for use when mapping extensions using the two-byte header.

See Also:
Constant Field Values
Constructor Detail

DynamicRTPExtensionsRegistry

public DynamicRTPExtensionsRegistry()
Method Detail

obtainExtensionMapping

public byte obtainExtensionMapping(RTPExtension extension)
                            throws IllegalStateException
Returns the ID that has been allocated for extension. A mapping for the specified extension would be created even if it did not previously exist. The method is meant for use primarily during generation of SDP descriptions.

Parameters:
extension - the RTPExtension instance that we'd like to obtain a dynamic ID for.
Returns:
the (possibly newly allocated) ID corresponding to the specified extension and valid for the lifetime of the media session.
Throws:
IllegalStateException - if we have already registered more RTP extensions than allowed for by RTP.

getExtensionMapping

public byte getExtensionMapping(RTPExtension extension)
Returns the ID that has been allocated for extension or -1 if no extension exists.

Parameters:
extension - the RTPExtension instance whose ID we'd like to find.
Returns:
the ID corresponding to the specified extension or -1 if extension is not registered with this registry.

addMapping

public void addMapping(RTPExtension extension,
                       byte extID)
                throws IllegalArgumentException
Adds the specified extension to extID mapping to the list of mappings known to this registry. The method is meant for use primarily when handling incoming media descriptions, methods generating local SDP should use the obtainExtensionMapping instead.

Parameters:
extID - the extension ID that we'd like to allocated to extension.
extension - the RTPExtension that we'd like to create a dynamic mapping for.
Throws:
IllegalArgumentException - in case extID has already been assigned to another RTPExtension.

findExtension

public RTPExtension findExtension(byte extID)
Returns a reference to the RTPExtension with the specified mapping or null if the number specified by extID has not been allocated yet.

Parameters:
extID - the ID whose RTPExtension we are trying to discover.
Returns:
the RTPExtension that has been mapped to extID in this registry or null if it hasn't been allocated yet.

getMappings

public Map<RTPExtension,Byte> getMappings()
Returns a copy of all mappings currently registered in this registry.

Returns:
a copy of all mappings currently registered in this registry.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.