private MediaFormat[] getEncodings() { if (encodings != null) return encodings; MediaFormat[] availableEncodings = encodingConfiguration.getAllEncodings(type); int encodingCount = availableEncodings.length; if (encodingCount < 1) encodings = MediaUtils.EMPTY_MEDIA_FORMATS; else { /* * The MediaFormats will be displayed by encoding (name) and clock * rate and EncodingConfiguration will store them that way so this * TableModel should better display unique encoding-clock rate * pairs. */ HashMap<String, MediaFormat> availableEncodingSet = new HashMap<String, MediaFormat>(); for (MediaFormat availableEncoding : availableEncodings) { availableEncodingSet.put( availableEncoding.getEncoding() + "/" + availableEncoding.getClockRateString(), availableEncoding); } availableEncodings = availableEncodingSet.values().toArray(MediaUtils.EMPTY_MEDIA_FORMATS); encodingCount = availableEncodings.length; encodings = new MediaFormat[encodingCount]; System.arraycopy(availableEncodings, 0, encodings, 0, encodingCount); // Display the encodings in decreasing priority. Arrays.sort( encodings, 0, encodingCount, new Comparator<MediaFormat>() { public int compare(MediaFormat format0, MediaFormat format1) { int ret = encodingConfiguration.getPriority(format1) - encodingConfiguration.getPriority(format0); if (ret == 0) { /* * In the cases of equal priorities, display them * sorted by encoding name in increasing order. */ ret = format0.getEncoding().compareToIgnoreCase(format1.getEncoding()); if (ret == 0) { /* * In the cases of equal priorities and equal * encoding names, display them sorted by clock * rate in decreasing order. */ ret = Double.compare(format1.getClockRate(), format0.getClockRate()); } } return ret; } }); } return encodings; }
public Object getValueAt(int rowIndex, int columnIndex) { MediaFormat encoding = getEncodings()[rowIndex]; switch (columnIndex) { case 0: return (encodingConfiguration.getPriority(encoding) > 0); case 1: if (MediaType.VIDEO.equals(encoding.getMediaType()) && (VideoMediaFormatImpl.DEFAULT_CLOCK_RATE == encoding.getClockRate())) return encoding.getEncoding(); else { return encoding.getEncoding() + "/" + encoding.getRealUsedClockRateString(); } default: return null; } }