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 Section data according to ISO/IEC 13818-1. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public abstract class SectionSettings extends Settings { 30 final boolean mCrcEnabled; 31 final boolean mIsRepeat; 32 final boolean mIsRaw; 33 SectionSettings(int mainType, boolean crcEnabled, boolean isRepeat, boolean isRaw)34 SectionSettings(int mainType, boolean crcEnabled, boolean isRepeat, boolean isRaw) { 35 super(TunerUtils.getFilterSubtype(mainType, Filter.SUBTYPE_SECTION)); 36 mCrcEnabled = crcEnabled; 37 mIsRepeat = isRepeat; 38 mIsRaw = isRaw; 39 } 40 41 /** 42 * Returns whether the filter enables CRC (Cyclic redundancy check) and discards data which 43 * doesn't pass the check. 44 */ isCrcEnabled()45 public boolean isCrcEnabled() { 46 return mCrcEnabled; 47 } 48 /** 49 * Returns whether the filter repeats the data with the same version. 50 */ isRepeat()51 public boolean isRepeat() { 52 return mIsRepeat; 53 } 54 /** 55 * Returns whether the filter sends {@link FilterCallback#onFilterStatusChanged} instead of 56 * {@link FilterCallback#onFilterEvent}. 57 */ isRaw()58 public boolean isRaw() { 59 return mIsRaw; 60 } 61 62 /** 63 * Builder for {@link SectionSettings}. 64 * 65 * @param <T> The subclass to be built. 66 */ 67 public abstract static class Builder<T extends Builder<T>> { 68 final int mMainType; 69 boolean mCrcEnabled; 70 boolean mIsRepeat; 71 boolean mIsRaw; 72 Builder(int mainType)73 Builder(int mainType) { 74 mMainType = mainType; 75 } 76 77 /** 78 * Sets whether the filter enables CRC (Cyclic redundancy check) and discards data which 79 * doesn't pass the check. 80 */ 81 @NonNull setCrcEnabled(boolean crcEnabled)82 public T setCrcEnabled(boolean crcEnabled) { 83 mCrcEnabled = crcEnabled; 84 return self(); 85 } 86 /** 87 * Sets whether the filter repeats the data with the same version. 88 */ 89 @NonNull setRepeat(boolean isRepeat)90 public T setRepeat(boolean isRepeat) { 91 mIsRepeat = isRepeat; 92 return self(); 93 } 94 /** 95 * Sets whether the filter send onFilterStatus instead of 96 * {@link FilterCallback#onFilterEvent}. 97 */ 98 @NonNull setRaw(boolean isRaw)99 public T setRaw(boolean isRaw) { 100 mIsRaw = isRaw; 101 return self(); 102 } 103 self()104 /* package */ abstract T self(); 105 } 106 } 107