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 android.media.tv.tuner.frontend;
18 
19 import android.annotation.IntDef;
20 import android.annotation.IntRange;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.hardware.tv.tuner.FrontendIptvSettingsFecType;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * FEC (Forward Error Correction) for IPTV.
30  *
31  * @hide
32  */
33 @SystemApi
34 public final class IptvFrontendSettingsFec {
35     /** @hide */
36     @IntDef(prefix = "FEC_TYPE_",
37             value = {FEC_TYPE_UNDEFINED, FEC_TYPE_COLUMN, FEC_TYPE_ROW, FEC_TYPE_COLUMN_ROW})
38     @Retention(RetentionPolicy.SOURCE)
39     public @interface FecType {}
40 
41     /**
42      * FEC (Forward Error Correction) type UNDEFINED.
43      */
44     public static final int FEC_TYPE_UNDEFINED = FrontendIptvSettingsFecType.UNDEFINED;
45 
46     /**
47      * FEC (Forward Error Correction) type Column.
48      */
49     public static final int FEC_TYPE_COLUMN = FrontendIptvSettingsFecType.COLUMN;
50 
51     /**
52      * FEC (Forward Error Correction) type ROW.
53      */
54     public static final int FEC_TYPE_ROW = FrontendIptvSettingsFecType.ROW;
55 
56     /**
57      * FEC (Forward Error Correction) type Column Row.
58      */
59     public static final int FEC_TYPE_COLUMN_ROW = FrontendIptvSettingsFecType.COLUMN_ROW;
60 
61     private final int mFecType;
62     private final int mFecRowNum;
63     private final int mFecColNum;
64 
IptvFrontendSettingsFec(@ecType int fecType, int fecRowNum, int fecColNum)65     private IptvFrontendSettingsFec(@FecType int fecType, int fecRowNum, int fecColNum) {
66         mFecType = fecType;
67         mFecRowNum = fecRowNum;
68         mFecColNum = fecColNum;
69     }
70 
71     /**
72      * Gets the FEC (Forward Error Correction) type.
73      */
74     @FecType
getFecType()75     public int getFecType() {
76         return mFecType;
77     }
78 
79     /**
80      * Get the FEC (Forward Error Correction) row number.
81      */
82     @IntRange(from = 0)
getFecRowNum()83     public int getFecRowNum() {
84         return mFecRowNum;
85     }
86 
87     /**
88      * Gets the FEC (Forward Error Correction) column number.
89      */
90     @IntRange(from = 0)
getFecColNum()91     public int getFecColNum() {
92         return mFecColNum;
93     }
94 
95     /**
96      * Builder for {@link IptvFrontendSettingsFec}.
97      */
98     public static final class Builder {
99         private int mFecType;
100         private int mFecRowNum;
101         private int mFecColNum;
102 
Builder()103         public Builder() {
104         }
105 
106         /**
107          * Sets the FEC (Forward Error Correction) type
108          */
109         @NonNull
setFecType(@ecType int fecType)110         public Builder setFecType(@FecType int fecType) {
111             mFecType = fecType;
112             return this;
113         }
114         /**
115          * Sets the FEC (Forward Error Correction) row number.
116          */
117         @NonNull
setFecRowNum(@ntRangefrom = 0) int fecRowNum)118         public Builder setFecRowNum(@IntRange(from = 0) int fecRowNum) {
119             mFecRowNum = fecRowNum;
120             return this;
121         }
122         /**
123          * Sets the FEC (Forward Error Correction) column number.
124          */
125         @NonNull
setFecColNum(@ntRangefrom = 0) int fecColNum)126         public Builder setFecColNum(@IntRange(from = 0) int fecColNum) {
127             mFecColNum = fecColNum;
128             return this;
129         }
130 
131         /**
132          * Builds a {@link IptvFrontendSettingsFec} object.
133          */
134         @NonNull
build()135         public IptvFrontendSettingsFec build() {
136             return new IptvFrontendSettingsFec(mFecType, mFecRowNum, mFecColNum);
137         }
138     }
139 }
140