1 /* 2 * Copyright 2023 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 androidx.camera.testing.impl.fakes 18 19 import android.util.Range 20 import androidx.camera.video.internal.encoder.VideoEncoderInfo 21 22 public class FakeVideoEncoderInfo( 23 @JvmField public var canSwapWidthHeight: Boolean = true, 24 @JvmField public var supportedWidths: Range<Int> = Range.create(0, Integer.MAX_VALUE), 25 @JvmField public var supportedHeights: Range<Int> = Range.create(0, Integer.MAX_VALUE), 26 @JvmField public var widthAlignment: Int = 2, 27 @JvmField public var heightAlignment: Int = 2, 28 @JvmField public var supportedBitrateRange: Range<Int> = Range(1, Int.MAX_VALUE) 29 ) : FakeEncoderInfo(), VideoEncoderInfo { 30 canSwapWidthHeightnull31 override fun canSwapWidthHeight(): Boolean { 32 return canSwapWidthHeight 33 } 34 isSizeSupportednull35 override fun isSizeSupported(width: Int, height: Int): Boolean = 36 supportedWidths.contains(width) && 37 supportedHeights.contains(height) && 38 width.mod(widthAlignment) == 0 && 39 height.mod(heightAlignment) == 0 40 41 override fun getSupportedWidths(): Range<Int> { 42 return supportedWidths 43 } 44 getSupportedHeightsnull45 override fun getSupportedHeights(): Range<Int> { 46 return supportedHeights 47 } 48 getSupportedWidthsFornull49 override fun getSupportedWidthsFor(height: Int): Range<Int> { 50 return supportedWidths 51 } 52 getSupportedHeightsFornull53 override fun getSupportedHeightsFor(width: Int): Range<Int> { 54 return supportedHeights 55 } 56 getWidthAlignmentnull57 override fun getWidthAlignment(): Int { 58 return widthAlignment 59 } 60 getHeightAlignmentnull61 override fun getHeightAlignment(): Int { 62 return heightAlignment 63 } 64 getSupportedBitrateRangenull65 override fun getSupportedBitrateRange(): Range<Int> { 66 return supportedBitrateRange 67 } 68 } 69