| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.camera2.params; |
| 18 |
|
| 19 |
import static com.android.internal.util.Preconditions.checkArgumentNonnegative; |
| 20 |
import static com.android.internal.util.Preconditions.checkArgumentPositive; |
| 21 |
|
| 22 |
import android.annotation.NonNull; |
| 23 |
import android.hardware.camera2.CameraCharacteristics; |
| 24 |
import android.hardware.camera2.CameraMetadata; |
| 25 |
import android.hardware.camera2.utils.HashCodeHelpers; |
| 26 |
import android.util.Range; |
| 27 |
import android.util.Size; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public final class Capability { |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public static final int COUNT = 3; |
| 41 |
|
| 42 |
private final int mMode; |
| 43 |
private final int mMaxStreamingWidth; |
| 44 |
private final int mMaxStreamingHeight; |
| 45 |
private final float mMinZoomRatio; |
| 46 |
private final float mMaxZoomRatio; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public Capability(int mode, int maxStreamingWidth, int maxStreamingHeight, |
| 61 |
float minZoomRatio, float maxZoomRatio) { |
| 62 |
mMode = mode; |
| 63 |
mMaxStreamingWidth = checkArgumentNonnegative(maxStreamingWidth, |
| 64 |
"maxStreamingWidth must be nonnegative"); |
| 65 |
mMaxStreamingHeight = checkArgumentNonnegative(maxStreamingHeight, |
| 66 |
"maxStreamingHeight must be nonnegative"); |
| 67 |
|
| 68 |
if (minZoomRatio > maxZoomRatio) { |
| 69 |
throw new IllegalArgumentException("minZoomRatio " + minZoomRatio |
| 70 |
+ " is greater than maxZoomRatio " + maxZoomRatio); |
| 71 |
} |
| 72 |
mMinZoomRatio = checkArgumentPositive(minZoomRatio, |
| 73 |
"minZoomRatio must be positive"); |
| 74 |
mMaxZoomRatio = checkArgumentPositive(maxZoomRatio, |
| 75 |
"maxZoomRatio must be positive"); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public int getMode() { |
| 87 |
return mMode; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public @NonNull Size getMaxStreamingSize() { |
| 96 |
return new Size(mMaxStreamingWidth, mMaxStreamingHeight); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
public @NonNull Range<Float> getZoomRatioRange() { |
| 105 |
return new Range<Float>(mMinZoomRatio, mMaxZoomRatio); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
@Override |
| 118 |
public boolean equals(final Object obj) { |
| 119 |
if (obj == null) { |
| 120 |
return false; |
| 121 |
} |
| 122 |
if (this == obj) { |
| 123 |
return true; |
| 124 |
} |
| 125 |
if (obj instanceof Capability) { |
| 126 |
final Capability other = (Capability) obj; |
| 127 |
return (mMode == other.mMode |
| 128 |
&& mMaxStreamingWidth == other.mMaxStreamingWidth |
| 129 |
&& mMaxStreamingHeight == other.mMaxStreamingHeight |
| 130 |
&& mMinZoomRatio == other.mMinZoomRatio |
| 131 |
&& mMaxZoomRatio == other.mMaxZoomRatio); |
| 132 |
} |
| 133 |
return false; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
@Override |
| 140 |
public int hashCode() { |
| 141 |
return HashCodeHelpers.hashCode(mMode, mMaxStreamingWidth, mMaxStreamingHeight, |
| 142 |
mMinZoomRatio, mMaxZoomRatio); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
@Override |
| 152 |
public String toString() { |
| 153 |
return String.format("(mode:%d, maxStreamingSize:%d x %d, zoomRatio: %f-%f)", |
| 154 |
mMode, mMaxStreamingWidth, mMaxStreamingHeight, mMinZoomRatio, |
| 155 |
mMaxZoomRatio); |
| 156 |
} |
| 157 |
} |