|
|
|
|
@ -23,13 +23,19 @@ public class MediaFormatFactoryImpl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new <tt>AudioMediaFormat</tt> instance with a specific encoding
|
|
|
|
|
* (name).
|
|
|
|
|
* Creates a <tt>MediaFormat</tt> for the specified <tt>encoding</tt> with
|
|
|
|
|
* default clock rate and set of format parameters. If <tt>encoding</tt> is
|
|
|
|
|
* known to this <tt>MediaFormatFactory</tt>, returns a
|
|
|
|
|
* <tt>MediaFormat</tt> which either an <tt>AudioMediaFormat</tt> or a
|
|
|
|
|
* <tt>VideoMediaFormat</tt> instance. Otherwise, returns <tt>null</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param encoding the encoding (name) of the new instance
|
|
|
|
|
* @return a new <tt>AudioMediaFormat</tt> instance with the specified
|
|
|
|
|
* encoding (name)
|
|
|
|
|
* @see MediaFormatFactory#createAudioMediaFormat(String)
|
|
|
|
|
* @param encoding the well-known encoding (name) to create a
|
|
|
|
|
* <tt>MediaFormat</tt> for
|
|
|
|
|
* @return a <tt>MediaFormat</tt> with the specified <tt>encoding</tt> which
|
|
|
|
|
* is either an <tt>AudioMediaFormat</tt> or a <tt>VideoMediaFormat</tt>
|
|
|
|
|
* instance if <tt>encoding</tt> is known to this
|
|
|
|
|
* <tt>MediaFormatFactory</tt>; otherwise, <tt>null</tt>
|
|
|
|
|
* @see MediaFormatFactory#createMediaFormat(String)
|
|
|
|
|
*/
|
|
|
|
|
public MediaFormat createMediaFormat(String encoding)
|
|
|
|
|
{
|
|
|
|
|
@ -37,14 +43,22 @@ public MediaFormat createMediaFormat(String encoding)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new <tt>AudioMediaFormat</tt> instance with specific encoding
|
|
|
|
|
* (name) and clock rate.
|
|
|
|
|
* Creates a <tt>MediaFormat</tt> for the specified <tt>encoding</tt> with
|
|
|
|
|
* the specified <tt>clockRate</tt> and a default set of format parameters.
|
|
|
|
|
* If <tt>encoding</tt> is known to this <tt>MediaFormatFactory</tt>,
|
|
|
|
|
* returns a <tt>MediaFormat</tt> which either an <tt>AudioMediaFormat</tt>
|
|
|
|
|
* or a <tt>VideoMediaFormat</tt> instance. Otherwise, returns
|
|
|
|
|
* <tt>null</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param encoding the encoding (name) of the new instance
|
|
|
|
|
* @param clockRate the clock rate of the new instance
|
|
|
|
|
* @return a new <tt>AudioMediaFormat</tt> instance with the specified
|
|
|
|
|
* encoding (name) and clock rate
|
|
|
|
|
* @see MediaFormatFactory#createAudioMediaFormat(String, double)
|
|
|
|
|
* @param encoding the well-known encoding (name) to create a
|
|
|
|
|
* <tt>MediaFormat</tt> for
|
|
|
|
|
* @param clockRate the clock rate in Hz to create a <tt>MediaFormat</tt>
|
|
|
|
|
* for
|
|
|
|
|
* @return a <tt>MediaFormat</tt> with the specified <tt>encoding</tt> and
|
|
|
|
|
* <tt>clockRate</tt> which is either an <tt>AudioMediaFormat</tt> or a
|
|
|
|
|
* <tt>VideoMediaFormat</tt> instance if <tt>encoding</tt> is known to this
|
|
|
|
|
* <tt>MediaFormatFactory</tt>; otherwise, <tt>null</tt>
|
|
|
|
|
* @see MediaFormatFactory#createMediaFormat(String, double)
|
|
|
|
|
*/
|
|
|
|
|
public MediaFormat createMediaFormat(
|
|
|
|
|
String encoding,
|
|
|
|
|
@ -87,16 +101,24 @@ public AudioMediaFormat createAudioMediaFormat(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new <tt>AudioMediaFormat</tt> instance with specific encoding
|
|
|
|
|
* (name), clock rate and set of format-specific parameters.
|
|
|
|
|
* Creates a <tt>MediaFormat</tt> for the specified <tt>encoding</tt>,
|
|
|
|
|
* <tt>clockRate</tt> and set of format parameters. If <tt>encoding</tt> is
|
|
|
|
|
* known to this <tt>MediaFormatFactory</tt>, returns a <tt>MediaFormat</tt>
|
|
|
|
|
* which either an <tt>AudioMediaFormat</tt> or a <tt>VideoMediaFormat</tt>
|
|
|
|
|
* instance. Otherwise, returns <tt>null</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param encoding the encoding (name) of the new instance
|
|
|
|
|
* @param clockRate the clock rate of the new instance
|
|
|
|
|
* @param formatParams the set of format-specific parameters of the new
|
|
|
|
|
* instance
|
|
|
|
|
* @return a new <tt>AudioMediaFormat</tt> instance with the specified
|
|
|
|
|
* encoding (name), clock rate and set of format-specific parameters
|
|
|
|
|
* @see MediaFormatFactory#createAudioMediaFormat(String, double, Map)
|
|
|
|
|
* @param encoding the well-known encoding (name) to create a
|
|
|
|
|
* <tt>MediaFormat</tt> for
|
|
|
|
|
* @param clockRate the clock rate in Hz to create a <tt>MediaFormat</tt>
|
|
|
|
|
* for
|
|
|
|
|
* @param formatParams any codec specific parameters which have been
|
|
|
|
|
* received via SIP/SDP or XMPP/Jingle
|
|
|
|
|
* @return a <tt>MediaFormat</tt> with the specified <tt>encoding</tt>,
|
|
|
|
|
* <tt>clockRate</tt> and set of format parameters which is either an
|
|
|
|
|
* <tt>AudioMediaFormat</tt> or a <tt>VideoMediaFormat</tt> instance if
|
|
|
|
|
* <tt>encoding</tt> is known to this <tt>MediaFormatFactory</tt>;
|
|
|
|
|
* otherwise, <tt>null</tt>
|
|
|
|
|
* @see MediaFormatFactory#createMediaFormat(String, double, Map)
|
|
|
|
|
*/
|
|
|
|
|
public MediaFormat createMediaFormat(
|
|
|
|
|
String encoding,
|
|
|
|
|
@ -182,6 +204,53 @@ public AudioMediaFormat createAudioMediaFormat(
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the <tt>MediaFormat</tt>s among the specified <tt>mediaFormats</tt>
|
|
|
|
|
* which have the specified <tt>encoding</tt> and, optionally,
|
|
|
|
|
* <tt>clockRate</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param mediaFormats the <tt>MediaFormat</tt>s from which to filter out
|
|
|
|
|
* only the ones which have the specified <tt>encoding</tt> and, optionally,
|
|
|
|
|
* <tt>clockRate</tt>
|
|
|
|
|
* @param encoding the well-known encoding (name) of the
|
|
|
|
|
* <tt>MediaFormat</tt>s to be retrieved
|
|
|
|
|
* @param clockRate the clock rate of the <tt>MediaFormat</tt>s to be
|
|
|
|
|
* retrieved; {@link #CLOCK_RATE_NOT_SPECIFIED} if any clock rate is
|
|
|
|
|
* acceptable
|
|
|
|
|
* @return a <tt>List</tt> of the <tt>MediaFormat</tt>s among
|
|
|
|
|
* <tt>mediaFormats</tt> which have the specified <tt>encoding</tt> and,
|
|
|
|
|
* optionally, <tt>clockRate</tt>
|
|
|
|
|
*/
|
|
|
|
|
private List<MediaFormat> getMatchingMediaFormats(
|
|
|
|
|
MediaFormat[] mediaFormats,
|
|
|
|
|
String encoding,
|
|
|
|
|
double clockRate)
|
|
|
|
|
{
|
|
|
|
|
List<MediaFormat> supportedMediaFormats = new ArrayList<MediaFormat>();
|
|
|
|
|
|
|
|
|
|
for (MediaFormat mediaFormat : mediaFormats)
|
|
|
|
|
if (mediaFormat.getEncoding().equals(encoding)
|
|
|
|
|
&& ((CLOCK_RATE_NOT_SPECIFIED == clockRate)
|
|
|
|
|
|| (mediaFormat.getClockRate() == clockRate)))
|
|
|
|
|
supportedMediaFormats.add(mediaFormat);
|
|
|
|
|
return supportedMediaFormats;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the <tt>MediaFormat</tt>s supported by this
|
|
|
|
|
* <tt>MediaFormatFactory</tt> and the <tt>MediaService</tt> associated with
|
|
|
|
|
* it and having the specified <tt>encoding</tt> and, optionally,
|
|
|
|
|
* <tt>clockRate</tt>.
|
|
|
|
|
*
|
|
|
|
|
* @param encoding the well-known encoding (name) of the
|
|
|
|
|
* <tt>MediaFormat</tt>s to be retrieved
|
|
|
|
|
* @param clockRate the clock rate of the <tt>MediaFormat</tt>s to be
|
|
|
|
|
* retrieved; {@link #CLOCK_RATE_NOT_SPECIFIED} if any clock rate is
|
|
|
|
|
* acceptable
|
|
|
|
|
* @return a <tt>List</tt> of the <tt>MediaFormat</tt>s supported by the
|
|
|
|
|
* <tt>MediaService</tt> associated with this <tt>MediaFormatFactory</tt>
|
|
|
|
|
* and having the specified encoding and, optionally, clock rate
|
|
|
|
|
*/
|
|
|
|
|
private List<MediaFormat> getSupportedMediaFormats(
|
|
|
|
|
String encoding,
|
|
|
|
|
double clockRate)
|
|
|
|
|
@ -190,7 +259,7 @@ private List<MediaFormat> getSupportedMediaFormats(
|
|
|
|
|
= NeomediaActivator
|
|
|
|
|
.getMediaServiceImpl().getEncodingConfiguration();
|
|
|
|
|
List<MediaFormat> supportedMediaFormats
|
|
|
|
|
= getSupportedMediaFormats(
|
|
|
|
|
= getMatchingMediaFormats(
|
|
|
|
|
encodingConfiguration
|
|
|
|
|
.getSupportedEncodings(MediaType.AUDIO),
|
|
|
|
|
encoding,
|
|
|
|
|
@ -198,26 +267,11 @@ private List<MediaFormat> getSupportedMediaFormats(
|
|
|
|
|
|
|
|
|
|
if (supportedMediaFormats.isEmpty())
|
|
|
|
|
supportedMediaFormats
|
|
|
|
|
= getSupportedMediaFormats(
|
|
|
|
|
= getMatchingMediaFormats(
|
|
|
|
|
encodingConfiguration
|
|
|
|
|
.getSupportedEncodings(MediaType.VIDEO),
|
|
|
|
|
encoding,
|
|
|
|
|
clockRate);
|
|
|
|
|
return supportedMediaFormats;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MediaFormat> getSupportedMediaFormats(
|
|
|
|
|
MediaFormat[] mediaFormats,
|
|
|
|
|
String encoding,
|
|
|
|
|
double clockRate)
|
|
|
|
|
{
|
|
|
|
|
List<MediaFormat> supportedMediaFormats = new ArrayList<MediaFormat>();
|
|
|
|
|
|
|
|
|
|
for (MediaFormat mediaFormat : mediaFormats)
|
|
|
|
|
if (mediaFormat.getEncoding().equals(encoding)
|
|
|
|
|
&& ((CLOCK_RATE_NOT_SPECIFIED == clockRate)
|
|
|
|
|
|| (mediaFormat.getClockRate() == clockRate)))
|
|
|
|
|
supportedMediaFormats.add(mediaFormat);
|
|
|
|
|
return supportedMediaFormats;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|