public class VideoCaptureConstraints extends Object
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()
.
// 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().
}
//
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.
}
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
Modifier and Type | Class and Description |
---|---|
static interface |
VideoCaptureConstraints.Compiler
An interface that will be implemented by the implementation.
|
Modifier and Type | Field and Description |
---|---|
static int |
QUALITY_HIGH |
static int |
QUALITY_LOW |
Constructor and Description |
---|
VideoCaptureConstraints()
Creates a new video cosntraint with no constraints specified.
|
VideoCaptureConstraints(int quality)
Creates a new constraint with the given quality constraint.
|
VideoCaptureConstraints(int width,
int height,
int maxLength)
Creates a new constraints with given preferred values.
|
VideoCaptureConstraints(VideoCaptureConstraints toCopy)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
int |
getHeight()
Gets the platform-supported height constraint.
|
long |
getMaxFileSize()
Gets the maximum file size of the capture in bytes.
|
int |
getMaxLength()
Returns the maximum length (in seconds) of this constraint.
|
int |
getPreferredHeight()
Gets the preferred height constraint.
|
long |
getPreferredMaxFileSize()
Gets the preferred max file size.
|
int |
getPreferredMaxLength()
Gets the preferred max length video capture, in seconds.
|
int |
getPreferredQuality()
Gets the preferred quality of the recording.
|
int |
getPreferredWidth()
Gets the preferred width constraint.
|
int |
getQuality()
Gets the quality of the recording.
|
int |
getWidth()
Gets the width constraint that is supported by the platform, and is nearest to the specified
preferred width.
|
int |
hashCode()
Returns a hash code value for the object.
|
static void |
init(VideoCaptureConstraints.Compiler cmp)
Deprecated.
Called by the platform. For internal use only.
|
boolean |
isMaxFileSizeSupported()
Checks if the max file size constraint is supported.
|
boolean |
isMaxLengthSupported()
Checks to see if the preferred max length specified in this constraint is supported
by the underlying platform.
|
boolean |
isNullConstraint()
Checks if this constraint is effectively a null constraint.
|
boolean |
isQualitySupported()
Checks if the preferred quality setting is supported.
|
boolean |
isSizeSupported()
Checks if the specified preferred width and height constraints are supported by the platform.
|
boolean |
isSupported()
Checks if this constraint is fully supported by the platform.
|
VideoCaptureConstraints |
preferredHeight(int height)
Sets the preferred height constraint.
|
VideoCaptureConstraints |
preferredMaxFileSize(long size)
Sets the preferred max file size.
|
VideoCaptureConstraints |
preferredMaxLength(int maxLength)
Set the preferred max length for the video capture in seconds.
|
VideoCaptureConstraints |
preferredQuality(int quality)
Sets the preferred quality of the video recording.
|
VideoCaptureConstraints |
preferredWidth(int width)
Sets the preferred width constraint.
|
String |
toString()
Returns a string representation of the object.
|
public static final int QUALITY_LOW
public static final int QUALITY_HIGH
public VideoCaptureConstraints()
public VideoCaptureConstraints(VideoCaptureConstraints toCopy)
toCopy
- public VideoCaptureConstraints(int quality)
quality
- The quality of the constraint. Should be one of QUALITY_LOW
or QUALITY_HIGH
public VideoCaptureConstraints(int width, int height, int maxLength)
width
- The preferred width. Pass 0 for no constraint.height
- The preferred height. Pass 0 for no constraint.maxLength
- The preferred max length in seconds. Pass 0 for no consraint.public static void init(VideoCaptureConstraints.Compiler cmp)
cmp
- public String toString()
Object
public boolean equals(Object obj)
Object
public int hashCode()
Object
public long getMaxFileSize()
preferredMaxFileSize(long)
public VideoCaptureConstraints preferredMaxFileSize(long size)
size
- The max file size in bytes.getMaxFileSize()
,
isMaxFileSizeSupported()
public long getPreferredMaxFileSize()
preferredMaxFileSize(long)
,
getMaxFileSize()
,
isMaxFileSizeSupported()
public int getMaxLength()
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.
isMaxLengthSupported()
,
preferredMaxLength(int)
,
getPreferredMaxLength()
public VideoCaptureConstraints preferredMaxLength(int maxLength)
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.
maxLength
- the maxLength to set, in seconds. Set 0 for no limit.getPreferredMaxLength()
,
getMaxLength()
,
isMaxLengthSupported()
public int getPreferredMaxLength()
preferredMaxLength(int)
,
getMaxLength()
,
isMaxLengthSupported()
public boolean isMaxLengthSupported()
getMaxLength()
,
preferredMaxLength(int)
,
getPreferredMaxLength()
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.getPreferredWidth()
,
isSizeSupported()
,
preferredWidth(int)
public int getPreferredWidth()
getWidth()
,
preferredWidth(int)
,
isSizeSupported()
public int getPreferredHeight()
getHeight()
,
preferredHeight(int)
,
`
public boolean isSizeSupported()
getWidth()
,
getHeight()
,
getPreferredWidth()
,
getPreferredHeight()
,
preferredWidth(int)
,
preferredHeight(int)
,
isSupported()
public VideoCaptureConstraints preferredWidth(int width)
width
- the width to setgetWidth()
,
getPreferredWidth()
,
isSizeSupported()
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.getPreferredHeight()
,
preferredHeight(int)
,
isSizeSupported()
public VideoCaptureConstraints preferredHeight(int height)
height
- the height to setgetPreferredHeight()
,
getHeight()
,
isSizeSupported()
public int getPreferredQuality()
QUALITY_LOW
, QUALITY_HIGH
, or 0.preferredQuality(int)
,
isQualitySupported()
,
getQuality()
public int getQuality()
QUALITY_LOW
, QUALITY_HIGH
, or 0.getPreferredQuality()
,
preferredQuality(int)
,
isQualitySupported()
public VideoCaptureConstraints preferredQuality(int quality)
quality
- May be one of QUALITY_LOW
, QUALITY_HIGH
, or 0.getQuality()
,
getPreferredQuality()
,
isQualitySupported()
public boolean isSupported()
isSizeSupported()
,
isMaxLengthSupported()
public boolean isQualitySupported()
getPreferredQuality()
,
getQuality()
,
preferredQuality(int)
public boolean isMaxFileSizeSupported()
preferredMaxFileSize(long)
,
getMaxFileSize()
,
getPreferredMaxFileSize()
public boolean isNullConstraint()