public class VideoCaptureConstraints
- Object
- VideoCaptureConstraints
Encapsulates constraints that can be used for capturing video.
You should set
the preferred constraints then if they are supported using #isSupported(), #isSizeSupported(), #isQualitySupported(),
#isMaxLengthSupported(), or #isMaxFileSizeSupported(). If all of the constraints
are supported, then, #isSupported() will return true, and the resolved
constraints (#getWidth(), #getHeight(), #getQuality(), #getMaxLength(),
#getMaxLength()) will match their preferred counterparts.
If #isSupported() is false, then at least one of the constraints
is not supported by the system. You can check support for a specific constraint using
#isSizeSupported(), #isMaxFileSizeSupported(), #isQualitySupported(), or #isMaxLengthSupported().
Example Using size and duration constraints:
`// Create capture constraint 320x240, with max length 20 seconds
VideoCaptureConstraints vcc = new VideoCaptureConstraints(320, 240, 20);
if (vcc.isSupported()) {
// These constraints are fully supported by this platform
// We can pass them directly to Capture.captureVideo() and the resulting
// video will match the constraints exactly.
// At this point, the following conditions are guaranteed to be true:
// 1. vcc.getPreferredWidth() == vcc.getWidth() == 320
// 2. vcc.getPreferredHeight() == vcc.getHeight() == 320
// 3. vcc.getPreferredMaxLength() == vcc.getMaxLength() == 20` else {
// At least one of the constraints is not supported.
// You can find out the "granted" constraints using getWidth(), getHeight(),
// and getMaxLength().
}
}
Example Using Quality:
`//
VideoCaptureConstraints vcc = new VideoCaptureConstraints(VideoCaptureConstraints.QUALITY_LOW);
if (vcc.isSupported()) {
// This platform supports a 'low quality' setting.
// Low quality generally means a smaller file size.` else {
// Low quality constraint is not supported.
}
}
Platform Support Status
Android #preferredQuality(int), #preferredMaxLength(int),
and #preferredMaxFileSize(long) natively. It doesn’t fully support specific widths and
heights, but if #preferredWidth(int), and #preferredHeight(int) are supplied, it will
translate these into either #QUALITY_LOW, or #QUALITY_HIGH.
Javascript supports …. TODO Add support for javascript and others
Nested types
interface VideoCaptureConstraints.Compiler | An interface that will be implemented by the implementation. |
Fields
public static final int QUALITY_LOW = 1 | |
public static final int QUALITY_HIGH = 2 |
Constructors
public VideoCaptureConstraints() | Creates a new video cosntraint with no constraints specified. |
public VideoCaptureConstraints(VideoCaptureConstraints toCopy) | Copy constructor. |
public VideoCaptureConstraints(int quality) | Creates a new constraint with the given quality constraint. |
public VideoCaptureConstraints(int width, int height, int maxLength) | Creates a new constraints with given preferred values. |
Methods
public static void init(VideoCaptureConstraints.Compiler cmp) | Deprecated Sets the native platform constraint compiler. |
public String toString() | Returns a string representation of the object. |
public boolean equals(Object obj) | Indicates whether some other object is “equal to” this one. |
public int hashCode() | Returns a hash code value for the object. |
public long getMaxFileSize() | Gets the maximum file size of the capture in bytes. |
public VideoCaptureConstraints preferredMaxFileSize(long size) | Sets the preferred max file size. |
public long getPreferredMaxFileSize() | Gets the preferred max file size. |
public int getMaxLength() | Returns the maximum length (in seconds) of this constraint. |
public VideoCaptureConstraints preferredMaxLength(int maxLength) | Set the preferred max length for the video capture in seconds. |
public int getPreferredMaxLength() | Gets the preferred max length video capture, in seconds. |
public boolean isMaxLengthSupported() | Checks to see if the preferred max length specified in this constraint is supported by the underlying platform. |
public int getWidth() | Gets the width constraint that is supported by the platform, and is nearest to the specified preferred width. |
public int getPreferredWidth() | Gets the preferred width constraint. |
public int getPreferredHeight() | Gets the preferred height constraint. |
public boolean isSizeSupported() | Checks if the specified preferred width and height constraints are supported by the platform. |
public VideoCaptureConstraints preferredWidth(int width) | Sets the preferred width constraint. |
public int getHeight() | Gets the platform-supported height constraint. |
public VideoCaptureConstraints preferredHeight(int height) | Sets the preferred height constraint. |
public int getPreferredQuality() | Gets the preferred quality of the recording. |
public int getQuality() | Gets the quality of the recording. |
public VideoCaptureConstraints preferredQuality(int quality) | Sets the preferred quality of the video recording. |
public boolean isSupported() | Checks if this constraint is fully supported by the platform. |
public boolean isQualitySupported() | Checks if the preferred quality setting is supported. |
public boolean isMaxFileSizeSupported() | Checks if the max file size constraint is supported. |
public boolean isNullConstraint() | Checks if this constraint is effectively a null constraint. |
Inherited methods
Field details
QUALITY_LOW
public static final int QUALITY_LOW = 1QUALITY_HIGH
public static final int QUALITY_HIGH = 2Constructor details
VideoCaptureConstraints
public VideoCaptureConstraints()VideoCaptureConstraints
public VideoCaptureConstraints(VideoCaptureConstraints toCopy)VideoCaptureConstraints
public VideoCaptureConstraints(int quality)Parameters
qualityint- The quality of the constraint. Should be one of
#QUALITY_LOWor#QUALITY_HIGH
VideoCaptureConstraints
public VideoCaptureConstraints(int width, int height, int maxLength)Parameters
widthint- The preferred width. Pass 0 for no constraint.
heightint- The preferred height. Pass 0 for no constraint.
maxLengthint- The preferred max length in seconds. Pass 0 for no consraint.
Method details
init
public static void init(VideoCaptureConstraints.Compiler cmp)toString
public String toString()equals
public boolean equals(Object obj)hashCode
public int hashCode()getMaxFileSize
public long getMaxFileSize()Returns
See also
preferredMaxFileSize
public VideoCaptureConstraints preferredMaxFileSize(long size)Parameters
sizelong- The max file size in bytes.
Returns
getPreferredMaxFileSize
public long getPreferredMaxFileSize()Returns
getMaxLength
public int getMaxLength()Returns the maximum length (in seconds) of this constraint.
This method always
returns the resolved value that the platform supports. If the platform doesn’t support
setting the max length of a video capture, then this will return 0. If it supports
the value of #getPreferredMaxLength(), then this will return the same value. If it
supports limiting the length of video capture, but it doesn’t support the preferred max length value,
then this will return the closest that the platform can provide to the preferred value.
Note: This value will be equal to #getPreferredMaxLength() iff #isMaxLengthSupported() is true.
Returns
preferredMaxLength
public VideoCaptureConstraints preferredMaxLength(int maxLength)Set the preferred max length for the video capture in seconds.
If the platform supports
this value, then #getMaxLength() will return this same value. If the platform
does not support this value, then #getMaxLength() will return the closest value
that the platform supports.
Parameters
maxLengthint- the maxLength to set, in seconds. Set 0 for no limit.
Returns
getPreferredMaxLength
public int getPreferredMaxLength()Returns
isMaxLengthSupported
public boolean isMaxLengthSupported()Returns
getWidth
public int getWidth()#getPreferredWidth()
will be the same as #getWidth(). If the platform doesn’t support any width constraints at all
then this will return 0. If the platform supports some width constraints, but not the constraint specified,
then this will return the most nearest value that the platform supports.Returns
getPreferredWidth
public int getPreferredWidth()Returns
getPreferredHeight
public int getPreferredHeight()Returns
isSizeSupported
public boolean isSizeSupported()Returns
preferredWidth
public VideoCaptureConstraints preferredWidth(int width)Parameters
widthint- the width to set
getHeight
public int getHeight()#getPreferredHeight(). If the platform doesn’t support any
height constraints, then this will return 0. If the platform
supports height constraints, but not the specific preferred height value, then
this will return the nearest value that is supported by the platform.Returns
preferredHeight
public VideoCaptureConstraints preferredHeight(int height)Parameters
heightint- the height to set
getPreferredQuality
public int getPreferredQuality()Returns
#QUALITY_LOW, #QUALITY_HIGH, or 0.getQuality
public int getQuality()Returns
#QUALITY_LOW, #QUALITY_HIGH, or 0.preferredQuality
public VideoCaptureConstraints preferredQuality(int quality)Parameters
qualityint- May be one of
#QUALITY_LOW,#QUALITY_HIGH, or 0.
Returns
isSupported
public boolean isSupported()Returns
isQualitySupported
public boolean isQualitySupported()Returns
isMaxFileSizeSupported
public boolean isMaxFileSizeSupported()Returns
isNullConstraint
public boolean isNullConstraint()