Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

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

public class DynamicPayloadTypeRegistry
extends Object

The RTP Audio/Video Profile [RFC 3551] specifies a number of static payload types for use with RTP and reserves the 96-127 field for use with dynamic payload types.

Mappings of dynamic payload types 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 dynamic payload mappings for the lifetime of a particular session. One instance of this registry is supposed to be mapped to one media session. They should have pretty much the same life cycle.

Author:
Emil Ivov

Constructor Summary
DynamicPayloadTypeRegistry()
           
 
Method Summary
 void addMapping(MediaFormat format, byte payloadType)
          Adds the specified format to payloadType mapping to the list of mappings known to this registry.
 MediaFormat findFormat(byte payloadType)
          Returns a reference to the MediaFormat with the specified mapping or null if the number specified by payloadType has not been allocated yet.
 Map<MediaFormat,Byte> getMappings()
          Returns a copy of all mappings currently registered in this registry.
 byte obtainPayloadTypeNumber(MediaFormat format)
          Returns the dynamic payload type that has been allocated for format.
 void setOverridePayloadTypeMappings(Map<Byte,String> mappings)
          Sets the override payload type numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicPayloadTypeRegistry

public DynamicPayloadTypeRegistry()
Method Detail

setOverridePayloadTypeMappings

public void setOverridePayloadTypeMappings(Map<Byte,String> mappings)
Sets the override payload type numbers.

Parameters:
mappings - the override payload-type mappings.

obtainPayloadTypeNumber

public byte obtainPayloadTypeNumber(MediaFormat format)
                             throws IllegalStateException
Returns the dynamic payload type that has been allocated for format. A mapping for the specified format would be created even if it did not previously exist. The method is meant for use primarily during generation of SDP descriptions.

Parameters:
format - the MediaFormat instance that we'd like to obtain a payload type number for.
Returns:
the (possibly newly allocated) payload type number corresponding to the specified format instance for the lifetime of the media session.
Throws:
IllegalStateException - if we have already registered more dynamic formats than allowed for by RTP.

addMapping

public void addMapping(MediaFormat format,
                       byte payloadType)
                throws IllegalArgumentException
Adds the specified format to payloadType 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 obtainPayloadTypeNumber instead.

Parameters:
payloadType - the payload type number that we'd like to allocated to format.
format - the MediaFormat that we'd like to create a dynamic mapping for.
Throws:
IllegalArgumentException - in case payloadType has already been assigned to another format.

findFormat

public MediaFormat findFormat(byte payloadType)
Returns a reference to the MediaFormat with the specified mapping or null if the number specified by payloadType has not been allocated yet.

Parameters:
payloadType - the number of the payload type that we are trying to get a format for.
Returns:
the MediaFormat that has been mapped to payloadType in this registry or null if it hasn't been allocated yet.

getMappings

public Map<MediaFormat,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.