for (Format format : supported) { if (format instanceof AudioFormat) { if (this.format.matches(format)) chosen = format;
/** * Utility to perform format matching. * * @param in input format * @param outs array of output formats * @return the first output format that is supported */ public static Format matches(Format in, Format outs[]) { for (Format out : outs) if (in.matches(out)) return out; return null; }
/** * Finds the first element of a specific array of <tt>Format</tt>s which * matches in the sense of {@link Format#matches(Format)} a specific * <tt>AudioFormat</tt>. * * @param formats the array of <tt>Format</tt>s which si to be searched * @param format the <tt>AudioFormat</tt> for which a match is to be found * in the specified <tt>formats</tt> * @param clazz the runtime type of the matches to be considered or * <tt>null</tt> if the runtime type is to not be limited * @return the first element of <tt>formats</tt> which matches the specified * <tt>format</tt> or <tt>null</tt> if no match could be found */ private static AudioFormat findFirstMatch( Format[] formats, AudioFormat format, Class<? extends AudioFormat> clazz) { for (Format aFormat : formats) { if (aFormat.matches(format) && ((clazz == null) || clazz.isInstance(aFormat))) { return (AudioFormat) aFormat.intersects(format); } } return null; }
/** * {@inheritDoc} */ @Override public List<CaptureDeviceInfo2> getDevices() { List<CaptureDeviceInfo2> devices = super.getDevices(); if (!devices.isEmpty()) { List<CaptureDeviceInfo2> thisDevices = new ArrayList<CaptureDeviceInfo2>(devices.size()); Format format = new AudioFormat(AudioFormat.LINEAR, -1, 16, -1); for(CaptureDeviceInfo2 device: devices) { for(Format deviceFormat : device.getFormats()) { if(deviceFormat.matches(format)) { thisDevices.add(device); break; } } } devices = thisDevices; } return devices; }
/** * Sets the <tt>Format</tt> of the media data to be rendered by this * <tt>Renderer</tt>. * * @param format the <tt>Format</tt> of the media data to be rendered by * this <tt>Renderer</tt> * @return <tt>null</tt> if the specified <tt>format</tt> is not compatible * with this <tt>Renderer</tt>; otherwise, the <tt>Format</tt> which has * been successfully set */ public Format setInputFormat(Format format) { Format matchingFormat = null; for (Format supportedInputFormat : getSupportedInputFormats()) { if (supportedInputFormat.matches(format)) { matchingFormat = supportedInputFormat.intersects(format); break; } } if (matchingFormat == null) return null; @SuppressWarnings("unchecked") T t = (T) matchingFormat; inputFormat = t; return inputFormat; }
if (supportedFormat.matches(format))
/** * {@inheritDoc} */ @Override public void open() throws IOException, SecurityException { synchronized (openCloseSyncRoot) { if (dataSource instanceof PushBufferDataSource) { PushBufferDataSource pbds = (PushBufferDataSource) dataSource; PushBufferStream[] streams = pbds.getStreams(); //XXX: should we allow for multiple streams in the data source? for (PushBufferStream stream : streams) { //XXX whats the proper way to check for this? and handle? if (!stream.getFormat().matches(new VideoFormat("VP8"))) throw new IOException("Unsupported stream format"); stream.setTransferHandler(this); } } dataSource.connect(); open = true; } }
= (processorFormat == null) ? (format == null) : processorFormat.matches(format);
return format.matches(this.format) ? format : null;
if ((size == null) && format.matches(outputFormat)) size = ((VideoFormat) outputFormat).getSize();
if ((size == null) && format.matches(outputFormat)) size = ((VideoFormat) outputFormat).getSize();
= (MediaFormatImpl<? extends Format>) mediaFormat; if (format.matches(mediaFormatImpl.getFormat()))
if ((size == null) && format.matches(outputFormat)) size = ((VideoFormat) outputFormat).getSize();
if ((size == null) && format.matches(outputFormat)) size = ((VideoFormat) outputFormat).getSize();
if ((size == null) && format.matches(outputFormat)) size = ((VideoFormat) outputFormat).getSize();
if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) setInputFormat(inFormat);
if ((inFormat != inputFormat) && !inFormat.matches(inputFormat)) setInputFormat(inFormat);