@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()]); }
/** * 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; }
/** * Get suitable video format to use (the largest one by default, but this * can be easily changed). * * @param device device to get video format for * @return Suitable video format */ private VideoFormat getLargestVideoFormat() { Format[] formats = device.getFormats(); VideoFormat format = null; int area = 0; // find the largest picture format for (Format f : formats) { if (!(f instanceof VideoFormat) || !"RGB".equalsIgnoreCase(f.getEncoding())) { continue; } VideoFormat vf = (VideoFormat) f; Dimension dim = vf.getSize(); int a = dim.width * dim.height; if (a > area) { area = a; format = vf; } } return format; }
/** * Gets the size of the image that this <tt>VideoMediaFormat</tt> describes. * * @return a {@link Dimension} instance indicating the image size (in * pixels) of this <tt>VideoMediaFormat</tt> * @see VideoMediaFormat#getSize() */ public Dimension getSize() { return format.getSize(); }
/** * Returns the download video size if this stream downloads a video, or * null if not. * * @return the download video size if this stream downloads a video, or null * if not. */ public Dimension getDownloadVideoSize() { VideoFormat format = getDownloadVideoFormat(); return (format == null) ? null : format.getSize(); }
/** * Returns the upload video size if this stream uploads a video, or null if * not. * * @return the upload video size if this stream uploads a video, or null if * not. */ public Dimension getUploadVideoSize() { VideoFormat format = getUploadVideoFormat(); return (format == null) ? null : format.getSize(); }
/** * Gets the output size. * * @return the output size */ public Dimension getOutputSize() { Format outputFormat = getOutputFormat(); if (outputFormat == null) { // They all have one and the same size. outputFormat = supportedOutputFormats[0]; } return ((VideoFormat) outputFormat).getSize(); }
/** * Gets the matching output formats for a specific format. * * @param in input format * @return array for formats matching input format */ private Format[] getMatchingOutputFormats(Format in) { VideoFormat videoIn = (VideoFormat) in; return new VideoFormat[] { new VideoFormat( Constants.H263P, videoIn.getSize(), Format.NOT_SPECIFIED, Format.byteArray, videoIn.getFrameRate()) }; }
/** * Get the matching output formats for a specific format. * * @param inputFormat input format * @return array for formats matching input format */ private Format[] getMatchingOutputFormats(Format inputFormat) { VideoFormat inputVideoFormat = (VideoFormat) inputFormat; return new Format[] { new VideoFormat( Constants.H263P_RTP, inputVideoFormat.getSize(), /* maxDataLength */ Format.NOT_SPECIFIED, Format.byteArray, inputVideoFormat.getFrameRate()) }; }
/** * Gets the matching output formats for a specific format. * * @param inputFormat input format * @return array of formats matching input format */ @Override protected Format[] getMatchingOutputFormats(Format inputFormat) { VideoFormat inputVideoFormat = (VideoFormat) inputFormat; return new VideoFormat[] { new VideoFormat( Constants.VP8, inputVideoFormat.getSize(), /* maxDataLength */ Format.NOT_SPECIFIED, Format.byteArray, inputVideoFormat.getFrameRate()) }; }
/** * Get matching outputs for a specified input <tt>Format</tt>. * * @param inputFormat input <tt>Format</tt> * @return array of matching outputs or null if there are no matching * outputs. */ @Override protected Format[] getMatchingOutputFormats(Format inputFormat) { VideoFormat inputVideoFormat = (VideoFormat) inputFormat; return new Format[] { new AVFrameFormat( inputVideoFormat.getSize(), inputVideoFormat.getFrameRate(), FFmpeg.PIX_FMT_YUV420P) }; }
if (videoFormat.getSize() != null) this.format = format;
/** * Get matching outputs for a specified input <tt>Format</tt>. * * @param inputFormat input <tt>Format</tt> * @return array of matching outputs or null if there are no matching * outputs. */ protected Format[] getMatchingOutputFormats(Format inputFormat) { VideoFormat inputVideoFormat = (VideoFormat) inputFormat; return new Format[] { new AVFrameFormat( inputVideoFormat.getSize(), ensureFrameRate(inputVideoFormat.getFrameRate()), FFmpeg.PIX_FMT_YUV420P) }; }
/** * Get matching outputs for a specified input <tt>Format</tt>. * * @param inputFormat input <tt>Format</tt> * @return array of matching outputs or null if there are no matching * outputs. */ protected Format[] getMatchingOutputFormats(Format inputFormat) { VideoFormat inputVideoFormat = (VideoFormat) inputFormat; return new Format[] { new AVFrameFormat( inputVideoFormat.getSize(), ensureFrameRate(inputVideoFormat.getFrameRate()), FFmpeg.PIX_FMT_YUV420P) }; }
if (inputFormat instanceof VideoFormat) Dimension inputSize = ((VideoFormat) inputFormat).getSize();
Dimension size = ((VideoFormat) format).getSize();
: new String[] { this.packetizationMode }; Format[] matchingOutputFormats = new Format[packetizationModes.length]; Dimension size = inputVideoFormat.getSize(); float frameRate = inputVideoFormat.getFrameRate();
/** * Gets the output formats matching a specific input format. * * @param input the input format to get the matching output formats for * @return an array of output formats matching the specified input format */ private Format[] getMatchingOutputFormats(Format input) { VideoFormat videoInput = (VideoFormat) input; Dimension size = videoInput.getSize(); float frameRate = videoInput.getFrameRate(); String packetizationMode = getPacketizationMode(input); return new Format[] { new ParameterizedVideoFormat( Constants.H264_RTP, size, Format.NOT_SPECIFIED, Format.byteArray, frameRate, ParameterizedVideoFormat.toMap( VideoMediaFormatImpl .H264_PACKETIZATION_MODE_FMTP, packetizationMode)) }; }
Dimension size = ((VideoFormat) inputFormat).getSize();