Class MediaFormatImpl<T extends javax.media.Format>
- java.lang.Object
-
- org.jitsi.impl.neomedia.format.MediaFormatImpl<T>
-
- Type Parameters:
T- the type of the wrapped Format
- All Implemented Interfaces:
MediaFormat
- Direct Known Subclasses:
AudioMediaFormatImpl,VideoMediaFormatImpl
public abstract class MediaFormatImpl<T extends javax.media.Format> extends Object implements MediaFormat
Implements MediaFormat for the JMF Format.- Author:
- Lyubomir Marinov
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLOCK_RATE_PNAMEThe name of the clockRate property of MediaFormatImpl.static StringENCODING_PNAMEThe name of the encoding property of MediaFormatImpl.protected TformatThe JMF Format this instance wraps and provides an implementation of MediaFormat for.static StringFORMAT_PARAMETERS_PNAMEThe name of the formatParameters property of MediaFormatImpl.-
Fields inherited from interface org.jitsi.service.neomedia.format.MediaFormat
MAX_DYNAMIC_PAYLOAD_TYPE, MIN_DYNAMIC_PAYLOAD_TYPE, RTP_PAYLOAD_TYPE_UNKNOWN
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMediaFormatImpl(T format)Initializes a new MediaFormatImpl instance which is to provide an implementation of MediaFormat for a specific Format.protectedMediaFormatImpl(T format, Map<String,String> formatParameters, Map<String,String> advancedAttributes)Initializes a new MediaFormatImpl instance which is to provide an implementation of MediaFormat for a specific Format and which is to have a specific set of codec-specific parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadvancedAttributesAreEqual(Map<String,String> adv, Map<String,String> adv2)Determines whether a specific set of advanced attributes is equal to another set of advanced attributes in the sense that they define an equal number of parameters and assign them equal values.static MediaFormatcreateInstance(javax.media.Format format)Creates a new MediaFormat instance for a specific JMF Format.static MediaFormatImpl<? extends javax.media.Format>createInstance(javax.media.Format format, double clockRate, Map<String,String> formatParameters, Map<String,String> advancedAttributess)Creates a new MediaFormat instance for a specific JMF Format and assigns it specific clock rate and set of format-specific parameters.booleanequals(Object mediaFormat)Implements MediaFormat#equals(Object) and actually compares the encapsulated JMF Format instances.static booleanformatParametersAreEqual(String encoding, Map<String,String> fmtps1, Map<String,String> fmtps2)Determines whether a specific set of format parameters is equal to another set of format parameters in the sense that they define an equal number of parameters and assign them equal values.protected booleanformatParametersAreEqual(Map<String,String> fmtps1, Map<String,String> fmtps2)Determines whether a specific set of format parameters is equal to another set of format parameters in the sense that they define an equal number of parameters and assign them equal values.booleanformatParametersMatch(Map<String,String> fmtps)Determines whether the format parameters of this MediaFormat match a specific set of format parameters.Map<String,String>getAdditionalCodecSettings()Returns additional codec settings.Map<String,String>getAdvancedAttributes()Implements MediaFormat#getAdvancedAttributes().StringgetClockRateString()Returns a String representation of the clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e.StringgetEncoding()Implements MediaFormat#getEncoding() and returns the encoding of the JMF Format that we are encapsulating here but it is the RFC-known encoding and not the internal JMF encoding.TgetFormat()Returns the JMF Format instance that we are wrapping here.Map<String,String>getFormatParameters()Implements MediaFormat#getFormatParameters().StringgetJMFEncoding()Gets the encoding of the JMF Format represented by this instance as it is known to JMF (in contrast to its RFC name).StringgetRealUsedClockRateString()Returns a String representation of the real used clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e.bytegetRTPPayloadType()Gets the RTP payload type (number) of this MediaFormat as it is known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".inthashCode()Overrides Object#hashCode() because Object#equals(Object) is overridden.booleanmatches(MediaFormat format)Determines whether this MediaFormat matches properties of a specific MediaFormat, such as mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal toMediaType.AUDIO.booleanmatches(org.jitsi.utils.MediaType mediaType, String encoding, double clockRate, int channels, Map<String,String> fmtps)Determines whether this MediaFormat has specific values for its properties mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal toMediaType.AUDIO.voidsetAdditionalCodecSettings(Map<String,String> settings)Sets additional codec settings.StringtoString()Returns a String representation of this MediaFormat containing, among other things, its encoding and clockrate values.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jitsi.service.neomedia.format.MediaFormat
getClockRate, getMediaType
-
-
-
-
Field Detail
-
CLOCK_RATE_PNAME
public static final String CLOCK_RATE_PNAME
The name of the clockRate property of MediaFormatImpl.- See Also:
- Constant Field Values
-
ENCODING_PNAME
public static final String ENCODING_PNAME
The name of the encoding property of MediaFormatImpl.- See Also:
- Constant Field Values
-
FORMAT_PARAMETERS_PNAME
public static final String FORMAT_PARAMETERS_PNAME
The name of the formatParameters property of MediaFormatImpl.- See Also:
- Constant Field Values
-
format
protected final T extends javax.media.Format format
The JMF Format this instance wraps and provides an implementation of MediaFormat for.
-
-
Constructor Detail
-
MediaFormatImpl
protected MediaFormatImpl(T format)
Initializes a new MediaFormatImpl instance which is to provide an implementation of MediaFormat for a specific Format.- Parameters:
format- the JMF Format the new instance is to provide an implementation of MediaFormat for
-
MediaFormatImpl
protected MediaFormatImpl(T format, Map<String,String> formatParameters, Map<String,String> advancedAttributes)
Initializes a new MediaFormatImpl instance which is to provide an implementation of MediaFormat for a specific Format and which is to have a specific set of codec-specific parameters.- Parameters:
format- the JMF Format the new instance is to provide an implementation of MediaFormat forformatParameters- any codec-specific parameters that have been received via SIP/SDP or XMPP/JingleadvancedAttributes- any parameters that have been received via SIP/SDP or XMPP/Jingle
-
-
Method Detail
-
createInstance
public static MediaFormat createInstance(javax.media.Format format)
Creates a new MediaFormat instance for a specific JMF Format.- Parameters:
format- the JMF Format the new instance is to provide an implementation of MediaFormat for- Returns:
- a new MediaFormat instance for the specified JMF Format
-
createInstance
public static MediaFormatImpl<? extends javax.media.Format> createInstance(javax.media.Format format, double clockRate, Map<String,String> formatParameters, Map<String,String> advancedAttributess)
Creates a new MediaFormat instance for a specific JMF Format and assigns it specific clock rate and set of format-specific parameters.- Parameters:
format- the JMF Format the new instance is to provide an implementation of MediaFormat forclockRate- the clock rate of the new instanceformatParameters- the set of format-specific parameters of the new instanceadvancedAttributess- advanced attributes of the new instance- Returns:
- a new MediaFormat instance for the specified JMF Format and with the specified clock rate and set of format-specific parameters
-
formatParametersAreEqual
public static boolean formatParametersAreEqual(String encoding, Map<String,String> fmtps1, Map<String,String> fmtps2)
Determines whether a specific set of format parameters is equal to another set of format parameters in the sense that they define an equal number of parameters and assign them equal values. Since the values are Strings, presumes that a value of null is equal to the empty String.The two Map instances of format parameters to be checked for equality are presumed to be modifiable in the sense that if the lack of a format parameter in a given Map is equivalent to it having a specific value, an association of the format parameter to the value in question may be added to or removed from the respective Map instance for the purposes of determining equality.
- Parameters:
encoding- the encoding (name) related to the two sets of format parameters to be tested for equalityfmtps1- the first set of format parameters to be tested for equalityfmtps2- the second set of format parameters to be tested for equality- Returns:
- true if the specified sets of format parameters are equal; false, otherwise
-
advancedAttributesAreEqual
public boolean advancedAttributesAreEqual(Map<String,String> adv, Map<String,String> adv2)
Determines whether a specific set of advanced attributes is equal to another set of advanced attributes in the sense that they define an equal number of parameters and assign them equal values. Since the values are Strings, presumes that a value of null is equal to the empty String.- Parameters:
adv- the first set of advanced attributes to be tested for equalityadv2- the second set of advanced attributes to be tested for equality- Returns:
- true if the specified sets of advanced attributes equal; false, otherwise
-
equals
public boolean equals(Object mediaFormat)
Implements MediaFormat#equals(Object) and actually compares the encapsulated JMF Format instances.- Specified by:
equalsin interfaceMediaFormat- Overrides:
equalsin classObject- Parameters:
mediaFormat- the object that we'd like to compare this one to. 8*- Returns:
- true if the JMF Format instances encapsulated by this class are equal and false otherwise.
-
formatParametersAreEqual
protected boolean formatParametersAreEqual(Map<String,String> fmtps1, Map<String,String> fmtps2)
Determines whether a specific set of format parameters is equal to another set of format parameters in the sense that they define an equal number of parameters and assign them equal values. Since the values are Strings, presumes that a value of null is equal to the empty String.The two Map instances of format parameters to be checked for equality are presumed to be modifiable in the sense that if the lack of a format parameter in a given Map is equivalent to it having a specific value, an association of the format parameter to the value in question may be added to or removed from the respective Map instance for the purposes of determining equality.
- Parameters:
fmtps1- the first set of format parameters to be tested for equalityfmtps2- the second set of format parameters to be tested for equality- Returns:
- true if the specified sets of format parameters are equal; false, otherwise
-
formatParametersMatch
public boolean formatParametersMatch(Map<String,String> fmtps)
Determines whether the format parameters of this MediaFormat match a specific set of format parameters.The default implementation of MediaFormatImpl always returns true because format parameters in general do not cause the distinction of payload types.
- Specified by:
formatParametersMatchin interfaceMediaFormat- Parameters:
fmtps- the set of format parameters to match to the format parameters of this MediaFormat- Returns:
- true if this MediaFormat considers fmtps matching its format parameters; otherwise, false
-
getAdditionalCodecSettings
public Map<String,String> getAdditionalCodecSettings()
Returns additional codec settings.- Specified by:
getAdditionalCodecSettingsin interfaceMediaFormat- Returns:
- additional settings represented by a map.
-
getAdvancedAttributes
public Map<String,String> getAdvancedAttributes()
Implements MediaFormat#getAdvancedAttributes(). Returns a copy of the attribute properties of this instance. Modifications to the returned Map do no affect the format properties of this instance.- Specified by:
getAdvancedAttributesin interfaceMediaFormat- Returns:
- a copy of the attribute properties of this instance. Modifications to the returned Map do no affect the format properties of this instance.
-
getClockRateString
public String getClockRateString()
Returns a String representation of the clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e. its long-casted value is equal to its original one) unless it is actually a non integer.- Specified by:
getClockRateStringin interfaceMediaFormat- Returns:
- a String representation of the clock rate associated with this MediaFormat.
-
getEncoding
public String getEncoding()
Implements MediaFormat#getEncoding() and returns the encoding of the JMF Format that we are encapsulating here but it is the RFC-known encoding and not the internal JMF encoding.- Specified by:
getEncodingin interfaceMediaFormat- Returns:
- the RFC-known encoding of the JMF Format that we are encapsulating
-
getFormat
public T getFormat()
Returns the JMF Format instance that we are wrapping here.- Returns:
- a reference to that JMF Format instance that this class is wrapping.
-
getFormatParameters
public Map<String,String> getFormatParameters()
Implements MediaFormat#getFormatParameters(). Returns a copy of the format properties of this instance. Modifications to the returned Map do no affect the format properties of this instance.- Specified by:
getFormatParametersin interfaceMediaFormat- Returns:
- a copy of the format properties of this instance. Modifications to the returned Map do no affect the format properties of this instance.
-
getJMFEncoding
public String getJMFEncoding()
Gets the encoding of the JMF Format represented by this instance as it is known to JMF (in contrast to its RFC name).- Returns:
- the encoding of the JMF Format represented by this instance as it is known to JMF (in contrast to its RFC name)
-
getRealUsedClockRateString
public String getRealUsedClockRateString()
Returns a String representation of the real used clock rate associated with this MediaFormat making sure that the value appears as an integer (i.e. contains no decimal point) unless it is actually a non integer. This function corrects the problem of the G.722 codec which advertises its clock rate to be 8 kHz while 16 kHz is really used to encode the stream (that's an error noted in the respective RFC and kept for the sake of compatibility.).- Specified by:
getRealUsedClockRateStringin interfaceMediaFormat- Returns:
- a String representation of the real used clock rate associated with this MediaFormat.
-
getRTPPayloadType
public byte getRTPPayloadType()
Gets the RTP payload type (number) of this MediaFormat as it is known in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal Control".- Specified by:
getRTPPayloadTypein interfaceMediaFormat- Returns:
- the RTP payload type of this MediaFormat if it is known
in RFC 3551 "RTP Profile for Audio and Video Conferences with Minimal
Control"; otherwise,
MediaFormat.RTP_PAYLOAD_TYPE_UNKNOWN - See Also:
MediaFormat.getRTPPayloadType()
-
hashCode
public int hashCode()
Overrides Object#hashCode() because Object#equals(Object) is overridden.
-
matches
public boolean matches(MediaFormat format)
Determines whether this MediaFormat matches properties of a specific MediaFormat, such as mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal toMediaType.AUDIO.- Specified by:
matchesin interfaceMediaFormat- Parameters:
format- theMediaFormatwhose properties we'd like to examine and compare with ours.- Returns:
- true if the specified format has specific values for its properties mediaType, encoding, clockRate and channels; otherwise, false
-
matches
public boolean matches(org.jitsi.utils.MediaType mediaType, String encoding, double clockRate, int channels, Map<String,String> fmtps)Determines whether this MediaFormat has specific values for its properties mediaType, encoding, clockRate and channels for MediaFormats with mediaType equal toMediaType.AUDIO.- Specified by:
matchesin interfaceMediaFormat- Parameters:
mediaType- the type we expectMediaFormatto haveencoding- the encoding we are looking for.clockRate- the clock rate that we'd like the format to have.channels- the number of channels that expect to find in this formatfmtps- the format parameters expected to match these of the specified format- Returns:
- true if the specified format has specific values for its properties mediaType, encoding, clockRate and channels; otherwise, false
-
setAdditionalCodecSettings
public void setAdditionalCodecSettings(Map<String,String> settings)
Sets additional codec settings.- Specified by:
setAdditionalCodecSettingsin interfaceMediaFormat- Parameters:
settings- additional settings represented by a map.
-
toString
public String toString()
Returns a String representation of this MediaFormat containing, among other things, its encoding and clockrate values.- Specified by:
toStringin interfaceMediaFormat- Overrides:
toStringin classObject- Returns:
- a String representation of this MediaFormat.
-
-