{
final String codecClassName = (String) codecs.get(j);
if (TRACE) logger.finer(indent(depth) + "Trying " + codecClassName);
final Codec codec = (Codec) instantiate(codecClassName);
if (codec == null)
continue;
final Format[] codecOutputFormats = codec.getSupportedOutputFormats(f);
if (TRACE && logger.isLoggable(Level.FINEST))
{
for (int codecOutputFormatIndex = 0; codecOutputFormatIndex < codecOutputFormats.length; ++codecOutputFormatIndex)
{
final Format codecOutputFormat = codecOutputFormats[codecOutputFormatIndex];
logger.finest(indent(depth) + "Found Codec output format: " + codecOutputFormat);
}
}
for (int codecOutputFormatIndex = 0; codecOutputFormatIndex < codecOutputFormats.length; ++codecOutputFormatIndex)
{
final Format codecOutputFormat = codecOutputFormats[codecOutputFormatIndex];
if (codecOutputFormat == null)
{ logger.finer(indent(depth) + "Skipping null Codec (" + codec.getClass() + ") output format, input format: " + f);
continue;
}
if (codecOutputFormat.equals(f))
{ if (TRACE) logger.finest(indent(depth) + (SKIP_NON_FORMAT_CHANGING_CODECS ? "YES " : "NOT ") + "Skipping Codec output format, same as input format: " + codecOutputFormat);
if (!FIND_NONSPECIFIC_GRAPH_FIRST && SKIP_NON_FORMAT_CHANGING_CODECS)
continue; // no need to have a codec that does not change formats. this can happen in the case of
// something like com.sun.media.codec.audio.rc.RateCvrt, which will offer an output format
// the same as an input format.
}
// instantiate a new copy of the codec for each pair.
codecFormatPairs.add(new CodecFormatPair((Codec) instantiate(codecClassName), codecOutputFormat));
}
}
// now that we have all of the codec/format pairs, sort them (if we know what format we are trying to reach)
if (muxInputFormat != null)
{ Collections.sort(codecFormatPairs, new CodecFormatPairProximityComparator(muxInputFormat));
// for (int j = 0; j < codecFormatPairs.size(); ++j)
// {
// final CodecFormatPair codecFormatPair = (CodecFormatPair) codecFormatPairs.get(j);
// final Codec codec =codecFormatPair.getCodec();
// final Format codecOutputFormat = codecFormatPair.getFormat();
//
// if (TRACE) logger.fine(indent(depth) + j + ". Will try " + codec.getClass().getName() + " with output format: " + codecOutputFormat);
//
// }
// best-first enabled.
if (maxBestCodecs > 1)
{ while (codecFormatPairs.size() > maxBestCodecs)
codecFormatPairs.remove(maxBestCodecs);
}
if (TRACE && logger.isLoggable(Level.FINER))
{
for (int j = 0; j < codecFormatPairs.size(); ++j)
{
final CodecFormatPair codecFormatPair = codecFormatPairs.get(j);
final Codec codec = codecFormatPair.getCodec();
final Format codecOutputFormat = codecFormatPair.getFormat();
logger.finer(indent(depth) + j + ". Will try " + codec.getClass().getName() + " with output format: " + codecOutputFormat);
}
}
}
return codecFormatPairs;