1 /* 2 * Copyright 2019 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.media.tv.tuner.filter; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.media.tv.tuner.TunerUtils; 22 23 /** 24 * Filter Settings for a Video and Audio. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public class AvSettings extends Settings { 30 private final boolean mIsPassthrough; 31 AvSettings(int mainType, boolean isAudio, boolean isPassthrough)32 private AvSettings(int mainType, boolean isAudio, boolean isPassthrough) { 33 super(TunerUtils.getFilterSubtype( 34 mainType, 35 isAudio 36 ? Filter.SUBTYPE_AUDIO 37 : Filter.SUBTYPE_VIDEO)); 38 mIsPassthrough = isPassthrough; 39 } 40 41 /** 42 * Checks whether it's passthrough. 43 */ isPassthrough()44 public boolean isPassthrough() { 45 return mIsPassthrough; 46 } 47 48 /** 49 * Creates a builder for {@link AvSettings}. 50 * 51 * @param mainType the filter main type. 52 * @param isAudio {@code true} if it's audio settings; {@code false} if it's video settings. 53 */ 54 @NonNull builder(@ilter.Type int mainType, boolean isAudio)55 public static Builder builder(@Filter.Type int mainType, boolean isAudio) { 56 return new Builder(mainType, isAudio); 57 } 58 59 /** 60 * Builder for {@link AvSettings}. 61 */ 62 public static class Builder { 63 private final int mMainType; 64 private final boolean mIsAudio; 65 private boolean mIsPassthrough; 66 Builder(int mainType, boolean isAudio)67 private Builder(int mainType, boolean isAudio) { 68 mMainType = mainType; 69 mIsAudio = isAudio; 70 } 71 72 /** 73 * Sets whether it's passthrough. 74 */ 75 @NonNull setPassthrough(boolean isPassthrough)76 public Builder setPassthrough(boolean isPassthrough) { 77 mIsPassthrough = isPassthrough; 78 return this; 79 } 80 81 /** 82 * Builds a {@link AvSettings} object. 83 */ 84 @NonNull build()85 public AvSettings build() { 86 return new AvSettings(mMainType, mIsAudio, mIsPassthrough); 87 } 88 } 89 } 90