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.frontend; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 22 /** 23 * Code rate for DVBS. 24 * 25 * @hide 26 */ 27 @SystemApi 28 public class DvbsCodeRate { 29 private final long mInnerFec; 30 private final boolean mIsLinear; 31 private final boolean mIsShortFrames; 32 private final int mBitsPer1000Symbol; 33 DvbsCodeRate(long fec, boolean isLinear, boolean isShortFrames, int bitsPer1000Symbol)34 private DvbsCodeRate(long fec, boolean isLinear, boolean isShortFrames, int bitsPer1000Symbol) { 35 mInnerFec = fec; 36 mIsLinear = isLinear; 37 mIsShortFrames = isShortFrames; 38 mBitsPer1000Symbol = bitsPer1000Symbol; 39 } 40 41 /** 42 * Gets inner FEC. 43 */ 44 @FrontendSettings.InnerFec getInnerFec()45 public long getInnerFec() { 46 return mInnerFec; 47 } 48 /** 49 * Checks whether it's linear. 50 */ isLinear()51 public boolean isLinear() { 52 return mIsLinear; 53 } 54 /** 55 * Checks whether short frame enabled. 56 */ isShortFrameEnabled()57 public boolean isShortFrameEnabled() { 58 return mIsShortFrames; 59 } 60 /** 61 * Gets bits number in 1000 symbols. 0 by default. 62 */ getBitsPer1000Symbol()63 public int getBitsPer1000Symbol() { 64 return mBitsPer1000Symbol; 65 } 66 67 /** 68 * Creates a builder for {@link DvbsCodeRate}. 69 */ 70 @NonNull builder()71 public static Builder builder() { 72 return new Builder(); 73 } 74 75 /** 76 * Builder for {@link DvbsCodeRate}. 77 */ 78 public static class Builder { 79 private long mFec; 80 private boolean mIsLinear; 81 private boolean mIsShortFrames; 82 private int mBitsPer1000Symbol; 83 Builder()84 private Builder() { 85 } 86 87 /** 88 * Sets inner FEC. 89 */ 90 @NonNull setInnerFec(@rontendSettings.InnerFec long fec)91 public Builder setInnerFec(@FrontendSettings.InnerFec long fec) { 92 mFec = fec; 93 return this; 94 } 95 /** 96 * Sets whether it's linear. 97 */ 98 @NonNull setLinear(boolean isLinear)99 public Builder setLinear(boolean isLinear) { 100 mIsLinear = isLinear; 101 return this; 102 } 103 /** 104 * Sets whether short frame enabled. 105 */ 106 @NonNull setShortFrameEnabled(boolean isShortFrames)107 public Builder setShortFrameEnabled(boolean isShortFrames) { 108 mIsShortFrames = isShortFrames; 109 return this; 110 } 111 /** 112 * Sets bits number in 1000 symbols. 113 */ 114 @NonNull setBitsPer1000Symbol(int bitsPer1000Symbol)115 public Builder setBitsPer1000Symbol(int bitsPer1000Symbol) { 116 mBitsPer1000Symbol = bitsPer1000Symbol; 117 return this; 118 } 119 120 /** 121 * Builds a {@link DvbsCodeRate} object. 122 */ 123 @NonNull build()124 public DvbsCodeRate build() { 125 return new DvbsCodeRate(mFec, mIsLinear, mIsShortFrames, mBitsPer1000Symbol); 126 } 127 } 128 } 129