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  * Physical Layer Pipe (PLP) settings for ATSC-3.
24  *
25  * @hide
26  */
27 @SystemApi
28 public class Atsc3PlpSettings {
29     private final int mPlpId;
30     private final int mModulation;
31     private final int mInterleaveMode;
32     private final int mCodeRate;
33     private final int mFec;
34 
Atsc3PlpSettings(int plpId, int modulation, int interleaveMode, int codeRate, int fec)35     private Atsc3PlpSettings(int plpId, int modulation, int interleaveMode, int codeRate, int fec) {
36         mPlpId = plpId;
37         mModulation = modulation;
38         mInterleaveMode = interleaveMode;
39         mCodeRate = codeRate;
40         mFec = fec;
41     }
42 
43     /**
44      * Gets Physical Layer Pipe (PLP) ID.
45      */
getPlpId()46     public int getPlpId() {
47         return mPlpId;
48     }
49     /**
50      * Gets Modulation.
51      */
52     @Atsc3FrontendSettings.Modulation
getModulation()53     public int getModulation() {
54         return mModulation;
55     }
56     /**
57      * Gets Interleave Mode.
58      */
59     @Atsc3FrontendSettings.TimeInterleaveMode
getInterleaveMode()60     public int getInterleaveMode() {
61         return mInterleaveMode;
62     }
63     /**
64      * Gets Code Rate.
65      */
66     @Atsc3FrontendSettings.CodeRate
getCodeRate()67     public int getCodeRate() {
68         return mCodeRate;
69     }
70     /**
71      * Gets Forward Error Correction.
72      */
73     @Atsc3FrontendSettings.Fec
getFec()74     public int getFec() {
75         return mFec;
76     }
77 
78     /**
79      * Creates a builder for {@link Atsc3PlpSettings}.
80      */
81     @NonNull
builder()82     public static Builder builder() {
83         return new Builder();
84     }
85 
86     /**
87      * Builder for {@link Atsc3PlpSettings}.
88      */
89     public static class Builder {
90         private int mPlpId;
91         private int mModulation;
92         private int mInterleaveMode;
93         private int mCodeRate;
94         private int mFec;
95 
Builder()96         private Builder() {
97         }
98 
99         /**
100          * Sets Physical Layer Pipe (PLP) ID.
101          */
102         @NonNull
setPlpId(int plpId)103         public Builder setPlpId(int plpId) {
104             mPlpId = plpId;
105             return this;
106         }
107         /**
108          * Sets Modulation.
109          */
110         @NonNull
setModulation(@tsc3FrontendSettings.Modulation int modulation)111         public Builder setModulation(@Atsc3FrontendSettings.Modulation int modulation) {
112             mModulation = modulation;
113             return this;
114         }
115         /**
116          * Sets Interleave Mode.
117          */
118         @NonNull
setInterleaveMode( @tsc3FrontendSettings.TimeInterleaveMode int interleaveMode)119         public Builder setInterleaveMode(
120                 @Atsc3FrontendSettings.TimeInterleaveMode int interleaveMode) {
121             mInterleaveMode = interleaveMode;
122             return this;
123         }
124         /**
125          * Sets Code Rate.
126          */
127         @NonNull
setCodeRate(@tsc3FrontendSettings.CodeRate int codeRate)128         public Builder setCodeRate(@Atsc3FrontendSettings.CodeRate int codeRate) {
129             mCodeRate = codeRate;
130             return this;
131         }
132         /**
133          * Sets Forward Error Correction.
134          */
135         @NonNull
setFec(@tsc3FrontendSettings.Fec int fec)136         public Builder setFec(@Atsc3FrontendSettings.Fec int fec) {
137             mFec = fec;
138             return this;
139         }
140 
141         /**
142          * Builds a {@link Atsc3PlpSettings} object.
143          */
144         @NonNull
build()145         public Atsc3PlpSettings build() {
146             return new Atsc3PlpSettings(mPlpId, mModulation, mInterleaveMode, mCodeRate, mFec);
147         }
148     }
149 }
150