1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.hardware.camera2.params; 18 19 import android.hardware.camera2.CameraCharacteristics; 20 import android.hardware.camera2.CameraDevice; 21 import android.hardware.camera2.utils.HashCodeHelpers; 22 23 /** 24 * Immutable class to store the recommended stream configurations to set up 25 * {@link android.view.Surface Surfaces} for creating a {@link CameraCaptureSession capture session} 26 * with {@link CameraDevice#createCaptureSession}. 27 * 28 * @see CameraCharacteristics#getRecommendedStreamConfigurationMap 29 * 30 * @hide 31 */ 32 public final class RecommendedStreamConfiguration extends StreamConfiguration{ 33 34 /** 35 * Create a new {@link RecommendedStreamConfiguration}. 36 * 37 * @param format image format 38 * @param width image width, in pixels (positive) 39 * @param height image height, in pixels (positive) 40 * @param input true if this is an input configuration, false for output configurations 41 * @param usecaseBitmap Use case bitmap 42 * 43 * @throws IllegalArgumentException 44 * if width/height were not positive 45 * or if the format was not user-defined in ImageFormat/PixelFormat 46 * (IMPL_DEFINED is ok) 47 * 48 * @hide 49 */ RecommendedStreamConfiguration( final int format, final int width, final int height, final boolean input, final int usecaseBitmap)50 public RecommendedStreamConfiguration( 51 final int format, final int width, final int height, final boolean input, final int 52 usecaseBitmap) { 53 super(format, width, height, input); 54 mUsecaseBitmap = usecaseBitmap; 55 } 56 57 /** 58 * Return usecase bitmap. 59 * 60 * @return usecase bitmap 61 */ getUsecaseBitmap()62 public int getUsecaseBitmap() { 63 return mUsecaseBitmap; 64 } 65 66 /** 67 * Check if this {@link RecommendedStreamConfiguration} is equal to another 68 * {@link RecommendedStreamConfiguration}. 69 * 70 * <p>Two vectors are only equal if and only if each of the respective elements is equal.</p> 71 * 72 * @return {@code true} if the objects were equal, {@code false} otherwise 73 */ 74 @Override equals(final Object obj)75 public boolean equals(final Object obj) { 76 if (obj == null) { 77 return false; 78 } 79 if (this == obj) { 80 return true; 81 } 82 if (obj instanceof RecommendedStreamConfiguration) { 83 final RecommendedStreamConfiguration other = (RecommendedStreamConfiguration) obj; 84 return mFormat == other.mFormat && 85 mWidth == other.mWidth && 86 mHeight == other.mHeight && 87 mUsecaseBitmap == other.mUsecaseBitmap && 88 mInput == other.mInput; 89 } 90 return false; 91 } 92 93 /** 94 * {@inheritDoc} 95 */ 96 @Override hashCode()97 public int hashCode() { 98 return HashCodeHelpers.hashCode(mFormat, mWidth, mHeight, mInput ? 1 : 0, mUsecaseBitmap); 99 } 100 101 private final int mUsecaseBitmap; 102 } 103