for (Format format : supported) { if (format instanceof AudioFormat) { if (this.format.matches(format)) chosen = format; if (tracks[i].getFormat().getEncoding().equals(AudioFormat.ULAW_RTP)) { Codec[] codec = new Codec[3];
@Override public List<WebcamDevice> getDevices() { if (devices == null) { devices = new ArrayList<WebcamDevice>(); @SuppressWarnings("unchecked") Vector<Object> cdis = CaptureDeviceManager.getDeviceList(new Format("RGB")); Iterator<Object> di = cdis.iterator(); while (di.hasNext()) { CaptureDeviceInfo cdi = (CaptureDeviceInfo) di.next(); devices.add(new JmfDevice(cdi)); } } return devices; }
/** * Get the best stanza size for a given codec and a codec rate * * @param codecFormat * @param milliseconds * @return the best stanza size * @throws IllegalArgumentException */ private int getPacketSize(Format codecFormat, int milliseconds) throws IllegalArgumentException { String encoding = codecFormat.getEncoding(); if (encoding.equalsIgnoreCase(AudioFormat.GSM) || encoding.equalsIgnoreCase(AudioFormat.GSM_RTP)) { return milliseconds * 4; // 1 byte per millisec } else if (encoding.equalsIgnoreCase(AudioFormat.ULAW) || encoding.equalsIgnoreCase(AudioFormat.ULAW_RTP)) { return milliseconds * 8; } else { throw new IllegalArgumentException("Unknown codec type"); } }
/** * 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; }
/** * Implements MediaFormat#equals(Object) and actually compares the * encapsulated JMF <tt>Format</tt> instances. * * @param mediaFormat the object that we'd like to compare <tt>this</tt> one * to. 8* * @return <tt>true</tt> if the JMF <tt>Format</tt> instances encapsulated * by this class are equal and <tt>false</tt> otherwise. */ @Override public boolean equals(Object mediaFormat) { if (this == mediaFormat) return true; if (!getClass().isInstance(mediaFormat)) return false; @SuppressWarnings("unchecked") MediaFormatImpl<T> mediaFormatImpl = (MediaFormatImpl<T>) mediaFormat; return getFormat().equals(mediaFormatImpl.getFormat()) && formatParametersAreEqual( getFormatParameters(), mediaFormatImpl.getFormatParameters()); }
= (AudioFormat) matchingInputFormat.intersects(inputFormat); Format outputFormat = new AudioFormat( new Format[] matchingOutputFormat.intersects(outputFormat) };
protected Format[] getMatchingOutputFormats(Format inputFormat) Class<?> inDataType = inputFormat.getDataType(); List<Format> matchingOutputFormats = new ArrayList<Format>(); continue; if ((Format.byteArray.equals(supportedFormat.getDataType()) && Format.byteArray.equals(inDataType)) || (supportedAudioFormat.getSampleRate()
@Override public Dimension[] getResolutions() { if (dimensions == null) { dimensions = new ArrayList<Dimension>(); Format[] formats = cdi.getFormats(); for (Format format : formats) { if ("RGB".equalsIgnoreCase(format.getEncoding())) { dimensions.add(((VideoFormat) format).getSize()); } } Collections.sort(dimensions, new Comparator<Dimension>() { @Override public int compare(Dimension a, Dimension b) { int apx = a.width * a.height; int bpx = b.width * b.height; if (apx > bpx) { return 1; } else if (apx < bpx) { return -1; } else { return 0; } } }); } return dimensions.toArray(new Dimension[dimensions.size()]); }
/** * 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; }
else if (processorIsPrematurelyClosed || ((processorState > Processor.Configured) && !this.format.getFormat().equals( getProcessorFormat())) || outputSizeChanged)
= format.intersects( new VideoFormat(
byte rtpPayloadType = getRTPPayloadType(format.getEncoding(), clockRate); = (MediaFormatImpl<? extends Format>) mediaFormat; if (format.matches(mediaFormatImpl.getFormat()))
/** * Get video format for size. * * @param device device to get format from * @param size specific size to search * @return VideoFormat */ private VideoFormat getSizedVideoFormat(Dimension size) { Format[] formats = device.getFormats(); VideoFormat format = null; for (Format f : formats) { if (!"RGB".equalsIgnoreCase(f.getEncoding()) || !(f instanceof VideoFormat)) { continue; } Dimension d = ((VideoFormat) f).getSize(); if (d.width == size.width && d.height == size.height) { format = (VideoFormat) f; break; } } return format; }
/** * {@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; }
&& !trackFormat.matches(outputFormat)) for (Format supportedTrackFormat : supportedTrackFormats) if (supportedTrackFormat.matches(outputFormat)) = supportedTrackFormat.intersects( outputFormat);
if (format != null && format != this.inputFormat && !format.equals(this.inputFormat) && setInputFormat(format) == null)
genericFormat.intersects( new VideoFormat( null,