public final class OutputConfiguration extends Object implements Parcelable
Surface
and its specific
configuration for creating capture session.CameraDevice#createCaptureSessionByOutputConfiguration
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<OutputConfiguration> |
CREATOR |
static int |
ROTATION_0
Rotation constant: 0 degree rotation (no rotation)
|
static int |
ROTATION_180
Rotation constant: 180 degree counterclockwise rotation.
|
static int |
ROTATION_270
Rotation constant: 270 degree counterclockwise rotation.
|
static int |
ROTATION_90
Rotation constant: 90 degree counterclockwise rotation.
|
static int |
SURFACE_GROUP_ID_NONE
Invalid surface group ID.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
OutputConfiguration(int surfaceGroupId,
Surface surface)
Create a new
OutputConfiguration instance with a Surface ,
with a surface group ID. |
OutputConfiguration(int surfaceGroupId,
Surface surface,
int rotation)
Create a new
OutputConfiguration instance, with rotation and a group ID. |
OutputConfiguration(OutputConfiguration other)
Create a new
OutputConfiguration instance with another OutputConfiguration
instance. |
OutputConfiguration(Size surfaceSize,
Class<T> klass)
Create a new
OutputConfiguration instance, with desired Surface size and Surface
source class. |
OutputConfiguration(Surface surface)
Create a new
OutputConfiguration instance with a Surface . |
OutputConfiguration(Surface surface,
int rotation)
Create a new
OutputConfiguration instance. |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object obj)
Check if this
OutputConfiguration is equal to another OutputConfiguration . |
int |
getRotation()
Get the rotation associated with this
OutputConfiguration . |
Surface |
getSurface()
Get the
Surface associated with this OutputConfiguration . |
int |
getSurfaceGroupId()
Get the surface group ID associated with this
OutputConfiguration . |
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isDeferredConfiguration()
Check if this configuration has deferred configuration.
|
void |
setDeferredSurface(Surface surface)
Set the deferred surface to this OutputConfiguration.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final int ROTATION_0
public static final int ROTATION_90
public static final int ROTATION_180
public static final int ROTATION_270
public static final int SURFACE_GROUP_ID_NONE
An OutputConfiguration
with this value indicates that the included surface
doesn't belong to any surface group.
public static final Parcelable.Creator<OutputConfiguration> CREATOR
public OutputConfiguration(Surface surface)
OutputConfiguration
instance with a Surface
.surface
- A Surface for camera to output to.
This constructor creates a default configuration, with a surface group ID of -1.
public OutputConfiguration(int surfaceGroupId, Surface surface)
OutputConfiguration
instance with a Surface
,
with a surface group ID.
A surface group ID is used to identify which surface group this output surface belongs to. A
surface group is a group of output surfaces that are not intended to receive camera output
buffer streams simultaneously. The CameraDevice
may be able to share the buffers used
by all the surfaces from the same surface group, therefore may reduce the overall memory
footprint. The application should only set the same set ID for the streams that are not
simultaneously streaming. A negative ID indicates that this surface doesn't belong to any
surface group. The default value is -1.
For example, a video chat application that has an adaptive output resolution feature would need two (or more) output resolutions, to switch resolutions without any output glitches. However, at any given time, only one output is active to minimize outgoing network bandwidth and encoding overhead. To save memory, the application should set the video outputs to have the same non-negative group ID, so that the camera device can share the same memory region for the alternating outputs.
It is not an error to include output streams with the same group ID in the same capture request, but the resulting memory consumption may be higher than if the two streams were not in the same surface group to begin with, especially if the outputs have substantially different dimensions.
surfaceGroupId
- A group ID for this output, used for sharing memory between multiple outputs.surface
- A Surface for camera to output to.public OutputConfiguration(Surface surface, int rotation)
OutputConfiguration
instance.
This constructor takes an argument for desired camera rotation
surface
- A Surface for camera to output to.rotation
- The desired rotation to be applied on camera output. Value must be one of
ROTATION_[0, 90, 180, 270]. Note that when the rotation is 90 or 270 degrees,
application should make sure corresponding surface size has width and height
transposed relative to the width and height without rotation. For example,
if application needs camera to capture 1280x720 picture and rotate it by 90 degree,
application should set rotation to ROTATION_90
and make sure the
corresponding Surface size is 720x1280. Note that CameraDevice
might
throw IllegalArgumentException
if device cannot perform such rotation.public OutputConfiguration(int surfaceGroupId, Surface surface, int rotation)
OutputConfiguration
instance, with rotation and a group ID.
This constructor takes an argument for desired camera rotation and for the surface group
ID. See OutputConfiguration(int, Surface)
for details of the group ID.
surfaceGroupId
- A group ID for this output, used for sharing memory between multiple outputs.surface
- A Surface for camera to output to.rotation
- The desired rotation to be applied on camera output. Value must be one of
ROTATION_[0, 90, 180, 270]. Note that when the rotation is 90 or 270 degrees,
application should make sure corresponding surface size has width and height
transposed relative to the width and height without rotation. For example,
if application needs camera to capture 1280x720 picture and rotate it by 90 degree,
application should set rotation to ROTATION_90
and make sure the
corresponding Surface size is 720x1280. Note that CameraDevice
might
throw IllegalArgumentException
if device cannot perform such rotation.public OutputConfiguration(Size surfaceSize, Class<T> klass)
OutputConfiguration
instance, with desired Surface size and Surface
source class.
This constructor takes an argument for desired Surface size and the Surface source class without providing the actual output Surface. This is used to setup a output configuration with a deferred Surface. The application can use this output configuration to create a session.
However, the actual output Surface must be set via setDeferredSurface(android.view.Surface)
and finish the
deferred Surface configuration via CameraCaptureSession.finishDeferredConfiguration(java.util.List<android.hardware.camera2.params.OutputConfiguration>)
before submitting a request with this Surface target. The deferred Surface can only be
obtained from either from SurfaceView
by calling
SurfaceHolder.getSurface()
, or from
SurfaceTexture
via
Surface.Surface(android.graphics.SurfaceTexture)
).
surfaceSize
- Size for the deferred surface.klass
- a non-null
Class
object reference that indicates the source of
this surface. Only SurfaceHolder.class
and
SurfaceTexture.class
are supported.public OutputConfiguration(OutputConfiguration other)
OutputConfiguration
instance with another OutputConfiguration
instance.other
- Another OutputConfiguration
instance to be copied.public boolean isDeferredConfiguration()
This will return true if the output configuration was constructed with surface deferred. It will return true even after the deferred surface is set later.
public void setDeferredSurface(Surface surface)
The deferred surface must be obtained from either from SurfaceView
by
calling SurfaceHolder.getSurface()
, or from
SurfaceTexture
via
Surface.Surface(android.graphics.SurfaceTexture)
). After the deferred
surface is set, the application must finish the deferred surface configuration via
CameraCaptureSession.finishDeferredConfiguration(java.util.List<android.hardware.camera2.params.OutputConfiguration>)
before submitting a request with
this surface target.
surface
- The deferred surface to be set.IllegalArgumentException
- if the Surface is invalid.IllegalStateException
- if a Surface was already set to this deferred
OutputConfiguration.public Surface getSurface()
Surface
associated with this OutputConfiguration
.Surface
associated with this OutputConfiguration
.public int getRotation()
OutputConfiguration
.OutputConfiguration
.
Value will be one of ROTATION_[0, 90, 180, 270]public int getSurfaceGroupId()
OutputConfiguration
.OutputConfiguration
.
The default value is -1.public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public boolean equals(Object obj)
OutputConfiguration
is equal to another OutputConfiguration
.
Two output configurations are only equal if and only if the underlying surfaces, surface properties (width, height, format, dataspace) when the output configurations are created, and all other configuration parameters are equal.
equals
in class Object
obj
- the reference object with which to compare.true
if the objects were equal, false
otherwiseObject.hashCode()
,
HashMap
public int hashCode()
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)