Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia
Class MediaUtils

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.MediaUtils

public class MediaUtils
extends Object

Implements static utility methods used by media classes.

Author:
Emil Ivov, Lyubomir Marinov

Field Summary
static MediaFormat[] EMPTY_MEDIA_FORMATS
          The constant which stands for an empty array of MediaFormats.
static int MAX_AUDIO_CHANNELS
          The maximum number of channels for audio that is available through MediaUtils.
static double MAX_AUDIO_SAMPLE_RATE
          The maximum sample rate for audio that is available through MediaUtils.
static int MAX_AUDIO_SAMPLE_SIZE_IN_BITS
          The maximum sample size in bits for audio that is available through MediaUtils.
 
Constructor Summary
MediaUtils()
           
 
Method Summary
static String createImageAttr(Dimension sendSize, Dimension maxRecvSize)
          Creates value of an imgattr.
static MediaFormat getMediaFormat(javax.media.Format format)
          Gets a MediaFormat predefined in MediaUtils which represents a specific JMF Format.
static MediaFormat getMediaFormat(String encoding, double clockRate)
          Gets the MediaFormat known to MediaUtils and having the specified well-known encoding (name) and clockRate.
static MediaFormat getMediaFormat(String encoding, double clockRate, Map<String,String> fmtps)
          Gets the MediaFormat known to MediaUtils and having the specified well-known encoding (name), clockRate and matching format parameters.
static int getMediaFormatIndex(MediaFormat mediaFormat)
          Gets the index of a specific MediaFormat instance within the internal storage of MediaUtils.
static MediaFormat[] getMediaFormats(byte rtpPayloadType)
          Gets the MediaFormats (expressed as an array) corresponding to a specific RTP payload type.
static MediaFormat[] getMediaFormats(MediaType mediaType)
          Gets the MediaFormats known to MediaUtils and being of the specified MediaType.
static List<MediaFormat> getMediaFormats(String encoding)
          Gets the MediaFormats predefined in MediaUtils with a specific well-known encoding (name) as defined by RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".
static byte getRTPPayloadType(String jmfEncoding, double clockRate)
          Gets the RTP payload type corresponding to a specific JMF encoding and clock rate.
static String jmfEncodingToEncoding(String jmfEncoding)
          Gets the well-known encoding (name) as defined in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control" corresponding to a given JMF-specific encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_MEDIA_FORMATS

public static final MediaFormat[] EMPTY_MEDIA_FORMATS
The constant which stands for an empty array of MediaFormats. Explicitly defined in order to reduce unnecessary allocations.


MAX_AUDIO_CHANNELS

public static final int MAX_AUDIO_CHANNELS
The maximum number of channels for audio that is available through MediaUtils.


MAX_AUDIO_SAMPLE_RATE

public static final double MAX_AUDIO_SAMPLE_RATE
The maximum sample rate for audio that is available through MediaUtils.


MAX_AUDIO_SAMPLE_SIZE_IN_BITS

public static final int MAX_AUDIO_SAMPLE_SIZE_IN_BITS
The maximum sample size in bits for audio that is available through MediaUtils.

Constructor Detail

MediaUtils

public MediaUtils()
Method Detail

getMediaFormat

public static MediaFormat getMediaFormat(javax.media.Format format)
Gets a MediaFormat predefined in MediaUtils which represents a specific JMF Format. If there is no such representing MediaFormat in MediaUtils, returns null.

Parameters:
format - the JMF Format to get the MediaFormat representation for
Returns:
a MediaFormat predefined in MediaUtils which represents format if any; null if there is no such representing MediaFormat in MediaUtils

getMediaFormat

public static MediaFormat getMediaFormat(String encoding,
                                         double clockRate)
Gets the MediaFormat known to MediaUtils and having the specified well-known encoding (name) and clockRate.

Parameters:
encoding - the well-known encoding (name) of the MediaFormat to get
clockRate - the clock rate of the MediaFormat to get
Returns:
the MediaFormat known to MediaUtils and having the specified encoding and clockRate

getMediaFormat

public static MediaFormat getMediaFormat(String encoding,
                                         double clockRate,
                                         Map<String,String> fmtps)
Gets the MediaFormat known to MediaUtils and having the specified well-known encoding (name), clockRate and matching format parameters.

Parameters:
encoding - the well-known encoding (name) of the MediaFormat to get
clockRate - the clock rate of the MediaFormat to get
fmtps - the format parameters of the MediaFormat to get
Returns:
the MediaFormat known to MediaUtils and having the specified encoding (name), clockRate and matching format parameters

getMediaFormatIndex

public static int getMediaFormatIndex(MediaFormat mediaFormat)
Gets the index of a specific MediaFormat instance within the internal storage of MediaUtils. Since the index is in the internal storage which may or may not be one and the same for the various MediaFormat instances and which may or may not be searched for the purposes of determining the index, the index is not to be used as a way to determine whether MediaUtils knows the specified mediaFormat

Parameters:
mediaFormat - the MediaFormat to determine the index of
Returns:
the index of the specified mediaFormat in the internal storage of MediaUtils

getMediaFormats

public static List<MediaFormat> getMediaFormats(String encoding)
Gets the MediaFormats predefined in MediaUtils with a specific well-known encoding (name) as defined by RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".

Parameters:
encoding - the well-known encoding (name) to get the corresponding MediaFormats of
Returns:
a List of MediaFormats corresponding to the specified encoding (name)

getMediaFormats

public static MediaFormat[] getMediaFormats(MediaType mediaType)
Gets the MediaFormats known to MediaUtils and being of the specified MediaType.

Parameters:
mediaType - the MediaType of the MediaFormats to get
Returns:
the MediaFormats known to MediaUtils and being of the specified mediaType

getMediaFormats

public static MediaFormat[] getMediaFormats(byte rtpPayloadType)
Gets the MediaFormats (expressed as an array) corresponding to a specific RTP payload type.

Parameters:
rtpPayloadType - the RTP payload type to retrieve the corresponding MediaFormats for
Returns:
an array of MediaFormats corresponding to the specified RTP payload type

jmfEncodingToEncoding

public static String jmfEncodingToEncoding(String jmfEncoding)
Gets the well-known encoding (name) as defined in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control" corresponding to a given JMF-specific encoding.

Parameters:
jmfEncoding - the JMF encoding to get the corresponding well-known encoding of
Returns:
the well-known encoding (name) as defined in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control" corresponding to jmfEncoding if any; otherwise, null

getRTPPayloadType

public static byte getRTPPayloadType(String jmfEncoding,
                                     double clockRate)
Gets the RTP payload type corresponding to a specific JMF encoding and clock rate.

Parameters:
jmfEncoding - the JMF encoding as returned by Format.getEncoding() or the respective AudioFormat and VideoFormat encoding constants to get the corresponding RTP payload type of
clockRate - the clock rate to be taken into account in the search for the RTP payload type if the JMF encoding does not uniquely identify it
Returns:
the RTP payload type corresponding to the specified JMF encoding and clock rate if known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control"; otherwise, MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN

createImageAttr

public static String createImageAttr(Dimension sendSize,
                                     Dimension maxRecvSize)
Creates value of an imgattr. http://tools.ietf.org/html/draft-ietf-mmusic-image-attributes-04

Parameters:
sendSize - maximum size peer can send
maxRecvSize - maximum size peer can display
Returns:
string that represent imgattr that can be encoded via SIP/SDP or XMPP/Jingle

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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